<?php
$num = $_GET['num'];
if($num == ''){$num = 0;}
//站群域名解析状态查询工具
$error_all = $_GET['error_all'];
$success_all = $_GET['success_all'];
if($success_all == ''){
$success_all=0;
}
if($error_all == ''){
$error_all=0;
}
//获取域名列表
$file_array = file("list.txt");
//二级域名前缀
$sub_domains = array('www','m','v','news','static');
$success = 0;
$error = 0;
$file = $file_array[$num];
if($file != ''){
//获取主域名
$domain = explode(":",$file);
$domain = trim($domain[0]);
//查询主域名状态
if( http_status($domain) == 200){
$matches = null;
$html = file_get_contents("http://$domain");
preg_match('/<title>(.*)<\/title>/s',$html, $matches);
echo "【$domain => $matches[1]】<br>";
$success++;
$success_all++;
}else{
echo "<font color='red'>$domain => 主域名检测失败/请检查!</font><br>";
$error++;
$error_all;
$error_domains = fopen("error.txt",'a');
fwrite($error_domains,$domain."\n");
fclose($error_domains);
}
//查询子域名
for($k=0;$k<sizeof($sub_domains);$k++){
$matches = null;
$domain_ = $sub_domains[$k].".".$domain;
if( http_status($domain_) == 200){
$html = file_get_contents("http://$domain_");
preg_match('/<title>(.*)<\/title>/s',$html, $matches);
echo $domain_." => ".$matches[1]."<br>";
$success++;
$success_all++;
}else{
echo "<font color='red'>$domain_ => 检测失败/请检查!</font><br>";
$error++;
$error_all;
$error_domains = fopen("error.txt",'a');
fwrite($error_domains,$domain."\n");
fclose($error_domains);
}
}
echo "<br>===============================================================<br>";
echo "<div style='margin-bottom: 20px;text-align:center;background: #c6dfc099;color:#be2ae6; padding: 30px;width: 100%;'><h2>【{$domain}】</h2><h1>当前成功:【".$success."】 === 当前失败:【".$error."】</h1></div>";
echo "<div style='color: green;padding: 30px;text-align:center;background: #c6dfc099; width: 100%;'><h1>一共成功:【".$success_all."】 === 一共失败:【".$error_all."】</h1></div>";
$num++;
echo "<script>window.location.href='http://104.227.29.146/domains_query_dns/zhanqun_query_dns.php?num=$num&error_all=$error_all&success_all=$success_all'</script>";
}else{
echo "<h1>程序执行结束</h1>";
exit();
}
function http_status($url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_NOBODY, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
curl_exec($ch);
$status = (int)curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
return $status;
}
php 建议查询DNS解析状态工具
最新推荐文章于 2022-01-06 22:09:47 发布