Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?
- $GLOBALS['file_codes']="/var/activecode/proxy.codes";
- $GLOBALS['file_act']="/var/activecode/proxy.act";
- $GLOBALS['file_user']="/var/activecode/user.xml";
- function sh_scr($user,$pass,$msg,$enddate)
- {
- $_GET['LastName']=$user;
- //==========================================================================================
- //!!!!!!!!! must always be there do not delete this line!!!!
- //==========================================================================================
- //echo "\nLastName:{$_GET['LastName']}\n";
- //==========================================================================================
- // u can only edit here !!!!!!!!!
- //==========================================================================================
- //make Mgcamd Lines
- echo "#!/bin/sh +e\n\n";
- echo "\necho \"CWS_KEEPALIVE = 300\" > /var/keys/newcamd.list";
- echo "\necho \"CWS_INCOMING_PORT = 21000\" >> /var/keys/newcamd.list";
- 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";
- echo "\nsleep 1";
- // make script
- echo "\necho \";; #delete\" >> /tmp/mga";
- echo "\necho \"esac #delete\" >> /tmp/mga";
- echo "\n";
- echo "\nkillall -9 mgcamd";
- echo "\ncd /var/bin";
- echo "\n./mgcamd";
- // make messages for in message box
- echo "{$msg}\n";
- }
- //==========================================================================================
- // !!!!!!!!! DO NOT EDIT BELOW !!!!
- //==========================================================================================
- //==========================================================================================
- function html_scr($user,$pass,$msg)
- {
- echo $msg;
- ?>
- </b></p>
- </div>
- <div class="login-form">
- <div class="form-block">
- <div class="inputlabel">Username:</div>
- <div><? echo $user; ?></div>
- <div class="inputlabel" style="margin-top:10px;">Password:</div>
- <div><? echo $pass; ?></div>
- </div>
- </div>
- <div class="clr"></div>
- <form action="" method="get" name="loginForm" id="loginForm">
- <div align="center" style="margin-top:20px;"><input type="submit" class="button" value=" Enter New code " /></div>
- </form>
- </div>
- </div>
- <?
- html_footer();
- exit;
- }
- function html_main()
- {
- ?>
- <div id="ctr" align="center">
- <div class="login">
- <div class="login-form">
- <form action="" method="get" name="loginForm" id="loginForm">
- <div class="form-block">
- <div class="inputlabel">Activation code:</div>
- <div><input name="actvcode" type="text" class="inputbox" size="15" /></div>
- <div align="center"><input type="submit" class="button" value=" Activate " /></div>
- </div>
- </form>
- </div>
- <div class="login-text">
- <p>Welcome to Activation code system!</p>
- <p>Enter code to activete user.</p>
- </div>
- <div class="clr"></div>
- </div>
- </div>
- <?
- }
- function html_main_re1()
- {
- ?>
- <div id="ctr" align="center">
- <div class="login">
- <div class="login-text">
- <p style="color:red"><b>
- <?
- }
- function html_main_re2()
- {
- ?>
- </b></p>
- </div>
- <div class="login-form">
- <form action="" method="get" name="loginForm" id="loginForm">
- <div class="form-block">
- <div class="inputlabel">Activation code:</div>
- <div><input name="actvcode" type="text" class="inputbox" size="15" /></div>
- <div align="center"><input type="submit" class="button" value=" Activate " /></div>
- </div>
- </form>
- </div>
- <div class="clr"></div>
- </div>
- </div>
- <?
- }
- function html_header()
- {
- ?>
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
- <html lang="en-US">
- <head>
- <title>Active Code By Dzsatellite.com</title>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <style type="text/css">
- 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;}
- </style>
- </head>
- <body>
- <div id="wrapper">
- <div id="header">
- <div id="mambo">Active Code By Dzsatellite.com</div>
- </div>
- </div>
- <?
- }
- function html_footer()
- {
- ?>
- <div id="break"></div>
- <div class="footer" align="center">
- <div align="center"><br />Softwared By Dzsatellite.com</div>
- </div>
- </body>
- </html>
- <?
- }
- //==========================================================================================
- if($_GET['file'])
- {
- download_file($_GET['file']);
- unlink($_GET['file']);
- exit();
- }
- if($_SERVER["HTTP_USER_AGENT"]==$GLOBALS['IDENT'])
- {
- //$ver=apache_request_headers();
- //if($ver['Version']) .....
- main();
- exit;
- }
- else
- {
- //echo "Hello!";
- html_header();
- if(trim($_GET['actvcode']))
- {
- html_main_re1();
- main();
- html_main_re2();
- }
- else
- {
- html_main();
- }
- html_footer();
- exit;
- }
- //==========================================================================================
- //==========================================================================================
- function main()
- {
- $_GET['actvcode']=trim($_GET['actvcode']);
- $_GET['LastName']=trim($_GET['LastName']);
- if(!$_GET['actvcode'])
- {
- echo "No code enter";
- return;
- }
- if(!is_numeric($_GET['actvcode']))
- {
- echo "Wrong code!";
- return;
- }
- $code=$_GET['actvcode'];
- $my_user=$_GET['LastName'];
- if(!$_GET['LastName']) $my_user="AB".time(); //.gen_pass();
- $my_pass=gen_pass();
- $days=file_codes_check($code);
- if($days>0)
- {
- $text_msg="Account is Active! Will expire at ".date("Y-m-d",time() + ($days * 24 * 60 * 60));
- $enddate=time() + ($days * 24 * 60 * 60);
- $str_date=0;
- $end_date=0;
- if($_GET['LastName'] && is_array($act=file_user_check("name=\"{$_GET['LastName']}\""))) //"Extend"
- {
- if($act['End']>time())
- {
- $str_date=$act['Start'];
- $end_date=$act['End']+($days * 24 * 60 * 60);
- $text_msg="Account is Extended with {$days} days! Will expire at ".date("Y-m-d",$end_date);
- $enddate=$end_date;
- }
- }
- //else is New
- file_act_add($my_user,$my_pass,$code,$days,$str_date,$end_date);
- file_codes_del($code);
- if($_SERVER["HTTP_USER_AGENT"]==$GLOBALS['IDENT']) sh_scr($my_user,$my_pass,$text_msg,$enddate);
- else html_scr($my_user,$my_pass,$text_msg);
- }
- else
- {
- $code_wrong=1;
- if($days==0)
- {
- $act=file_user_check("code=\"{$code}\"");
- if(is_array($act)) //reactivet
- {
- $code_wrong=0;
- $my_user=$act['name'];
- if($act['End']>time())
- {
- file_act_add($my_user,$my_pass,$code,$act['days'],$act['Start'],$act['End']);
- //echo "reActivate";
- 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']);
- else html_scr($my_user,$my_pass,"Account is reActive! Will expire at ".date("Y-m-d",$act['End']));
- }
- else
- {
- echo "Expire code";
- }
- }
- }
- if($code_wrong)
- {
- echo "Wrong code";
- }
- }
- }
- //==========================================================================================
- //==========================================================================================
- function gen_pass()
- {
- $str = uniqid();
- return $str;
- }
- function xml2array($xml)
- {
- $xmlary = array();
- $reels = '/<(\w+)\s*([^\/>]*)\s*(?:\/>|>(.*)<\/\s*\\1\s*>)/s';
- $reattrs = '/(\w+)=(?:"|\')([^"\']*)(:?"|\')/';
- preg_match_all($reels, $xml, $elements);
- foreach ($elements[1] as $ie => $xx) {
- $xmlary[$ie]["name"] = $elements[1][$ie];
- if ($attributes = trim($elements[2][$ie])) {
- preg_match_all($reattrs, $attributes, $att);
- foreach ($att[1] as $ia => $xx)
- $xmlary[$ie]["attributes"][$att[1][$ia]] = $att[2][$ia];
- }
- $cdend = strpos($elements[3][$ie], "<");
- if ($cdend > 0) {
- $xmlary[$ie]["text"] = substr($elements[3][$ie], 0, $cdend - 1);
- }
- if (preg_match($reels, $elements[3][$ie]))
- $xmlary[$ie]["elements"] = xml2array($elements[3][$ie]);
- else if ($elements[3][$ie]) {
- $xmlary[$ie]["text"] = $elements[3][$ie];
- }
- }
- return $xmlary;
- }
- //==========================================================================================
- //==========================================================================================
- function file_act_add($user,$pass,$code,$days,$date_st=0,$date_end=0)
- {
- if($file_handle = fopen($GLOBALS['file_act'],"a+"))
- {
- if($date_st==0) $date_st=time();
- $txt_date_st=date("Y/m/d",$date_st);
- if($date_end==0) $date_end=time() + ($days * 24 * 60 * 60);
- $txt_date_end=date("Y/m/d",$date_end);
- fwrite($file_handle, date("[Y/m/d][H:i:s] "));
- fwrite($file_handle, "Username = {$user} Password = {$pass} {$code}={$days} Start: {$txt_date_st} End: {$txt_date_end} IP: {$_SERVER['REMOTE_ADDR']}\n");
- fclose($file_handle);
- file_user_update($user,$pass,$code,$days,date("d-m-Y",$date_st),date("d-m-Y",$date_end));
- }
- }
- function file_act_check($code)
- {
- $lines = file($GLOBALS['file_act']);
- if(is_array($lines ))
- {
- $code=" ".$code."=";
- foreach ($lines as $line)
- {
- if(strstr($line, $code))
- {
- $pieces = explode(" ",$line);
- $days=explode("=",$pieces[3]);
- $date_st=explode(": ",$pieces[4]);
- $date_end=explode(": ",$pieces[5]);
- $days=$days[1];
- list($year, $month, $day) = split('[/.-]', $date_st[1]);
- $date_st= mktime(0, 0, 0, $month, $day, $year);
- list($year, $month, $day) = split('[/.-]', $date_end[1]);
- $date_end= mktime(0, 0, 0, $month, $day, $year);
- return array("Days"=>"{$days}","Start"=>"{$date_st}","End"=>"{$date_end}");
- }
- }
- }
- return 0;
- }
- //==========================================================================================
- //==========================================================================================
- function file_codes_check($code)
- {
- $lines = file($GLOBALS['file_codes']);
- if(is_array($lines ))
- {
- foreach ($lines as $line)
- {
- list($cc, $day) = split('=', $line);
- if(strcmp($cc,$code) == 0)
- {
- return trim($day);
- }
- }
- }
- return 0;
- }
- function file_codes_del($code)
- {
- $lines = file($GLOBALS['file_codes']);
- if(is_array($lines ))
- {
- if($file_handle = fopen($GLOBALS['file_codes'],"w"))
- {
- $code=$code."=";
- foreach ($lines as $line)
- {
- if(strstr($line, $code)===FALSE) fwrite($file_handle,$line);
- }
- fclose($file_handle);
- }
- }
- }
- //==========================================================================================
- //==========================================================================================
- function file_user_write($data)
- {
- $fp=fopen($GLOBALS['file_user'],"w");
- if($fp)
- {
- foreach($data as $value)
- {
- $value=trim($value);
- if($value) fwrite($fp,$value."\n");
- }
- fclose($fp);
- }
- }
- function file_user_check($find)
- {
- $lines = file($GLOBALS['file_user']);
- if(is_array($lines))
- {
- foreach ($lines as $line)
- {
- if(strstr($line, $find))
- {
- $act=xml2array($line);
- if($act[0]['name']=="user" && is_array($act[0]['attributes']))
- {
- $act=$act[0]['attributes'];
- list($day, $month, $year) = split('[/.-]', $act['startDate']);
- $act['Start']= mktime(0, 0, 0, $month, $day, $year);
- list($day, $month, $year) = split('[/.-]', $act['endDate']);
- $act['End']= mktime(0, 0, 0, $month, $day, $year);
- return $act;
- }
- return 0;
- }
- }
- }
- return 0;
- }
- function file_user_update($user,$pass,$code,$days,$date_st,$date_end)
- {
- $lines = file($GLOBALS['file_user']);
- // $newline="<user name=\"{$user}\" password=\"{$pass}\" max-connections=\"1\" rate=\"-1\" husain=\"true\" code=\"{$code}\" days=\"{$days}\" startDate=\"{$date_st}\" expire-date=\"{$date_end}\"/>";
- $newline="<user name=\"{$user}\" password=\"{$pass}\" code=\"{$code}\" startDate=\"{$date_st}\" days=\"{$days}\" expire-date=\"{$date_end}\" max-connections=\"false\" admin=\"false\"/>";
- if(is_array($lines))
- {
- $code_str="code=\"{$code}\"";
- if($_GET['LastName']) $code_str="name=\"{$_GET['LastName']}\"";
- $i=0;
- foreach ($lines as $line)
- {
- if(strstr($line, $code_str))
- {
- $lines[$i]=$newline;
- file_user_write($lines);
- return 1;
- }
- $i++;
- }
- $frstel=$lines[0];
- $lines[0]=$newline;
- array_unshift($lines, $frstel);
- file_user_write($lines);
- }
- return 0;
- }
- function file_dm_write($file_,$data)
- {
- $fp=fopen($file_,"w");
- if($fp)
- {
- foreach($data as $value)
- {
- $value=trim($value);
- if($value) fwrite($fp,$value."\n");
- }
- fclose($fp);
- }
- }
- function file_dm_update($file_,$outfile_,$user,$pass)
- {
- $lines = file($file_);
- if(is_array($lines))
- {
- $i=0;
- foreach ($lines as $line)
- {
- $lines[$i]=str_replace("dummyuser", "{$user}", $lines[$i]);
- $lines[$i]=str_replace("dummypass", "{$pass}", $lines[$i]);
- $i++;
- }
- file_dm_write($outfile_,$lines);
- }
- return 0;
- }
- function download_file($file_)
- {
- header('Content-Type: application/octet-stream');
- header('Content-Length: ' . filesize($file_));
- @readfile($file_);
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement