if($_GET[‘action‘]=="check"){
$domain=$_POST[‘domain‘];
//域名表单项为空,则获取地址栏参数
if($domain==""){
$domain=$_GET[‘domain‘];
}
//网址
$url="http://".$domain;
//读取网页,返回网页源文件内容
function read_url($str){
$file=fopen($str,"r") or die($str.‘->远程网址读取失败! 点击继续查询
‘);
while(!feof($file)){
$result.=fgets($file,9999);
}
fclose($file);
return $result;
}
//打开session
session_start();
//如果$_SESSION[‘matches‘]没有赋值就设置它;
if(!isset($_SESSION[‘matches‘])){
$result=read_url($url);
preg_match_all(‘/(.*?)/i‘,$result,$matches);
$num=count($matches[2]);
for($i=0;$i
if(strpos($matches[2][$i],$domain)>0){
unset($matches[2][$i]);
}
}
$_SESSION[‘matches‘]=$matches[2];
}
//直接从session中取出包含网址数组;
$matches[2]=$_SESSION[‘matches‘];
$n=count($matches[2]);
$next=0;
$next+=$_GET[‘next‘];
$result=read_url($matches[2][$next]);
if(strpos($result,$domain)>0){
$value=$matches[2][$next].‘ true
‘;
}else{
$value=$matches[2][$next].‘ false
‘;
}
$values=$_COOKIE[‘check_result‘].$value;
setcookie("check_result",$values,time()+3600);
echo $values;
if($next==$n){
echo "扫描结束!";
}else{
echo ‘‘;
}
}else{
//删除cookies
setcookie("check_result","",time()-3600);
echo ‘
*输入域名 如:jb51.net
‘;
}
?>
原文:http://www.jb51.net/article/21739.htm