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

//鎻愬彇椤甸溃鍐呭鍜屾闷瀹氭墦寮€镞堕棿
$Start=microtime(true);
$PageCode=file_get_contents("http://".$Domain);
$fp = fsockopen($Domain, 80, $errno, $errstr, 30);
if(!$fp){
	echo "$errstr ($errno)<br />\n";
}else{
	$out = "GET / HTTP/1.1\r\n" ;
	$out .= "Host: ".$Domain."\r\n" ;
	$out .= "Connection: Close\r\n\r\n" ; 
	fwrite($fp, $out);
	$PageCode="";
	while (!feof($fp)) {
		$PageCode.= fgets($fp, 128);
	}
	fclose($fp); 
}
$Finish=microtime(true);
$GetTime=$Finish-$Start;

$SiteStr=$GetTime;

//鍒ゆ柇缂栫爜杩涜杞爜
if(strpos(strtolower($PageCode),"charset=gb2312")>0){
	$PageCode=mb_convert_encoding($PageCode,"UTF-8","gb2312");
}
//鎻愬彇缃戦〉镙囬
$Arr=spliti("<title>",$PageCode);
$Arr=spliti("</title>",$Arr[1]);
$PageTitle=$Arr[0];
$SiteStr.="|-ITool-|".$PageTitle;

//鎻愬彇缃戦〉鎻忚堪
$Arr=spliti("description\" content=\"",$PageCode);
$Arr=spliti("\"",$Arr[1]);
$PageDescription=$Arr[0];
$SiteStr.="|-ITool-|".$PageDescription;

//鎻愬彇缃戦〉鍏抽敭瀛?
$Arr=spliti("keywords\" content=\"",$PageCode);
$Arr=spliti("\"",$Arr[1]);
$PageKeywords=$Arr[0];
$SiteStr.="|-ITool-|".$PageKeywords;

//鎻愬彇缃戦〉鍐呴摼涓庡阈?
$LinkCount1=0;
$LinkCount2=0;
$Arr=spliti("<a",$PageCode);
for($i=1;$i<count($Arr)-1;$i++){
	$Arr2=spliti("</a>",$Arr[$i]);
	if(strpos($Arr2[0],$Domain)!=""||strpos($Arr2[0],"http://")==""){
		$LinkCount1=$LinkCount1+1;
	}else{
		$LinkCount2=$LinkCount2+1;
	}
}
$SiteStr.="|-ITool-|"."鍐呴摼".$LinkCount1."涓紝澶栭摼".$LinkCount2."涓?;

//鎻愬彇缃戦〉锲剧墖
$ImageCount=0;
$ImageAltCount=0;
$Arr=spliti("<img",$PageCode);
$ImageCount=count($Arr)-1;
for($i=1;$i<count($Arr)-1;$i++){
	$Arr2=spliti(">",$Arr[$i]);
	if(strpos($Arr2[0],"alt=")!=""){
		$ImageAltCount=$ImageAltCount+1;
	}
}
$SiteStr.="|-ITool-|"."鍏辨湁".$ImageCount."涓浘鐗囷紝".$ImageAltCount."涓浘鐗囨湁Alt镙囩";
echo $SiteStr;
?>