Here's one I've written một lúc trước bằng cách sử dụng một mẹo đơn giản (không liệt kê tất cả các máy chủ whois). Tôi chuyển đổi nó từ Perl, và nó cũng trong C# và một đối tượng COM quá.
Nó không thực hiện tất cả tra cứu whois vì một số đăng ký tên miền tham lam * &! $ Và muốn bạn thanh toán cho tra cứu hoặc giữ riêng tư. Có chi tiết về nó trên trang.
Cập nhật
Đây là mã để bạn tải xuống. Tôi đã viết nó sử dụng PHP 3.x vì vậy một số massage cho PHP5 thể là cần thiết:
class Whois
{
/*
* Optional parameter for the server to be used for the lookup.
* If this is not set, an appropriate whois server for the domain name
* specified is automagically found by the Whois class.
* @type string
* @access public
*/
var $whois_server;
/*
* The timeout, in seconds, for the lookup. Default is 30.
* @type integer
* @access public
*/
var $timeout = 30;
/*
* Returns a string, with new-lines (\n) converted to non-breaking spaces (<BR>),
* with details for the domain specified by $domain.
* @access public
* @param string $domain the domain to lookup, excluding http:// and www
* @return string the results of the whois
*/
function lookup($domain)
{
$result = "";
$parts = array();
$host = "";
// .tv don't allow access to their whois
if (strstr($domain,".tv"))
{
$result = "'.tv' domain names require you to have an account to do whois searches.";
// New domains fix (half work, half don't)
} elseif (strstr($domain,".name") || strstr($domain,".pro") >0){
$result = ".name,.pro require you to have an account to do whois searches.";
} else{
if (empty($this->whois_server))
{
$parts = explode(".",$domain);
$testhost = $parts[sizeof($parts)-1];
$whoisserver = $testhost . ".whois-servers.net";
$this->host = gethostbyname($whoisserver);
$this->host = gethostbyaddr($this->host);
if ($this->host == $testhost)
{
$this->host = "whois.internic.net";
}
flush();
}
$whoisSocket = fsockopen($this->host,43, $errno, $errstr, $this->timeout);
if ($whoisSocket)
{
fputs($whoisSocket, $domain."\015\012");
while (!feof($whoisSocket))
{
$result .= fgets($whoisSocket,128) . "<br>";
}
fclose($whoisSocket);
}
}
return $result;
}
}
sử dụng Ví dụ
$whois = new Whois();
echo "<B>compaq.it</B><BR>";
echo $whois->lookup("compaq.it");
echo "<HR>";
Nguồn
2009-02-17 10:19:17
Chủ sở hữu trang web đã xóa 'lớp'. –
Cập nhật nó để bao gồm một lớp mới hơn. – Sam152
http://www.nott.org/uploads/whois.class.php.txt là 404 –