<?php
ob_implicit_flush();
include "../Lib/Include.php";
$Domain=$_GET["S"];
$SiteStr="";

$fp = fsockopen("www.alexa.com", 80, $errno, $errstr, 30);
if(!$fp){
	echo "$errstr ($errno)<br />\n";
}else{
	$out = "GET /siteinfo/".str_replace("www.","",$Domain)." HTTP/1.1\r\n" ;
	$out .= "Host: www.alexa.com\r\n" ;
	$out .= "Connection: Close\r\n\r\n" ; 
	fwrite($fp, $out);
	$PageCode="";
	while (!feof($fp)) {
		$PageCode.= fgets($fp, 128);
	}
	fclose($fp); 
}
//銮峰彇鎺掑悕
$Arr=spliti("<td class=\"small\" align=\"center\">Traffic Rank</td>",$PageCode);
$Arr=spliti("</table>",$Arr[1]);
$AlexaData=$Arr[0];
$Arr=spliti("<th>7 day</th>",$AlexaData);
$Arr=spliti("</td>",$Arr[1]);
$Arr=spliti(">",$Arr[0]);
$AlexaDay=$Arr[1];
$Arr=spliti("<th>1 month</th>",$AlexaData);
$Arr=spliti("</td>",$Arr[1]);
$Arr=spliti(">",$Arr[0]);
$AlexaMonth1=$Arr[1];
$Arr=spliti("<th>3 month</th>",$AlexaData);
$Arr=spliti("</td>",$Arr[1]);
$Arr=spliti(">",$Arr[0]);
$AlexaMonth3=$Arr[1];
//鎺掑悕杈揿嚭
$SiteStr=$AlexaDay;
$SiteStr.="|-ITool-|".$AlexaMonth1;
$SiteStr.="|-ITool-|".$AlexaMonth3;

$Arr=spliti("<td class=\"small\" align=\"center\">Reach</td>",$PageCode);
$Arr=spliti("</table>",$Arr[1]);
$AlexaData=$Arr[0];
$Arr=spliti("<th>1 month</th>",$AlexaData);
$Arr=spliti("</td>",$Arr[1]);
$Arr=spliti(">",$Arr[0]);
$AlexaIp=$Arr[1];
$AlexaIp=$AlexaIp*10000*600;
$Arr=spliti("<td class=\"small\" align=\"center\">Pageviews/User</td>",$PageCode);
$Arr=spliti("</table>",$Arr[1]);
$AlexaData=$Arr[0];
$Arr=spliti("<th>1 month</th>",$AlexaData);
$Arr=spliti("</td>",$Arr[1]);
$Arr=spliti(">",$Arr[0]);
$AlexaPv=$Arr[1];
$AlexaPv=$AlexaIp*$AlexaPv;
$SiteStr.="|-ITool-|"."IP 铌?".$AlexaIp." PV 铌?".$AlexaPv."锛堜竴链埚钩鍧囷级";
echo $SiteStr;
?>