PHP whois查询类定义与用法示例
本文实例讲述了PHP whois查询类定义与用法。分享给大家供大家参考,具体如下
whois.class.php
<?php class Whois{ private $WHOIS_SERVERS = array( "" => array("whois.verisign-grs.","whois.crsnic."), "" => array("whois.verisign-grs.","whois.crsnic."), "" => array("whois.pir.","whois.publicinterestregistry."), "info" => array("whois.afilias.info","whois.afilias."), "" => array("whois.neulevel."), "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"), "" => array("whois.nic."), "eu" => array("whois.eu"), "nu" => array("whois.nic.nu"), "au" => array("whois.aunic.","whois.ausregistry..au"), "de" => array("whois.denic.de"), "ws" => array("whois.worldsite.ws","whois.nic.ws",".nic.ws"), "sc" => array("whois2.afilias-grs."), "mobi" => array("whois.dotmobiregistry."), "pro" => array("whois.registrypro.pro","whois.registry.pro"), "edu" => array("whois.educause.","whois.crsnic."), "tv" => array("whois.nic.tv","tvwhois.verisign-grs."), "travel" => array("whois.nic.travel"), "name" => array("whois.nic.name"), "in" => array("whois.inregistry.","whois.registry.in"), "me" => array("whois.nic.me","whois.meregistry."), "at" => array("whois.nic.at"), "be" => array("whois.dns.be"), "" => array("whois.nic.","whois.nic.."), "asia" => array("whois.nic.asia"), "ru" => array("whois.ripn.ru","whois.ripn."), "ro" => array("whois.rotld.ro"), "aero" => array("whois.aero"), "fr" => array("whois.nic.fr"), "se" => array("whois.iis.se","whois.nic-se.se","whois.nic.se"), "nl" => array("whois.sidn.nl","whois.domain-registry.nl"), "nz" => array("whois.srs..nz","whois.domainz..nz"), "mx" => array("whois.nic.mx"), "tw" => array("whois.apnic.","whois.twnic..tw"), "ch" => array("whois.nic.ch"), "hk" => array("whois.hknic..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."), "am" => array("whois.amnic."), "as" => array("whois.nic.as"), "az" => array("whois.ripe."), "ba" => array("whois.ripe."), "bg" => array("whois.register.bg"), "bi" => array("whois.nic.bi"), "bj" => array(".nic.bj"), "br" => array("whois.nic.br"), "bt" => array("whois.names."), "by" => array("whois.ripe."), "bz" => array("whois.belizenic.bz"), "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."), "cz" => array("whois.nic.cz"), "dk" => array("whois.dk-hostmaster.dk"), "dm" => array("whois.nic.cx"), "dz" => array("whois.ripe."), "ee" => array("whois.ee.ee"), "eg" => array("whois.ripe."), "es" => array("whois.ripe."), "fi" => array("whois.ficora.fi"), "fo" => array("whois.ripe."), "gb" => array("whois.ripe."), "ge" => array("whois.ripe."), "gl" => array("whois.ripe."), "gm" => array("whois.ripe."), "gov" => array("whois.nic.gov"), "gr" => array("whois.ripe."), "gs" => array("whois.adamsnames.tc"), "hm" => array("whois.registry.hm"), "hn" => array("whois2.afilias-grs."), "hr" => array("whois.ripe."), "hu" => array("whois.ripe."), "il" => array("whois.isoc..il"), "int" => array("whois.isi.edu"), "iq" => array("vrx."), "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."), "lt" => array("whois.domreg.lt"), "lu" => array("whois.restena.lu"), "lv" => array("whois.nic.lv"), "ly" => array("whois.lydomains."), "ma" => array("whois.iam..ma"), "mc" => array("whois.ripe."), "md" => array("whois.nic.md"), "mil" => array("whois.nic.mil"), "mk" => array("whois.ripe."), "ms" => array("whois.nic.ms"), "mt" => array("whois.ripe."), "mu" => array("whois.nic.mu"), "my" => array("whois.mynic..my"), "nf" => array("whois.nic.cx"), "pl" => array("whois.dns.pl"), "pr" => array("whois.nic.pr"), "pt" => array("whois.dns.pt"), "sa" => array("saudinic..sa"), "sb" => array("whois.nic..sb"), "sg" => array("whois.nic..sg"), "sh" => array("whois.nic.sh"), "si" => array("whois.arnes.si"), "sk" => array("whois.sk-nic.sk"), "sm" => array("whois.ripe."), "st" => array("whois.nic.st"), "su" => array("whois.ripn."), "tc" => array("whois.adamsnames.tc"), "tf" => array("whois.nic.tf"), "th" => array("whois.thnic."), "tj" => array("whois.nic.tj"), "tk" => array("whois.nic.tk"), "tl" => array("whois.domains.tl"), "tm" => array("whois.nic.tm"), "tn" => array("whois.ripe."), "to" => array("whois.tonic.to"), "tp" => array("whois.domains.tl"), "tr" => array("whois.nic.tr"), "ua" => array("whois.ripe."), "uy" => array("nic.uy"), "uz" => array("whois.tld.uz"), "va" => array("whois.ripe."), "vc" => array("whois2.afilias-grs."), "ve" => array("whois.nic.ve"), "vg" => array("whois.adamsnames.tc"), "yu" => array("whois.ripe.") ); public function whoislookup($domain) { $domain = trim($domain); //remove space from start and end of domain if(substr(strtolower($domain), 0, 7) == "http://") $domain = substr($domain, 7); // remove http:// if included if(substr(strtolower($domain), 0, 4) == ".") $domain = substr($domain, 4);//remove from domain if(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.laic.",$domain); elseif(preg_match("/^([-a-z0-9]{2,100})\.([a-z\.]{2,8})$/i",$domain)) { $domain_parts = explode(".", $domain); $tld = strtolower(array_pop($domain_parts)); $server = $this->WHOIS_SERVERS[$tld][0]; if(!$server) { return "Error: No appropriate Whois server found for $domain domain!"; } $res=$this->queryWhois($server,$domain); while(preg_match_all("/Whois Server: (.)/", $res, $matches)) { $server=array_pop($matches[1]); $res=$this->queryWhois($server,$domain); } return $res; } else return "Invalid Input"; } private function queryWhois($server,$domain) { $fp = @fsockopen($server, 43, $errno, $errstr, 20) or die("Socket Error " . $errno . " - " . $errstr); if($server=="whois.verisign-grs.") $domain="=".$domain; fputs($fp, $domain . "\r\n"); $out = ""; while(!feof($fp)){ $out .= fgets($fp); } fclose($fp); return $out; } } ?>
调用的方式
<?php require("whois.class.php"); $whois=new Whois; echo $whois->whoislookup(".jb51."); ?>
运行结果
Domain Name: JB51.NET Registry Domain ID: 527217184_DOMAIN_NET-VRSN Registrar WHOIS Server: whois.godaddy. Registrar URL: http://.godaddy. Updated Date: 2016-05-26T08:17:44Z Creation Date: 2006-07-22T03:11:39Z Registry Expiry Date: 2024-07-22T03:11:39Z Registrar: GoDaddy., LLC Registrar IANA ID: 146 Registrar Abuse Contact Email: abuse@godaddy. Registrar Abuse Contact Phone: 480-624-2505 Domain Status: clientDeleteProhibited https://icann./epp#clientDeleteProhibited Domain Status: clientRenewProhibited https://icann./epp#clientRenewProhibited Domain Status: clientTransferProhibited https://icann./epp#clientTransferProhibited Domain Status: clientUpdateProhibited https://icann./epp#clientUpdateProhibited Name Server: NS1.DNSV2.COM Name Server: NS2.DNSV2.COM DNSSEC: unsigned URL of the ICANN Whois Inauracy Complaint Form: https://.icann./wicf/ >>> Last update of whois database: 2019-04-03T03:32:17Z <<< For more information on Whois status codes, please visit https://icann./epp 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 set to expire. This date does not necessarily reflect the expiration date of the domain name registrant's agreement with the sponsoring registrar. Users may consult the sponsoring registrar's Whois database to view the registrar's reported date of expiration for this registration. TERMS OF USE: You are not authorized to aess or query our Whois database through the use of electronic processes that are high-volume and automated except as reasonably necessary to register domain names or modify existing registrations; the Data in VeriSign Global Registry Services' ("VeriSign") Whois database is provided by VeriSign for information purposes only, and to assist persons in obtaining information about or related to a domain name registration record. VeriSign does not guarantee its auracy. By submitting a Whois query, you agree to abide by the following terms of use: You agree that you may use this Data only for lawful purposes and that under no circumstances will you use this Data to: (1) allow, enable, or otherwise support the transmission of mass unsolicited, mercial advertising or solicitations via e-mail, telephone, or facsimile; or (2) enable high volume, automated, electronic processes that apply to VeriSign (or its puter systems). The pilation, repackaging, dissemination or other use of this Data is expressly prohibited without the prior written consent of VeriSign. You agree not to use electronic processes that are automated and high-volume to aess or query the Whois database except as reasonably necessary to register domain names or modify existing registrations. VeriSign reserves the right to restrict your aess to the Whois database in its sole discretion to ensure operational stability. VeriSign may restrict or terminate your aess to the Whois database for failure to abide by these terms of use. VeriSign reserves the right to modify these terms at any time. The Registry database contains ONLY .COM, .NET, .EDU domains and Registrars.
更多关于PHP相关内容感兴趣的读者可查看本站专题《》、《》、《》、《》、《》、《》、《》及《》
希望本文所述对大家PHP程序设计有所帮助。
编程语言
- 宿迁百度关键词排名指南:实现精准营销的关键
- 四川SEO优化怎么做网络推广
- 立昂技术备案老域名收购:如何为您的业务赋能
- 安徽百度关键词seo贵不贵,一般需要多少钱
- 吉林百度快照排名怎么做电话营销
- 多伦新手做SEO怎么做
- 甘肃优化关键词排名推广怎么做论坛营销
- 沙雅SEO网站推广:提升您的在线可见性
- 四川SEO优化如何提升销售额和销售量
- 聂荣网站排名优化:提升网站可见性的全方位指
- 涞水SEO:提升地方企业在线可见性的策略
- 辽宁百度seo排名怎样做网站排名
- 临湘哪有关键词排名优化:提升网站可见度的关
- 黑龙江百度网站优化有没有优惠
- 凉城优化关键词排名推广:提升您的网络可见性
- 萝北整站优化:提升您网站流量和排名的全面指