Copy CodeThe code is as follows:
Class Searchdomain
{
var $domain = "";
function SetDomain ($udomain)
{
$this->domain = $udomain;
}
//
Get whois and analyze domain name status
OK is not registered
Non-null value expiration time
Null value Unknown
//
function GetInfo ()
{
/*
$dinfo = Trim ($this->getwhois ());
if ($dinfo = = "") return "";
if (eregi ("No Match", $dinfo)) return "OK";
return $rs;
*/
$WL = "";
$w _server = $this->getserver ();
if ($w _server== "") return "";
$fp = Fsockopen ($w _server, $errno, $errstr, 30);
if (! $fp)
{
Echo $errstr;
Return "";
}
$out = $this->domain. " \ r \ n ";
$out. = "connection:close\r\n\r\n";
Fputs ($fp, $out);
while (!feof ($FP))
{
$WL = fgets ($fp, 255);
if (eregi ("No Match", $WL))
{
Fclose ($FP);
return "OK";
}
if (eregi ("Expiration Date", $WL))
{
$lines = Split (":", $WL);
$t = Trim ($lines [1]);
$ts = Split ("", $t);
$t = $ts [0];
if (Ereg ("[^0-9-]", $t))
{
$ts = Split ("-", $t);
$t = $ts [2]. " -". $this->monthtonum ($ts [1])." -". $ts [0];
}
Fclose ($FP);
return $t;
}
}
Fclose ($FP);
Return "";
}
//
Get the entire WHOIS information for a domain name
//
function Getwhois ()
{
$WH = "";
$w _server = $this->getserver ();
if ($w _server== "") return "";
$fp = Fsockopen ($w _server, $errno, $errstr, 30);
if (! $fp)
{
Echo $errstr;
Return "";
}
$out = $this->domain. " \ r \ n ";
$out. = "connection:close\r\n\r\n";
Fputs ($fp, $out);
while (!feof ($FP))
{
$wh. = NL2BR (fgets ($fp, 255));
}
Fclose ($FP);
return $WH;
}
//
Outputs status information for the current domain name
//
function Printsta ()
{
$rs = $this->getinfo ();
if ($rs = = "OK") echo $this->domain. "Not registered!
\ r \ n ";
else if ($rs = = "") echo "Cannot query". $this->domain. "State!
\ r \ n ";
else echo $this->domain. "Registered, expiry time: $rs
\ r \ n ";
}
//
Get a WHOIS query server
//
function Getserver ()
{
$udomain =substr ($this->domain,-3);
Switch ($udomain)
{
Case "com":
$w _server= "Whois.internic.net";
Break
Case "NET":
$w _server= "Whois.internic.net";
Break
Case "org":
$w _server= "whois.pir.org";
Break
Case "NFO":
$w _server= "Whois.afilias.info";
Break
Case "Biz":
$w _server= "Whois.biz";
Break
Case ". CC":
$w _server= "whois.nic.cc";
Break
Case "Edu":
$w _server= "Whois.educause.net";
Break
Case "gov":
$w _server= "whois.nic.gov";
Break
Case ". CN":
$w _server= "whois.cnnic.net.cn";
Break
Default
$w _server= "";
}
return $w _server;
}
//
The month of English is converted to digital
//
function Monthtonum ($m)
{
$m = Strtolower ($m);
for ($i =1; $i <=12; $i + +)
{
$tt = Mktime (0,0,0, $i +1,0,2005);
if ($m ==strtolower (strftime ("%b", $tt)))
{
if ($i >9) return $i-1;
else return "0". $i-1;
}
}
}
}
$SD = new Searchdomain ();
$SD->setdomain ("job-sky.com");
Query domain name is registered, equivalent to $SD->printsta ();
$rs = $sd->getinfo ();
if ($rs = = "OK") echo $sd->domain. "Not registered!
\ r \ n ";
else if ($rs = = "") echo "Cannot query". $SD->domain. "State!
\ r \ n ";
else echo $sd->domain. "Registered, expiry time: $rs
\ r \ n ";
Get detailed whois information for a domain name
echo $SD->getwhois ();
?>
http://www.bkjia.com/PHPjc/317052.html www.bkjia.com true http://www.bkjia.com/PHPjc/317052.html techarticle Copy the code as follows:? classsearchdomain {var$domain= ""; Functionsetdomain ($udomain) {$this-domain= $udomain;}////Get Whois and Analysis of domain name status//ok not registered//non-empty ...