我遇到了以下域检查功能,但似乎无法正常工作。
function domain_checker($domain){
$extension = explode(".",$domainname);
$extension = $extension[1];
switch($extension)
{
case "com": $server = "whois.verisign-grs.com"; break;
case "net": $server = "whois.verisign-grs.com"; break;
case "org": $server = "whois.pir.org"; break;
case "info": $server = "whois.afilias.net"; break;
case "biz": $server = "whois.biz"; break;
case "name": $server = "whois.nic.name"; break;
default: return "Given Extension not supported"; exit();
}
// connecting to the whois server.
$handle = fsockopen($server, 43);
if (!$handle)
return false; // connectin failure
//asking the server
fwrite($handle, $domainname."\r\n");
// getting response
$response = '';
while (!feof($handle))
$response .= fgets($handle, 1024);
fclose($handle);
//checking if domain is available or not
if($extension=="com" || $extension=="net" || $extension=="name")
{
if(stripos($response, 'No match') === FALSE )
return $domainname." is not Available!";
else
return $domainname. " is Available!";
}
else
{
if(stripos($response, "NOT FOUND") === FALSE)
return $domainname. " is not Available!";
else
return $domainname. " is Available!";
}
}
我不断收到以下错误:
警告:fsockopen() [function.fsockopen]:无法连接到 whois.verisign-grs.com:43
帮助表示赞赏!