need help with code

hello

dont know if i’m in the right forum,but i realy need help with this code -

[php]include “conf.php”;
$GLOBALS[‘file_codes’] = “/var/users/proxy.codes”;
$GLOBALS[‘file_act’] = “/var/users/proxy.act”;
$GLOBALS[‘file_user’] = “/var/users/user.xml”;
$GLOBALS[‘file_cccam’] = “/var/etc/CCcam.cfg”;
$GLOBALS[‘USER_AG’] = “MY_AGENT”;

function plugin_src( $user, $pass, $msg, $code, $enddate=0 )
{
echo “grep -v “#L” /var/tuxbox/plugins/active_code.cfg > /tmp/actv.cfg”;
echo “\necho “#LastName={$user}” >> /tmp/actv.cfg”;
echo “\nmv /tmp/actv.cfg /var/tuxbox/plugins/active_code.cfg”;
echo “\ngrep -v “#C” /var/tuxbox/plugins/active_code.cfg > /tmp/actv.cfg”;
echo “\necho “#Code={$code}” >> /tmp/actv.cfg”;
echo “\nmv /tmp/actv.cfg /var/tuxbox/plugins/active_code.cfg”;
include “Lines.php”;
echo “\necho “{$msg}” > /var/tmp/msgS.tmp”;
}

function plugin_src2( $user, $pass, $msg )
{
echo “echo “{$msg}” > /var/tmp/msgS.tmp”;
include “Lines.php”;
}

function browser_src( $user=NULL, $pass=NULL, $msg=NULL )
{
}

if ( $_SERVER[“HTTP_USER_AGENT”] == $GLOBALS[‘USER_AG’] )
{
main();
exit;
}
else
{
// echo “hello !\n”;
main();
exit;
}

function main()
{
if ( !$_GET[‘code’] || empty( $_GET[‘code’] ) )
{
echo “1”;
return;
}
else
{
$code = trim( $_GET[‘code’] );
}

if ( !is_numeric( $_GET[‘code’] ) )
{
echo “2”;
return;
}
$my_pass = gen_pass();

if ( !isset( $_GET[‘LastName’] ) || empty( $_GET[‘LastName’] ) )
{
$my_user = “abd” . time();
}
else
{
$my_user = trim( $_GET[‘LastName’] );
}
$days = file_codes_check( $code );
if ( $days > 0 )
{
$text_msg = “{$GLOBALS[‘WELCOME’]} votre compte est active avec succes! Expirera a " . 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’]}”" ) ) )
{
if ( $act[‘End’] > time() )
{
$str_date = $act[‘Start’];
$end_date = $act[‘End’] + ($days * 24 * 60 * 60);
$text_msg = “Compte est etendue avec {$days} jours! Expirera a " . date( “Y-m-d”, $end_date );
$enddate = $end_date;
}
}
file_act_add( $my_user, $my_pass, $code, $days, $str_date, $end_date );
file_codes_del( $code );
if ( $_SERVER[“HTTP_USER_AGENT”] == $GLOBALS[‘USER_AG’] )
plugin_src( $my_user, $my_pass, $text_msg, $code, $enddate );
else
browser_src( $my_user, $my_pass, $text_msg );
}
else
{
$code_wrong = 1;
if ( $days == 0 )
{
$act = file_user_check( “code=”{$code}”" );
if ( is_array( $act ) )
{
$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’] );
if ( $_SERVER[“HTTP_USER_AGENT”] == $GLOBALS[‘USER_AG’] )
{
plugin_src( $my_user, $my_pass, "Compte est reactif! Expirera a " . date( “Y-m-d”, $act[‘End’] ), $code, $act[‘End’] );
}
else
{
browser_src( $my_user, $my_pass, "Compte est reactif! Expirera a " . date( “Y-m-d”, $act[‘End’] ) );
}
}
else
{
if ( $_SERVER[“HTTP_USER_AGENT”] == $GLOBALS[‘USER_AG’] && isset( $_GET[‘update’] ) && $_GET[‘update’] == “ok” )
{
$passwd = $act[‘password’];
plugin_src2( $my_user, $passwd, “Votre compte a ete mise a jour avec succes!” );
}
else
{
echo “3”;
}
}
}
}
if ( $code_wrong )
{
echo “2”;
}
}
}

function gen_pass()
{
$str = md5( uniqid() * time() );

return $str = strtolower( substr( $str, -13 ) );
}

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];
$attributes = trim( $elements[2][$ie] );
if ( $attributes )
{
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 )
{
$file_handle = fopen( $GLOBALS[‘file_act’], “a+” );
if ( $file_handle )
{
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}\n” );
fclose( $file_handle );
if ( $GLOBALS[‘ACTION’] == “N” )
{
file_user_update( $user, $pass, $code, $days, date( “d-m-Y”, $date_st ), date( “d-m-Y”, $date_end ) );
}
elseif ( $GLOBALS[‘ACTION’] == “C” )
{
file_CCcam_update( $user, $pass, $code, date( “d-m-Y”, $date_end ) );
file_user_update( $user, $pass, $code, $days, date( “d-m-Y”, $date_st ), date( “d-m-Y”, $date_end ) );
}
elseif ( $GLOBALS[‘ACTION’] == “NC” )
{
file_user_update( $user, $pass, $code, $days, date( “d-m-Y”, $date_st ), date( “d-m-Y”, $date_end ) );
file_CCcam_update( $user, $pass, $code, 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 ) )
{
$file_handle = fopen( $GLOBALS[‘file_codes’], “w” );
if ( $file_handle )
{
$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_CCcam_write( $data )
{
$fp = fopen( $GLOBALS[‘file_cccam’], “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[‘date’] );
$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” EcmRate="-1" code="{$code}" days="{$days}" startDate="{$date_st}" expire-date="{$date_end}"/>";
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_cccam_update( $user, $pass, $code, $date_end )
{
$lines = file( $GLOBALS[‘file_cccam’], FILE_IGNORE_NEW_LINES );
$newline = “F: {$user} {$pass} 3 0 0 { 0:0:1 } # {$date_end}”;
if ( is_array( $lines ) )
{
if ( $_GET[‘LastName’] )
{
$code_str = “F: {$_GET[‘LastName’]}”;
}
else
{
$code_str=“F: $user”;
}
$i = 0;
foreach ( $lines as $line )
{
if ( strstr( $line, $code_str ))
{
$lines[$i] = $newline;
file_CCcam_write( $lines );
return 1;
}
$i++;
}
$frstel = $lines[0];
$lines[0] = $newline;
array_unshift( $lines, $frstel );
file_CCcam_write( $lines );
}
return 0;
}[/php]

can someone please explain in simple English what it do ? i really need to know

i have this files -

index.php >>> this is the php code above
conf.php
Lines.php
user.xml

i know i must create proxy.codes and proxy.act but don’t know what to put in this 2 files.

if this is not the place for this kind of question i apologize.

many thanx

Sponsor our Newsletter | Privacy Policy | Terms of Service