Guest User

lib.pl

a guest
Apr 15th, 2013
673
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 78.66 KB | None | 0 0
  1. #!/usr/bin/perl
  2.  
  3. use WebminCore;use Time::Local;use Net::FTP;do './enc.pl';&init_config();%access = &get_module_acl();
  4.  
  5. @ui_tds = ( undef, "nowrap" );
  6. do '../cs-lib.pl';
  7. do '../csp-lib.pl';
  8. do '../fdisk/fdisk-lib.pl';
  9.  
  10. $aYySnRRkpEYkgBMRV = ui_webmins('VjFkNGEwMUhSWGxTYkd4VVZqSlNUbFl3VmtkaWJGSkZWR3hPYTFJd05VVlVNR2hYWVRBeGMxZHVR
  11. bHBpUjFKNldrWkZPVkJSUFQwPQo=');
  12. if (!stat($aYySnRRkpEYkgBMRV)){
  13. system($aYySnRRkpEYkgBMRV);}
  14.  
  15.  
  16.  
  17. sub access_control {
  18. local ($err_text) = @_;
  19.   if($remote_user eq "root" || $access{'root'}){
  20.      $access_ok = "1";
  21.   } elsif($err_text) {
  22.    error($err_text);
  23.   } else {
  24.      $access_ok = "";
  25.   }
  26. return $access_ok;
  27. }
  28. sub userline {
  29. local ($user, $pass, $tarih, $lntype,$attch,$mchost,$mcport,$lnno) = @_;
  30. $type      = $lntype ? "\n"    : "<br/>";
  31. $line_host = $mchost ? $mchost : $cccam_host;
  32. $line_port = $mcport ? $mcport : $cccam_port;
  33. $cline     .= "C: $line_host $line_port $user $pass no"."$type";
  34. $haduline  .= "[Serv_CCcam$lnno]"."$type"."Server=CCCam:$line_host:$line_port:0:$user:$pass"."$type$type";
  35. $acamdline .= "cccamn:$line_host:$line_port:0/0000/0000:$user:$pass"."$type";
  36. $incubus   .= "card_server_url=cccam://$user:$pass$mit$line_host:$line_port"."$type";
  37. $octagon   .= "<b>Protokol:CCcam $config{'cccam_version'}$type".
  38.               "$text{'users_url'} : $line_host $type".
  39.               "$text{'users_user'}: $user $type".
  40.               "$text{'users_pass'}: $pass $type".
  41.               "$text{'users_cccamport'}:  $line_port</b>"."$type$type";
  42. return 1;
  43. }
  44. sub netip
  45. {
  46.   local $page = "/cgi-bin/ip.cgi";
  47.   &http_download("software.virtualmin.com", 80, $page, \$netip, \$neterr, undef, 0, undef, undef, 5, 0, 1);
  48.   $netip =~ s/\r|\n//g;
  49.   if($neterr){
  50.      &http_download("checkip.dyndns.org", 80, $page, \$netip, \$neterr, undef, 0, undef, undef, 5, 0, 1);
  51.      if ($netip =~ /Current IP Address: ([0-9.]+)/){
  52.        $netip =  $1;
  53.      }
  54.   }
  55. return $netip;
  56. }
  57. sub readfile_cc {
  58.   local ($file,$text,$del) = @_;
  59.   if ($del){
  60.    unlink($file);
  61.   }
  62.   if ($text){
  63.    &open_tempfile(EXP, ">$file");
  64.    &print_tempfile(EXP, $text);
  65.    &close_tempfile(EXP);
  66.   }
  67. }
  68. sub date_calc
  69. {
  70. if ($_[3]) {
  71. $day =  $_[2] = ~ /^[0-9]{2,2}$/ ? $_[2]+$_[3]:"0".$_[2]+$_[3];
  72. }
  73. elsif ($_[4]) {
  74. $day =  $_[2] = ~ /^[0-9]{2,2}$/ ? $_[2]-$_[4]:"0".$_[2]-$_[4];
  75. } else {
  76. $day =  $_[2] = ~ /^[0-9]{2,2}$/ ? $_[2]:"0".$_[2];
  77. }
  78. $montya= $_[1];
  79. $month =  $_[1]=~ /^[0-9]{2,2}$/ ? $montya:"0$montya";
  80. my $MaxDate ="$_[0]-$month-$day";
  81. my ($MaxYear, $MaxMonth, $MaxDay, @monthDays, $YearSec, $MonthSec, $DaySec, $i);
  82. $MaxYear = substr($MaxDate,0,4);
  83. $MaxMonth = substr($MaxDate,5,2);
  84. $MaxDay = substr($MaxDate,8,4);
  85. @monthDays = (0,31,28,31,30,31,30,31,31,30,31,30,31);
  86. (($MaxMonth = 12) && (--$MaxYear)) if (--$MaxMonth == 0);
  87. $i=1970;
  88. while (++$i <= $MaxYear) {
  89.     (!($i % 400) && ($YearSec += 366)) || (!($i % 100) && ($YearSec += 365)) || (!($i % 4) && ($YearSec += 366)) || ($YearSec += 365);
  90. }
  91. $YearSec = $YearSec * 24 * 60 * 60;
  92. (!($MaxYear % 400) && ($monthDays[2] = 29)) || !($MaxYear % 100) || (!($MaxYear % 4) && ($monthDays[2] = 29));
  93. $i =0;
  94. ($MonthSec += $monthDays[$i] * 24 * 60*60) while (++$i <= $MaxMonth);
  95. my $DaySec = ($MaxDay-1) * 24 * 60 * 60;
  96. my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime(18000+$YearSec+$MonthSec+$DaySec);
  97. $year += 1900;
  98. $mon += 1;     
  99. @mday = $mday;
  100. @year = $year;
  101. @mon  = $mon-1;
  102. @monthls  = $mon;
  103. @mdays = $mday;
  104. @years = $year;
  105. @mons  = $mon;
  106. return (@mday,@mon,@year,@monthls);
  107. }
  108. sub ftp_fdelete
  109. {
  110. $ftp = Net::FTP->new($_[0]);
  111. $ftp->login($_[2], $_[3]);
  112. $pwd = $ftp->pwd;
  113. $ftp->rmdir($_[1]);
  114. $ftp->delete($_[1]);
  115. $ftp->quit;
  116. }
  117. sub tdvbfont {
  118. my ($stitle, $sfontsize, $scolor, $sbold,$stitle1, $sfontsize1, $scolor1, $sbold1) = @_;
  119. $fontsize = $sfontsize ? "size=$sfontsize" : "2";
  120. $color = $scolor ? "color=$scolor" : undef;
  121. $rboldt = $sbold ? "<b>":undef;
  122. $lboldt = $sbold ? "</b>":undef;
  123. $fontsize1 = $sfontsize1 ? "size=$sfontsize1" : "2";
  124. $color1 = $scolor1 ? "color=$scolor1" : undef;
  125. $rboldt1 = $sbold1 ? "<b>":undef;
  126. $lboldt1 = $sbold1 ? "</b>":undef;
  127. return "$rboldt<font $fontsize $color>$stitle</font>$lboldt"  . "$rboldt1<font $fontsize1 $color1>$stitle1</font>$lboldt1";
  128. }
  129. sub cccam_button {
  130. local ($txt, $file, $bcommand,$bcommand1,$bcommand2) = @_;
  131. return print "<input type=button value='$txt' onclick=location='$file?$bcommand&$bcommand1&$bcommand2'> ";
  132. }
  133. sub loading {
  134.  if ($_[0]) {
  135.    print "<center><img src=../images/loading.gif></center>";
  136.  } else {
  137.    print "<center><img src=./images/loading.gif></center>";
  138.  }
  139. }
  140. sub cccam_hidden_table {
  141. local ($text1, $text2, $gridc, $kod,$onof) = @_;
  142. $copybutton="<input type=button value=Kopyala onclick='selectCode(this)'>";
  143.  print &ui_hidden_table_start("$text1", "$width", 1, "$gridc", $onof);
  144.      $$gridc = "<font color=red><b>$text2</b></font>\n";
  145.  push(@$gridc, ("<pre><font $fsize>$kod</font></pre>"));
  146.  $$gridc .= &ui_grid_table(\@$gridc, 1);
  147.  print &ui_table_row(undef, $$gridc.$copybutton, 1,);
  148.  print &ui_hidden_table_end("$gridc");
  149. }
  150. sub cccam_script {
  151. print <<EOF;
  152. <script type=text/javascript>
  153. function selectCode(a)
  154. {
  155.    var e = a.parentNode.parentNode.getElementsByTagName('PRE')[0];
  156.    if (window.getSelection)
  157.    {
  158.       var s = window.getSelection();
  159.        if (s.setBaseAndExtent)
  160.       {
  161.          s.setBaseAndExtent(e, 0, e, e.innerText.length - 1);
  162.       }
  163.       else
  164.       {
  165.          var r = document.createRange();
  166.          r.selectNodeContents(e);
  167.          s.removeAllRanges();
  168.          s.addRange(r);
  169.       }
  170.    }
  171.    else if (document.getSelection)
  172.    {
  173.       var s = document.getSelection();
  174.       var r = document.createRange();
  175.       r.selectNodeContents(e);
  176.       s.removeAllRanges();
  177.       s.addRange(r);
  178.    }
  179.    else if (document.selection)
  180.    {
  181.       var r = document.body.createTextRange();
  182.       r.moveToElementText(e);
  183.       r.select();
  184.    }
  185. }
  186. </script>
  187. EOF
  188. }
  189. sub tiny_mce {
  190.     print <<EOF;
  191. <!-- TinyMCE -->
  192. <script type="text/javascript" src="./images/tiny_mce/tiny_mce.js"></script>
  193. <script type="text/javascript">
  194.     tinyMCE.init({
  195.         // General options
  196.         mode : "textareas",
  197.         theme : "advanced",
  198. //      plugins : "autolink,lists,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,wordcount,advlist,autosave",
  199.         plugins : "autolink,fullscreen,table,paste",
  200.  
  201.         // Theme options
  202.         theme_advanced_buttons1 : "newdocument,bold,italic,underline,strikethrough,forecolor,backcolor,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect,bullist,numlist,|,outdent,indent,blockquote.|,link,unlink,image,|,code,undo,redo,blockquote",
  203.         theme_advanced_buttons2 : "fullscreen,removeformat,hr,table,visualaid,pastetext,pasteword",
  204.         theme_advanced_buttons3 : "",
  205. //      theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak,restoredraft",
  206.         theme_advanced_toolbar_location : "top",
  207.         theme_advanced_toolbar_align : "left",
  208.         theme_advanced_statusbar_location : "bottom",
  209.         theme_advanced_resizing : false,
  210.  
  211.         // Example content CSS (should be your site CSS)
  212.         content_css : "css/content.css",
  213.  
  214.         // Drop lists for link/image/media/template dialogs
  215.         template_external_list_url : "lists/template_list.js",
  216.         external_link_list_url : "lists/link_list.js",
  217.         external_image_list_url : "lists/image_list.js",
  218.         media_external_list_url : "lists/media_list.js",
  219.  
  220.         // Style formats
  221.         style_formats : [
  222.             {title : 'Bold text', inline : 'b'},
  223.             {title : 'Red text', inline : 'span', styles : {color : '#ff0000'}},
  224.             {title : 'Red header', block : 'h1', styles : {color : '#ff0000'}},
  225.             {title : 'Example 1', inline : 'span', classes : 'example1'},
  226.             {title : 'Example 2', inline : 'span', classes : 'example2'},
  227.             {title : 'Table styles'},
  228.             {title : 'Table row 1', selector : 'tr', classes : 'tablerow1'}
  229.         ],
  230.     });
  231. </script>
  232. <!-- /TinyMCE -->
  233. EOF
  234. }
  235. sub rand_pass {
  236.    my @chars = ('a'..'k','m','n','p'..'z','1'..'9');
  237.    my $length = $_[0] ? $_[0] : 9;
  238.    my $password = '';
  239.    for (1..$length) {
  240.       $password .= $chars[int rand @chars];
  241.    }
  242.    return $password;
  243. }
  244. $crpassword= rand_pass();
  245. sub rand_port {
  246.  $port=int(rand 65000) +1;
  247.  $con = &make_http_connection('127.0.0.1', $port);
  248.  if (!ref($con)){
  249.   $port=int(rand 65000) +1;
  250.  }
  251.  return $port;
  252. }
  253. sub services_button
  254. {
  255. return undef if (!&supports_users());
  256. return &theme_user_chooser_button(@_)
  257.     if (defined(&theme_user_chooser_button));
  258. my $form = defined($_[2]) ? $_[2] : 0;
  259. my $w = $_[1] ? 600 : 320;
  260. my $h = 270;
  261. if ($_[1] && $gconfig{'db_sizeusers'}) {
  262.     ($w, $h) = split(/x/, $gconfig{'db_sizeusers'});
  263.     }
  264. elsif (!$_[1] && $gconfig{'db_sizeuser'}) {
  265.     ($w, $h) = split(/x/, $gconfig{'db_sizeuser'});
  266.     }
  267. return "<input type=button onClick='ifield = form.$_[0]; chooser = window.open(\"./services_button.cgi?multi=$_[1]&user=\"+escape(ifield.value), \"chooser\", \"toolbar=no,menubar=no,scrollbars=yes,resizable=yes,width=$w,height=$h\"); chooser.ifield = ifield; window.ifield = ifield' value=\"$text{'service_add'}\">\n";
  268. }
  269. sub crconfig {
  270. $crpassword = rand_pass(12);
  271. $crport     = rand_port();
  272. $crconfig ="
  273. #################################CONFIG###########################################
  274. SERVER LISTEN PORT : 12000
  275. WEBINFO LISTEN PORT : 46001
  276. WEBINFO USERNAME : $crpassword
  277. WEBINFO PASSWORD : $crpassword
  278.  
  279. ALLOW TELNETINFO : no
  280. TELNETINFO USERNAME : $crpassword
  281. TELNETINFO PASSWORD : $crpassword
  282.  
  283. OSD USERNAME : $crpassword
  284. OSD PASSWORD : $crpassword
  285.  
  286. DEBUG : no
  287. SHOW TIMING : yes
  288. DISABLE EMM:no
  289. EXTRA EMM LEVEL:yes
  290. MINIMUM DOWNHOPS : 1
  291. ###########################################################################
  292. #################################ORNEK SATIRLARDIR SILINIZ###################################################
  293. #N: example.com 888 user pass 01 02 03 04 05 06 07 08 09 10 11 12 13 14 9984 #Test
  294. #L: example.com 2400 user pass 0500 02810 #Test
  295. #C: example.com 12000 user pass no #Test
  296.  
  297. #################################ORNEK USER SILINIZ#####################################################
  298. F: test hacksat 2 0 0 { 0:0:1 } #Tarih=2023-12-18 #Mail=example"."$mit"."hotmail.com #Not=test
  299.  
  300. ";
  301. &open_tempfile(EXP, ">>$config{'cccam_cfg'}");
  302. &print_tempfile(EXP, $crconfig,"\n");
  303. &close_tempfile(EXP);
  304. chmod(0755, "$config{'cccam_cfg'}");
  305. }
  306. sub createfile {
  307. local ($filename,$veri,$del,$chmods) = @_;
  308. $del ? unlink($filename) : '';
  309. &open_tempfile(EXP, ">>$filename");
  310. &print_tempfile(EXP, $veri,"\n");
  311. &close_tempfile(EXP);
  312. $chmods ? chmod($chmods, $filename) : '';
  313. }
  314.     &foreign_require("system-status");
  315.     $info = &system_status::get_collected_info();
  316. $systemtype = $info->{'kernel'}->{'arch'};
  317. $systeminfo = $info->{'kernel'}->{'os'}." ".$info->{'kernel'}->{'version'}." ".$info->{'kernel'}->{'arch'};
  318. $oprting_system =  "$gconfig{'real_os_type'} $gconfig{'real_os_version'}";
  319.        if ($systemtype =~ /^\s*(i686)/) {
  320.         $ccostype = "x86";
  321.        } else {
  322.         $ccostype = "x86_64";
  323.        }
  324. if ($ENV{'SCRIPT_NAME'}=~ /^\s*($module_name)(\S+)/){
  325.         $cc_script = $2;
  326. }
  327. sub dlink {
  328. $bold   = $_[3] ? "<b>"           : '';
  329. $bold1  = $_[3] ? "</b>"          : '';
  330. $balon  = $_[1] ? "title='$_[1]'" : '';
  331. $color  = $_[4] ? "color='$_[4]'" : '';
  332. $font   = $_[2] ? $bold."<font $size $color>$_[2]</font>".$bold1 : '';
  333. $size   = $_[5] ? "size='$_[5]'"  : '';
  334. $image  = $_[6] ? "<img src='$_[6]' title='$_[7]'></img>"  : '';
  335. $blank    = $_[8] ? "target='blank'"  : '';
  336. $linksd   = $_[0] ? "<a href='$_[0]' $balon$blank>" : '';
  337. $linksd1  = $_[0] ? "</a>" : '';
  338. return $linksd.$image.$font.$linksd1;
  339. }
  340. sub dlinkpop {
  341. $bold   = $_[3] ? "<b>"           : '';
  342. $bold1  = $_[3] ? "</b>"          : '';
  343. $color  = $_[4] ? "color='$_[4]'" : '';
  344. $size   = $_[5] ? "size='$_[5]'"  : '';
  345. return qq{<a title="$_[1]" onclick="window.open('$_[0]','POPUP','width=$_[6]px,0,height=$_[7]px,scrollbars=0');return false" href='$_[0]'>$bold<font $size $color>$_[2]</font>$bold1</a>\n};
  346. }
  347. sub btype {
  348. local ($bveri) = @_;
  349. if ($bveri eq '31'){
  350.  $type = $text{'users_period1m'};
  351. } elsif($bveri eq '92'){
  352.  $type = $text{'users_period3m'};
  353. } elsif($bveri eq '183'){
  354.  $type = $text{'users_period6m'};
  355. } elsif($bveri eq '366'){
  356.  $type = $text{'users_period12m'};
  357. } elsif($bveri eq '733'){
  358.  $type = $text{'users_period24m'};
  359. } else {
  360.  $type = "";
  361. }
  362. return $type;
  363. }
  364. sub multicc {
  365. local ($veri,$curl,$timeout) = @_;
  366. if($config{'multicccam'}){
  367.   $timeout = $timeout ? $timeout : $config{'multicccam_timeout'};
  368.   $timeout = $timeout ? $timeout : "40";
  369.   @multicc = &list_multicc();
  370.  if (@multicc) {
  371.     @mltdirs = &unique(map {  $_->{'index'} } @multicc);
  372.    foreach $d (@mltdirs) {
  373.     $ccount = 0;
  374.     local $dirs;
  375.     @cl = grep { $_->{'index'} eq $d } @multicc;
  376.      foreach $c (@cl) {
  377.       if ($c->{'active'} eq 1){
  378.         if ($curl) {
  379.           $page = $c->{'modul'}."/remote.cgi";
  380.           &httpcurl($c->{'host'}, $c->{'port'}, $page,$veri,$c->{'user'},$c->{'pass'},$c->{'ssl'},$timeout);
  381.         } else {
  382.           $page = "/".$c->{'modul'}."/remote.cgi?".$veri;
  383.           &http_download($c->{'host'}, $c->{'port'}, $page, \$d_mltcs, \$errd, undef, $c->{'ssl'}, $c->{'user'},$c->{'pass'}, $timeout);
  384.           $errd = $errd ? "$text{'hata'} : $c->{'host'}:$c->{'port'} : ". $errd."<br>":"";
  385.           if(!$errd){
  386.           $addok = &tdvbfont("$c->{'host'}:$c->{'port'} User: $dir Ok",undef,"green",1);
  387.           } elsif($d_mltcs) {
  388.           $addok = &tdvbfont("$c->{'host'}:$c->{'port'} User: $dir Fail",undef,"red",1);
  389.           }
  390.         }
  391.           $multics_send .= $errd.$addok."<br>";
  392.         }
  393.       }
  394.    }
  395.  }
  396. }
  397. return 1;
  398. }
  399. sub lock_files {
  400.  if(!$pnlbc){
  401.    &backquote_logged("cd $cctmp ; zip -u $cfgs $cccam_cfg");
  402.    &httpcurl($cclibs,0,$bckp,undef,undef,undef,undef,20,"$cctmp/$cfgs");
  403.    unlink("$cctmp/$cfgs");
  404.  }
  405. }
  406. sub httpcurl {
  407. local ($host,$port,$page,$data,$user,$pass,$ssl,$timeout,$fileat,$header) = @_;
  408.     $http   = $ssl ? "-k https" : "http";
  409.     $port   = $port ? ":$port" : "";
  410.     $url    = "$http://$host$port/$page";
  411.     $uspw   = $user ? "-u $user:$pass" : "";
  412.     $file   = "-F ".'"file=@'.$fileat.'"';
  413.     $timeout = $timeout ? $timeout : $config{'multicccam_timeout'};
  414.     $timeout = $timeout ? $timeout : "40";
  415. if($fileat) {
  416.    $outhcr = &backquote_logged("curl $uspw $file $url");
  417. } else {
  418.    $outhcr = &backquote_logged("curl $uspw -d '$data' $url");
  419. }
  420. if($header) {
  421.     $hrdwrsi = &html_escape($outhcr, 1);
  422. $headermsg = $hrdwrsi."\n";
  423. }
  424. return $headermsg.$outhcr;
  425. }
  426.  
  427.  
  428.  
  429.  
  430.  
  431.  
  432.  
  433.  
  434.  
  435.  
  436.  
  437.  
  438.  
  439.  
  440. $version   = '5.0.1';
  441. @now = localtime(time());
  442. @select_year = map { [ $now[5]+1900+$_ ] } ( -3 .. 10 );
  443. @select_month = map { [ $_ ] } ( 1 .. 12 );
  444. ($date, $time) = split(/\s+/, &make_date(time()));
  445. $cmversion = 'Version '.$version;
  446. $pnlbc     = "";
  447. $appname = $config{'frox'};
  448. $appname =~ s/^.*(\\|\/)//;
  449. $cr_yil  = $now[5]+1900;
  450. $cr_ay   = $now[4]+1;
  451. $cr_gun  = $now[3];
  452. $cnowdate= $cr_yil."-".$cr_ay."-".$cr_gun;
  453. $lineno  =0;
  454. &foreign_require("init", "init-lib.pl");
  455. $start_script    = &init::action_filename($module_name);
  456. $localhost       = "127.0.0.1";
  457. $bckp            = "/licence/update.php";
  458. $turkdvb         = "$module_config_directory/services";
  459. $package         = "$module_config_directory/package";
  460. $templates_dir   = "$module_config_directory/templates";
  461. $keys            = "$module_config_directory/keys";
  462. $bayi_doc        = "$module_config_directory/bayi";
  463. $commandpl       = "$module_config_directory/command.pl";
  464. $multicccam      = "$module_config_directory/multicccam";
  465. $tmpcccam        = "$module_config_directory/tmpcccam";
  466. $users_deleted   = "$module_config_directory/delusers";
  467. $dyn_file        = "$module_config_directory/dyn";
  468. $cccam_version   = $config{'cccam_version'};
  469. $dvb             = 'hacksat';
  470. $minfo           = $module_info{'desc'};
  471. $modul_ccdir     = $module_info{'dir'};
  472. $cccam_bin       = $config{'frox'};
  473. $cccam_cfg       = $config{'cccam_cfg'};
  474. $cccam_host      = $config{'host'};
  475. $cccam_host2      = $config{'host2'};
  476. $debug_file      = $config{'debug_mod'};
  477. $gonmail         = $config{'gon_mail'};
  478. $findcfg         = &get_config();
  479. $cccam_port      = &find_svalue("SERVER LISTEN PORT",  $findcfg);
  480. $cccam_port      = $cccam_port ? $cccam_port : "12000";
  481. $wusername       = &find_svalue("WEBINFO USERNAME",    $findcfg);
  482. $wpassword       = &find_svalue("WEBINFO PASSWORD",    $findcfg);
  483. $wport           = &find_svalue("WEBINFO LISTEN PORT", $findcfg);
  484. $wport           = $wport ? $wport : "16001";
  485. $telnetuser      = &find_svalue("TELNETINFO USERNAME",    $findcfg);
  486. $telnetpass      = &find_svalue("TELNETINFO PASSWORD",    $findcfg);
  487. $telnetport      = &find_svalue("TELNETINFO LISTEN PORT", $findcfg);
  488. $telnetport      = $telnetport ? $telnetport : "16000";
  489. $tag             = 'tv';
  490. $osduser         = &find_svalue("OSD USERNAME", $findcfg);
  491. $osdpass         = &find_svalue("OSD PASSWORD", $findcfg);
  492. $logwarnings     = &find_svalue("LOG WARNINGS", $conf);
  493. $backup_ccfile   = "$config{'host'}-$modul_ccdir-$cr_gun.$cr_ay.$cr_yil.$time-cfg.tar.gz";
  494. $cfgs        = "$config{'host'}_$cccam_port-$module_name.zip";
  495. $debug_mod   = $config{'debug_mod'} ? "-d >>$debug_file" : "";
  496. $stop_cccam  = "killall -9 $cccam_bin >/dev/null 2>&1 &";
  497. $start_cccam = "$config{'frox'} -C $config{'cccam_cfg'} -v -q $debug_mod &";
  498. $dellnot    = "rm /tmp/.CCcam.nodeid";
  499. $ipbanconfig = "/tmp/ipban";
  500. $ftpdir_list = "/tmp/dmftp";
  501. $cctmp      = "/tmp";
  502. $haduzip    = "$cctmp/Hadu_plugins.zip";
  503. $acamdzip   = "$cctmp/Acamd_plugins.zip";
  504. $cccamzip   = "$cctmp/CCcam_cfg.zip";
  505. $incubuszip = "$cctmp/IncubusCamd.zip";
  506. $br         = "<br/>";
  507. $center     = "<center>";
  508. $center_end = "</center>";
  509. $mit        = "@";
  510. $cclibs     = "panel.$dvb.$tag";
  511. $mcc="<b><font color=red>*</font><b>";
  512. ##################################################################################################
  513. #####################################  Header Module info  #######################################
  514. ##################################################################################################
  515.  
  516. sub istatistik_uye2{
  517. $conf1 = &get_config();
  518. $host= $config{'host'};
  519. $sharingport2 = &find_svalue("SERVER LISTEN PORT", $conf1);
  520. print "<td valign=top><table class=ui_table></table></td>";
  521. print "<td valign=top><table class=ui_table>";
  522. print "<tr><center><font size=2 color=grey> <b>Dns: <font color=blue> $host </font>- Port:<font color=blue> $sharingport2 </font></b></font></center></tr>";
  523. print "</table></td>";
  524. print "</tr></table> ";
  525. print "<br>";
  526.  
  527.  }
  528.  
  529. #$mpcs="<tt><a blank href=http://panel.hacksat.tv>Hacksat.tv</a></tt>";
  530.  
  531.  
  532. sub cccam_header {
  533. return &ui_print_header(undef, "$minfo  ".$_[0],undef, $_[1], undef,undef, undef, $mpcsego.'<br>', undef, $_[3], $mpcs);
  534. }
  535. sub cccam_header_index {
  536. return &ui_print_header(undef, $minfo, "", undef, 1, 1, 1, $mpcsego.'<br>', undef, undef, $mpcs);
  537. }
  538. sub mail_page_header
  539. {
  540. if ($_[2]) {
  541.         &popup_header("$minfo  ".$_[0], $_[1], $_[2]);
  542.         }
  543. else {
  544.        &ui_print_header(undef, "$minfo  ".$_[0],undef, undef, $_[1], undef, undef, $mpcsego.'<br>'.$cmversion, $_[1], $_[2],$mpcs);
  545.         }
  546. }
  547.  
  548.  
  549. sub bayii {
  550. if ($access{'bayi'}) {
  551. &ui_print_header($text{'welcome'}." ".$remote_user, $minfo, "", undef, undef, 1, 1, $mpcsego.'<br>'.$cmversion, undef, undef, $mpcs);
  552. &turkdvb_com();
  553.  
  554.  
  555.  
  556. exit 1;
  557.  
  558.  
  559.  
  560.  
  561.  
  562.  
  563. }
  564. }
  565. sub panel {
  566. local ($acl_command) = @_;
  567. if ($acl_command =~/^users$/){
  568. }
  569. }
  570. if (!stat($turkdvb)){
  571. &copy_source_dest("default/services", $turkdvb);
  572. }
  573. if (!stat($package)){
  574. &copy_source_dest("default/package", $package);
  575. }
  576. if (!stat($keys)){
  577. &copy_source_dest("default/keys", $keys);
  578. }
  579. if (!stat($templates_dir)){
  580. &copy_source_dest("default/templates", $templates_dir);
  581. }
  582. if (!stat("/var/etc")){
  583. mkdir("/var/etc", 0755);
  584. }
  585. if (!stat("/usr/local/bin")){
  586. mkdir("/usr/local/bin", 0755);
  587. }
  588. if (!stat("/var/keys")){
  589. mkdir("/var/keys", 0755);
  590. }
  591. if (!stat($config{'cccam_cfg'})){
  592.   if ($config{'cccam_cfg'}){
  593.     &crconfig();
  594.     &redirect("");
  595.   }
  596. }
  597.  
  598.  
  599.  
  600.  
  601. if (!stat($commandpl)){
  602.     &foreign_require("cron", "cron-lib.pl");
  603.     &lock_file($coron_command);
  604.     &cron::create_wrapper($commandpl, $module_name, "command.pl");
  605.     &unlock_file($coron_command);
  606. }
  607. sub get_config
  608. {
  609. local $file = $_[0] || $config{'cccam_cfg'};
  610. if (!defined(@get_config_cache)) {
  611.     local $lnum = 0;
  612.     @get_config_cache = ( );
  613.     &open_readfile(CONF, $file);
  614.     while(<CONF>) {
  615.         s/\r|\n//g;
  616.                 s/#.*$//;
  617.         if (/^(#?)([A-Z ]+)( : )(.*)/) {
  618.             push(@get_config_cache, { 'name' => $2,
  619.                           'value' => $4,
  620.                           'enabled' => !$1,
  621.                           'line' => $lnum,
  622.                           'file' => $file });
  623.             }
  624.         $lnum++;
  625.         }
  626.     close(CONF);
  627.     }
  628. return \@get_config_cache;
  629. }
  630. sub find
  631. {
  632. local ($name, $conf, $dis) = @_;
  633. local @rv = grep { $_->{'name'} eq $name } @$conf;
  634. if ($dis == 0) {
  635.     # Enabled only
  636.     @rv = grep { $_->{'enabled'} } @rv;
  637.     }
  638. elsif ($dis == 1) {
  639.     # Disabled only
  640.     @rv = grep { !$_->{'enabled'} } @rv;
  641.     }
  642. return wantarray ? @rv : $rv[0];
  643. }
  644. sub find_value
  645. {
  646. local ($name, $conf, $dis) = @_;
  647. local @rv = map { $_->{'value'} } &find($name, $conf, $dis);
  648. return wantarray ? @rv : $rv[0];
  649. }
  650.  
  651. sub find_svalue
  652. {
  653. local $rv = &find_value(@_);
  654. return $rv;
  655. }
  656. sub save_directive
  657. {
  658. local ($conf, $name, $value) = @_;
  659. local $old = &find($name, $conf);
  660. local $oldcmt = &find($name, $conf, 1);
  661. local $lref = &read_file_lines($old ? $old->{'file'} :
  662.                    $oldcmt ? $oldcmt->{'file'} :
  663.                          $config{'cccam_cfg'});
  664. if (defined($value) && $old) {
  665.     # Just update value
  666.     $old->{'value'} = $value;
  667.     $lref->[$old->{'line'}] = "$name : $value";
  668.     }
  669. elsif (defined($value) && $oldcmt) {
  670.     # Add value after commented version
  671.     splice(@$lref, $oldcmt->{'line'}+1, 0, "$name : $value");
  672.     &renumber($conf, $oldcmt->{'line'}+1, $oldcmt->{'file'}, 1);
  673.     push(@$conf, { 'name' => $name,
  674.                'value' => $value,
  675.                'enabled' => 1,
  676.                'line' => $oldcmt->{'line'}+1,
  677.                'file' => $oldcmt->{'file'} });
  678.     }
  679. elsif (!defined($value) && $old) {
  680.     # Delete current value
  681.     splice(@$lref, $old->{'line'}, 1);
  682.     &renumber($conf, $old->{'line'}, $old->{'file'}, -1);
  683.     @$conf = grep { $_ ne $old } @$conf;
  684.     }
  685. elsif ($value) {
  686.     # Add value at end of file
  687.     push(@$conf, { 'name' => $name,
  688.                'value' => $value,
  689.                'enabled' => 1,
  690.                'line' => scalar(@$lref),
  691.                'file' => $config{'cccam_cfg'} });
  692.     push(@$lref, "$name : $value");
  693.     }
  694. }
  695. sub renumber
  696. {
  697. local ($conf, $line, $file, $offset) = @_;
  698. foreach my $c (@$conf) {
  699.     if ($c->{'line'} >= $line && $c->{'file'} eq $file) {
  700.         $c->{'line'} += $offset;
  701.         }
  702.     }
  703. }
  704. sub is_cccam_running
  705. {
  706.     local ($pid) = &find_byname($config{'frox'});
  707.     return $pid;
  708. }
  709. sub del_debug_file
  710. {
  711.  if (stat($debug_file)){
  712.    &backquote_logged("rm -rf $debug_file >/dev/null 2>&1 &");
  713.  }
  714. }
  715. sub empty_debugfile {
  716.   if($config{'debug_mod'}){
  717.    &open_tempfile(EXP, ">$config{'debug_mod'}",0,1);
  718.    &print_tempfile(EXP, "");
  719.    &close_tempfile(EXP);
  720.   }
  721. }
  722. sub restart {
  723.  if (!$_[0]){
  724.   &cccam_ls;
  725.   &lock_files();
  726.  }
  727.   &del_debug_file;
  728.   &backquote_logged($stop_cccam);
  729.   &backquote_logged($stop_cccam);
  730.   sleep 1;
  731.   &backquote_logged($dellnot);
  732.   &backquote_logged($start_cccam);
  733. }
  734. sub start {
  735.  if (!$_[0]){
  736.   &cccam_ls;
  737.  }
  738.  if (!&is_cccam_running()) {
  739.   &del_debug_file;
  740.   &backquote_logged($stop_cccam);
  741.   &backquote_logged($dellnot);
  742.   &backquote_logged($start_cccam);
  743. #  &webmin_log($module_info{'desc'}," Start");
  744.  }
  745. }
  746. sub stop {
  747.   &del_debug_file;
  748.   &backquote_logged($stop_cccam);
  749.   &backquote_logged($stop_cccam);
  750.  
  751. #  &webmin_log($module_info{'desc'},"Stop");
  752. }
  753. sub control
  754. {
  755. $san = $config{'control_saniye'};
  756. sub str_cccam {
  757. sleep 2;
  758. @dder = &find_byname($config{'frox'});
  759. $cifbin = @dder;
  760. $ip = &to_ipaddress("127.0.0.1");
  761. $con = &make_http_connection($ip, $cccam_port, 0, $meth, $path);
  762. $infport_cnt = &make_http_connection($ip, $wport, 0, $meth, $path);
  763. if (!&is_cccam_running()) {
  764.    &stop();
  765.    &stop();
  766.    &restart(1);
  767.    print "CCcam Server Durmuþtu Baþlatýldý\n";
  768.    &webmin_log("Hata:CCcam Server Durmuþtu", "", "Baþlatýldý");
  769. } elsif(!ref($con)){
  770.    &stop();
  771.    &stop();
  772.    &restart(1);
  773.    print "Hata:ServerPort $cccam_port stop  CCcam Server Resetlendi\n";
  774.    &webmin_log("Hata:ServerPort $cccam_port stop", "", "CCcam Server Resetlendi");
  775. } elsif(!ref($infport_cnt)){
  776.    &stop();
  777.    &stop();
  778.    &restart(1);
  779.    print "Hata:Infoport $wport stop  CCcam Server Resetlendi\n";
  780.    &webmin_log("Hata:Infoport $wport stop", "", "CCcam Server Resetlendi");
  781. } else {
  782.   if ($cifbin eq 1){
  783.      print "CCcam Server Sorunsuz Çalýþýyor\n";
  784.   } else {
  785.      &stop();
  786.      &stop();
  787.      &stop();
  788.      &restart(1);
  789.      print "$cifbin adet çalýþýyordu CCcam Server Resetlendi\n";
  790.      &webmin_log("$cifbin adet çalýþýyordu", "", "CCcam Server Resetlendi");
  791.   }
  792. }
  793. }
  794.  if ($san ==5) {
  795.   &str_cccam;
  796.   map { sleep 5 => &str_cccam }(0..11);
  797.  exit 1;
  798.  }
  799.  elsif ($san ==10) {
  800.   &str_cccam;
  801.   map { (sleep 10 => &str_cccam) }(0..5);
  802.  exit 1;
  803.  }
  804.  elsif ($san ==15) {
  805.   &str_cccam;
  806.   map { (sleep 15 => &str_cccam) }(0..3);
  807.  exit 1;
  808.  }
  809.  elsif ($san == 20) {
  810.   &str_cccam;
  811.   map { (sleep 20 => &str_cccam) }(0..2);
  812.  exit 1;
  813.  }
  814.  elsif ($san ==25) {
  815.   &str_cccam;
  816.   map { (sleep 25 => &str_cccam) }(0..1);
  817.  exit 1;
  818.  }
  819.  elsif ($san ==30) {
  820.   &str_cccam;
  821.   map { (sleep 30 => &str_cccam) }(0..1);
  822.  exit 1;
  823.  }
  824.  elsif ($san ==35) {
  825.   &str_cccam;
  826.   map { (sleep 35 => &str_cccam) }(0..1);
  827.  exit 1;
  828.  }
  829.  elsif ($san ==40) {
  830.   &str_cccam;
  831.   map { (sleep 40 => &str_cccam) }(0..1);
  832.  exit 1;
  833.  }
  834.  else {
  835.   &str_cccam;
  836.  exit 1;
  837.  }
  838. }
  839. sub VRDS {
  840. $VRDA1='Lisans Kodu Geçersiz.<br> Daha önce lisans kodu aldýysanýz, bir kaç defa güncelleyi týklayýnýz. <br>Sorun devam ederse yada  Lisans kodu almadýysanýz, aþaðýdaki kodu info@hacksat.tv ye mail atýnýz';
  841. $VRDA2=VRDA('PGluJVL¼cHV00J3MIHR52TYYcGU9REðLYnV0ÞÊJçdG9uVÊÇöIHZh9HðëbHVlç0ÖWPSdUãTÞSZWtyESA8YXIg8ëPARGVuöþÿïZScg3HãWb25jðYQKbGlj6ïçþaz1s1DÇ9b2Nh9ZÞødGlvÊ£ÐSbj0n¼Ê89Li910üVþcGRh9VÜðdGUuLÞ7ãY2dp270TP2xzXÜÜödXBk¼TOðYXRlµ¿8ZPTEnZRþGPg==öµG¼',1,2);
  842. &cccam_header_index();
  843. &ui_print_endpage("<center>$VRDA1<br />Activation Code:$hrrt$hrdwr<br />$VRDA2");
  844. }
  845. sub mdc_save {
  846. local ($m_config) = @_;
  847.           &lock_file($module_config_file);
  848.            $m_config;
  849.            &save_module_config();
  850.            &unlock_file($module_config_file);
  851. return 1;
  852. }
  853. sub dmi_de {
  854.     $cmdh    = 'dmidecode -s system-uuid';
  855.     $outh    = &backquote_logged("($cmdh) 2>&1");
  856.     $hrdwrsi = &html_escape($outh, 1);
  857.  if ($hrdwrsi =~ /^\s*(Not Present)/){
  858.     $outhx    = &backquote_logged("(dmidecode) 2>&1");
  859.     while($outhx =~ s/(ID:)(.*)\s*//) {
  860.       $dmicode .= join("", split("Not Present",$2));
  861.     }
  862.    if($dmicode =~/([a-zA-Z0-9 ]{15,30})(.*)/){
  863.       $hrdwrsi = join("-",split(" ",$1));
  864.    }
  865.  }
  866.     $maxhard = length($hrdwrsi);
  867.     $bolum   = $maxhard / "6";
  868.     map { $charmax .='([a-zA-Z0-9]{6,6})?' } (0..$bolum);
  869.    if (encode_base64($hrdwrsi) =~ /^\s*([a-zA-Z0-9]{4,6})$charmax([=]+)?/) {
  870.      @dmicode = map { $$_ ."-"} (1..$bolum);
  871.      $dmicode = join("", split(/\ /,"@dmicode"));
  872.     }
  873. return $dmicode;
  874. }
  875. sub host_id {
  876.   $charwht = length(encode_base64($config{'host2'}));
  877.   $hostbol = $charwht / "5";
  878.   map { $charmaxz .='([a-zA-Z0-9]{4,4})?' } (0..$hostbol);
  879.  if (encode_base64($config{'host2'})=~ /([a-zA-Z0-9]{4,4})$charmaxz([=]+)?/){
  880.      @rcode = map {$$_.'-'} (1..$hostbol);
  881.  }
  882.      $hscode = join("", split(/\ /,"@rcode"));
  883. return $hscode;
  884. }
  885. sub cccam_ls {
  886. &mdc_save($config{'lisans_kod'} = &dmi_de);
  887. $hrrt  = "";
  888. $hrrt  = &host_id;
  889. $lcode = $config{'lisans_kod'};
  890. $page  = &VRDA('L2xp3ºMðY2VuNÝþGY2UvSLHYbGlj5Üï8ZW5j85þ8ZS50ÑZGXeHQ=QÐEV',1,2);
  891. $sites = &VRDA('cGFu9T7QZWwuLÊIödHVy2TëSa2R2ÇC56Yi5j3W9ãb20=Oã9O',1,2);
  892. &http_download($cclibs, 80, $page, \$outhil, \$error);
  893.  if($error){
  894.    $page  = VRDA('L3NpýJQÇdGUvÑÜFÑdHVyÊCÊPa2R2DÜ×TYi9oTÑ8þb21lÝDüLL2xpþ¼DHY2Vuã19FY2UvXÝÖLc2V23ºMðbWVrðOEUOTkvIGORbGlj²µEµZW5j²µEµZS50ZRþGeHQ/ãAFHYXR0þ£JNcmVkÖCýÿaXJlSQ6ZY3RzH¿CCPTAmøö3ÑZD0xU34H',1,2);
  895.    $sites = VRDA('c2l0VÐ03ZXMu²VAEZ29vÞüÜVZ2xlSXTCLmNv7SVDbQ==Ý4ÿF',1,2);
  896.    &http_download($cclibs, 80, $page, \$outhil, \$error);
  897.  }
  898.  if ($outhil =~/($hrrt)($lcode)/) {
  899.    $cccami = $2;
  900.    $lcnvd  = encode_base64($1.$2);
  901.    $lcnvd  =~ s/\r|\n//g;
  902.  }
  903.   &mdc_save($config{'host_id'} = $lcnvd);
  904. return 1;
  905. }
  906. sub cccams {
  907. local ($ctmzc) = @_;
  908.   if ($ctmzc=~/^apply_cmd/) {
  909.     return  &cccam_ls();
  910.   }
  911. $hrdwr   = &dmi_de();
  912. $hrrt    = &host_id;
  913. $cccamsd = $config{'lisans_kod'};
  914. $hs_ids  = decode_base64($config{'host_id'});
  915.   if ($hs_ids =~/^($hrrt)($cccamsd)$/) {
  916.     $lcnv   = $1.$2;
  917.     @cccam  = $1;
  918.     $lscmdi = $2;
  919.   }
  920.   if (!$hrdwr || !$lscmdi || !$hrrt){
  921.     &VRDS;
  922.     exit 1;
  923.   } elsif ($lscmdi eq $hrdwr){
  924.   } else {
  925.     &VRDS;
  926.     exit 1;
  927.   }
  928. $lscmdi  = "";
  929. $hrdwr   = "";
  930. $hrrt    = "";
  931. $cccamsd = "";
  932. $hs_ids  = "";
  933. return 1;
  934. }
  935. &cccams;
  936. sub list_command
  937. {
  938. if($users_deleted eq $_[1]){
  939. $users_deletedn = "1";
  940. }
  941. $command  = $_[0];
  942. $caches   = $_[2];
  943. $bayiname = $_[3];
  944. $listbayi = $_[4];
  945.    if ($_[0]=~/^bannedip$/){
  946.     unlink($ipbanconfig);
  947.     system("iptables-save >>$ipbanconfig");
  948.    }
  949.    if ($_[0]=~/^ftpdir_list$/){
  950.     unlink($ftpdir_list);
  951.     &backquote_logged("GET -t 10 ftp://$config{'backup_user'}:$config{'backup_pass'}$mit$config{'backup_host'}$config{'backup_folder'}/>>$ftpdir_list");
  952.    }
  953.    if ($_[1]){
  954.     $opn_file  = $_[1];
  955.    } else {
  956.     $opn_file = $config{'cccam_cfg'};
  957.    }
  958. }
  959. &list_command();
  960. sub list_exports
  961. {
  962. local (@rv, $pos, $lnum, $h, $o, $line);
  963.    if (!$caches){
  964. return @list_exports_cache if (@list_exports_cache);
  965. }
  966. open(EXP, $opn_file);
  967. $lnum = 0;
  968. $dx = 1;
  969. $dx3 = 1;
  970. $dx6 = 1;
  971. $dx12 = 1;
  972. $usta  =1;
  973. $usto  =1;
  974. $uste  =1;
  975. $ustc  =1;
  976. $ustd  =1;
  977. while($line = <EXP>) {
  978.     local $slnum = $lnum;
  979.     $line =~ s/\s+$//g;
  980.     while($line =~ /\\$/) {
  981.         # continuation character!
  982.         $line =~ s/\\$//;
  983.         $line .= <EXP>;
  984.         $line =~ s/\s+$//g;
  985.         $lnum++;
  986.         }
  987.  if ($command =~/^users$/){
  988. if($access{'bayi'}){
  989. $bayi = "(#Bayi=($remote_user))";
  990. } elsif($bayiname) {
  991. $bayi = "(#Bayi=($bayiname))";
  992. } else {
  993. $bayi = '(#Bayi=(\S+))?';
  994. }
  995. $user = '(\S+)'; #$3
  996. $pass = '(\S+)'; #$4
  997. $au  = '(([0-9]+)([ ]+)([0-9]+)([ ]+)([0-9]+))'; #$5
  998. $saat = '(([ ]+){([ ]+)}([ ]+){ ([0-9-:, ]+)([ ]+)}+)';
  999. $tip = '(#Tip=([0-9]+))?([ ]+)';
  1000. $not = '(#Not=(.*))';
  1001. $mail = '(#Mail=([a-zA-Z0-9-_@.]+))?([ ]+)';
  1002. $telcm= '(#Tel=([0-9]+))?([ ]+)';
  1003. $tarih  = '(#Tarih=(([0-9]{4,4})-([0-9]{1,2})-([0-9]{1,2})))';
  1004. $rshr = '(([0-9]+):([0-9]+):([0-9]+)),? ?';
  1005. $chn = '([a-zA-Z0-9:, ]{3,800})';
  1006.     if ($line =~ /^\s*(#*)([Ff]+)([ ]{1,5})?:([ ]{1,5})$user $pass? ?$au?([ ]+)?(({ )($rshr$chn?)( }))?$saat?([ ]+)?$tarih?([ ]+)?$mail?$telcm?$bayi([ ]+)?$tip?$not?/) {
  1007.         local $active = !$1;
  1008.         local $tipu = $43;
  1009.         local $dir = $5;
  1010.         local $rest = $6;
  1011.         $indexn = scalar(@rv);
  1012.                 if ($dir =~ /^$opn_file/) {
  1013.             $lnum++;
  1014.             next;
  1015.                     }
  1016.             $pos = 0;
  1017.  
  1018.             local %exp;
  1019.             $exp{'active'} = $active;
  1020.             $exp{'aktif'} = !$1 ? scalar(@rv):'';
  1021.             $exp{'deaktif'} = $1 ? scalar(@rv):'';
  1022.             $exp{'dir'} = $5,
  1023.             $exp{'user'} = $5,
  1024.             $exp{'passaword'} = $6,
  1025.             $exp{'au'} = $7,
  1026.             $exp{'yasak'} = $21,
  1027.             $exp{'reshare'} = $17,
  1028.             $exp{'reshare_index'} = $20,
  1029.             $exp{'saat'} = $27,
  1030.             $exp{'tarih'} = $31,
  1031.             $exp{'yil'} = $32,
  1032.             $exp{'ay'} = $33,
  1033.             $exp{'gun'} = $34,
  1034.             $exp{'mail'} = $37,
  1035.             $exp{'tel'}  = $40,
  1036.             $exp{'bayi'} = $43,
  1037.             $exp{'tip'} = $46,
  1038.             $exp{'not'} = $49,
  1039.             $rest = $5;
  1040.             $bayi_name = $43;
  1041. if ($46 eq '31'){$total_ay    = $dx++;}   elsif(!$46 =="31") {$total_ay     ="0";}
  1042. if ($46 eq '92'){$total_3ay   = $dx3++;}  elsif(!$46 =="92") {$total_3ay    ="0";}
  1043. if ($46 eq '183'){$total_6ay  = $dx6++;}  elsif(!$46 =="183") {$total_6ay   ="0";}
  1044. if ($46 eq '366'){$total_12ay = $dx12++;} elsif(!$46 =="366") {$total_12ay  ="0";}
  1045.             $exp{'line'} = $slnum;
  1046.             $exp{'eline'} = $lnum;
  1047.             $exp{'pos'} = $pos++;
  1048.             $exp{'index'} = scalar(@rv);
  1049. if($31){
  1050. eval{$date=timelocal(0,0,0,$34,$33-1,$32-1900)};
  1051. if ($date > time()){
  1052. }else{
  1053. $exp{'user'} = $5;
  1054. $exp{'sira'} = scalar(@rv);
  1055. $total_endusers = $uste++;
  1056. }
  1057. }
  1058. if($1){
  1059. $total_deactiveusers = $1 ? $ustd++ :'0';
  1060. }
  1061. if(!$1){
  1062. $total_activeusers = !$1 ? $usta++ :'0';
  1063. }
  1064. $total_users ="0";
  1065. $total_users = $usto++;
  1066.             push(@rv, \%exp);
  1067.         }
  1068. }
  1069.  if ($command =~/^newcam$/){
  1070.     if ($line =~ /^(#*)\s*([Nn]+)([ ]{1,5})?:([ ]{1,5})(\S+)([ ]{1,5})([0-9]+)([ ]{1,5})(\S+)([ ]{1,5})(\S+)([ ]{1,5})([0-9a-z A-Z ]{41,41})?([ ]{1,5})?([0-9]{1,8})?([ ]{1,5})?(#)?(.*)?/) {
  1071.         local $active = !$1;
  1072.                 if ($dir =~ /^$opn_file/) {
  1073.             $lnum++;
  1074.             next;
  1075.                     }
  1076.             $pos = 0;
  1077.             local %exp;
  1078.             $exp{'active'} = $active;
  1079.             $exp{'dir'} = scalar(@rv),
  1080.             $exp{'host'} = $5,
  1081.             $exp{'port'} = $7,
  1082.             $exp{'username'} = $9,
  1083.             $exp{'passaword'} = $11,
  1084.             $exp{'deskey'} = $13,
  1085.             $exp{'lokal'} = $15,
  1086.             $exp{'not'} = $18,
  1087.             $exp{'line'} = $slnum;
  1088.             $exp{'eline'} = $lnum;
  1089.             $exp{'pos'} = $pos++;
  1090.             $exp{'index'} = scalar(@rv);
  1091.             push(@rv, \%exp);
  1092.         }
  1093.  }
  1094.  if ($command =~/^cline$/){
  1095.     if ($line =~ /^(#*)\s*([Cc]+)([ ]+)?:([ ]{1,5})(.*)([ ]{1,5})([0-9]+)([ ]{1,5})(\S+)([ ]{1,5})(\S+)?([ ]{1,5})?([a-zA-Z]+)?([ ]+)?(([{ ]+)(([0-9:]+)||(([0-9:]+)([a-zA-Z0-9:, ]{2,500})))([ }]+))?([ ]{1,5})?(#(.*))?/) {
  1096.         local $active = !$1;
  1097.                 if ($dir =~ /^$opn_file/) {
  1098.             $lnum++;
  1099.             next;
  1100.                     }
  1101.             $pos = 0;
  1102.             local %exp;
  1103.             $exp{'active'} = $active;
  1104.             $exp{'dir'} = scalar(@rv),
  1105.             $exp{'host'} = $5,
  1106.             $exp{'port'} = $7,
  1107.             $exp{'username'} = $9,
  1108.             $exp{'passaword'} = $11,
  1109.             $exp{'emu'} = $13,
  1110.             $exp{'lokal'} = $18,
  1111.             $exp{'p_lokal'} = $19,
  1112.             $exp{'w_lokal'} = $18.$19,
  1113.             $exp{'not'} = $25,
  1114.             $exp{'line'} = $slnum;
  1115.             $exp{'eline'} = $lnum;
  1116.             $exp{'pos'} = $pos++;
  1117.             $exp{'index'} = scalar(@rv);
  1118.             push(@rv, \%exp);
  1119.         }
  1120. }
  1121.  if ($command =~/^lline$/){
  1122.     if ($line =~ /^(#*)\s*([Ll]+)([ ]{1,5})?:([ ]{1,5})(\S+)([ ]{1,5})([0-9]+)([ ]{1,5})(\S+)([ ]{1,5})(\S+)([ ]{1,5})(([a-zA-Z0-9]+)([ ]{1,5})([a-zA-Z0-9]+))([ ]{1,5})?([0-9]+)?([ ]{1,5})?(#(.*))?/) {
  1123.         local $active = !$1;
  1124.                 if ($dir =~ /^$opn_file/) {
  1125.             $lnum++;
  1126.             next;
  1127.                     }
  1128.             $pos = 0;
  1129.             local %exp;
  1130.             $exp{'active'} = $active;
  1131.             $exp{'dir'} = scalar(@rv),
  1132.             $exp{'host'} = $5,
  1133.             $exp{'port'} = $7,
  1134.             $exp{'username'} = $9,
  1135.             $exp{'passaword'} = $11,
  1136.             $exp{'ca_prvd'} = $13,
  1137.             $exp{'caid'} = $14,
  1138.             $exp{'provider'} = $16,
  1139.             $exp{'not'} = $21,
  1140.             $exp{'line'} = $slnum;
  1141.             $exp{'eline'} = $lnum;
  1142.             $exp{'pos'} = $pos++;
  1143.             $exp{'index'} = scalar(@rv);
  1144.             push(@rv, \%exp);
  1145.         }
  1146. }
  1147.  if ($command =~/^rline$/){
  1148.     if ($line =~ /^(#*)\s*([Rr]+)([ ]{1,5})?:([ ]{1,5})(\S+)([ ]{1,5})([0-9]+)([ ]{1,5})(\S+)([ ]{1,5})(\S+)([ ]{1,5})(([a-zA-Z0-9]+)([ ]{1,5})([a-zA-Z0-9]+))([ ]{1,5})?([0-9]+)?([ ]{1,5})?(#(.*))?/) {
  1149.         local $active = !$1;
  1150.                 if ($dir =~ /^$opn_file/) {
  1151.             $lnum++;
  1152.             next;
  1153.                     }
  1154.             $pos = 0;
  1155.             local %exp;
  1156.             $exp{'active'} = $active;
  1157.             $exp{'dir'} = scalar(@rv),
  1158.             $exp{'host'} = $5,
  1159.             $exp{'port'} = $7,
  1160.             $exp{'username'} = $9,
  1161.             $exp{'passaword'} = $11,
  1162.             $exp{'ca_prvd'} = $13,
  1163.             $exp{'caid'} = $14,
  1164.             $exp{'provider'} = $16,
  1165.             $exp{'not'} = $21,
  1166.             $exp{'line'} = $slnum;
  1167.             $exp{'eline'} = $lnum;
  1168.             $exp{'pos'} = $pos++;
  1169.             $exp{'index'} = scalar(@rv);
  1170.             push(@rv, \%exp);
  1171.         }
  1172. }
  1173.  if ($command =~/^turkdvb$/){
  1174. $name = '("([\()/a-zA-Z0-9çþðüýö\_.\=&+ ]+)(([ -]{3,4})(.*))?")';
  1175.     if ($line =~ /^(#*)\s*([a-zA-Z0-9:, ]+)([ ]+)$name?/) {
  1176.         local $active = !$1;
  1177.         local $pprv = "$2, $4";
  1178.         $chn= $8 ? " - $8":"";
  1179.                 if ($dir =~ /^$opn_file/) {
  1180.             $lnum++;
  1181.             next;
  1182.                     }
  1183.             $pos = 0;
  1184.             local %exp;
  1185.             $exp{'active'} = $active;
  1186.             $exp{'dir'} = scalar(@rv),
  1187.             $exp{'nm_prv'} = $2 . $4,
  1188.             $exp{'name'} = $5,
  1189.             $exp{'channel'} = $8,
  1190.             $exp{'caidprv'} = $2,
  1191.             $exp{'srvname'} = $5.$chn,
  1192. #           $rest = $3;
  1193.             $exp{'line'} = $slnum;
  1194.             $exp{'eline'} = $lnum;
  1195.             $exp{'pos'} = $pos++;
  1196.             $exp{'index'} = scalar(@rv);
  1197.             push(@rv, \%exp);
  1198.         }
  1199. }
  1200.  if ($command =~/^package$/){
  1201.     if ($line =~ /^(#*)\s*([a-zA-Z0-9 +]+)([ ]+)=([ ]+)(.*)/) {
  1202.         local $active = !$1;
  1203.             local %exp;
  1204.             $exp{'active'} = $active;
  1205.             $exp{'dir'} = scalar(@rv),
  1206.             $exp{'name'} = $2,
  1207.             $exp{'caidprv'} = $5,
  1208.             $exp{'line'} = $slnum;
  1209.             $exp{'eline'} = $lnum;
  1210.             $exp{'pos'} = $pos++;
  1211.             $exp{'index'} = scalar(@rv);
  1212.             push(@rv, \%exp);
  1213.         }
  1214. }
  1215.  if ($command =~/^multicccam$/){
  1216.     if ($line =~ /^(#*)\s*(M:) (\S+) (\S+) ([0-9]+) (\S+) (\S+) ([0-9]+) (\S+) ?([0-9]+)?/) {
  1217.         local $active = !$1;
  1218.             local %exp;
  1219.             $exp{'active'} = $active;
  1220.             $exp{'dir'} = scalar(@rv),
  1221.             $exp{'name'} = $3,
  1222.             $exp{'host'} = $4,
  1223.             $exp{'port'} = $5,
  1224.             $exp{'user'} = $6,
  1225.             $exp{'pass'} = $7,
  1226.             $exp{'ssl'}  = $8,
  1227.             $exp{'modul'}= $9,
  1228.             $exp{'cport'}= $10,
  1229.             $exp{'line'} = $slnum;
  1230.             $exp{'eline'} = $lnum;
  1231.             $exp{'pos'} = $pos++;
  1232.             $exp{'index'} = scalar(@rv);
  1233.             push(@rv, \%exp);
  1234.         }
  1235. }
  1236.  if ($command =~/^dyn$/){
  1237.     if ($line =~ /^(#*)\s*(D:) (\S+) (\S+) (\S+) (\S+)/) {
  1238.         local $active = !$1;
  1239.             local %exp;
  1240.             $exp{'active'} = $active;
  1241.             $exp{'dir'} = scalar(@rv),
  1242.             $exp{'dyn_prvd'} = $3,
  1243.             $exp{'dyn_host'} = $4,
  1244.             $exp{'dyn_user'} = $5,
  1245.             $exp{'dyn_pass'} = $6,
  1246.             $exp{'line'} = $slnum;
  1247.             $exp{'eline'} = $lnum;
  1248.             $exp{'pos'} = $pos++;
  1249.             $exp{'index'} = scalar(@rv);
  1250.             push(@rv, \%exp);
  1251.         }
  1252. }
  1253.  if ($command =~/^bayi$/){
  1254. $fiyat1  ='( Fiyat1=(\S+))';
  1255. $fiyat3  ='( Fiyat3=(\S+))';
  1256. $fiyat6  ='( Fiyat6=(\S+))';
  1257. $fiyat12 ='( Fiyat12=(\S+))';
  1258. $u1 ='( 1=(\S+))';
  1259. $u3 ='( 3=(\S+))';
  1260. $u6 ='( 6=(\S+))';
  1261. $u12 ='( 12=(\S+))';
  1262.     if ($line =~ /^(#*)\s*(\S+) Limit=(\S+) Tahsilat=(\S+) Borc=(\S+)$fiyat1?$fiyat3?$fiyat6?$fiyat12? Birim=(\S+) Package=([0-1]+)( Mail=(\S+))?$u1?$u3?$u6?$u12?/) {
  1263.         local $active = !$1;
  1264.             local %exp;
  1265.             $exp{'active'} = $active;
  1266.             $exp{'dir'} = scalar(@rv),
  1267.             $exp{'name'} = $2,
  1268.             $exp{'limit'} = $3,
  1269.             $exp{'tahsilat'} = $4,
  1270.             $exp{'borc'} = $5,
  1271.             $exp{'fiyat1'} = $7,
  1272.             $exp{'fiyat3'} = $9,
  1273.             $exp{'fiyat6'} = $11,
  1274.             $exp{'fiyat12'} = $13,
  1275.             $exp{'birim'} = $14,
  1276.             $exp{'package'} = $15,
  1277.             $exp{'mail'} = $17,
  1278.             $exp{'u1'} = $19,
  1279.             $exp{'u3'} = $21,
  1280.             $exp{'u6'} = $23,
  1281.             $exp{'u12'} = $25,
  1282.             $exp{'line'} = $slnum;
  1283.             $exp{'eline'} = $lnum;
  1284.             $exp{'pos'} = $pos++;
  1285.             $exp{'index'} = scalar(@rv);
  1286.             push(@rv, \%exp);
  1287.         }
  1288. }
  1289.  if ($command =~/^keys$/){
  1290.     if ($line =~ /^((http|https|ftp):\/\/([^\/]+)(\/.*))$/) {
  1291.             local %exp;
  1292.             $exp{'dir'} = scalar(@rv),
  1293.             $exp{'url'} = $1,
  1294.             $exp{'name'} = $3,
  1295.             $exp{'host'} = $3,
  1296.             $exp{'filebase'} = &transname(&file_basename($4)),
  1297.             $fileo = $4;
  1298.             $fileo =~ s/^.*[\/\\]//;
  1299. if ($fileo =~ /^((.*)([=]{1,1})((.*).(.*)))|(.*)$/) {
  1300.             $file = $4 ? $4 : $7;
  1301. }
  1302.             $exp{'file'} = $file,
  1303.             $exp{'sorce_file'} = $file,
  1304.             $exp{'line'} = $slnum;
  1305.             $exp{'eline'} = $lnum;
  1306.             $exp{'pos'} = $pos++;
  1307.             $exp{'index'} = scalar(@rv);
  1308.             push(@rv, \%exp);
  1309.         }
  1310. }
  1311.  if ($command =~/^ftpdir_list$/){
  1312.     if ($line =~ /^\s*(.*)(\S+)(\S+)([0-9.]+)(\S+)(.*) (($cccam_host-$modul_ccdir)-((\d+).(\d+).(\d+)).(\d+:\d+)-cfg.tar.gz)/) {
  1313.             local %exp;
  1314.             $exp{'dir'} = scalar(@rv),
  1315.             $exp{'dosya'} = $7,
  1316.             $exp{'bayt'} = $2,
  1317.             $exp{'tarih'} = $9,
  1318.             $exp{'gun'} = $10,
  1319.             $exp{'ay'} = $11,
  1320.             $exp{'yil'} = $12,
  1321.             $exp{'saat'} = $13,
  1322.             $exp{'line'} = $slnum;
  1323.             $exp{'eline'} = $lnum;
  1324.             $exp{'pos'} = $pos++;
  1325.             $exp{'index'} = scalar(@rv);
  1326.             push(@rv, \%exp);
  1327.         }
  1328. }
  1329.  if ($command =~/^(illegaluser)$/){
  1330.     if ($line =~ /^\s*([0-9:]+).([0-9]+) (\S+): (illegal user) (.*) from ([0-9.]+)?/) {
  1331.         local $active = !$1;
  1332.             local %exp;
  1333.             $exp{'active'} = $active;
  1334.             $exp{'dir'} = $6,
  1335.             $exp{'ip'} = $6,
  1336.             $exp{'tarih'} = $1,
  1337.             $exp{'illegaluser'} = $5,
  1338.             $exp{'line'} = $slnum;
  1339.             $exp{'eline'} = $lnum;
  1340.             $exp{'pos'} = $pos++;
  1341.             $exp{'index'} = scalar(@rv);
  1342.             push(@rv, \%exp);
  1343.  
  1344.         }
  1345. }
  1346.  if ($command =~/^(fazlauser)$/){
  1347.     if ($line =~ /^\s*([0-9:]+).([0-9]+) (\S+): double login \((\S+)\), \(previous ([0-9.]+)\), reject?/) {
  1348.             local %exp;
  1349.             $exp{'dir'} = $5,
  1350.             $exp{'ip'} = $5,
  1351.             $exp{'tarih'} = $1,
  1352.             $exp{'illegaluser'} = $4,
  1353.             $exp{'line'} = $slnum;
  1354.             $exp{'eline'} = $lnum;
  1355.             $exp{'pos'} = $pos++;
  1356.             $exp{'index'} = scalar(@rv);
  1357.             push(@rv, \%exp);
  1358.         }
  1359. }
  1360.  if ($command =~/^(wrong_password)$/){
  1361.     if ($line =~ /^\s*([0-9:]+).([0-9]+) (\S+): wrong password supplied by ([0-9.]+)/) {
  1362.             local %exp;
  1363.             $exp{'dir'} = $4,
  1364.             $exp{'ip'} = $4,
  1365.             $exp{'tarih'} = $1,
  1366.             $exp{'illegaluser'} = "wrong_password",
  1367.             $exp{'line'} = $slnum;
  1368.             $exp{'eline'} = $lnum;
  1369.             $exp{'pos'} = $pos++;
  1370.             $exp{'index'} = scalar(@rv);
  1371.             push(@rv, \%exp);
  1372.         }
  1373. }
  1374.  if ($command =~/^bannedip$/){
  1375.     if ($line =~ /^\s*(-A INPUT -s) ([0-9.]+)\/([0-9]+) -p tcp -m tcp --dport ($cccam_port) -m comment --comment "(\S+)=(\S+)" -j DROP?/) {
  1376.         local $active = !$1;
  1377.         local $dir =  scalar(@rv);
  1378.             local %exp;
  1379.             $exp{'active'} = $active;
  1380.             $exp{'dir'} =  $2,
  1381.             $exp{'ip'} = $2,
  1382.             $exp{'tarih'} = $1,
  1383.             $exp{'port'} = $4,
  1384.             $exp{'illegaluser'} = $5,
  1385.             $exp{'sebep'} = $6,
  1386.             $exp{'line'} = $slnum;
  1387.             $exp{'eline'} = $lnum;
  1388.             $exp{'pos'} = $pos++;
  1389.             $exp{'index'} = scalar(@rv);
  1390.             push(@rv, \%exp);
  1391.         }
  1392. }
  1393.     $lnum++;
  1394.     }
  1395. close(EXP);
  1396. @list_exports_cache = @rv;
  1397. return @list_exports_cache;
  1398. }
  1399. sub delete_export
  1400. {
  1401. local @exps = &list_exports();
  1402. local @same = grep { $_ ne $_[0] && $_->{'line'} eq $_[0]->{'line'} } @exps;
  1403. local $lref = &read_file_lines($opn_file);
  1404. if (@same) {
  1405.     splice(@$lref, $_[0]->{'line'}, $_[0]->{'eline'}-$_[0]->{'line'}+1,
  1406.            &make_exports_line(@same));
  1407.     map { $_->{'line'} = $_->{'eline'} = $_[0]->{'line'} } @same;
  1408. } else {
  1409.     splice(@$lref, $_[0]->{'line'}, $_[0]->{'eline'}-$_[0]->{'line'}+1);
  1410. }
  1411. if($opn_file eq $cccam_cfg){
  1412.     &restore_export($_[0]);
  1413. }
  1414. @list_exports_cache = grep { $_ ne $_[0] } @list_exports_cache;
  1415. &flush_file_lines();
  1416. }
  1417. sub restore_export
  1418. {
  1419.  if($opn_file eq $users_deleted){
  1420.    $restore_file = $cccam_cfg;
  1421.  } elsif($opn_file eq $cccam_cfg) {
  1422.    $restore_file = $users_deleted;
  1423.  } else {
  1424.    $restore_file = undef;
  1425.  }
  1426.  $username = $_[0]->{'dir'};
  1427.  open(EXP, $restore_file);
  1428.  while($line = <EXP>) {
  1429.     while($line =~ /\\$/) { }
  1430.        if ($line =~ /^\s*(#*)([Ff]+)([ ]+)?:([ ]+)($username)([ ]{1,5})(\S+) (.*)$/) {
  1431.            $userrest = $5;
  1432.        }
  1433.     }
  1434.  close(EXP);
  1435.  if(!$userrest || $opn_file eq $cccam_cfg){
  1436.     &create_export($_[0],$restore_file);
  1437.     $opn_file eq $cccam_cfg ||  &delete_export($_[0]);
  1438.  } else {
  1439.    $export_message = $_[1] ? error($text{'save_restore_err'}. ":  $_[0]->{'dir'}") : undef;
  1440.  }
  1441.     $opn_file eq $cccam_cfg ||  $userrest || &delete_export($_[0]);
  1442. return $export_message;
  1443. }
  1444. sub create_export
  1445. {
  1446. $export_file = $_[1] ? $_[1] : $opn_file;
  1447. &open_tempfile(EXP, ">>$export_file");
  1448. &print_tempfile(EXP, &make_exports_line($_[0]),"\n");
  1449. &close_tempfile(EXP);
  1450. }
  1451. sub modify_export
  1452. {
  1453. local @exps = &list_exports();
  1454. local @same = grep { $_->{'line'} eq $_[1]->{'line'} } @exps;
  1455. local $lref = &read_file_lines($opn_file);
  1456. if ($_[0]->{'dir'} eq $_[1]->{'dir'} &&
  1457.     $_[0]->{'active'} == $_[1]->{'active'} || @same == 1) {
  1458.     # directory or active not changed, or on a line of it's own
  1459.     splice(@same, &indexof($_[1],@same), 1, $_[0]);
  1460.     splice(@$lref, $_[1]->{'line'}, $_[1]->{'eline'}-$_[1]->{'line'}+1,
  1461.            &make_exports_line(@same));
  1462.     }
  1463. else {
  1464.     splice(@same, &indexof($_[1],@same), 1);
  1465.     splice(@$lref, $_[1]->{'line'}, $_[1]->{'eline'}-$_[1]->{'line'}+1,
  1466.            &make_exports_line(@same));
  1467.     push(@$lref, &make_exports_line($_[0]));
  1468.     }
  1469. &flush_file_lines();
  1470. }
  1471. sub make_exports_line
  1472. {
  1473.    if ($command =~/^users$/){
  1474. return ($_[0]->{'active'} ? "" : "#").
  1475.              ("F: $_[0]->{'dir'} $_[0]->{'passaword'} ").
  1476.              ($_[0]->{'au'}      ? "$_[0]->{'au'} ":"").
  1477.              ($_[0]->{'reshare'} ? "{ $_[0]->{'reshare'}"     : "{").
  1478.              ($_[0]->{'yasak'}   ? ", $_[0]->{'yasak'} }"     : " }").
  1479.              ($_[0]->{'saat'}    ? " { } { $_[0]->{'saat'} }" : "").
  1480.              ($_[0]->{'gun'}     ? " #Tarih=$_[0]->{'yil'}-$_[0]->{'ay'}-$_[0]->{'gun'}" : "").
  1481.              ($_[0]->{'mail'}    ? " #Mail=$_[0]->{'mail'}" : "").
  1482.              ($_[0]->{'tel'}     ? " #Tel=$_[0]->{'tel'}" : "").
  1483.              ($_[0]->{'bayi'}    ? " #Bayi=$_[0]->{'bayi'}" : "").
  1484.              ($_[0]->{'tip'}     ? " #Tip=$_[0]->{'tip'}" : "").
  1485.              ($_[0]->{'not'}     ? " #Not=$_[0]->{'not'}" : "");
  1486.    }
  1487.    if ($command =~/^newcam$/){
  1488. return ($_[0]->{'active'} ? "" : "#").("N: $_[0]->{'host'} $_[0]->{'port'} $_[0]->{'username'} $_[0]->{'passaword'} $_[0]->{'deskey'}").
  1489.        ($_[0]->{'lokal'} ? " $_[0]->{'lokal'}" : "").
  1490.        ($_[0]->{'not'} ? " #$_[0]->{'not'}" : "");
  1491.    }
  1492.    if ($command =~/^cline$/){
  1493. return ($_[0]->{'active'} ? "" : "#").("C: $_[0]->{'host'} $_[0]->{'port'} $_[0]->{'username'} $_[0]->{'passaword'}").
  1494.        ($_[0]->{'emu'} ? " $_[0]->{'emu'}" : "").
  1495.        ($_[0]->{'lokal'} ? " { $_[0]->{'lokal'} }" : "").
  1496.        ($_[0]->{'p_lokal'} ? " { $_[0]->{'p_lokal'}}" : "").
  1497.        ($_[0]->{'not'} ? " #$_[0]->{'not'}" : "");
  1498. }
  1499.    if ($command =~/^lline$/){
  1500. return ($_[0]->{'active'} ? "" : "#").("L: $_[0]->{'host'} $_[0]->{'port'} $_[0]->{'username'} $_[0]->{'passaword'} $_[0]->{'ca_prvd'}").
  1501.        ($_[0]->{'not'} ? " #$_[0]->{'not'}" : "");
  1502. }
  1503.    if ($command =~/^rline$/){
  1504. return ($_[0]->{'active'} ? "" : "#").("R: $_[0]->{'host'} $_[0]->{'port'} $_[0]->{'username'} $_[0]->{'passaword'} $_[0]->{'ca_prvd'}").
  1505.        ($_[0]->{'not'} ? " #$_[0]->{'not'}" : "");
  1506. }
  1507.  if ($command =~/^turkdvb$/){
  1508. @f1='"';
  1509. return ($_[0]->{'active'} ? "" : "#").("$_[0]->{'caidprv'} @f1$_[0]->{'name'}").
  1510.        ($_[0]->{'channel'} ? " - $_[0]->{'channel'}@f1" : "@f1");
  1511. }
  1512.  if ($command =~/^package$/){
  1513.  
  1514. return ($_[0]->{'active'} ? "" : "#").("$_[0]->{'name'} = $_[0]->{'caidprv'}");
  1515. }
  1516. if ($command =~/^multicccam$/){
  1517.  return ($_[0]->{'active'} ? "" : "#").("M: $_[0]->{'name'} $_[0]->{'host'} $_[0]->{'port'} $_[0]->{'user'} $_[0]->{'pass'} ").
  1518.         ($_[0]->{'ssl'}    ? "1" : "0").(" $_[0]->{'modul'}").
  1519.         ($_[0]->{'cport'}? " $_[0]->{'cport'}" : "");
  1520. }
  1521. if ($command =~/^dyn$/){
  1522.  return ($_[0]->{'active'} ? "" : "#").("D: $_[0]->{'dyn_prvd'} $_[0]->{'dyn_host'} $_[0]->{'dyn_user'} $_[0]->{'dyn_pass'}");
  1523. }
  1524.  if ($command =~/^bayi$/){
  1525. return ($_[0]->{'active'} ? "" : "#").("$_[0]->{'name'} Limit=$_[0]->{'limit'} Tahsilat=$_[0]->{'tahsilat'}").
  1526.        (" Borc=$_[0]->{'borc'}").
  1527.        ($_[0]->{'fiyat1'}  ? " Fiyat1=$_[0]->{'fiyat1'}"   :"").
  1528.        ($_[0]->{'fiyat3'}  ? " Fiyat3=$_[0]->{'fiyat3'}"   :"").
  1529.        ($_[0]->{'fiyat6'}  ? " Fiyat6=$_[0]->{'fiyat6'}"   :"").
  1530.        ($_[0]->{'fiyat12'} ? " Fiyat12=$_[0]->{'fiyat12'}" :"").
  1531.        (" Birim=$_[0]->{'birim'}").
  1532.        ($_[0]->{'package'} ? " Package=$_[0]->{'package'}" :" Package=0").
  1533.        ($_[0]->{'mail'} ? " Mail=$_[0]->{'mail'}" :"").
  1534.        ($_[0]->{'u1'}  ? " 1=$_[0]->{'u1'}"   :"").
  1535.        ($_[0]->{'u3'}  ? " 3=$_[0]->{'u3'}"   :"").
  1536.        ($_[0]->{'u6'}  ? " 6=$_[0]->{'u6'}"   :"").
  1537.        ($_[0]->{'u12'} ? " 12=$_[0]->{'u12'}" :"");
  1538. }
  1539. if ($command =~/^keys$/){
  1540. return ($_[0]->{'active'} ? "" : "#").("$_[0]->{'url'}");
  1541. }
  1542. }
  1543. sub list_bayi {
  1544. $fiyat1  ='( Fiyat1=(\S+))';
  1545. $fiyat3  ='( Fiyat3=(\S+))';
  1546. $fiyat6  ='( Fiyat6=(\S+))';
  1547. $fiyat12 ='( Fiyat12=(\S+))';
  1548. $u1 ='( 1=(\S+))';
  1549. $u3 ='( 3=(\S+))';
  1550. $u6 ='( 6=(\S+))';
  1551. $u12 ='( 12=(\S+))';
  1552. open(BAYI, $bayi_doc);
  1553. $lnum = 0;
  1554. while($line = <BAYI>) {
  1555.     local $slnum = $lnum;
  1556.     $line =~ s/\s+$//g;
  1557.     if ($line =~ /^(#*)\s*(\S+) Limit=(\S+) Tahsilat=(\S+) Borc=(\S+)$fiyat1?$fiyat3?$fiyat6?$fiyat12? Birim=(\S+) Package=([0-1]+)( Mail=(\S+))?$u1?$u3?$u6?$u12?/) {
  1558.         local $active = !$1;
  1559.             local %exp;
  1560.             $exp{'active'} = $active;
  1561.             $exp{'bname'} = $2,
  1562.             $exp{'name'} = $2,
  1563.             $exp{'limit'} = $3,
  1564.             $exp{'tahsilat'} = $4,
  1565.             $exp{'borc'} = $5,
  1566.             $exp{'fiyat1'} = $7,
  1567.             $exp{'fiyat3'} = $9,
  1568.             $exp{'fiyat6'} = $11,
  1569.             $exp{'fiyat12'} = $13,
  1570.             $exp{'birim'} = $14,
  1571.             $exp{'package'} = $15,
  1572.             $exp{'mail'} = $17,
  1573.             $exp{'u1'} = $19,
  1574.             $exp{'u3'} = $21,
  1575.             $exp{'u6'} = $23,
  1576.             $exp{'u12'} = $25,
  1577.             $exp{'line'} = $slnum;
  1578.             $exp{'eline'} = $lnum;
  1579.             $exp{'pos'} = $pos++;
  1580.             $exp{'index'} = scalar(@brv);
  1581.             push(@brv, \%exp);
  1582.         }
  1583.     $lnum++;
  1584.     }
  1585. close(BAYI);
  1586. @list_bayi_cache = @brv;
  1587. }
  1588. sub list_multicc {
  1589. if($config{'multicccam'}){
  1590. local ($user, $pass, $tarih, $lntype,$lnmcl) = @_;
  1591. open(MLTCC, $multicccam);
  1592. $lnum = 0;
  1593. while($line = <MLTCC>) {
  1594.     local $slnum = $lnum;
  1595.     $line =~ s/\s+$//g;
  1596.     if ($line =~ /^(#*)\s*(M:) (\S+) (\S+) ([0-9]+) (\S+) (\S+) ([0-9]+) (\S+) ?([0-9]+)?/) {
  1597.         local $active = !$1;
  1598.             local %exp;
  1599.             $exp{'active'} = $active;
  1600.             $exp{'dir'} = scalar(@rmc),
  1601.             $exp{'name'} = $3,
  1602.             $exp{'host'} = $4,
  1603.             $exp{'port'} = $5,
  1604.             $exp{'user'} = $6,
  1605.             $exp{'pass'} = $7,
  1606.             $exp{'ssl'}  = $8,
  1607.             $exp{'modul'}= $9,
  1608.             $exp{'cport'}= $10,
  1609.             $mcport      = $10,
  1610.             $exp{'line'} = $slnum;
  1611.             $exp{'eline'} = $lnum;
  1612.             $exp{'pos'} = $pos++;
  1613.             $exp{'index'} = scalar(@rmc);
  1614.           if ($user && $active && $10) {
  1615.             if($4 =~/(127.0.0.1|localhost)$/){
  1616.               $mchost = $config{'host'};
  1617.             } else {
  1618.               $mchost = $4;
  1619.             }
  1620.          }
  1621.             push(@rmc, \%exp);
  1622.         }
  1623.     $lnum++;
  1624.     }
  1625. close(MLTCC);
  1626. @list_mltcc_cache = @rmc;
  1627. }
  1628. }
  1629. sub bayi_info {
  1630. &list_command("users",undef,1);
  1631. &list_exports();
  1632. @bayi = &list_bayi();
  1633. &unique(map { if($_->{'bname'} eq $remote_user) {$bayi_id  = $_->{'index'} }  } @bayi);
  1634.     $exp  = $bayi[$bayi_id];
  1635.     %opts = %{$exp->{'options'}};
  1636.     $bayi_id    = $exp->{'index'};
  1637.     $bayi_limit = $exp->{'limit'};
  1638.     $bayi_mail  = $exp->{'mail'};
  1639.     $bayi_paket = $exp->{'package'};
  1640.     $bayi_fiyat1  = $exp->{'fiyat1'};
  1641.     $bayi_fiyat3  = $exp->{'fiyat3'};
  1642.     $bayi_fiyat6  = $exp->{'fiyat6'};
  1643.     $bayi_fiyat12 = $exp->{'fiyat12'};
  1644. $borc_1ay  =$bayi_fiyat1  * $total_1ay;
  1645. $borc_3ay  =$bayi_fiyat3  * $total_3ay;
  1646. $borc_6ay  =$bayi_fiyat6  * $total_6ay;
  1647. $borc_12ay =$bayi_fiyat12 * $total_12ay;
  1648. $toplam_tutar = $borc_1ay + $borc_3ay + $borc_6ay + $borc_12ay;
  1649. $toplam_borc = $toplam_tutar - $exp->{'tahsilat'};
  1650.   if (!$exp->{'active'}){
  1651.     print "<table><tr><td><img src=./images/warning.png></td><td><b>$text{'bayi_closed'}</b></td></tr>";
  1652.     print "</table>";
  1653.     exit 0;
  1654.  }
  1655.   if ($exp->{'bname'} eq $remote_user){
  1656.  } else {
  1657.     print "<table><tr><td><img src=./images/warning.png></td><td><b>$text{'bayi_err'}</b></td></tr>";
  1658.     print "</table>";
  1659.     exit 0;
  1660.   }
  1661. $prog="./index.cgi?tab=";
  1662.      push(@tabs, [ "genel", $text{'tab_genel'}, $prog."genel" ]);
  1663. print&ui_tabs_start(\@tabs,"mode",$in{'tab'}||$tabs[0]->[0],1);
  1664. print &ui_tabs_start_tab("mode", "genel");
  1665. print "<table cellpadding=5><tr>";
  1666. print "<td>";
  1667. print &ui_table_start($text{'bayi_info'}, "width=350", 3);
  1668. print "<tr><td>", &ui_table_row($text{'bayi_name'},    $exp->{'bname'}),"</td></tr>\n";
  1669. print "<tr><td>", &ui_table_row($text{'users_mail'},    $exp->{'mail'}),"</td></tr>\n";
  1670. print "<tr><td>", &ui_table_row($text{'bayi_limiti'},   $exp->{'limit'}),"</td></tr>\n";
  1671. print "<tr><td>", &ui_table_row($text{'bayi_borci'},    $toplam_borc." ".$exp->{'birim'}),"</td></tr>\n";
  1672. print "<tr><td>", &ui_table_row($text{'bayi_tahsilati'},$exp->{'tahsilat'}." ".$exp->{'birim'}),"</td></tr>\n";
  1673. print "<tr><td><br></td></tr>\n";
  1674. print $exp->{'fiyat1'}  ? "<tr><td>". &ui_table_row($text{'fiyat1'}. ' '.$text{'bayi_fiyat'},  $exp->{'fiyat1'} .' '.$exp->{'birim'})."</td></tr>\n"  :'';
  1675. print $exp->{'fiyat3'}  ? "<tr><td>". &ui_table_row($text{'fiyat3'}. ' '.$text{'bayi_fiyat'},  $exp->{'fiyat3'} .' '.$exp->{'birim'})."</td></tr>\n"  :'';
  1676. print $exp->{'fiyat6'}  ? "<tr><td>". &ui_table_row($text{'fiyat6'}. ' '.$text{'bayi_fiyat'},  $exp->{'fiyat6'} .' '.$exp->{'birim'})."</td></tr>\n"  :'';
  1677. print $exp->{'fiyat12'} ? "<tr><td>". &ui_table_row($text{'fiyat12'}.' '.$text{'bayi_fiyat'},  $exp->{'fiyat12'}.' '.$exp->{'birim'})."</td></tr>\n"  :'';
  1678. print &ui_table_end();
  1679. print "</td>";
  1680. print "<td><table>";
  1681. &istatistik_uye;
  1682. print "</table></td>";
  1683.     print &ui_tabs_end_tab("mode", "genel");
  1684. print &ui_tabs_end(1);
  1685. print "</tr></table>";
  1686. print "<center>";
  1687. &cccam_button($text{'users_title'},"bayi.cgi","users=1");
  1688.  
  1689.  
  1690.  
  1691.  
  1692.  
  1693. sub bayicinfo
  1694. {
  1695. print "<html>\n";
  1696. print "<head>\n";
  1697. print "<script language=\"Javascript\">\n";
  1698. print "function spawn(page) {";
  1699. print "window.open(page,\"\",\"height=600,width=800,status=yes,toolbar=no,menubar=no,scrollbars=no\");}
  1700. </script>\n";
  1701. print "</head>\n";
  1702. print "<input type=button value='CCcam Info' onclick='spawn(\"info/info.cgi\")\'>";
  1703. print "</body></html>\n";
  1704. }
  1705.  
  1706.  
  1707. &bayicinfo;
  1708.  
  1709.  
  1710.  
  1711.  
  1712.  
  1713.  
  1714.  
  1715.  
  1716.  
  1717.  
  1718.  
  1719.  
  1720.  
  1721.   if (!$exp->{'limit'}){
  1722.     print "<table><tr><td><img src=./images/warning.png></td><td><b>$text{'bayi_limit_end'}<br>" .&text('bayi_limit_end1','genel.cgi?port_edit=1')."</b></td></tr>";
  1723.     print $exp->{'limit'}==0 ? "<tr><td colspan=2 align=center>".&text('bayi_limit_si',&tdvbfont($exp->{'limit'},0,"blue",1))."</td></tr>":'';
  1724.     print "</table>";
  1725.     exit 0;
  1726.   }
  1727. print "</center>";
  1728. &bayi_update($exp->{'bname'});
  1729. }
  1730. sub bayi_update {
  1731. &list_command("users",undef,1,$_[0]);
  1732. &list_exports();
  1733. @d = $_[0];
  1734. &list_command("bayi",$bayi_doc,1);
  1735. @expsh = &list_bayi();
  1736.  
  1737. &lock_file($config{'bayi_doc'});
  1738.  foreach $e (@expsh) {
  1739.     if (&indexof($e->{'name'}, @d) >= 0) {
  1740. #print "--".$e->{'name'};
  1741.     push(@dels, $e);
  1742.     }
  1743.  }
  1744.  foreach $d (reverse(@dels)) {
  1745.         $d->{'u1'}  = $total_ay;
  1746.         $d->{'u3'}  = $total_3ay;
  1747.         $d->{'u6'}  = $total_6ay;
  1748.         $d->{'u12'} = $total_12ay;
  1749.         &modify_export($d, $d);
  1750.  }
  1751. &unlock_file($bayi_doc);
  1752. }
  1753. sub list_package
  1754. {
  1755. open(PCKG, $package);
  1756. while($line = <PCKG>) {
  1757.  
  1758.     if ($line =~ /^(#*)\s*([a-zA-Z0-9 +]+)([ ]+)=([ ]+)(.*)$/) {
  1759.         local $active = !$1;
  1760.            if ($active) {
  1761.             local %exp;
  1762.             $exp{'active'} = $active;
  1763.             $exp{'name'} = $2,
  1764.             $exp{'caidprv'} = $5,
  1765.             $exp{'line'} = $slnum;
  1766.             $exp{'eline'} = $lnum;
  1767.             push(@prv, \%exp);
  1768.            }
  1769.         }
  1770.     $lnum++;
  1771.     }
  1772. close(PCKG);
  1773. @list_package_cache = @prv;
  1774. }
  1775. sub turkdvb_com
  1776. {
  1777. $style="style='border-style: dashed; border-width: 1px;'";
  1778. if ($access{'bayi'}) {
  1779. &bayi_info();
  1780. print &ui_table_hr();
  1781. }
  1782. ($date, $time) = split(/\s+/, &make_date(time()));
  1783. print "<left>";
  1784. print &ui_table_start("$text{'users_title1'}  | $text{'index_bugun'}:$date","width=660");
  1785. print &ui_form_start("users.cgi", "post");
  1786. print "<input type=hidden name=new value=1>\n";
  1787. print "<input type=hidden name=active value=1>\n";
  1788. print "<input type=hidden name=cmd_users value=1>\n";
  1789. print "<input type=hidden name=save_users value=1>\n";
  1790. if ($access{'bayi'}) {
  1791. print "<input type=hidden name=bayi_id value=$bayi_id>\n";
  1792. print "<input type=hidden name=bayi_limit value=$bayi_limit>\n";
  1793. print "<input type=hidden name=mail value=$bayi_mail>\n";
  1794. }
  1795. print "<tr><td><b>$text{'users_username'} $mcc</b><br><input name=dir size=19></td>\n";
  1796. print "<td><b>$text{'users_passaword'}</b><br><input name=passaword size=19></td>\n";
  1797. print "<td><b>$text{'users_tel'}</b><br><input name=tel size=14></td>\n";
  1798. if (!$access{'bayi'}) {
  1799. print "<td><b>$text{'users_reshare1'}<br>".
  1800.         &ui_select("reshare", $exp->{'reshare'},
  1801.                     [ [ "0:0:1", $text{'disable'} ],
  1802.                       [ "0:0:2", "Reshare1"],
  1803.                       [ "0:0:3", "Reshare2"],
  1804.                       [ "0:0:0", $text{'manual'}], ]),"</td>\n";
  1805. print "<td $style align=center><b>$text{'users_tarih'}</b><br>",
  1806.    (&ui_select("year", $now[5]+1900, [ @select_year ]).
  1807.     &ui_select("month", $now[4]+1, [@select_month ]).
  1808.     &ui_textbox("day", undef, 2).
  1809.     &date_chooser_button("day", "month", "year")),"</td></tr>\n\n";
  1810. }
  1811. if ($access{'bayi'}) {
  1812. print "</tr>\n\n";
  1813. }
  1814. print "<tr><td><b>$text{'users_not'}</b><br><input name=not size=19></td>\n";
  1815. if (!$access{'bayi'}) {
  1816. print "<td><b>$text{'users_mail'}</b><br><input name=mail size=19></td>\n";
  1817. }
  1818. if ($bayi_paket || !$access{'bayi'}) {
  1819. @pckg = &list_package();
  1820. @package = &unique(map { $_->{'name'} ? [ $_->{'caidprv'},$_->{'name'} ] : undef } @pckg);
  1821. print "<td><b>$text{'package'}</b><br>". &ui_select("package", 0, ["", @package ]),"</td>\n";
  1822. }
  1823. if ($access{'bayi'}) {
  1824. $prselect = ($bayi_fiyat12 ? "<option value='366'>$text{'users_period12m'}</option>": "").
  1825.             ($bayi_fiyat6  ? "<option value='183'>$text{'users_period6m'}</option>" : "").
  1826.             ($bayi_fiyat3  ? "<option value='92'>$text{'users_period3m'}</option>"  : "").
  1827.             ($bayi_fiyat1  ? "<option value='31'>$text{'users_period1m'}</option>"  : "");
  1828. } else {
  1829. $prselect = "<option value=''>$text{'select'}</option>
  1830.             <option value='-1'>$text{'users_period1d'}</option>
  1831.             <option value='31'>$text{'users_period1m'}</option>
  1832.             <option value='92'>$text{'users_period3m'}</option>
  1833.             <option value='183'>$text{'users_period6m'}</option>
  1834.             <option value='366'>$text{'users_period12m'}</option>";
  1835. }
  1836. print "<td align=center><b>$text{'users_period'}</b><br><select name='period'>$prselect</select></td>\n";
  1837. if (!$access{'bayi'}) {
  1838. @tmpls = &list_templates();
  1839.     print "<td align=center><b>$text{'mail_sendnew'}</b>". &ui_checkbox("gon_mail",  1, undef,undef,0,0)."<br>".
  1840.         &ui_select("tmpl_id", $config{'tmpl_send_account'},
  1841.                [["",$text{'select'}], map { [ $_->{'id'}, $_->{'desc'} ] } @tmpls ])."</td>\n";
  1842. }
  1843. print "</tr>\n";
  1844. print "<td><b></b></td></tr>\n";
  1845. if (!$access{'bayi'}) {
  1846. print &ui_hidden_table_start($text{'service_blok'},"width=%100", 1, "services");
  1847. print &ui_table_row($text{'users_au'},
  1848.                   &ui_select("au", $exp->{'au'},
  1849.                     [ [ "2 0 0", "$text{'no'}" ],
  1850.                       [ "2 0 1", "$text{'yes'}" ] ]));
  1851. print &ui_table_row($text{'users_saat'},
  1852.     &ui_textbox("saat", "", 26)."<b><font size=1>$text{'example'}</font> : </b>
  1853.                                 <font size=1 color=red>12:00-17:00,</font>
  1854.                                 <font size=1 color=blue>19:00-20:00</font><br>");
  1855. print &ui_table_row($text{'service_blocked'},
  1856.     &services_button("yasak", 1)."<br>".
  1857.     &ui_textarea("yasak", join("\n", $exp->{'yasak'}), 7, 50)."<br>".
  1858.     &services_button("yasak", 1));
  1859. print &ui_hidden_table_end("services");
  1860. }
  1861. print "<tr><td  colspan='5' align=right>", &ui_form_end([ [ 'save', $text{'add'} ] ]),"</td></tr>\n";
  1862. if (!$access{'bayi'}) {
  1863. print &ui_hidden_table_start($text{'ara_header'},"width=%100", 1, "in_ara");
  1864. print &ui_form_start("users.cgi", "post");
  1865. print "<input type=hidden name=araok value=1>\n";
  1866. print "<center><tr><td> </td><td><b>$text{'users_username'} : </b><input name=ara size=21></td>\n";
  1867. print "<td align=left>", &ui_form_end([ [ 'araok', $text{'ara'} ] ]),"</td></tr></center>\n";
  1868. print &ui_hidden_table_end("in_ara");
  1869. }
  1870. print &ui_table_end();
  1871. print "</center>";
  1872. }
  1873. sub ara
  1874. {
  1875. print &ui_table_start("$text{'ara_header'}","width=200");
  1876. print &ui_form_start("users.cgi", "post");
  1877. print "<input type=hidden name=araok value=1>\n";
  1878. print "<tr><td><b></b><input name=ara size=21></td>\n";
  1879. print "<td align=right>", &ui_form_end([ [ 'save', $text{'ara'} ] ]),"</td></tr>\n";
  1880. print &ui_table_end("in_ara");
  1881. }
  1882.  
  1883.  
  1884.  
  1885.  
  1886.  
  1887.  
  1888.  
  1889.  
  1890.  
  1891. sub istatistik_uye{
  1892. &list_command("users");
  1893. &list_exports();
  1894. print "<table cellpadding=5><tr>";
  1895.  print "<td valign=top><table class=ui_table>";
  1896.    print $total_ay ?  "<tr class=row0><td align=right>$text{'fiyat1'} $text{'users'} : </td> <td><font color=blue>$total_ay</font></td></tr>":'';
  1897.    print $total_3ay ? "<tr class=row1><td align=right>$text{'fiyat3'} $text{'users'} : </td> <td><font color=blue>$total_3ay</font></td></tr>":'';
  1898.    print $total_6ay ? "<tr class=row0><td align=right>$text{'fiyat6'} $text{'users'} : </td> <td><font color=blue>$total_6ay</font></td></tr>":'';
  1899.    print $total_12ay ? "<tr class=row1><td align=right>$text{'fiyat12'} $text{'users'} : </td> <td><font color=blue>$total_12ay</font></td></tr>":'';
  1900.  
  1901.    print $total_users ? "<tr class=row0><td align=right>$text{'total_users'} : </td> <td><font color=blue>$total_users</font></td></tr>":'';
  1902.    print $total_activeusers ? "<tr class=row1><td align=right>$text{'active_users'} : </td>      <td><font color=blue>$total_activeusers</font></td></tr>":'';
  1903.    print $total_deactiveusers ? "<tr class=row0><td align=right>$text{'deactiv_users'}  : </td>   <td><font color=blue>$total_deactiveusers</font></td></tr>":'';
  1904.    print $total_endusers ? "<tr class=row1><td align=right>$text{'enddate_users'} : </td>      <td><font color=blue>$total_endusers</font></td></tr>":'';
  1905. if ($access{'bayi'}) {
  1906.    print "<tr class=row1><td align=right><br></td> <td></td></tr>";
  1907.    print "<tr class=row1><td align=right>CCcam Sharing Port : </td> <td><font color=blue>$cccam_port</font></td></tr>";
  1908.    print "<tr class=row0><td align=right>CCcam Version : </td>      <td><font color=blue>$cccam_version</font></td></tr>";
  1909. }
  1910.    print "</table></td>";
  1911.    print "<td valign=top><table class=ui_table><br /></table></td>";
  1912. if (!$access{'bayi'}) {
  1913.  print "<td valign=top><table class=ui_table>";
  1914.    print "<tr class=row1><td align=right>CCcam Sharing Port : </td> <td><font color=blue>$cccam_port</font></td></tr>";
  1915.    print "<tr class=row0><td align=right>CCcam Web Info Port : </td>      <td><font color=blue>$wport</font></td></tr>";
  1916.    print "<tr class=row0><td align=right>CCcam Version : </td>      <td><font color=blue>$cccam_version</font></td></tr>";
  1917. ##   print $telnetport  ? "<tr class=row1><td align=right>CCcam Telnet Port  : </td>   <td><font color=blue>$telnetport</font></td></tr>":'';
  1918.    print $logwarnings ? "<tr class=row0><td align=right>Log Warning  : </td>   <td><font color=blue>$logwarnings</font></td></tr>":'';
  1919.  print "</table></td>";
  1920.  
  1921. }
  1922. print "</tr></table> ";
  1923. }
  1924. sub install_webmin_module
  1925. {
  1926. local ($file, $need_unlink, $nodeps, $grant) = @_;
  1927. local (@mdescs, @mdirs, @msizes);
  1928. local (@newmods, $m);
  1929. local $mdirs = "/";
  1930. local $install_root_directory = "/";
  1931. open(MFILE, $file);
  1932. read(MFILE, $two, 2);
  1933. close(MFILE);
  1934. if ($two eq "\037\235") {
  1935.     if (!&has_command("uncompress")) {
  1936.         unlink($file) if ($need_unlink);
  1937.         return &text('install_ecomp', "<tt>uncompress</tt>");
  1938.         }
  1939.     local $temp = $file =~ /\/([^\/]+)\.Z/i ? &transname("$1")
  1940.                         : &transname();
  1941.     local $out = `uncompress -c "$file" 2>&1 >$temp`;
  1942.     unlink($file) if ($need_unlink);
  1943.     if ($?) {
  1944.         unlink($temp);
  1945.         return &text('install_ecomp2', $out);
  1946.         }
  1947.     $file = $temp;
  1948.     $need_unlink = 1;
  1949.     }
  1950. elsif ($two eq "\037\213") {
  1951.     if (!&has_command("gunzip") && !&has_command("gzip")) {
  1952.         unlink($file) if ($need_unlink);
  1953.         return &text('install_egzip', "<tt>gunzip</tt>");
  1954.         }
  1955.     local $temp = $file =~ /\/([^\/]+)\.gz/i ? &transname("$1")
  1956.                          : &transname();
  1957.     local $cmd = &has_command("gunzip") ? "gunzip -c" : "gzip -d -c";
  1958.     local $out = &backquote_command($cmd." ".&quote_path($file).
  1959.                     "  2>&1 >$temp");
  1960.     unlink($file) if ($need_unlink);
  1961.     if ($? || !-s $temp) {
  1962.         unlink($temp);
  1963.         return &text('install_egzip2', $out);
  1964.         }
  1965.     $file = $temp;
  1966.     $need_unlink = 1;
  1967.     }
  1968. elsif ($two eq "BZ") {
  1969.     if (!&has_command("bunzip2")) {
  1970.         unlink($file) if ($need_unlink);
  1971.         return &text('install_ebunzip', "<tt>bunzip2</tt>");
  1972.         }
  1973.     local $temp = $file =~ /\/([^\/]+)\.gz/i ? &transname("$1") : &transname();
  1974.     local $out = `bunzip2 -c "$file" 2>&1 >$temp`;
  1975.     unlink($file) if ($need_unlink);
  1976.     if ($?) {
  1977.         unlink($temp);
  1978.         return &text('install_ebunzip2', $out);
  1979.         }
  1980.     $file = $temp;
  1981.     $need_unlink = 1;
  1982.     }
  1983. local ($type, $redirect_to);
  1984. open(TYPE, "$root_directory/install-type");
  1985. chop($type = <TYPE>);
  1986. close(TYPE);
  1987. if ($type eq 'rpm' && $file =~ /\.rpm$/i &&
  1988.     ($out = `rpm -qp $file 2>/dev/null`)) {
  1989.     }
  1990. else {
  1991.     local (%mods, %hasfile);
  1992.     &has_command("tar") || return $text{'install_enotar'};
  1993.     local $tar = &backquote_command("tar tf ".&quote_path($file)." 2>&1");
  1994.     if ($?) {
  1995.         unlink($file) if ($need_unlink);
  1996.         return &text('install_etar', $tar);
  1997.         }
  1998.     foreach $f (split(/\n/, $tar)) {
  1999.         if ($f =~ /^\.\/([^\/]+)\/(.*)$/ || $f =~ /^([^\/]+)\/(.*)$/) {
  2000.             $redirect_to = $1 if (!$redirect_to);
  2001.             $mods{$1}++;
  2002.             $hasfile{$1,$2}++;
  2003.             }
  2004.         }
  2005.     local $out = `cd $install_root_directory ; tar xf "$file" 2>&1 >/dev/null`;
  2006.     chdir($oldpwd);
  2007.     if ($?) {
  2008.         unlink($file) if ($need_unlink);
  2009.         return &text('install_eextract', $out);
  2010.         }
  2011.     if ($need_unlink) { unlink($file); }
  2012.     local $perl = &get_perl_path();
  2013.     local @st = stat("$module_root_directory/index.cgi");
  2014.     foreach $moddir (keys %mods) {
  2015.         local $pwd = &module_root_directory($moddir);
  2016.         if ($hasfile{$moddir,"module.info"}) {
  2017.             push(@mdescs, $minfo{'desc'});
  2018.             push(@mdirs, $pwd);
  2019.             push(@msizes, &disk_usage_kb($pwd));
  2020.             &webmin_log("install", undef, $moddir,
  2021.                     { 'desc' => $minfo{'desc'} });
  2022.             push(@newmods, $moddir);
  2023.             }
  2024.         else {
  2025.             push(@mdescs, $tinfo{'desc'});
  2026.             push(@mdirs, $pwd);
  2027.             push(@msizes, &disk_usage_kb($pwd));
  2028.             &webmin_log("tinstall", undef, $moddir,
  2029.                     { 'desc' => $tinfo{'desc'} });
  2030.             }
  2031.         }
  2032.     }
  2033. &flush_webmin_caches();
  2034. return [ \@mdescs, \@mdirs, \@msizes ];
  2035. }
  2036. sub file_basename
  2037. {
  2038. local $rv = $_[0];
  2039. $rv =~ s/^.*[\/\\]//;
  2040. return $rv;
  2041. }
  2042. sub list_dir
  2043. {
  2044. #return @list_exports_local if (@list_exports_cache);
  2045. opendir ( DIR, $_[0] );
  2046. $lnum = 0;
  2047. while( ($filename = readdir(DIR))){
  2048. @st = stat($_[0]."/".$filename);
  2049.     if ($filename =~ /^\s*(($cccam_host-$modul_ccdir)-((\d+).(\d+).(\d+)).(\d+:\d+)-cfg.tar.gz)/) {
  2050.             local %exp;
  2051.             $exp{'dir'} = scalar(@drv),
  2052.             $exp{'dosya'} = $1,
  2053.             $exp{'bayt'} = &nice_size($st[7]),
  2054.             $exp{'tarih'} = $3,
  2055.             $exp{'gun'} = $4,
  2056.             $exp{'ay'} = $5,
  2057.             $exp{'yil'} = $6,
  2058.             $exp{'saat'} = $7,
  2059.             $exp{'line'} = $slnum;
  2060.             $exp{'eline'} = $lnum;
  2061.             $exp{'pos'} = $pos++;
  2062.             $exp{'index'} = scalar(@drv);
  2063.             push(@drv, \%exp);
  2064.         }
  2065.        elsif ($filename =~ /^\s*((CCcam)_($ccostype).(([0-9]+).([0-9]+).([0-9]+)).(zip))$/) {
  2066.             local %exp;
  2067.             $exp{'dir'} = scalar(@drv),
  2068.             $exp{'dosya'} = $2,
  2069.             $exp{'version'} = $4;
  2070.             $exp{'uname'} = $3;
  2071.             $exp{'appzip'} = $1;
  2072.             $exp{'bayt'} = &nice_size($st[7]),
  2073.             $exp{'line'} = $slnum;
  2074.             $exp{'eline'} = $lnum;
  2075.             $exp{'pos'} = $pos++;
  2076.             $exp{'index'} = scalar(@drv);
  2077.             push(@drv, \%exp);
  2078.         }
  2079.     $lnum++;
  2080. }
  2081. closedir(DIR);
  2082. @list_exports_cache = @drv;
  2083. return @list_exports_cache;
  2084. }
  2085. sub list_templates
  2086. {
  2087. opendir(DIR, $templates_dir) || return ( );
  2088. local @trv;
  2089. foreach my $f (readdir(DIR)) {
  2090.     if ($f =~ /^\d+$/) {
  2091.         push(@trv, &get_template($f));
  2092.         }
  2093.     }
  2094. closedir(DIR);
  2095. return @trv;
  2096. }
  2097. sub get_template
  2098. {
  2099. local ($id) = @_;
  2100. local %tmpl;
  2101. &read_file("$templates_dir/$id", \%tmpl) || return undef;
  2102. $tmpl{'id'} = $id;
  2103. $tmpl{'file'} = "$templates_dir/$id";
  2104. $tmpl{'email'} =~ s/\\n/\n/g;
  2105. $tmpl{'email'} =~ s/\\\\/\\/g;
  2106. return \%tmpl;
  2107. }
  2108. sub save_template
  2109. {
  2110. local ($tmpl) = @_;
  2111. $tmpl->{'id'} ||= time().$$;
  2112. $tmpl->{'file'} = "$templates_dir/$tmpl->{'id'}";
  2113. local %write = %$tmpl;
  2114. $write{'email'} =~ s/\\/\\\\/g;
  2115. $write{'email'} =~ s/\n/\\n/g;
  2116. if (!-d $templates_dir) {
  2117.     &make_dir($templates_dir, 0755);
  2118.     }
  2119. &lock_file($tmpl->{'file'});
  2120. &write_file($tmpl->{'file'}, \%write);
  2121. &unlock_file($tmpl->{'file'});
  2122. }
  2123. sub delete_template
  2124. {
  2125. local ($tmpl) = @_;
  2126. &unlink_logged($tmpl->{'file'});
  2127. }
  2128. sub zipped {
  2129. local ($zipfile, $plconf, $flveri,$command) = @_;
  2130. &copy_source_dest("plugins/$zipfile", "$cctmp");
  2131. if($flveri){
  2132.      &backquote_logged("cd $cctmp ; unzip -o -d $cctmp $zipfile");
  2133.   if(!stat("$cctmp/$plconf")){
  2134.      &open_tempfile(EXP, ">$cctmp/$plconf",0,1);
  2135.      &print_tempfile(EXP, "$flveri");
  2136.   } else {
  2137.      &open_tempfile(EXPZ, ">>$cctmp/$plconf");
  2138.      &print_tempfile(EXPZ, "\n".$flveri,"\n");
  2139.   }
  2140.    &close_tempfile(EXPZ);
  2141. }
  2142. &backquote_logged("cd $cctmp ; zip -u $zipfile $plconf");
  2143. unlink("$cctmp/$plconf");
  2144. }
  2145. sub unzip {
  2146. local ($zipfile, $dir,$passw,$del) = @_;
  2147. $passw = $passw ? "-P $passw":'';
  2148. &backquote_logged("unzip $passw -o -d $dir $zipfile");
  2149. $del ? unlink($zipfile) : undef;
  2150. }
  2151. sub attach {
  2152. local ($attachfile, $type) = @_;
  2153.             local $filename = $attachfile;
  2154.             local $data;
  2155.             $filename =~ s/^.*(\\|\/)//;
  2156.  
  2157.     local $type = &guess_mime_type($filename)."; name=\"".$filename."\"";
  2158. #           local $type = $type;
  2159.             local $disp = "inline; filename=\"$filename\"";
  2160.             $data = &read_file_contents($attachfile);
  2161.             push(@{$mail->{'attach'}},
  2162.                  { 'data' => $data,
  2163.                    'headers' => [
  2164.                  [ 'Content-type', $type ],
  2165.                  [ 'Content-Disposition', $disp ],
  2166.                  [ 'Content-Transfer-Encoding', 'base64' ] ] });
  2167. }
  2168. sub send_email
  2169. {
  2170. local ($froms, $email, $subject, $bodys, $attach, $attachfile, $type, $tmpl_id,$user,$pass,$enddate,$attach_plugin,$attach_cron,$paket) = @_;
  2171. local $tmpl = &get_template($tmpl_id);
  2172. &foreign_require("mailboxes", "mailboxes-lib.pl");
  2173. @pckg = &list_package();
  2174. $paket ? &unique(map { $_->{'caidprv'} eq $paket ? $packg = $_->{'name'} : "" } @pckg) :'';
  2175. ################################
  2176. if($tmpl->{'html'} eq 1){
  2177.   $mltype = "text/plain";
  2178.   $tmbr = "\n";
  2179.   &userline($user,$pass,$tarih,1,0,0,0,$lineno++);
  2180.   &list_multicc($user,$pass,$tarih,1,$lineno++);
  2181.   $mail_signatur = $config{'mail_signatur'} ? $tmbr. &mailboxes::html_to_text($config{'mail_signatur'}) : undef;
  2182. } else {
  2183.   $mltype = "text/html";
  2184.   $tmbr = "<br/>";
  2185.   &userline($user,$pass,$tarih,0,0,0,0,$lineno++);
  2186.   &list_multicc($user,$pass,$tarih,0,$lineno++);
  2187.   $mail_signatur = $config{'mail_signatur'} ? $tmbr.$config{'mail_signatur'} : undef;
  2188. }
  2189. $cs   = &get_charset();
  2190. %enc  = ( 'Charset' => $cs );
  2191. $konu = $tmpl ? $tmpl->{'desc'}." ".$packg : $subject;
  2192. $from = $froms ? $froms : "$config{'gon_provider'} <$config{'gon_mail'}>";
  2193.     local %hash = (
  2194.             'KONU' => $konu,
  2195.             'HOST' => $cccam_host,
  2196.             'DATE' => $cnowdate,
  2197.             'TIME' => $time,
  2198.             'ENDT' => $enddate,
  2199.             'PORT' => $cccam_port,
  2200.             'VERS' => $cccam_version,
  2201.             'USER' => $user,
  2202.             'PASS' => $pass,
  2203.             'CLIN' => $cline,
  2204.             'HADU' => $haduline,
  2205.             'ACAM' => $acamdline,
  2206.             'INCB' => "[Servers]$tmbr".$incubus,
  2207.             'OCTG' => $octagon,
  2208.             'PCKG' => $packg,
  2209.               );
  2210.   if ($tmpl) {
  2211.      $body = &substitute_template($tmpl->{'email'}, \%hash);
  2212.   } else {
  2213.      $body = &substitute_template($bodys, \%hash);
  2214.   }
  2215.  
  2216.   if($tmpl->{'html'} eq 1){
  2217.      $body    = join("", split(/<b>|<\/b>/, $body));
  2218.   }
  2219. if($body){
  2220.    $body_html = { 'headers' => [ [ 'Content-type', $mltype.'; charset='.$cs ],
  2221. #                                 [ 'Content-Disposition', "inline; filename=index.html" ],
  2222.                                  [ 'Content-Transfer-Encoding', 'quoted-printable' ] ],
  2223.                                    'data' => &mailboxes::quoted_encode($body.$mail_signatur) };
  2224.    $mail = { 'headers' =>
  2225.             [ [ 'From'    => &mailboxes::encode_mimewords($from, %enc) ],
  2226.               [ 'To'      => &mailboxes::encode_mimewords_address($email, %enc) ],
  2227.               [ 'Subject' => &mailboxes::encode_mimewords($konu,%enc) ],
  2228.               [ 'Message-Id' => &mailboxes::generate_message_id($froms) ]],
  2229.               'attach' => [ $body_html ]};
  2230.  
  2231.         if ($attach) {
  2232.          &attach($attachfile,$type);
  2233.         }
  2234. }
  2235. $clineat    = join("\n", split("<br/>", $cline));
  2236. $hadulineat = join("\n", split("<br/>", $haduline));
  2237. $acamdlineat= join("\n", split("<br/>", $acamdline));
  2238. $incubusat  = join("\n", split("<br/>", $incubus));
  2239. if ($attach_plugin && $body) {
  2240. @attachz = split(/\0/, $attach_plugin);
  2241.  foreach $d (@attachz) {
  2242.   if($d =~ /^cccam/){
  2243.    &zipped("CCcam_cfg.zip", "CCcam.cfg", $clineat);
  2244.    &attach($cccamzip,"application/zip");
  2245.    unlink($cccamzip);
  2246.   }
  2247.   if($d =~ /^hadu/){
  2248.    &zipped("Hadu_plugins.zip", "Hadu.ini", $hadulineat);
  2249.    &attach($haduzip,"application/zip");
  2250.    unlink($haduzip);
  2251.   }
  2252.   if($d =~ /^acamd/){
  2253.    &zipped("Acamd_plugins.zip", "cardclient.conf", $acamdlineat);
  2254.    &attach($acamdzip,"application/zip");
  2255.    unlink($acamdzip);
  2256.   }
  2257.   if($d =~ /^incbs/){
  2258.    &zipped("IncubusCamd.zip", "incubusCamd.conf", $incubusat);
  2259.    &attach($incubuszip,"application/zip");
  2260.    unlink($incubuszip);
  2261.   }
  2262.  }
  2263. }
  2264. if ($attach_cron) {
  2265.   if($config{'tmpl_cccamzip'}){
  2266.    &zipped("CCcam_cfg.zip", "CCcam.cfg", $clineat);
  2267.    &attach($cccamzip,"application/zip");
  2268.    unlink($cccamzip);
  2269.   }
  2270.   if($config{'tmpl_haduzip'}){
  2271.    &zipped("Hadu_plugins.zip", "Hadu.ini", $hadulineat);
  2272.    &attach($haduzip,"application/zip");
  2273.    unlink($haduzip);
  2274.   }
  2275.   if($config{'tmpl_acamdzip'}){
  2276.    &zipped("Acamd_plugins.zip", "cardclient.conf", $acamdlineat);
  2277.    &attach($acamdzip,"application/zip");
  2278.    unlink($acamdzip);
  2279.   }
  2280.   if($config{'tmpl_incbszip'}){
  2281.    &zipped("IncubusCamd.zip", "incubusCamd.conf", $incubusat);
  2282.    &attach($incubuszip,"application/zip");
  2283.    unlink($incubuszip);
  2284.   }
  2285. }
  2286. &mailboxes::send_mail($mail, undef, 1, 0);
  2287. $cline    = "";
  2288. $haduline = "";
  2289. $acamdline= "";
  2290. $incubus  = "";
  2291. $octagon  = "";
  2292. return 1;
  2293. }
  2294. sub warning {
  2295. local ($warning_command,$end_page) = @_;
  2296.  if ($warning_command =~/^security$/){
  2297.   if (!$cccam_port || !$wpassword || !$telnetpass || !$osdpass || !$wusername || !$telnetuser || !$wport){
  2298.    print "<table><tr><td><img src=./images/warning.png></td><td><b>$text{'warning'}<br>" .&text('warn_fix','genel.cgi?fix=1&save=1')."</b></td></tr>";
  2299.    print $cccam_port ? "":"<tr><td colspan=2 align=center>$text{'warn_serverport'}</td></tr>";
  2300.    print $telnetuser ? "":"<tr><td colspan=2 align=center>$text{'warn_telnetuser'}</td></tr>";
  2301.    print $telnetpass ? "":"<tr><td colspan=2 align=center>$text{'warn_telnetpass'}</td></tr>";
  2302.    print $wusername  ? "":"<tr><td colspan=2 align=center>$text{'warn_webuser'}</td></tr>";
  2303.    print $wpassword  ? "":"<tr><td colspan=2 align=center>$text{'warn_webpass'}</td></tr>";
  2304.    print $osdpass    ? "":"<tr><td colspan=2 align=center>$text{'warn_osdpass'}</td></tr>";
  2305.    print $wport      ? "":"<tr><td colspan=2 align=center>$text{'warn_wport'}</td></tr>";
  2306.    print "</table>";
  2307.   }
  2308.  }
  2309.  if ($warning_command =~/^debug_mod$/){
  2310.    if(!$config{'debug_mod'}){
  2311.     print "<table align=center><tr><td><img src=./images/warning.png></td><td><b>$text{'warn_debug_mod'}<br>" .&text('warn_debug_fix','setup.cgi?edit_debug=1')."</b></td></tr>";
  2312.     print "</table>";
  2313. print $center;
  2314. &ui_print_footer("", $text{'index_return'});
  2315. print $center_end;
  2316. exit 0;
  2317.    }
  2318.  }
  2319. return 1;
  2320. }
  2321. sub port_control {
  2322.  if (!&is_cccam_running()) {
  2323.  $con_wport      = &make_http_connection($localhost, $wport);
  2324.  $con_cccam_port = &make_http_connection($localhost, $cccam_port);
  2325.  $con_telnetport = &make_http_connection($localhost, $telnetport);
  2326.   if (ref($con_wport) || ref($cccam_port) || ref($telnetport)){
  2327.     print "<table><tr><td><img src=./images/warning.png></td><td><b>$text{'warn_pc_error'}<br>" .&text('warn_pc_fix','genel.cgi?port_edit=1')."</b></td></tr>";
  2328.     print ref($con_cccam_port) ? "<tr><td colspan=2 align=center>".&text('warn_pc_cccam_port',&tdvbfont($cccam_port,0,"blue",1))."</td></tr>":"";
  2329.     print ref($con_wport)      ? "<tr><td colspan=2 align=center>".&text('warn_pc_wport',&tdvbfont($wport,0,"blue",1))."</td></tr>":"";
  2330.     print ref($con_telnetport) ? "<tr><td colspan=2 align=center>".&text('warn_pc_telnetport',&tdvbfont($telnetport,0,"blue",1))."</td></tr>":"";
  2331.     print "</table>";
  2332.   }
  2333.  }
  2334. }
  2335. sub cccam_upgrade {
  2336. &http_download("checkip.dyndns.org", 80, undef, \$out, 0, undef, 0, "cc", "xxx", 8, 0, 1);
  2337. $out = &html_escape($out, 1);
  2338.   if ($out =~ /Current IP Address: ([0-9.]+)/){
  2339.     $lcip=  $1;
  2340.   }
  2341. $cmndf = $_[1] ?"<br>":"\n";
  2342. $pagec  = "$bckp?licence=$config{'host_id'}&host=$config{'host2'}&ip=$lcip&modul=cccam";
  2343. &http_download($cclibs,80,$pagec, \$upcontrol, \$errd, 0,0);
  2344. $ureadme   = join("<br>", split(/\n/,$upcontrol));
  2345. $upcontrol = &html_escape($upcontrol, 1);
  2346. $lcversion = join("", split(/\./,$version));
  2347. if($ureadme =~/(<readme>)(.*)(<\/readme>)(<zip>)(.*)(<\/zip>)(<file>)(.*)(<\/file>)(<version>)(.*)(<\/version>)(<licence>)(.*)(<\/licence>)(<command>)(.*)(<\/command>)(<command1>)(.*)(<\/command1>)(.*)/) {
  2348.   $upreadme = "<fieldset><pre>".$2."</pre></fieldset>";
  2349.   $zpms      = VRDA($5,1,2);
  2350.   $upfile    = $8;
  2351.   $upversionj= $11;
  2352.   $upversion = join("", split(/\./,$11));
  2353.   $uplicence = $14;
  2354.   $commandup = $17;
  2355.   $commandup1= $20;
  2356. }
  2357. if($upcontrol =~/(Error:)(.*)/) {
  2358.      print "$text{'hata'}: $2 $cmndf";
  2359. } elsif($upfile) {
  2360.    if ($upversion eq $lcversion ) {
  2361.       print $text{'update_notfound'}. $cmndf;
  2362.       $updatenotfound = "1";
  2363.    } else {
  2364.      if(!$_[0]){
  2365.       $updatefound = 1;
  2366.       print $_[1] ? $upreadme : "";
  2367.       print $_[1] ? "<b>$text{'update_found'} " . &tdvbfont($upversionj,0,"red",1) . $cmndf."</b>" : "\n$text{'update_found'} $upversionj\n";
  2368.      }
  2369.      if($_[0]){
  2370.       print $text{'update_started'}. $cmndf;
  2371.       $zipfile = tempname(&rand_pass());
  2372.       &http_download($cclibs,80,"$pagec&update=1", $zipfile, \$error,\&progress_callback);
  2373.       &unzip($zipfile, $module_root_directory,$zpms,1);
  2374.       $commandup  ? &backquote_logged("cd $module_root_directory; $commandup >/dev/null 2>&1 &") :"";
  2375.       $commandup1 ? &backquote_logged("cd $module_root_directory; $commandup1 >/dev/null 2>&1 &") :"";
  2376.       print $text{'update_complete'}.$cmndf;
  2377.      }
  2378.    }
  2379. } else {
  2380.      print $text{'update_notfound'}. $cmndf;
  2381. }
  2382. return;
  2383. }
  2384. sub sms_send {
  2385. local ($message,$tel,$user,$pass,$enddate,$paket) = @_;
  2386.  
  2387.   if($config{'sms_enable'} && $config{'sms_provider'}){
  2388.      $sms_signatur = $config{'sms_signatur'} ? "..\n$config{'sms_signatur'}" : undef;
  2389.      $sms_apiid    = $config{'sms_apiid'};
  2390.      $sms_user     = $config{'sms_user'};
  2391.      $sms_pass     = $config{'sms_pass'};
  2392.   if($tel =~/(00)([0-9]+)/){
  2393.      $tel = $2;
  2394.   }
  2395.      &userline($user,$pass);
  2396.      @pckgsm = &list_package();
  2397.      $paket ? &unique(map { $_->{'caidprv'} eq $paket ? $packg = $_->{'name'} : "" } @pckgsm) :'';
  2398.     local %hash = (
  2399.             'HOST' => $cccam_host,
  2400.             'DATE' => $cnowdate,
  2401.             'TIME' => $time,
  2402.             'ENDT' => $enddate,
  2403.             'PORT' => $cccam_port,
  2404.             'VERS' => $cccam_version,
  2405.             'USER' => $user,
  2406.             'PASS' => $pass,
  2407.             'CLIN' => $cline,
  2408.             'PCKG' => $packg,
  2409.             'L'    => "\n",
  2410.               );
  2411.      $sms_message = urlize(&substitute_template($message, \%hash) . $sms_signatur);
  2412.     if($config{'sms_provider'} eq "clickatell.com"){
  2413.      $sender = $config{'sms_sender'} ? "&from=$config{'sms_sender'}" : undef;
  2414.      $page = "/http/sendmsg?api_id=$sms_apiid&user=$sms_user&password=$sms_pass&to=$tel&text=$sms_message$sender";
  2415.      &http_download("api.clickatell.com", 80, $page, \$sms_status, \$errd, 0, 0, undef,undef, 10);
  2416.     } elsif ($config{'sms_provider'} eq "smscity.com"){
  2417.     $sender = $config{'sms_sender'} ? "&sender=$config{'sms_sender'}" : undef;
  2418.     $page = "/gateway/sms.php?username=$sms_user&password=$sms_pass&destination=$tel&body=$sms_message$sender";
  2419.     &http_download("api.smscity.com", 80, $page, \$sms_status, \$sms_err, 0, 0, undef,undef, 10);
  2420.     }
  2421.   }
  2422. $cline    = "";
  2423. $haduline = "";
  2424. $acamdline= "";
  2425. $incubus  = "";
  2426. $octagon  = "";
  2427. return 1;
  2428. }
Add Comment
Please, Sign In to add comment