网络营销电子商务研究中心  
How to buy the best prescription safety glasses in Canada? Let's study!
Go Back   网络营销电子商务研究中心 > 网站建设 > 代码交流
User Name
Password
 
FAQ Members List Calendar Cheap Glasses

代码交流 ASP,PHP,JSP等网站源代码下载与交流。

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1   IP: 61.139.126.97
Old 2006-10-15, 05:36 AM
topvip topvip is offline
超级版主
 
Join Date: 2006-01-04
Posts: 1206
topvip 正向着好的方向发展
Default Php实现域名查询源代码

直接从服务器读取信息
<?php
#域名及IP地址查询工具
set_time_limit(0);
#取得传递来的参数,并查询

get();

function whois($name='',$domain='.com'){

if(!$name){return false;}

$ns=array( "CNNIC" =>"whois.cnnic.net.cn",
"INTERNIC" =>"rs.internic.net"
);

$server='';
switch (strtolower(trim($domain))){
#.com
case '.com' :$server=$ns['INTERNIC']; break;
#.net
case '.net' :$server=$ns['INTERNIC']; break;
#.org
case '.org' :$server=$ns['INTERNIC']; break;
#.biz
case '.biz' :$server=$ns['INTERNIC']; break;
#.info
case '.info' :$server=$ns['INTERNIC']; break;
#.cc
case '.cc' :$server=$ns['INTERNIC']; break;
#.cn
case '.cn' :$server=$ns['CNNIC']; break;
#.com.cn
case '.com.cn' :$server=$ns['CNNIC']; break;
#.gov.cn
case '.gov.cn' :$server=$ns['CNNIC']; break;
#.net.cn
case '.net.cn' :$server=$ns['CNNIC']; break;
}#判断结束

return query($name.$domain,$server);
}

function query($domain,$server){
if(!$domain){return false;}
$showmore=$_POST['more'];
$a=array();
$response='';
$fp=@fsockopen($server,43,&$a['err_num'],&$a['err_msg'],10);
if($fp){
#set_socket_blocking($fp,false);
fputs($fp,"$domain\r\n");
while(!feof($fp)) {
$buf= @fgets($fp,1024);
if(ereg( "Name Server:", $buf)){
$a['Server'].="·".trim(str_replace("Name Server: ","",$buf));
}
if(ereg("Expiration Date:",$buf)){
$a['EndDate']=trim(str_replace("Expiration Date: ","",$buf));
}
if(ereg("Whois Server:",$buf)){
$a['Whois']=trim(str_replace("Whois Server:","",$buf));
}
if(eregi("no matching record",$buf)){
$buf=eregi_replace("no matching record","没有发现记录,可以注册!",$buf);
}
if(eregi("Sorry, the Whois database is currently down.",$buf)){
$buf=eregi_replace("Sorry, the Whois database is currently down.","域名服务器重启,请稍等再查询!",$buf);
}
$a['More'].=$buf;
}
fclose($fp);
if($showmore&&$a['Whois']){
$fp=@fsockopen($a['Whois'],43,&$a['err_num'],&$a['err_msg'],10);
if($fp){
fputs($fp, "$domain\r\n");
while(!feof($fp)) {
$buf.=fgets($fp,10240);
}
$a['More']=$buf;
}
@fclose($fp);
}
$a['domain']=$domain;
$a['More']="<pre>".$a['More']."</pre>";
if((!empty($a['Server']))||(!empty($a['EndDate']))){
$a['Result']="该域名已被注册";
}else{
$d=substr($domain,0,strpos($domain,"."));
$s=strstr($domain,".");
$a['Result']="<a href=\"/buy.php?kindof=domain&value=".$a['domain']."\" title=\"注册该域名\"><font color=red>可以注册,立即注册</a></a>";
}
}

return $a;
}


function get(){

$domain=$_POST['domain'];
if(!$domain){$domain=$_GET['domain'];}
if(empty($domain)){return false;}
$a=$_POST['suffix'];
if((!is_array($a))&&(!$a)){$a=array($_GET['suffix']);}
$more=$_POST['more'];
if(!$more){$_GET['more'];}
$str.="<style type=\"text/css\"> .tb { font-size: 12px; border: 1px solid #CCCCCC; } </style>\r\n";
$str.="<table width=\"100%\" cellpadding=\"3\" cellspacing=\"1\" class=\"tb\"> \n\t";
$str.="<tr align=\"center\" bgcolor=\"#FFCC66\" nowrap > \n\t";
$str.="<td height=\"22\" nowrap>查询域名</td> \n\t";
$str.="<td height=\"22\" nowrap>能否注册</td> \n\t";
$str.="<td height=\"22\" nowrap>域名服务器地址</td> \n\t";
$str.="<td height=\"22\" nowrap>到期时间</td> \n\t";
$str.="</tr> \n\t";
$str.="<tr title=\"点击域名查看更详细信息\"> \n\t";
while(list(,$val)=@each($a)){
$b=whois($domain,$val,$more);
$str.="<td bgcolor=\"#efefef\" style=\"cursor:hand\" onclick=\"javascript:if(document.getElementById('$val$key').style.display=='none'){document.getElementById('$val$key').style.display='block';}else{document.getElementById('$val$key').style.display='none';}\">".$b['domain']."</td> \n\t";
$str.="<td bgcolor=\"#efefef\">".$b['Result']."</td> \n\t";
$str.="<td bgcolor=\"#efefef\">".$b['Server']."</td> \n\t";
$str.="<td bgcolor=\"#efefef\">".$b['EndDate']."</td> \n\t";
$str.="</tr> \n\t";
$str.="<tr style=\"display:none;cursor:text;background-color: #efeffa;\" id=\"$val$key\"> \n\t";
$str.="<td colspan=\"4\" bgcolor=\"#efefef\" >".$b['More']."</td> \n\t";
$str.="</tr>";
}
$str.="</table>\n\t";
echo($str);

unset($a);unset($b);
unset($domain);
unset($str);

}


#<FORM ACTION="" METHOD="post">
#主机名: <INPUT TYPE="text" NAME="domain" SIZE="30" MAXLENGTH="100" value=sohu>
#<INPUT TYPE="hidden" name="more" value="true">
#<INPUT TYPE=submit VALUE="查询">
#</FORM>
?>
Reply With Quote
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is On
HTML code is Off

Forum Jump

Prescription-glasses.com offers prescription glasses online at discount prices.
All times are GMT +8. The time now is 11:08 AM.


Powered by vBulletin Version 3.8.7
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.