<?php
function make_token( )
{
return md5( "c02c536681fc06cd2d809ad4e8a42432".time( ) );
}
function get_key( )
{
$data = @file( "key.php" );
if ( !$data )
{
return false;
}
$buffer = false;
foreach ( $data as $line )
{
$buffer .= $line;
}
if ( !$buffer )
{
return false;
}
$buffer = @str_replace( "<", "", $data );
$buffer = @str_replace( ">", "", $buffer );
$buffer = @str_replace( "?PHP", "", $buffer );
$buffer = @str_replace( "?", "", $buffer );
$buffer = @str_replace( "/*--", "", $buffer );
$buffer = @str_replace( "--*/", "", $buffer );
return str_replace( "\n", "", $buffer );
}
function parse_local_key( )
{
if ( !file_exists( "key.php" ) )
{
return false;
}
$raw_data = @base64_decode( @get_key( ) );
$raw_array = @explode( "|", $raw_data );
if ( @is_array( $raw_array ) && count( $raw_array ) < 8 )
{
return false;
}
return $raw_array;
}
function pa_wildcard( $host_array )
{
if ( !is_array( $host_array ) )
{
return array( );
}
foreach ( $host_array as $access )
{
$first_dot = strpos( $_SERVER['HTTP_HOST'], "." );
$strlen = strlen( $_SERVER['HTTP_HOST'] );
$target = substr( $_SERVER['HTTP_HOST'], $first_dot, $strlen );
if ( $host = md5( "c02c536681fc06cd2d809ad4e8a42432*".$target ) == $access )
{
return $host_array[] = $_SERVER['HTTP_HOST'];
}
}
return $host_array;
}
function validate_local_key( $array )
{
$raw_array = parse_local_key( );
if ( !is_array( $raw_array ) || $raw_array === false )
{
return "<verify status='invalid_key' message='Please contact support for a new license key.' />";
}
if ( $raw_array[11] && strcmp( @md5( "c02c536681fc06cd2d809ad4e8a42432".$raw_array[11] ), $raw_array[12] ) != 0 )
{
return "<verify status='invalid_key' message='Please contact support for a new license key.' />";
}
if ( $raw_array[9] && strcmp( @md5( "c02c536681fc06cd2d809ad4e8a42432".$raw_array[9] ), $raw_array[10] ) != 0 )
{
return "<verify status='invalid_key' message='Please contact support for a new license key.' />";
}
if ( strcmp( @md5( "c02c536681fc06cd2d809ad4e8a42432".$raw_array[1] ), $raw_array[2] ) != 0 )
{
return "<verify status='invalid_key' message='Please contact support for a new license key.' ".$raw_array[9]." addon_array='{$raw_array[11]}' />";
}
if ( $raw_array[1] < time( ) && $raw_array[1] != "never" )
{
return "<verify status='invalid_key' message='Please contact support for a new license key.' ".$raw_array[9]." addon_array='{$raw_array[11]}' />";
}
if ( $array['per_server'] )
{
$server = phpaudit_get_mac_address( );
$mac_array = @explode( ",", $raw_array[6] );
if ( !in_array( @md5( "c02c536681fc06cd2d809ad4e8a42432".$server[0] ), $mac_array ) )
{
return "<verify status='invalid_key' message='Please contact support for a new license key.' ".$raw_array[9]." addon_array='{$raw_array[11]}' />";
}
$host_array = @explode( ",", $raw_array[4] );
if ( !in_array( @md5( "c02c536681fc06cd2d809ad4e8a42432".@gethostbyaddr( @gethostbyname( $server[1] ) ) ), $host_array ) )
{
return "<verify status='invalid_key' message='Please contact support for a new license key.' ".$raw_array[9]." addon_array='{$raw_array[11]}' />";
}
}
else if ( $array['per_install'] || $array['per_site'] )
{
if ( $array['per_install'] )
{
$directory_array = @explode( ",", $raw_array[3] );
$valid_dir = path_translated( );
$valid_dir = @md5( "c02c536681fc06cd2d809ad4e8a42432".$valid_dir );
if ( !in_array( $valid_dir, $directory_array ) )
{
return "<verify status='invalid_key' message='Please contact support for a new license key.' ".$raw_array[9]." addon_array='{$raw_array[11]}' />";
}
}
$host_array = @explode( ",", $raw_array[4] );
$host_array = pa_wildcard( $host_array );
if ( !in_array( @md5( "c02c536681fc06cd2d809ad4e8a42432".$_SERVER['HTTP_HOST'] ), $host_array ) )
{
return "<verify status='invalid_key' message='Please contact support for a new license key.' ".$raw_array[9]." addon_array='{$raw_array[11]}' />";
}
$ip_array = @explode( ",", $raw_array[5] );
if ( !in_array( @md5( "c02c536681fc06cd2d809ad4e8a42432".@server_addr( ) ), $ip_array ) )
{
return "<verify status='invalid_key' message='Please contact support for a new license key.' ".$raw_array[9]." addon_array='{$raw_array[11]}' />";
}
}
return "<verify status='active' message='The license key is valid.' ".$raw_array[9]." addon_array='{$raw_array[11]}' />";
}
function phpaudit_exec_socket( $http_host, $http_dir, $http_file, $querystring )
{
$fp = @fsockopen( $http_host, 80, &$errno, &$errstr, 10 );
if ( !$fp )
{
return false;
}
else
{
$header = "POST ".( $http_dir.$http_file )." HTTP/1.0\r\n";
$header .= "Host: ".$http_host."\r\n";
$header .= "Content-type: application/x-www-form-urlencoded\r\n";
$header .= "User-Agent: PHPAudit v2 (http://www.phpaudit.com)\r\n";
$header .= "Content-length: ".@strlen( $querystring )."\r\n";
$header .= "Connection: close\r\n\r\n";
$header .= $querystring;
$data = false;
if ( @function_exists( "stream_set_timeout" ) )
{
stream_set_timeout( $fp, 20 );
}
@fputs( $fp, $header );
if ( @function_exists( "socket_get_status" ) )
{
$status = @socket_get_status( $fp );
}
else
{
$status = true;
}
while ( !feof( $fp ) && $status )
{
$data .= @fgets( $fp, 1024 );
if ( @function_exists( "socket_get_status" ) )
{
$status = @socket_get_status( $fp );
}
else if ( feof( $fp ) == true )
{
$status = false;
}
else
{
$status = true;
}
}
@fclose( $fp );
if ( !strpos( $data, "200" ) )
{
return false;
}
if ( !$data )
{
return false;
}
$data = @explode( "\r\n\r\n", $data, 2 );
if ( !$data[1] )
{
return false;
}
if ( strpos( $data[1], "verify" ) === false )
{
return false;
}
return $data[1];
}
}
function phpaudit_get_mac_address( )
{
$fp = @popen( "/sbin/ifconfig", "r" );
if ( !$fp )
{
return 0 - 1;
}
$res = @fread( $fp, 4096 );
@pclose( $fp );
$array = @explode( "HWaddr", $res );
if ( count( $array ) < 2 )
{
$array = @explode( "ether", $res );
}
$array = @explode( "\n", $array[1] );
$buffer[] = trim( $array[0] );
$array = @explode( "inet addr:", $res );
if ( count( $array ) < 2 )
{
$array = @explode( "inet ", $res );
}
$array = @explode( " ", $array[1] );
$buffer[] = trim( $array[0] );
return $buffer;
}
function path_translated( )
{
$option = array( "PATH_TRANSLATED", "ORIG_PATH_TRANSLATED", "SCRIPT_FILENAME", "DOCUMENT_ROOT", "APPL_PHYSICAL_PATH" );
foreach ( $option as $key )
{
if ( !isset( $_SERVER[$key] ) )
{
continue;
}
if ( substr( @php_uname( ), 0, 7 ) == "Windows" )
{
return substr( $_SERVER[$key], 0, @strrpos( $_SERVER[$key], "\\" ) );
}
return substr( $_SERVER[$key], 0, @strrpos( $_SERVER[$key], "/" ) );
}
return false;
}
function server_addr( )
{
$options = array( "SERVER_ADDR", "LOCAL_ADDR" );
foreach ( $options as $key )
{
if ( isset( $_SERVER[$key] ) )
{
return $_SERVER[$key];
}
}
return false;
}
include( "_config.php" );
$servers = array( );
$servers[] = "http://www.x10media.com/orders/";
$query_string = "license=".$license;
$per_server = false;
$per_install = false;
$per_site = true;
$enable_dns_spoof = "yes";
if ( $per_server )
{
$server_array = phpaudit_get_mac_address( );
$query_string .= "&access_host=".@gethostbyaddr( @gethostbyname( $server_array[1] ) );
$query_string .= "&access_mac=".$server_array[0];
}
else if ( $per_install )
{
$query_string .= "&access_directory=".path_translated( );
$query_string .= "&access_ip=".server_addr( );
$query_string .= "&access_host=".$_SERVER['HTTP_HOST'];
}
else if ( $per_site )
{
$query_string .= "&access_ip=".server_addr( );
$query_string .= "&access_host=".$_SERVER['HTTP_HOST'];
}
$query_string .= "&access_token=";
$query_string .= $token = make_token( );
foreach ( $servers as $server )
{
$sinfo = @parse_url( $server );
$data = phpaudit_exec_socket( $sinfo['host'], $sinfo['path'], "/validate_internal.php", $query_string );
if ( $data )
{
break;
}
}
$skip_dns_spoof = false;
if ( !$data )
{
$array['per_server'] = $per_server;
$array['per_install'] = $per_install;
$array['per_site'] = $per_site;
$data = validate_local_key( $array );
$skip_dns_spoof = true;
}
$parser = @xml_parser_create( "" );
@xml_parser_set_option( $parser, XML_OPTION_CASE_FOLDING, 0 );
@xml_parser_set_option( $parser, XML_OPTION_SKIP_WHITE, 1 );
@xml_parse_into_struct( $parser, $data, $values, $tags );
@xml_parser_free( $parser );
$returned = $values[0]['attributes'];
$returned['addon_array'] = str_replace( " ", "+", @unserialize( @base64_decode( $returned['addon_array'] ) ) );
if ( empty( $returned ) )
{
$returned['status'] = "invalid";
}
if ( $returned['status'] != "active" )
{
$sinfo = @parse_url( $servers[0] );
}
if ( $returned['status'] == "invalid" )
{
echo "<META HTTP-EQUIV=\"refresh\" content=\"0; URL=http://".$sinfo['host'].$sinfo['path']."license_invalid.php\">";
exit( );
}
if ( $returned['status'] == "suspended" )
{
echo "<META HTTP-EQUIV=\"refresh\" content=\"0; URL=http://".$sinfo['host'].$sinfo['path']."license_suspended.php\">";
exit( );
}
if ( $returned['status'] == "expired" )
{
echo "<META HTTP-EQUIV=\"refresh\" content=\"0; URL=http://".$sinfo['host'].$sinfo['path']."license_expired.php\">";
exit( );
}
if ( $returned['status'] == "pending" )
{
echo "<META HTTP-EQUIV=\"refresh\" content=\"0; URL=http://".$sinfo['host'].$sinfo['path']."license_pending.php\">";
exit( );
}
if ( $returned['status'] == "invalid_key" )
{
echo "\r\n\t";
echo "<S";
echo "CRIPT LANGUAGE=\"JavaScript\">\r\n\t<!-- Begin\r\n\talert('Your local license key is missing or invalid. We will now try to redirect you to create a new key. If this operation fails or you feel it is in error please contact our support department.');\r\n\r\n\twindow.location=\"";
echo "http://";
echo $sinfo['host'];
echo $sinfo['path'];
echo "license_key_invalid.php?access=".urlencode( base64_encode( $query_string ) );
echo "\";\r\n\r\n\t// End -->\r\n\t</script>\r\n\r\n\t";
exit( );
}
unset( $query_string );
unset( $per_server );
unset( $per_install );
unset( $per_site );
unset( $server );
unset( $data );
unset( $parser );
unset( $values );
unset( $tags );
unset( $sinfo );
unset( $token );
$selected_engines = $_POST['selected_engines'];
$url = $_POST['url'];
$email = $_POST['email'];
include( "inc/submit.class.php" );
$addit->set_mode( $SF_mode );
$addit->queue_engines( $engine_file );
$addit->init( $url, $email, $user, $selected_engines );
$addit->submit_page( );
?>