这是我保留顶级域名和扩展名的服务器数组
受保护的$ servers = array(
"com.tr" => "whois.nic.tr",
"gen.tr" => "whois.nic.tr",
"web.tr" => "whois.nic.tr",
"k12.tr" => "whois.nic.tr",
"org.tr" => "whois.nic.tr"
);
我需要获取whois信息,所以我编写了此函数
function whois($domain,$ext)
{
$server=$this->servers[$ext];
$domain=$domain.".".$ext;
if (function_exists('curl_version')) {
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $server);
curl_setopt($curl, CURLOPT_PORT, 43);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 5);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $domain."\r\n");
$result = curl_exec($curl);
curl_close($curl);
echo '<pre>';
echo print_r($result);
echo '</pre>';
} else {
trigger_error('cURL is not found!');
exit();
}
}
我正在使用这种方式 whois(“ google”,“ com”);
此功能适用于google.com,它为我提供了正确的域信息,但是当我执行google.org.tr时,(这是很有趣的一部分)有时会重新调整
No match found for "google.org.tr"(whis is expected)
and somethimes return "1"
@update
curl_setopt($curl, CURLOPT_URL, $server);
curl_setopt($curl, CURLOPT_URL, "telnet://whois.web.tr:43");
curl_setopt($curl, CURLOPT_PORT, 43);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $domain."\r\n");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($curl, CURLOPT_NOPROGRESS, TRUE);
curl_setopt($curl, CURLOPT_PROTOCOLS, CURLPROTO_TELNET);