whois.php<?php
Class Whois
{
var $whois_server;
var $timeout = 30;
function lookup($domain)
{
$result = "";
$host = "";
// .tv don't allow access to their whois
{
$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)) {
$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";
}
}
$whoisSocket = fsockopen($this->host,43
, $errno, $errstr, $this->timeout);
if ($whoisSocket)
{
fputs($whoisSocket, $domain."\015\012"); while (!feof($whoisSocket)) {
$result .= fgets($whoisSocket,128) . "<br>"; }
}
}
return $result;
}
}
?>
check.php<?php
include("whois.php");
$val = "example.com";
$who = new Whois;
$adres = "www." . $val;
$IP = @gethostbyname($adres);
$hostname = @gethostbyaddr($IP);
$Validiate = @checkdnsrr($hostname, "A");
if ($Validiate == FALSE) {
if (eregi("No information about domain", $who->lookup(str_replace("www.", "", $adres)))) { echo "Domena jest wolna"; }
else { $Validiate = TRUE; }
}
if ($Validiate == TRUE) {
}
?>
Aby odciążyć serwer najpierw sprawdzam checkdnsrr jeśli zwraca mi False wtedy łączę się z serwerem Whois... Działa. Tylko troche wolno :/ pozdrawiam.