daily pastebin goal
82%
SHARE
TWEET

active

a guest Aug 20th, 2012 15 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?
  2. $GLOBALS['file_codes']="/var/activecode/proxy.codes";
  3. $GLOBALS['file_act']="/var/activecode/proxy.act";
  4. $GLOBALS['file_user']="/var/activecode/user.xml";
  5.  
  6.  
  7.  
  8.  
  9. function sh_scr($user,$pass,$msg,$enddate)
  10. {
  11.        
  12.  
  13.  
  14. $_GET['LastName']=$user;
  15.         //==========================================================================================
  16.         //!!!!!!!!!  must always be there do not delete this line!!!!
  17.         //==========================================================================================
  18.        
  19.         //echo "\nLastName:{$_GET['LastName']}\n";
  20.        
  21.         //==========================================================================================
  22.         // u can only edit here !!!!!!!!!
  23.         //==========================================================================================
  24.         //make Mgcamd Lines
  25.        echo "#!/bin/sh +e\n\n";
  26.         echo "\necho \"CWS_KEEPALIVE = 300\" > /var/keys/newcamd.list";
  27.         echo "\necho \"CWS_INCOMING_PORT = 21000\" >> /var/keys/newcamd.list";
  28.         echo "\necho \"CWS = host 15112 {$user} {$pass} 01 02 03 04 05 06 07 08 09 10 11 12 13 14 lan newcs\" >> /var/keys/newcamd.list";
  29.         echo "\nsleep 1";
  30.     // make script     
  31.         echo "\necho \";;   #delete\" >> /tmp/mga";
  32.         echo "\necho \"esac   #delete\" >> /tmp/mga";
  33.        echo "\n";
  34.        echo "\nkillall -9 mgcamd";
  35.        
  36.        echo "\ncd /var/bin";
  37.        echo "\n./mgcamd";
  38.        
  39.         // make messages for in message box
  40.    echo "{$msg}\n";
  41. }
  42.  
  43. //==========================================================================================
  44. // !!!!!!!!! DO NOT EDIT BELOW !!!!
  45. //==========================================================================================
  46. //==========================================================================================
  47. function html_scr($user,$pass,$msg)
  48. {      
  49.         echo $msg;
  50. ?>     
  51.                 </b></p>
  52.         </div>
  53.         <div class="login-form">                               
  54.                         <div class="form-block">
  55.                         <div class="inputlabel">Username:</div>
  56.                         <div><? echo $user; ?></div>   
  57.                         <div class="inputlabel" style="margin-top:10px;">Password:</div>
  58.                         <div><? echo $pass; ?></div>   
  59.                 </div>                 
  60.         </div>
  61.                 <div class="clr"></div>
  62.                 <form action="" method="get" name="loginForm" id="loginForm">
  63.                         <div align="center" style="margin-top:20px;"><input type="submit" class="button" value="   Enter New code   " /></div>
  64.                 </form>
  65.         </div>
  66. </div>
  67. <?
  68.         html_footer();
  69.         exit;
  70.  
  71. }
  72.  
  73. function html_main()
  74. {
  75. ?>
  76.         <div id="ctr" align="center">
  77.         <div class="login">
  78.                 <div class="login-form">               
  79.                 <form action="" method="get" name="loginForm" id="loginForm">
  80.                         <div class="form-block">
  81.                         <div class="inputlabel">Activation code:</div>
  82.                         <div><input name="actvcode" type="text" class="inputbox" size="15" /></div>    
  83.                         <div align="center"><input type="submit" class="button" value="   Activate   " /></div>
  84.                 </div>
  85.                         </form>
  86.         </div>
  87.                 <div class="login-text">                       
  88.                 <p>Welcome to Activation code system!</p>
  89.                         <p>Enter code to activete user.</p>
  90.         </div>
  91.                 <div class="clr"></div>
  92.         </div>
  93. </div>
  94. <?             
  95. }
  96.  
  97.  
  98. function html_main_re1()
  99. {
  100. ?>
  101.         <div id="ctr" align="center">
  102.         <div class="login">
  103.                 <div class="login-text">                       
  104.                 <p style="color:red"><b>
  105. <?             
  106. }
  107.  
  108.  
  109. function html_main_re2()
  110. {
  111. ?>
  112.         </b></p>
  113.         </div>
  114.         <div class="login-form">               
  115.                 <form action="" method="get" name="loginForm" id="loginForm">
  116.                         <div class="form-block">
  117.                         <div class="inputlabel">Activation code:</div>
  118.                         <div><input name="actvcode" type="text" class="inputbox" size="15" /></div>    
  119.                         <div align="center"><input type="submit" class="button" value="   Activate   " /></div>
  120.                 </div>
  121.                         </form>
  122.         </div>
  123.                 <div class="clr"></div>
  124.         </div>
  125. </div>
  126. <?             
  127. }
  128.  
  129. function html_header()
  130. {
  131. ?>
  132.         <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  133.         <html lang="en-US">
  134.         <head>         
  135.                 <title>Active Code By Dzsatellite.com</title>
  136.                 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  137.                 <style type="text/css">
  138.                 body{margin:0;padding:0;color:#333;background-color:#FFF;font-size:11px;font-family:Arial,Helvetica,sans-serif;}#wrapper{border:0;margin:0;margin-left:auto;margin-right:auto;padding:0;}#header{background-color:#FFF;background-position:right top;border-bottom:4px solid #80B5D7;}#mambo{position:relative;width:100%;background-color:#30569D;margin:0;padding:0;font-size: 18px;color:white;height:24px;}#break{height:50px;}form{margin:0;}.button{border:solid 1px #ccc;background:#E9ECEF;color:#666;font-weight:bold;font-size:11px;padding:4px;}.login{margin-left:auto;margin-right:auto;margin-top:6em;padding:15px;border:1px solid #ccc;width:429px;background:#F1F3F5;}.login h1{background:url(../images/login_header.png) no-repeat;background-position:left top;color:#333;margin:0;height:50px;padding:15px 4px 0 50px;text-align:left;font-size:1.5em;}.login p{padding:0 1em 0 1em;}.form-block{border:1px solid #ccc;background:#E9ECEF;padding-top:15px;padding-left:10px;padding-bottom:10px;padding-right:10px;}.login-form{text-align:left;float:right;width:60%;}.login-text{text-align:left;width:40%;float:left;}.inputlabel{font-weight:bold;text-align:left;}.inputbox{width:230px;margin:0 0 1em 0;border:1px solid #ccc;}.clr{clear:both;}.ctr{text-align:center;}.version{font-size:.8em;}
  139.                 </style>
  140.         </head>
  141.         <body>
  142. <div id="wrapper">
  143.     <div id="header">
  144.            <div id="mambo">Active Code By Dzsatellite.com</div>
  145.     </div>
  146. </div>
  147. <?
  148. }
  149.  
  150. function html_footer()
  151. {
  152. ?>
  153.         <div id="break"></div>
  154.  
  155.        
  156.         <div class="footer" align="center">
  157.         <div align="center"><br />Softwared By Dzsatellite.com</div>
  158.         </div>
  159.  
  160.        
  161.         </body>
  162.         </html>
  163. <?     
  164. }
  165. //==========================================================================================
  166. if($_GET['file'])
  167. {      
  168.         download_file($_GET['file']);
  169.         unlink($_GET['file']);
  170.         exit();
  171. }
  172.  
  173. if($_SERVER["HTTP_USER_AGENT"]==$GLOBALS['IDENT'])
  174. {
  175.         //$ver=apache_request_headers();       
  176.         //if($ver['Version']) .....    
  177.  
  178.         main();
  179.         exit;
  180. }
  181. else
  182. {
  183.         //echo "Hello!";
  184.         html_header();
  185.         if(trim($_GET['actvcode']))
  186.         {
  187.                  html_main_re1();
  188.                  main();
  189.                  html_main_re2();
  190.         }
  191.         else
  192.         {
  193.                 html_main();
  194.         }
  195.         html_footer();
  196.         exit;
  197. }
  198.  
  199. //==========================================================================================
  200. //==========================================================================================
  201. function main()
  202. {
  203.         $_GET['actvcode']=trim($_GET['actvcode']);
  204.         $_GET['LastName']=trim($_GET['LastName']);
  205.        
  206.         if(!$_GET['actvcode'])
  207.         {
  208.                 echo "No code enter";
  209.                 return;
  210.         }
  211.        
  212.         if(!is_numeric($_GET['actvcode']))
  213.         {
  214.                 echo "Wrong code!";
  215.                 return;
  216.         }
  217.  
  218.         $code=$_GET['actvcode'];
  219.         $my_user=$_GET['LastName'];
  220.         if(!$_GET['LastName']) $my_user="AB".time();  //.gen_pass();
  221.  
  222.         $my_pass=gen_pass();
  223.        
  224.         $days=file_codes_check($code);
  225.         if($days>0)
  226.         {
  227.                 $text_msg="Account is Active! Will expire at ".date("Y-m-d",time() + ($days * 24 * 60 * 60));
  228.                 $enddate=time() + ($days * 24 * 60 * 60);
  229.                 $str_date=0;
  230.                 $end_date=0;
  231.                 if($_GET['LastName'] && is_array($act=file_user_check("name=\"{$_GET['LastName']}\""))) //"Extend"
  232.                 {
  233.                         if($act['End']>time())
  234.                         {
  235.                                 $str_date=$act['Start'];
  236.                                 $end_date=$act['End']+($days * 24 * 60 * 60);
  237.                                 $text_msg="Account is Extended with {$days} days! Will expire at ".date("Y-m-d",$end_date);
  238.                                 $enddate=$end_date;
  239.                         }
  240.                 }
  241.                 //else is New
  242.                
  243.                 file_act_add($my_user,$my_pass,$code,$days,$str_date,$end_date);
  244.                 file_codes_del($code);
  245.                
  246.                 if($_SERVER["HTTP_USER_AGENT"]==$GLOBALS['IDENT']) sh_scr($my_user,$my_pass,$text_msg,$enddate);
  247.                 else html_scr($my_user,$my_pass,$text_msg);
  248.         }
  249.         else
  250.         {
  251.                 $code_wrong=1;
  252.                 if($days==0)
  253.                 {
  254.                         $act=file_user_check("code=\"{$code}\"");
  255.                         if(is_array($act)) //reactivet
  256.                         {
  257.                                 $code_wrong=0;
  258.                                
  259.                                 $my_user=$act['name'];
  260.                                
  261.                                 if($act['End']>time())
  262.                                 {
  263.                                         file_act_add($my_user,$my_pass,$code,$act['days'],$act['Start'],$act['End']);
  264.                                         //echo "reActivate";                                   
  265.                                         if($_SERVER["HTTP_USER_AGENT"]==$GLOBALS['IDENT']) sh_scr($my_user,$my_pass,"Account is reActive! Will expire at ".date("Y-m-d",$act['End']),$act['End']);
  266.                                         else html_scr($my_user,$my_pass,"Account is reActive! Will expire at ".date("Y-m-d",$act['End']));
  267.                                 }
  268.                                 else
  269.                                 {
  270.                                         echo "Expire code";
  271.                                 }
  272.                         }
  273.                 }
  274.  
  275.                 if($code_wrong)
  276.                 {
  277.                         echo "Wrong code";
  278.                 }
  279.         }
  280. }
  281.  
  282. //==========================================================================================
  283. //==========================================================================================
  284. function gen_pass()
  285. {
  286.         $str = uniqid();  
  287.          
  288.    return $str;
  289. }
  290.  
  291. function xml2array($xml)
  292. {
  293.         $xmlary = array();
  294.                
  295.         $reels = '/<(\w+)\s*([^\/>]*)\s*(?:\/>|>(.*)<\/\s*\\1\s*>)/s';
  296.         $reattrs = '/(\w+)=(?:"|\')([^"\']*)(:?"|\')/';
  297.  
  298.         preg_match_all($reels, $xml, $elements);
  299.  
  300.         foreach ($elements[1] as $ie => $xx) {
  301.                 $xmlary[$ie]["name"] = $elements[1][$ie];
  302.                
  303.                 if ($attributes = trim($elements[2][$ie])) {
  304.                         preg_match_all($reattrs, $attributes, $att);
  305.                         foreach ($att[1] as $ia => $xx)
  306.                                 $xmlary[$ie]["attributes"][$att[1][$ia]] = $att[2][$ia];
  307.                 }
  308.  
  309.                 $cdend = strpos($elements[3][$ie], "<");
  310.                 if ($cdend > 0) {
  311.                         $xmlary[$ie]["text"] = substr($elements[3][$ie], 0, $cdend - 1);
  312.                 }
  313.  
  314.                 if (preg_match($reels, $elements[3][$ie]))
  315.                         $xmlary[$ie]["elements"] = xml2array($elements[3][$ie]);
  316.                 else if ($elements[3][$ie]) {
  317.                         $xmlary[$ie]["text"] = $elements[3][$ie];
  318.                 }
  319.         }
  320.  
  321.         return $xmlary;
  322. }
  323. //==========================================================================================
  324. //==========================================================================================
  325. function file_act_add($user,$pass,$code,$days,$date_st=0,$date_end=0)
  326. {
  327.         if($file_handle = fopen($GLOBALS['file_act'],"a+"))
  328.         {
  329.                 if($date_st==0)  $date_st=time();
  330.                 $txt_date_st=date("Y/m/d",$date_st);
  331.                
  332.                 if($date_end==0) $date_end=time() + ($days * 24 * 60 * 60);
  333.                 $txt_date_end=date("Y/m/d",$date_end);
  334.                
  335.                 fwrite($file_handle, date("[Y/m/d][H:i:s]   "));
  336.                 fwrite($file_handle, "Username = {$user}   Password = {$pass}   {$code}={$days}   Start: {$txt_date_st}   End: {$txt_date_end}  IP: {$_SERVER['REMOTE_ADDR']}\n");
  337.                 fclose($file_handle);
  338.                
  339.                 file_user_update($user,$pass,$code,$days,date("d-m-Y",$date_st),date("d-m-Y",$date_end));
  340.         }
  341. }
  342.  
  343. function file_act_check($code)
  344. {
  345.         $lines = file($GLOBALS['file_act']);
  346.         if(is_array($lines ))
  347.         {
  348.                 $code=" ".$code."=";           
  349.                 foreach ($lines as $line)
  350.                 {
  351.                         if(strstr($line, $code))
  352.                         {
  353.                                 $pieces = explode("   ",$line);
  354.                                 $days=explode("=",$pieces[3]);
  355.                                 $date_st=explode(": ",$pieces[4]);
  356.                                 $date_end=explode(": ",$pieces[5]);
  357.                                
  358.                                 $days=$days[1];
  359.                                 list($year, $month, $day) = split('[/.-]', $date_st[1]);
  360.                                 $date_st= mktime(0, 0, 0, $month, $day, $year);
  361.                                 list($year, $month, $day) = split('[/.-]', $date_end[1]);
  362.                                 $date_end= mktime(0, 0, 0, $month, $day, $year);                               
  363.                                 return array("Days"=>"{$days}","Start"=>"{$date_st}","End"=>"{$date_end}");
  364.                         }
  365.            }
  366.         }
  367.  
  368.         return 0;
  369. }
  370.  
  371. //==========================================================================================
  372. //==========================================================================================
  373. function file_codes_check($code)
  374. {
  375.         $lines = file($GLOBALS['file_codes']);
  376.         if(is_array($lines ))
  377.         {
  378.                 foreach ($lines as $line)
  379.                 {
  380.                         list($cc, $day) = split('=', $line);
  381.                         if(strcmp($cc,$code) == 0)
  382.                         {
  383.                                  return trim($day);
  384.                         }
  385.            }
  386.         }
  387.        
  388.         return 0;
  389. }
  390.  
  391. function file_codes_del($code)
  392. {
  393.         $lines = file($GLOBALS['file_codes']);
  394.         if(is_array($lines ))
  395.         {
  396.                 if($file_handle = fopen($GLOBALS['file_codes'],"w"))
  397.                 {
  398.                         $code=$code."=";
  399.                         foreach ($lines as $line)
  400.                         {
  401.                                 if(strstr($line, $code)===FALSE) fwrite($file_handle,$line);
  402.                         }
  403.  
  404.                         fclose($file_handle);
  405.                 }
  406.         }
  407. }
  408.  
  409. //==========================================================================================
  410. //==========================================================================================
  411. function file_user_write($data)
  412. {
  413.         $fp=fopen($GLOBALS['file_user'],"w");
  414.         if($fp)
  415.         {
  416.                 foreach($data as $value)
  417.                 {                      
  418.                         $value=trim($value);
  419.                         if($value) fwrite($fp,$value."\n");
  420.                 }
  421.                 fclose($fp);
  422.         }
  423.        
  424. }
  425.  
  426. function file_user_check($find)
  427. {
  428.         $lines = file($GLOBALS['file_user']);
  429.  
  430.         if(is_array($lines))
  431.         {              
  432.                 foreach ($lines as $line)
  433.                 {                              
  434.                         if(strstr($line, $find))
  435.                         {                              
  436.                                 $act=xml2array($line);                         
  437.                                 if($act[0]['name']=="user" && is_array($act[0]['attributes']))
  438.                                 {
  439.                                         $act=$act[0]['attributes'];
  440.                                         list($day, $month, $year) = split('[/.-]', $act['startDate']);
  441.                                         $act['Start']= mktime(0, 0, 0, $month, $day, $year);
  442.                                         list($day, $month, $year) = split('[/.-]', $act['endDate']);
  443.                                         $act['End']= mktime(0, 0, 0, $month, $day, $year);
  444.                                
  445.                                         return $act;
  446.                                 }
  447.                                 return 0;
  448.                         }              
  449.            }       
  450.         }      
  451.         return 0;
  452. }
  453.  
  454. function file_user_update($user,$pass,$code,$days,$date_st,$date_end)
  455. {
  456.         $lines = file($GLOBALS['file_user']);
  457.         // $newline="<user name=\"{$user}\" password=\"{$pass}\" max-connections=\"1\" rate=\"-1\" husain=\"true\" code=\"{$code}\" days=\"{$days}\" startDate=\"{$date_st}\" expire-date=\"{$date_end}\"/>";
  458.         $newline="<user name=\"{$user}\" password=\"{$pass}\" code=\"{$code}\" startDate=\"{$date_st}\" days=\"{$days}\" expire-date=\"{$date_end}\" max-connections=\"false\" admin=\"false\"/>";
  459.         if(is_array($lines))
  460.         {              
  461.                 $code_str="code=\"{$code}\"";
  462.                 if($_GET['LastName']) $code_str="name=\"{$_GET['LastName']}\"";
  463.        
  464.                 $i=0;
  465.                 foreach ($lines as $line)
  466.                 {                              
  467.                         if(strstr($line, $code_str))
  468.                         {                      
  469.                                 $lines[$i]=$newline;
  470.                                 file_user_write($lines);
  471.                                 return 1;
  472.                         }
  473.                         $i++;
  474.            }
  475.            
  476.            $frstel=$lines[0];
  477.            $lines[0]=$newline;
  478.            array_unshift($lines, $frstel);
  479.            file_user_write($lines);
  480.         }      
  481.         return 0;
  482. }
  483.  
  484. function file_dm_write($file_,$data)
  485. {
  486.         $fp=fopen($file_,"w");
  487.         if($fp)
  488.         {
  489.                 foreach($data as $value)
  490.                 {                      
  491.                         $value=trim($value);
  492.                         if($value) fwrite($fp,$value."\n");
  493.                 }
  494.                 fclose($fp);
  495.         }
  496.        
  497. }
  498.  
  499. function file_dm_update($file_,$outfile_,$user,$pass)
  500. {
  501.         $lines = file($file_);
  502.         if(is_array($lines))
  503.         {              
  504.                 $i=0;
  505.                 foreach ($lines as $line)
  506.                 {                              
  507.                         $lines[$i]=str_replace("dummyuser", "{$user}", $lines[$i]);
  508.                         $lines[$i]=str_replace("dummypass", "{$pass}", $lines[$i]);
  509.                         $i++;
  510.            }
  511.  
  512.            file_dm_write($outfile_,$lines);
  513.         }      
  514.         return 0;
  515. }
  516.  
  517. function download_file($file_)
  518. {
  519.         header('Content-Type: application/octet-stream');
  520.         header('Content-Length: ' . filesize($file_));
  521.         @readfile($file_);
  522. }
  523.  
  524. ?>
RAW Paste Data
Pastebin PRO WINTER Special!
Get 40% OFF Pastebin PRO accounts!
Top