複製程式碼 程式碼如下:
class SearchDomain
{
var $domain="";
function SetDomain($udomain)
this
{
udomain;
}
//
// 取得whois並分析網域狀態
// ok 未註冊
// 🎜> //
function GetInfo()
{
/*
$dinfo = trim($this->GetWhois());
"";
if(eregi("no match",$dinfo)) return "ok";
//return $rs;
*/
$wl = ";
*/
$wl = "; $w_server = $this->GetServer();
if($w_server=="") return "";
$fp = fsockopen($w_server, 43,1$errno,fp = fsock 🎜> if(!$fp)
{
echo $errstr;
return "";
}
$out = $this->domain."rn"; out .= "Connection: Closernrn";
fputs($fp, $out);
while (!feof($fp))
{
$5 ;
if(eregi("no match",$wl))
{
fclose($fp);
return "ok";
}
return "ok";
}
Expiration Date",$wl))
{
$lines = split(":",$wl);
$t = trim($lines[1]);
$t = trim($lines[1]);
$ts (" ",$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);
}
fclose($fp);
}
fclose($fp);
} > //
//取得網域的整個whois資訊
//
function GetWhois()
{
=$h ();
if($w_server=="") return "";
$fp = fsockopen($w_server, 43, $errno, $errstr, 30);
(!$fpfpp.
{
echo $errstr;
return "";
}
$out = $this->doman"rn } ;
fputs($fp, $out);
while (!feof($fp))
{
$wh .= nl2br(fgets($fp, >🎜); }
fclose($fp);
return $wh;
}
//
//輸出目前網域的狀態資訊
//
//輸出目前網域的狀態資訊
//
PrintSftion 🎜> {
$rs = $this->GetInfo();
if($rs=="ok") echo $this->domain." 未註冊!
rn"; else if($rs=="") echo "無法查詢 ".$this->domain." 狀態!
rn";
else echo $this->domain." 已註冊,回覆時間:$rs
rn";
}
//
//取得whoisis查詢伺服器
//
函數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";
case "nfo":
$w_server="whois.afilias.info"; "biz":
$w_server="whois.biz";
case ".cc":
$w_server="whois.nic.cc";
case "edu"; : case "edu"; :
$w_server="whois.educause.net";
break;
case "gov":
$w_server="whois.nic.gov";
; case ".cn":
$w_server="whois.cnnic.net.cn";
預設值:
$w_server="
}
回傳$ w_server;
}
> //英文月份轉為數字
//
function MonthToNum($m)
{
$m = strtolower($m );
for($i=1;$i {
$tt = mktime(0,0,0,$i 1,0,2005); > if($m==strtolower(strftime("%b", $tt)))
{
if($i>9) return $i-1;
否則回傳 "0".$i-1;
}
}
}
}
$sd = new SearchDomain();
$sd->SetDomain("job-sky.com");
///main("job-sky.com");已註冊,等價於 $sd->PrintSta();
$rs = $sd->GetInfo();
if($rs=="ok") echo $sd->domain." 未註冊!
rn";
else if($rs=="") echo "無法查詢 ".$sd->domain." 狀態!
rn";
else echo $sd->domain." 已註冊,對抗時間:$rs
>rn";
//取得網域的詳細whois資訊
//echo $sd->GetWhois();
?
http://www.bkjia.com/PHPjc/317052.html
www.bkjia.com
true
http: //www.bkjia.com/PHPjc/317052.html
TechArticle
複製程式碼如下: ?類別搜尋網域{ var$domain=""; functionSetDomain($udomain) { $ this-domain=$udomain; } } // //取得whois並分析網域狀態//ok進行註冊//非空...