每位程序员和开发者都喜欢讨论他们最爱的代码片段,尤其是当PHP开发者花费数个小时为网页编码或创建应用时,他们更知道这些代码的重要性。为了节约编码时间,笔者收集了一些较为实用的代码片段,帮助开发者提高工作效率。>>>
1)Whois query using PHP ——利用PHP获取Whois请求利用这段代码,在特定的域名里可获得whois信息。把域名名称作为参数,并显示所有域名的相关信息。
?123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 | function whois_query( $domain ) {
// fix the domain name:
$domain = strtolower (trim( $domain ));
$domain = PReg_replace( '/^http:\/\//i' , '' , $domain );
$domain = preg_replace( '/^www\./i' , '' , $domain );
$domain = explode ( '/' , $domain );
$domain = trim( $domain [0]);
// split the TLD from domain name
$_domain = explode ( '.' , $domain );
$lst = count ( $_domain )-1;
$ext = $_domain [ $lst ];
// You find resources and lists
// like these on wikipedia:
//
// <a href="http://de.wikipedia.org/wiki/Whois">http://de.wikipedia.org/wiki/Whois</a>
//
$servers = array (
"biz" => "whois.neulevel.biz" ,
"com" => "whois.internic.net" ,
"us" => "whois.nic.us" ,
"coop" => "whois.nic.coop" ,
"info" => "whois.nic.info" ,
"name" => "whois.nic.name" ,
"net" => "whois.internic.net" ,
"gov" => "whois.nic.gov" ,
"edu" => "whois.internic.net" ,
"mil" => "rs.internic.net" ,
"int" => "whois.iana.org" ,
"ac" => "whois.nic.ac" ,
"ae" => "whois.uaenic.ae" ,
"at" => "whois.ripe.net" ,
"au" => "whois.aunic.net" ,
"be" => "whois.dns.be" ,
"bg" => "whois.ripe.net" ,
"br" => "whois.registro.br" ,
"bz" => "whois.belizenic.bz" ,
"ca" => "whois.cira.ca" ,
"cc" => "whois.nic.cc" ,
"ch" => "whois.nic.ch" ,
"cl" => "whois.nic.cl" ,
"cn"
|