by Web Guru on September 5th, 2008, 6:47 am
The following script will enable you to check the availability of a Domain Name for registeration.
- Code: Select all
<?
error_reporting(E_ALL);
ini_set('display_errors', 1);
ini_set("max_execution_time", 0);
$sDomainName = "GeoSourceCode";
$sExtension = ".com";
if ($sExtension != "" && $sDomainName != "")
{
$sDomainName = str_replace("www.", "", $sDomainName);
$sDomainName = str_replace("http://", "", $sDomainName);
$sDomainName .= $sExtension;
switch($sExtension)
{
case ".com" : $sServer = "whois.internic.net";
break;
case ".net" : $sServer = "whois.internic.net";
break;
case ".org" : $sServer = "whois.publicinterestregistry.net";
break;
case ".info" : $sServer = "whois.afilias.info";
break;
case ".biz" : $sServer = "whois.nic.biz";
break;
case ".name" : $sServer = "whois.nic.name";
break;
}
$hSock = fsockopen($sServer, 43);
$sResult = "";
if (!$hSock)
$sResult = "Could Not Connect to Server.";
else
{
if (!fputs($hSock,"$sDomainName\r\n"))
$sResult = "Unable to send request.";
else
{
$sResultDetails = "";
while(!feof($hSock))
$sResultDetails .= fgets($hSock,128);
$sResultDetails = str_replace("\n", "<br>", $sResultDetails);
if (eregi("No match",$sResultDetails) OR eregi("Not found",$sResultDetails))
print "$sDomainName is available!";
else
{
print "$sDomainName is not available!";
print $sResultDetails;
}
fclose($hSock);
}
}
}
?>