From 63277c69c6dcda8238b86a3485fd8631fba9c81b Mon Sep 17 00:00:00 2001 From: sparc Date: Tue, 13 Apr 2010 08:14:47 +0000 Subject: [PATCH] added .ly handler & other fixes --- Changes.md | 3 ++ example.php | 1 - src/whois.gtld.php | 12 ++++--- src/whois.ly.php | 81 +++++++++++++++++++++++++++++++++++++++++++ src/whois.main.php | 4 +-- src/whois.servers.php | 3 +- test.txt | 1 + 7 files changed, 97 insertions(+), 8 deletions(-) create mode 100644 src/whois.ly.php diff --git a/Changes.md b/Changes.md index 34efc2c..a2e441e 100644 --- a/Changes.md +++ b/Changes.md @@ -1,3 +1,6 @@ +2010/04/13 + - added .ly handler + 2009/12/29 - released version 4.2.0 - added handler for .tel diff --git a/example.php b/example.php index d74f488..821c791 100644 --- a/example.php +++ b/example.php @@ -61,7 +61,6 @@ if (isSet($_GET['query'])) // $whois->non_icann = true; $result = $whois->Lookup($query); - $resout = str_replace('{query}', $query, $resout); $winfo = ''; diff --git a/src/whois.gtld.php b/src/whois.gtld.php index eb156f8..442b50c 100755 --- a/src/whois.gtld.php +++ b/src/whois.gtld.php @@ -63,7 +63,7 @@ class gtld_handler extends WhoisClient $this->Query = array(); $this->SUBVERSION = sprintf('%s-%s', $query['handler'], $this->HANDLER_VERSION); $this->result = generic_parser_b($data['rawdata'], $this->REG_FIELDS, 'dmy'); - + unset($this->result['registered']); if (isset($this->result['nodomain'])) @@ -72,11 +72,15 @@ class gtld_handler extends WhoisClient $this->result['regrinfo']['registered'] = 'no'; return $this->result; } - + + if ($this->deep_whois) $this->result = $this->DeepWhois($query,$this->result); + + // Next server could fail to return data + if (count($this->result['rawdata']) < 2) $this->result['rawdata'] = $data['rawdata']; + + // Domain is registered no matter what next server says $this->result['regrinfo']['registered'] = 'yes'; - if ($this->deep_whois) $this->result = $this->DeepWhois($query,$this->result); - return $this->result; } } diff --git a/src/whois.ly.php b/src/whois.ly.php new file mode 100644 index 0000000..8cd1e44 --- /dev/null +++ b/src/whois.ly.php @@ -0,0 +1,81 @@ + For .ly domains */ + +require_once('whois.parser.php'); + +if (!defined('__LY_HANDLER__')) + define('__LY_HANDLER__', 1); + +class ly_handler + { + + function parse($data_str, $query) + { + + $items = array( + 'owner' => 'Registrant:', + 'admin' => 'Administrative Contact:', + 'tech' => 'Technical Contact:', + 'domain.name' => 'Domain Name:', + 'domain.status' => 'Domain Status:', + 'domain.created' => 'Created:', + 'domain.changed' => 'Updated:', + 'domain.expires' => 'Expired:', + 'domain.nserver' => 'Domain servers in listed order:' + ); + + $extra = array( 'zip/postal code:' => 'address.pcode' ); + + $r['regrinfo'] = get_blocks($data_str['rawdata'], $items); + + if (!empty($r['regrinfo']['domain']['name'])) + { + $r['regrinfo'] = get_contacts($r['regrinfo'],$extra); + + $r['regrinfo']['domain']['name'] = $r['regrinfo']['domain']['name'][0]; + + $r['regyinfo'] = array( + 'referrer' => 'http://www.nic.ly', + 'registrar' => 'Libya ccTLD' + ); + + $r['regrinfo']['registered'] = 'yes'; + } + else + { + $r = ''; + $r['regrinfo']['registered'] = 'no'; + } + + return ($r); + } + } +?> + + diff --git a/src/whois.main.php b/src/whois.main.php index d2fc67e..b010113 100755 --- a/src/whois.main.php +++ b/src/whois.main.php @@ -205,9 +205,9 @@ class Whois extends WhoisClient break; } - // Regular handler exists for the tld ? - + // Regular handler exists for the tld ? if (($fp = @fopen('whois.'.$htld.'.php', 'r', 1)) and fclose($fp)) + //if (file_exists('whois.'.$htld.'.php')) { $handler = $htld; break; diff --git a/src/whois.servers.php b/src/whois.servers.php index 7aea5bc..8705bf2 100644 --- a/src/whois.servers.php +++ b/src/whois.servers.php @@ -82,7 +82,8 @@ $this->WHOIS_SPECIAL = array( 'me' => 'whois.meregistry.net', 'mobi' => 'whois.dotmobiregistry.net', 'ms' => 'http://www.adamsnames.tc/whois/?domain={domain}.ms', - 'mt' => 'http://www.um.edu.mt/cgi-bin/nic/whois?domain={domain}.mt', + 'mt' => 'http://www.um.edu.mt/cgi-bin/nic/whois?domain={domain}.mt', + 'ly' => 'whois.nic.ly', 'pe' => 'http://nic.pe/detpublic.php?decid=B&ndom={domain}.pe', 'pr' => 'whois.uprr.pr', 'pro' => 'whois.registry.pro', diff --git a/test.txt b/test.txt index 6bf81cd..f8ce2e2 100644 --- a/test.txt +++ b/test.txt @@ -22,6 +22,7 @@ it nic.it li nic.li lt domreg.lt lu dns.lu +ly nic.ly mx nic.mx nl domain-registry.nl nu nunames.nu