Full-service Internet Marketing & Web Development
Recent Posts

Sponsors
![]() |
WHOIS Function Library v1 0 2Code Wizard, 12-30-2006 |
This suite of functions is comprised of parsing the WHOIS information about a site, and gathering quite a bit of information for your use.
<?php
/*
Version v1.0.2
This WHOIS software fucntion suite is published under
the GNU license terms.
This script (c)2001 Andrew Heebner/EvilWalrus.com
--
Freely distribute, and please, email me if there are
any modifications (better) to the suite. Thanx!
Web: http://evilwalrus.com
Mail: andrew@evilwalrus.com
*/
// standard registrar
$whois = "rs.internic.net";
// WHOIS port
$port = "43";
// timeout for fsockopen() retrieval
$timeout = "10";
//--------------------------------------------------------------------------------
// Structure: void openServer()
// Required Vars: $domain
// Return(s): displays name of registrar at which domain was registered
//--------------------------------------------------------------------------------
function wRegistrar($domain) {
global $whois,$port,$timeout;
$fp = fsockopen($whois, $port, &$errno, &$errstr, $timeout);
if(!$fp) {
echo "$errstr ($errno)<br>
";
} else {
fputs($fp, "$domain
");
while(!feof($fp)) {
$buf = fgets($fp,128);
if(ereg("Whois Server:", $buf)) {
$server = str_replace("Whois Server: ", "", $buf);
$server = trim($server);
}
}
fclose($fp);
}
return $server;
}
//--------------------------------------------------------------------------------
// Structure: void getWhois()
// Required Vars: $domain
// Return(s): opens WHOIS server and returns all Whois information about domain
//--------------------------------------------------------------------------------
function whois($domain) {
global $whois,$port,$timeout;
$serve = wRegistrar($domain);
if($serve) {
$data .= "<B>$domain is registered at $serve:</B><BR>";
$data .= "<PRE>";
$fp = fsockopen($serve, $port, &$errno, &$errstr, $timeout);
if(!$fp) {
$data .= "Could not open connection to $serve on port $port.
";
$data .= "$errstr ($errno)<br>
";
} else {
fputs($fp, "$domain
");
while(!feof($fp)) {
$data .= fgets($fp,128);
}
fclose($fp);
}
$data .= "</PRE><BR>";
} else {
$data .= "<b>$domain does not appear to be registered.</b><BR>";
}
return $data;
}
//--------------------------------------------------------------------------------
// Structure: void wParseCountry()
// Required Vars: $domain
// Return(s): reads a specified domain and returns extension (country code)
//--------------------------------------------------------------------------------
function wParseCountry($domain) {
$ret = "";
if(ereg(".([^.]+)$",$domain,$ext)) {
$ret = strtolower($ext[1]);
}
return $ret;
}
//--------------------------------------------------------------------------------
// Structure: void wAvailable()
// Required Vars: $domain
// Return(s): checks a domain's availability
//--------------------------------------------------------------------------------
function wAvailable($domain) {
global $whois,$port,$timeout;
$avail = wRegistrar($domain);
if($avail) {
$fp = fsockopen($serve, $port, &$errno, &$errstr, $timeout);
if(!fp) {
echo "Could not make a connection to the registrar
";
}
fclose($fp);
} else {
echo "<b>$domain</b> is available!
";
}
}
// example(s)
if(!empty($dom)) {
print whois($dom);
} else {
print "No domain specified";
}
?>
|
|
Subscribe Now to receive new posts via Email as soon as they come out.
Comments
Post your comments

