Updated to do a 'whois-servers.net' DNS lookup to determine which tld whois server to query.
This commit is contained in:
parent
447cf125a8
commit
fbaa650262
|
@ -1,3 +1,7 @@
|
|||
2003/02/09 Ross Golder <ross@golder.org>
|
||||
- updated to do a 'whois-servers.net' DNS lookup to determine
|
||||
the tld whois server to query
|
||||
|
||||
2003/01/29 David Saez <david@ols.es>
|
||||
- fixed nicse.whois and updated to common object model
|
||||
|
||||
|
|
59
main.whois
59
main.whois
|
@ -31,7 +31,7 @@ class Whois {
|
|||
var $VERSION;
|
||||
|
||||
// This release of the package
|
||||
var $CODE_VERSION = "3.0.1";
|
||||
var $CODE_VERSION = "3.0.4";
|
||||
|
||||
// Network Solutions registry server
|
||||
var $NSI_REGISTRY = "whois.nsiregistry.net";
|
||||
|
@ -104,19 +104,35 @@ class Whois {
|
|||
}
|
||||
|
||||
// Set domain to query in query array
|
||||
$this->Query["string"] = strtolower($query);
|
||||
$this->Query["string"] = $domain = strtolower($query);
|
||||
|
||||
// Determine top level whois server
|
||||
$tld = $this->GetTld($this->Query["string"]);
|
||||
if($tld) {
|
||||
// Determine the top level domain, and it's whois server using
|
||||
// DNS lookups on 'whois-servers.net'.
|
||||
// Assumes a valid DNS response indicates a recognised tld (!?)
|
||||
$tld = "";
|
||||
$server = "";
|
||||
$dp = explode(".", $domain);
|
||||
$np = count($dp);
|
||||
$tldtests = array(
|
||||
//$dp[$np-3].".".$dp[$np-2].".".$dp[$np-1],
|
||||
$dp[$np-2].".".$dp[$np-1],
|
||||
$dp[$np-1]);
|
||||
foreach($tldtests as $tld) {
|
||||
$cname = checkdnsrr($tld.".whois-servers.net", "CNAME");
|
||||
if(!$cname) continue;
|
||||
$server = gethostbyname($tld.".whois-servers.net");
|
||||
break;
|
||||
}
|
||||
|
||||
if($tld && $server) {
|
||||
// If found, set tld and whois server in query array
|
||||
$this->Query["server"] = $this->DATA[$tld][0];
|
||||
$this->Query["server"] = $server;
|
||||
$this->Query["tld"] = $tld;
|
||||
|
||||
// If a handler exists for the tld
|
||||
if(isSet($this->DATA[$tld][1])) {
|
||||
if(isSet($this->DATA[$tld])) {
|
||||
// Set fle/handler in query array
|
||||
$handler = $this->DATA[$tld][1];
|
||||
$handler = $this->DATA[$tld];
|
||||
$this->Query["file"] = sprintf("%s.whois", $handler);
|
||||
$this->Query["handler"] = $handler;
|
||||
}
|
||||
|
@ -279,36 +295,11 @@ class Whois {
|
|||
$result['rawdata'] = $output;
|
||||
|
||||
// If we have a handler, post-process it with that
|
||||
if(isSet($this->DATA[$this->Query["tld"]][1]))
|
||||
if(isSet($this->DATA[$this->Query["tld"]]))
|
||||
$result = $this->Process($result);
|
||||
|
||||
return($result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Determine top-level whois server for a given domain
|
||||
*/
|
||||
function GetTld ($domain) {
|
||||
// Loop through server/tld list
|
||||
reset($this->DATA);
|
||||
$curr_match = "";
|
||||
while(list($tld, $param) = each($this->DATA)) {
|
||||
// If the tld matches the end of the given domain
|
||||
if(eregi("\.$tld$", $domain)) {
|
||||
// If we have already found a match
|
||||
if(!empty($curr_match)) {
|
||||
// FIXME: we assume we'll never support a 3rd
|
||||
// level registry. If we do, this breaks.
|
||||
$curr_match = strchr($tld,".") ? $tld : $curr_match;
|
||||
}
|
||||
else
|
||||
$curr_match = $tld;
|
||||
}
|
||||
}
|
||||
|
||||
return($curr_match);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
133
servers.whois
133
servers.whois
|
@ -26,121 +26,30 @@
|
|||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* servers.whois v17 ross golder 2003/02/09 */
|
||||
/* servers.whois v16 mark jeftovic 2001/02/28 */
|
||||
|
||||
$this->DATA_VERSION = "16";
|
||||
$this->DATA_VERSION = "17";
|
||||
$this->DATA = array(
|
||||
"ac"=>array("whois.nic.ac"),
|
||||
"al"=>array("whois.ripe.net"),
|
||||
"am"=>array("whois.amnic.net"),
|
||||
"as"=>array("whois.nic.as"),
|
||||
"at"=>array("whois.nic.at","atnic"),
|
||||
"au"=>array("whois.aunic.net","aunic"),
|
||||
"az"=>array("whois.ripe.net"),
|
||||
"ba"=>array("whois.ripe.net"),
|
||||
"be"=>array("whois.dns.be"),
|
||||
"biz"=>array("whois.neulevel.biz", "neulevel"),
|
||||
"bg"=>array("whois.ripe.net"),
|
||||
"br"=>array("whois.registro.br", "brnic"),
|
||||
"by"=>array("whois.ripe.net"),
|
||||
"ca"=>array("whois.cira.ca","cira"),
|
||||
"cc"=>array("whois.nic.cc"),
|
||||
"ch"=>array("whois.nic.ch","chnic"),
|
||||
"ck"=>array("whois.ck-nic.org.ck"),
|
||||
"cn"=>array("whois.cnnic.net.cn"),
|
||||
"com"=>array($this->NSI_REGISTRY,"gtld"),
|
||||
"cx"=>array("whois.nic.cx"),
|
||||
"cy"=>array("whois.ripe.net"),
|
||||
"cz"=>array("whois.nic.cz"),
|
||||
"de"=>array("whois.denic.de","denic"),
|
||||
"dk"=>array("whois.dk-hostmaster.dk"),
|
||||
"dz"=>array("whois.ripe.net"),
|
||||
"edu"=>array("rs.internic.net"),
|
||||
"ee"=>array("whois.ripe.net"),
|
||||
"eg"=>array("whois.ripe.net"),
|
||||
// "es"=>array("whois.ripe.net"),
|
||||
"fi"=>array("whois.ripe.net"),
|
||||
"fj"=>array("whois.usp.ac.fj"),
|
||||
"fo"=>array("whois.ripe.net"),
|
||||
"fr"=>array("whois.nic.fr"),
|
||||
"gb"=>array("whois.ripe.net"),
|
||||
"gb.com"=>array("whois.nomination.net"),
|
||||
"gb.net"=>array("whois.nomination.net"),
|
||||
"ge"=>array("whois.ripe.net"),
|
||||
"gov"=>array("whois.nic.gov"),
|
||||
"gr"=>array("whois.ripe.net"),
|
||||
"gs"=>array("whois.adamsnames.tc"),
|
||||
"hk"=>array("whois.hknic.net.hk"),
|
||||
"hm"=>array("whois.registry.hm"),
|
||||
"hr"=>array("whois.ripe.net"),
|
||||
"hu"=>array("whois.ripe.net"),
|
||||
"id"=>array("whois.idnic.net.id"),
|
||||
"ie"=>array("whois.domainregistry.ie"),
|
||||
"info"=>array("whois.afilias.info", "info"),
|
||||
"int"=>array("whois.isi.edu"),
|
||||
"il"=>array("whois.ripe.net"),
|
||||
"is"=>array("whois.isnet.is"),
|
||||
"it"=>array("whois.nic.it"),
|
||||
"jp"=>array("whois.nic.ad.jp"),
|
||||
"ke"=>array("whois.rg.net"),
|
||||
"kg"=>array("whois.domain.kg"),
|
||||
"kr"=>array("whois.nic.or.kr"),
|
||||
"kz"=>array("whois.domain.kz"),
|
||||
"li"=>array("whois.nic.li","chnic"),
|
||||
"lk"=>array("whois.nic.lk"),
|
||||
"lt"=>array("whois.ripe.net"),
|
||||
"lu"=>array("whois.dns.lu","lunic"),
|
||||
"lv"=>array("whois.ripe.net"),
|
||||
"ma"=>array("whois.ripe.net"),
|
||||
"md"=>array("whois.ripe.net"),
|
||||
"mil"=>array("whois.nic.mil"),
|
||||
"mk"=>array("whois.ripe.net"),
|
||||
// "mm"=>array("whois.nic.mm"), // down?
|
||||
"ms"=>array("whois.adamsnames.tc"),
|
||||
"mt"=>array("whois.ripe.net"),
|
||||
"mx"=>array("whois.nic.mx"),
|
||||
"net"=>array($this->NSI_REGISTRY,"gtld"),
|
||||
// "net.au"=>array("whois.net.au","aunic"), // is need ?
|
||||
"nl"=>array("whois.domain-registry.nl","nlnic"),
|
||||
"no"=>array("whois.norid.no"),
|
||||
"no.com"=>array("whois.nomination.net"),
|
||||
"nu"=>array("whois.nic.nu","nunames"),
|
||||
"nz"=>array("whois.domainz.net.nz"),
|
||||
"org"=>array($this->NSI_REGISTRY,"gtld"),
|
||||
"pl"=>array("whois.ripe.net"),
|
||||
// "pk"=>array("whois.pknic.net.pk"), // down ?
|
||||
"pt"=>array("whois.ripe.net"),
|
||||
"ro"=>array("whois.ripe.net"),
|
||||
"ru"=>array("whois.ripn.ru"),
|
||||
"se"=>array("whois.nic-se.se","nicse"),
|
||||
"se.com"=>array("whois.nomination.net"),
|
||||
"se.net"=>array("whois.nomination.net"),
|
||||
"sg"=>array("whois.nic.net.sg"),
|
||||
"si"=>array("whois.ripe.net"),
|
||||
"sh"=>array("whois.nic.sh"),
|
||||
"sk"=>array("whois.ripe.net"),
|
||||
"sm"=>array("whois.ripe.net"),
|
||||
"st"=>array("whois.nic.st"),
|
||||
"su"=>array("whois.ripe.net"),
|
||||
"tc"=>array("whois.adamsnames.tc"),
|
||||
"tf"=>array("whois.adamsnames.tc"),
|
||||
"tj"=>array("whois.nic.tj"),
|
||||
"th"=>array("whois.thnic.net"),
|
||||
// "tm"=>array("whois.nic.tm"), // down?
|
||||
"tn"=>array("whois.ripe.net"),
|
||||
"to"=>array("whois.tonic.to"),
|
||||
"tr"=>array("whois.ripe.net"),
|
||||
"tw"=>array("whois.twnic.net"),
|
||||
"ua"=>array("whois.ripe.net"),
|
||||
"uk"=>array("whois.nic.uk","uknic"),
|
||||
"uk.com"=>array("whois.nomination.net"),
|
||||
"us"=>array("whois.isi.edu"),
|
||||
"va"=>array("whois.ripe.net"),
|
||||
"vg"=>array("whois.adamsnames.tc"),
|
||||
"ws"=>array("whois.nic.ws"),
|
||||
"yu"=>array("whois.ripe.net"),
|
||||
"za"=>array("whois.frd.ac.za"),
|
||||
"ipw"=>array("","ipw") // Dummy, just for ip whois
|
||||
"at"=>"atnic",
|
||||
"au"=>"aunic",
|
||||
"biz"=>"neulevel",
|
||||
"br"=>"brnic",
|
||||
"ca"=>"cira",
|
||||
"ch"=>"chnic",
|
||||
"com"=>"gtld",
|
||||
"de"=>"denic",
|
||||
"info"=>"info",
|
||||
"li"=>"chnic",
|
||||
"lu"=>"lunic",
|
||||
"net"=>"gtld",
|
||||
"nl"=>"nlnic",
|
||||
"nu"=>"nunames",
|
||||
"org"=>"gtld",
|
||||
"se"=>"nicse",
|
||||
"uk"=>"uknic",
|
||||
"ipw"=>"ipw" // Dummy, just for ip whois
|
||||
);
|
||||
|
||||
?>
|
||||
|
||||
|
|
Loading…
Reference in a new issue