如何修改前面加WWW也能查询

yaohaijin 发布于 2016/10/17 23:10
阅读 89
收藏 0
<?php
$url = $_GET['url'];
$whoisservers = array(
"aero"=>"whois.aero",
"arpa" =>"whois.iana.org",
"asia" =>"whois.nic.asia",
"at" =>"whois.nic.at",
"be" =>"whois.dns.be",
"biz" =>"whois.biz",
"br" =>"whois.registro.br",
"ca" =>"whois.cira.ca",
"cc" =>"whois.nic.cc",
"cn" =>"whois.cnnic.net.cn",
"com" =>"whois.verisign-grs.com",
"gov" =>"whois.nic.gov",
"in" =>"whois.inregistry.net",
"co.in" =>"whois.inregistry.net",
"net.in" =>"whois.inregistry.net",
"org.in" =>"whois.inregistry.net",
"ind.in" =>"whois.inregistry.net",
"firm.in" =>"whois.inregistry.net",
"info" =>"whois.afilias.info",
"int" =>"whois.iana.org",
"is" =>"whois.isnic.is",
"it" =>"whois.nic.it",
"jobs" =>"jobswhois.verisign-grs.com",
"me" =>"whois.meregistry.net",
"mil" =>"whois.nic.mil",
"mobi" =>"whois.dotmobiregistry.net",
"museum" =>"whois.museum",
"name" =>"whois.nic.name",
"net" =>"whois.verisign-grs.net",
"org" =>"whois.pir.org",
"pro" =>"whois.registrypro.pro",
"tc" =>"whois.adamsnames.tc",
"tel" =>"whois.nic.tel",
"travel" =>"whois.nic.travel",
"tv" => "whois.www.tv",
"co.uk" =>"whois.nic.uk",
"org.uk" =>"whois.nic.uk",
"us" =>"whois.nic.us",
"ws" =>"whois.website.ws");


function Lookupurl($url){
global $whoisservers;
$whoisserver = "";


$dotpos=strpos($url,".");
$domtld=substr($url,$dotpos+1);


$whoisserver = $whoisservers[$domtld];


if(!$whoisserver) {
return "Error: No appropriate Whois server found for <b>$url</b> url!";
}
$result = QueryWhoisServer($whoisserver, $url);
if(!$result) {
return "Error: No results retrieved $url !";
}


preg_match("/Whois Server: (.*)/", $result, $matches);
$secondary = $matches[1];
if($secondary) {
$result = QueryWhoisServer($secondary, $url);
}
return  $result;
}


function QueryWhoisServer($whoisserver, $url) {
$port = 43;
$timeout = 10;
$fp = @fsockopen($whoisserver, $port, $errno, $errstr, $timeout) or die("Socket Error " . $errno . " - " . $errstr);
fputs($fp, $url . "\r\n");
$out = "";
while(!feof($fp)){
$out .= fgets($fp);
}
fclose($fp);
return $out;
}

?>


<?php
if($url) {
if(!preg_match("/^([-a-z0-9]{2,100})\.([a-z\.]{2,8})$/i", $url)) {
die("查询域名WHOIS格式, 比如. <i>qzmulu.com</i>!");
}
$result = Lookupurl($url);
echo "<pre>\n" . $result . "\n</pre>\n";
}
?>
<?php } ?>


如何把上门的代码修改前面加WWW也能查询到,现在只能查询前面不加WWW的

加载中
返回顶部
顶部