<?PHP
# PLEASE NOTE: This integration code will not work with HTTPS
# You should use one of the other methods if you require HTTPS
# This file is for the order profile:
# Default [Profile ID: 1] [created: Sun, 17 Sep 2006 19:24:37 -0500]
# This include holds the $license variable.
# Feel free to change it as you see needed.
# It's only a suggestion, you could even hard
# code the $license variable here instead
# of doing the include. Up to you. :)
global $root_dir;
include $root_dir . 'includes/db.inc.php';
$servers = array();
$servers[] = 'http://www.fsrevolution.com/order/'; // main server
# You can ignore everything below this line if you want to --------------------------
# functions -------------------------------------------------------------------------
function phpaudit_exec_socket($http_host, $http_dir, $http_file, $querystring)
{
$fp=@fsockopen($http_host, 80, $errno, $errstr, 10); // was 5
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);
# echo "<textarea rows='100' cols='100'>".$data."</textarea>"; die;
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];
}
}
# DOES NOT WORK FOR WINDOWS!!!!!!!
# No good way to get the mac address for win.
function phpaudit_get_mac_address()
{
$fp=@popen("/sbin/ifconfig", "r");
if (!$fp) { return -1; } # returns invalid, cannot open ifconfig
$res=@fread($fp, 4096);
@pclose($fp);
$array=@explode("HWaddr", $res);
if (@count($array)<2) { $array=@explode("ether", $res); } # FreeBSD
$array=@explode("\n", $array[1]);
$buffer[]=@trim($array[0]);
$array=@explode("inet addr:", $res);
if (@count($array)<2) { $array=@explode("inet ", $res); } # FreeBSD
$array=@explode(" ", $array[1]);
$buffer[]=@trim($array[0]);
return $buffer;
}
function path_translated()
{
if ($_SERVER['PATH_TRANSLATED'])
{
return @substr($_SERVER['PATH_TRANSLATED'], 0, @strrpos($_SERVER['PATH_TRANSLATED'], "/"));
}
if ($_SERVER['SCRIPT_FILENAME'])
{
return @substr($_SERVER['SCRIPT_FILENAME'], 0, @strrpos($_SERVER['SCRIPT_FILENAME'], "/"));
}
return @substr($_SERVER['ORIG_PATH_TRANSLATED'], 0, @strrpos($_SERVER['ORIG_PATH_TRANSLATED'], "\\"));
}
function server_addr()
{
return ($_SERVER['SERVER_ADDR'])?$_SERVER['SERVER_ADDR']:$_SERVER['LOCAL_ADDR'];
}
# END functions ---------------------------------------------------------------------
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'];
}
foreach($servers as $server)
{
$sinfo=@parse_url($server);
$data=phpaudit_exec_socket($sinfo['host'], $sinfo['path'], '/validate_internal.php', $query_string);
if ($data) { break; }
}
$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'];
if (empty($returned)) { $returned['status']="invalid"; }
if ($returned['status']!="active") { $sinfo=@parse_url($servers[0]); }
if ($returned['status']=="invalid")
{
header("Location: http://".$sinfo['host'].$sinfo['path']."license_invalid.php");
exit;
}
if ($returned['status']=="suspended")
{
header("Location: http://".$sinfo['host'].$sinfo['path']."license_suspended.php");
exit;
}
if ($returned['status']=="expired")
{
header("Location: http://".$sinfo['host'].$sinfo['path']."license_expired.php");
exit;
}
if ($returned['status']=="pending")
{
header("Location: http://".$sinfo['host'].$sinfo['path']."license_pending.php");
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);
?>