本文实例讲述了php whois查询类定义与用法。分享给大家供大家参考,具体如下:
whois.class.php
<?phpclass whois{private $whois_rvers = array("com" => array("whois.verisign-grs.com","whois.crsnic.net"),"net" => array("whois.verisign-grs.com","whois.crsnic.net"),"org" => array("whois科技作文500字.pir.org","whois.publicinterestregistry.net"),"info" => array("whois.afilias.info","whois.afilias.net"),"biz" => array("whois.neulevel.biz"),"us" => array("whois.nic.us"),"uk" => array("whois.nic.uk"),"ca" => array("whois.cira.ca"),"tel" => array("whois.nic.tel"),"ie" => array("whois.iedr.ie","whois.domainregistry.ie"),"it" => array("whois.nic.it"),"li" => array("whois.nic.li"),"no" => array("whois.norid.no"),"cc" => array("whois.nic.cc"),"eu" => array("whois.eu"),"nu" => array("whois.nic.nu"),"au" => array("whois.aunic.net","whois.ausregistry.net.au"),"de" => array("whois.denic.de"),"ws" => array("whois.worldsite.ws","whois.nic.ws","www.nic.ws"),"sc" => array("whois2.afilias-grs.net"),"mobi" => array("whois.dotmobiregistry.net"),"pro" => array("whois.registrypro.pro","whois.registry.pro"),"edu" => array("whois.educau.net","whois.crsnic.net"),"tv" => array("whois.nic.tv","tvwhois.verisign-grs.com"),"travel" => array("whois.nic.travel"),"name" => array("whois.nic.name"),"in" => array("whois.inregistry.net","whois.registry.in"),"me" => array("whois.nic.me","whois.meregistry.net"),"at" => array("whois.nic.at"),"be" => array("whois.dns.be"),"cn" => array("whois.cnnic.cn","whois.cnnic.net.cn"),"asia" => array("whois.nic.asia"),"ru" => array("whois.ripn.ru","whois.ripn.net"),"ro" => array("whois.rotld.ro"),"aero" => array("whois.aero"),"fr" => array("whois.nic.fr"),"" => array("whois.iis.","whois.nic-.","whois.nic."),"nl" => array("whois.sidn.nl","whois.domain-registry.nl"),"nz" => array("whois.srs.net.nz","whois.domainz.net.nz"),"mx" => array("whois.nic.mx"),"tw" => array("whois.apnic.net","whois.twnic.net.tw"),"ch" => array("whois.nic.ch"),"hk" => array("whois.hknic.net.hk"),"ac" => array("whois.nic.ac"),"ae" => array("whois.nic.ae"),"af" => array("whois.nic.af"),"ag" => array("whois.nic.ag"),"al" => array("whois.ripe.net"),"am" => array("whois.amnic.net"),"as" => array("whois.nic.as"),"az" => array("whois.ripe.net"),"ba" => array("whois.ripe.net"),"bg" => array("whois.register.bg"),"bi" => array("whois.nic.bi"),"bj" => array("www.nic.bj"),"br" => array("whois.nic.br"),"bt" => array("whois.netnames.net"),"by" => array("whois.ripe.net"),"bz" => array("whois.belizenic.b英语寓言小故事z"),"cd" => array("whois.nic.cd"),"ck" => array("whois.nic.ck"),"cl" => array("nic.cl"),"coop" => array("whois.nic.coop"),"cx" => array("whois.nic.cx"),"cy" => array("whois.ripe.net"),"cz" => array("whois.nic.cz"),"dk" => array("whois.dk-hostmaster.dk"),"dm" => array("whois.nic.cx"),"dz" => array("whois.ripe.net"),"ee" => array("whois.eenet.ee"),"eg" => array("whois.ripe.net"),"es" => array("whois.ripe.net"),"fi" => array("whois.ficora.fi"),"fo" => array("whois.ripe.net"),"gb" => array("whois.ripe.net"),"ge" => array("whois.ripe.net"),"gl" => array("whois.ripe.net"),"gm" => array("whois.ripe.net"),"gov" => array("whois.nic.gov"),"gr" => array("whois.ripe.net"),"gs" => array("whois.adamsnames.tc"),"hm" => array("whois.registry.hm"),"hn" => array("whois2.afilias-grs.net"),"hr" => array("whois.ripe.net"),"hu" => array("whois.ripe.net"),"il" => array("whois.isoc.org.il"),"int" => array("whois.isi.edu"),"iq" => array("vrx.net"),"ir" => array("whois.nic.ir"),"is" => array("whois.isnic.is"),"je" => array("whois.je"),"jp" => array("whois.jprs.jp"),"kg" => array("whois.domain.kg"),"kr" => array("whois.nic.or.kr"),"la" => array("whois2.afilias-grs.net"),"lt" => array("whois.domreg.lt"),"lu" => array("whois.restena.lu"),"lv" => array("whois.nic.lv"),"ly" => array("whois.lydomains.com"),"ma" => array("whois.iam.net.ma清明这首诗"),"mc" => array("whois.ripe.net"),"md" => array("whois.nic.md"),"mil" => array("whois.nic.mil"),"mk" => array("whois.ripe.net"),"ms" => array("whois.nic.ms"),"mt" => array("whois.ripe.net"),"mu" => array("whois.nic.mu"),"my" => array("whois.mynic.net.my"),"nf" => array("whois.nic.cx"),"pl" => array("whois.dns.pl"),"pr" => array("whois.nic.pr"),"pt" => array("whois.dns.pt"),"sa" => array("saudinic.net.sa"),"sb" => array("whois.nic.net.sb"),"sg" => array("wh旋风少女4ois.nic.net.sg"),"sh" => array("whois.nic.sh"),"si" => array("whois.arnes.si"),"sk" => array("whois.sk-nic.sk"),"sm" => array("whois.ripe.net"),"st" => array("whois.nic.st"),"su" => array("whois.ripn.net"),"tc" => array("whois.adamsnames.tc"),"tf" => array("whois.nic.tf"),"th" => array("whois.thnic.net"),"tj" => array("whois.nic.tj"),"tk" => array("whois.nic.tk"),"tl" => array("whois.domains.tl"),"tm" => array("whois.nic.tm"),"tn" => array("whois.ripe.net"),"to" => array("whois.tonic.to"),"tp" => array("whois.domains.tl"),"tr" => array("whois.nic.tr"),"ua" => array("whois.ripe.net"),"uy" => array("nic.uy"),"uz" => array("whois.cctld.uz"),"va" => array("whois.ripe.net"),"vc" => array("whois2.afilias-grs.net"),"ve" => array("whois.nic.ve"),"vg" => array("whois.adamsnames.tc"),"yu" => array("whois.ripe.net"));public function whoislookup($domain){$domain = trim($domain); //remove space from start and end of domainif(substr(strtolower($domain), 0, 7) == "http://") $domain = substr($domain, 7); // remove http:// if includedif(substr(strtolower($domain), 0, 4) == "www.") $domain = substr($domain, 4);//remove www from domainif(preg_match("/^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/",$domain))return $this->querywhois("whois.lacnic.net",$domain);elif(preg_match("/^([-a-z0-9]{2,100})\.([a-z\.]{2,8})$/i",$domain)){$domain_parts = explode(".", $domain);$tld = strtolower(array_pop($domain_parts));$rver = $this->whois_rvers[$tld][0];if(!$rver) {return "error: no appropriate whois rver found for $domain domain!";}$res=$this->querywhois($rver,$domain);while(preg_match_all("/whois rver: (.*)/", $res, $matches)){$rver=array_pop($matches[1]);$res=$this->querywhois($rver,$domain);}return $res;}elreturn "invalid input";}private function querywhois($rver,$domain){$fp = @fsockopen($rver, 43, $errno, $errstr, 20) or die("socket error " . $errno . " - " . $errstr);if($rver=="whois.verisign-grs.com")$domain="=".$domain;fputs($fp, $domain . "\r\n");$out = "";while(!feof($fp)){$out .= fgets($fp);}fclo($fp);return $out;}}?>
调用的方式
<?phprequire("whois.class.php");$whois=new whois;echo $whois->whoislookup("www.jb51.net");?>
运行结果:
domain name: jb51.net registry domain id: 527217184_domain_net-vrsn registrar whois rver: whois.godaddy.com registrar url: http://www.godaddy.com updated date: 2016-05-26t08:17:44z creation date: 2006-07-22t03:11:39z registry expiry date: 2024-07-22t03:11:39z registrar: godaddy.com, llc registrar iana id: 146 registrar abu contact email: abu@godaddy.com registrar abu contact phone: 480-624-2505 domain status: clientdeleteprohibited /d/file/titlepic/epp-status-codes-2014-06-16-en domain status: clientrenewprohibited /d/file/titlepic/epp-status-codes-2014-06-16-en domain status: clienttransferprohibited /d/file/titlepic/epp-status-codes-2014-06-16-en domain status: clientupdateprohibited /d/file/titlepic/epp-status-codes-2014-06-16-en name rver: ns1.dnsv2.com name rver: ns2.dnsv2.com dnsc: unsigned url of the icann whois inaccuracy complaint form: /d/file/titlepic/complaint >>> last update of whois databa: 2019-04-03t03:32:17z <<< for more information on whois status codes, plea visit /d/file/titlepic/epp-status-codes-2014-06-16-en notice: the expiration date displayed in this record is the date the registrar’s sponsorship of the domain name registration in the registry is currently t to expire. this date does not necessarily reflect the expiration date of the domain name registrant’s agreement with the sponsoring registrar. urs may consult the sponsoring registrar’s whois databa to view the registrar’s reported date of expiration for this registration. terms of u: you are not authorized to access or query our whois databa through the u of electronic process that are high-volume and automated except as reasonably necessary to register domain names or modify existing registrations; the data in verisign global registry rvices’ (“verisign”) whois databa is provided by verisign for information purpos only, and to assist persons in obtaining information about or related to a domain name registration record. verisign does not北京冬奥会口号 guarantee its accuracy. by submitting a whois query, you agree to abide by the following terms of u: you agree that you may u this data only for lawful purpos and that under no circumstances will you u this data to: (1) allow, enable, or otherwi support the transmission of mass unsolicited, commercial advertising or solicitations via e-mail, telephone, or facsimile; or (2) enable high volume, automated, electronic process that apply to verisign (or its computer systems). the compilation, repackaging, dismination or other u of this data is expressly prohibited without the prior written connt of verisign. you agree not to u electronic process that are automated and high-volume to access or query the whois databa except as reasonably necessary to register domain names or modify existing registrations. verisign rerves the right to restrict your access to the whois databa in its sole discretion to ensure operational stability. verisign may restrict or terminate your access to the whois databa for failure to abide by the terms of u. verisign rerves the right to modify the terms at any time. the registry databa contains only .com, .net, .edu domains and registrars.
更多关于php相关内容感兴趣的读者可查看本站专题:《php socket用法总结》、《php字符串(string)用法总结》、《php数学运算技巧总结》、《php面向对象程序设计入门教程》、《php数组(array)操作技巧大全》、《php数据结构与算法教程》、《php程序设计算法总结》及《php网络编程技巧总结》
希望本文所述对大家php程序设计有所帮助。
本文发布于:2023-04-07 09:30:42,感谢您对本站的认可!
本文链接:https://www.wtabcd.cn/fanwen/zuowen/247e8a6000ccfcb9dd43c5d27af90eed.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文word下载地址:PHP whois查询类定义与用法示例.doc
本文 PDF 下载地址:PHP whois查询类定义与用法示例.pdf
留言与评论(共有 0 条评论) |