many changes & fixes

This commit is contained in:
sparc 2010-07-28 08:35:55 +00:00
parent 87dcafd02c
commit f54fdbbb5a
27 changed files with 477 additions and 512 deletions

View file

@ -1,5 +1,14 @@
2010/07/27
- better AS support
- ip handlers rewritten
2010/07/21
- added dnssec info to domain object
- parser improved
- better support for some non utf-8 servers
- removed buydomains handler
- added afternic handler
- fixes for many handlers
2010/07/20
- fixed arin new query format

View file

@ -273,7 +273,7 @@ class WhoisClient {
$result['errstr'] = $this->Query['errstr'];
// Fix/add nameserver information
if (method_exists($this,'FixResult') && $this->Query['tld']!='ip')
if (method_exists($this,'FixResult') && $this->Query['tld'] != 'ip')
$this->FixResult($result,$query);
return($result);
@ -481,7 +481,7 @@ class WhoisClient {
if (!isset($result['regyinfo']['whois'])) return $result;
$this->Query['server'] = $wserver = $result['regyinfo']['whois'];
unset($result['regyinfo']['whois']);
$subresult = $this->GetRawData($query);
if (!empty($subresult))

View file

@ -61,32 +61,19 @@ class de_handler
);
$extra = array(
'address:' => 'address.street',
'address:' => 'address.street.',
'city:' => 'address.city',
'pcode:' => 'address.pcode',
'country:' => 'address.country',
'organisation:' => 'organization',
'name:' => 'name',
'remarks:' => '',
'sip:' => 'sip',
'type:' => ''
);
$r['regrinfo'] = easy_parser($data_str['rawdata'], $items, 'ymd',$extra);
/*
if (isset($r['regrinfo']['domain']['desc']))
{
if (!isset($r['regrinfo']['owner']['name']))
$r['regrinfo']['owner']['name'] = $r['regrinfo']['domain']['desc'][0];
if (!isset($r['regrinfo']['owner']['address']))
for ($i=1; $i<count($r['regrinfo']['domain']['desc']); $i++)
$r['regrinfo']['owner']['address'][] = $r['regrinfo']['domain']['desc'][$i];
unset($r['regrinfo']['domain']['desc']);
}
*/
$r['regyinfo'] = array(
'registrar' => 'DENIC eG',
'referrer' => 'http://www.denic.de/'

View file

@ -40,7 +40,7 @@ class fm_handler
$items = array(
'owner' => 'Registrant',
'admin' => 'Administrative',
'admin' => 'Admin',
'tech' => 'Technical',
'billing' => 'Billing',
'domain.nserver' => 'Name Servers:',
@ -48,12 +48,17 @@ class fm_handler
'domain.expires' => 'Expires:',
'domain.changed' => 'Modified:',
'domain.status' => 'Status:',
'domain.sponsor' => 'Registrar:'
'domain.sponsor' => 'Registrar Name:'
);
$r['regrinfo'] = get_blocks($data['rawdata'], $items);
$items = array( 'voice:' => 'phone' );
$items = array(
'phone number:' => 'phone',
'email address:' => 'email',
'fax number:' => 'fax',
'organisation:' => 'organization'
);
if (!empty($r['regrinfo']['domain']['created']))
{

View file

@ -0,0 +1,54 @@
<?php
/*
Whois.php PHP classes to conduct whois queries
Copyright (C)1999,2005 easyDNS Technologies Inc. & Mark Jeftovic
Maintained by David Saez (david@ols.es)
For the most recent version of this package visit:
http://www.phpwhois.org
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* buydomains.whois 1.0 david@ols.es 2003/03/30 */
if (!defined('__AFTERNIC_HANDLER__'))
define('__AFTERNIC_HANDLER__', 1);
require_once('whois.parser.php');
class afternic_handler
{
function parse($data_str, $query)
{
$items = array(
'owner' => 'Registrant:',
'admin' => 'Administrative Contact',
'tech' => 'Technical Contact',
'zone' => 'Zone Contact',
'domain.name' => 'Domain Name:',
'domain.changed' => 'Last updated on',
'domain.created' => 'Domain created on',
'domain.expires' => 'Domain expires on'
);
return easy_parser($data_str, $items, 'dmy', false, false, true);
}
}
?>

View file

@ -52,35 +52,31 @@ class fastdomain_handler
'domain.status' => 'Status:'
);
//print_r($data_str);
while (list($key, $val) = each($data_str))
{
$faststr = strpos($val, ' (FAST-');
if($faststr)
{
$data_str[$key] = substr($val, 0, $faststr);
}
}
while (list($key, $val) = each($data_str))
{
$faststr = strpos($val, ' (FAST-');
if ($faststr)
$data_str[$key] = substr($val, 0, $faststr);
}
$r = easy_parser($data_str, $items, 'dmy', false, false, true);
if (isset($r['domain']['sponsor']) && is_array($r['domain']['sponsor']))
$r['domain']['sponsor'] = $r['domain']['sponsor'][0];
if (isset($r['domain']['nserver']))
{
reset($r['domain']['nserver']);
$endnserver = false;
while (list($key, $val) = each($r['domain']['nserver']))
{
if($val == '=-=-=-=')
$endnserver = true;
if($endnserver)
unset($r['domain']['nserver'][$key]);
}
}
// print_r($r);
return ($r);
if (isset($r['domain']['sponsor']) && is_array($r['domain']['sponsor']))
$r['domain']['sponsor'] = $r['domain']['sponsor'][0];
if (isset($r['domain']['nserver']))
{
reset($r['domain']['nserver']);
$endnserver = false;
while (list($key, $val) = each($r['domain']['nserver']))
{
if ($val == '=-=-=-=')
unset($r['domain']['nserver'][$key]);
}
}
return ($r);
}
}
?>

View file

@ -41,19 +41,20 @@ class names4ever_handler
$items = array(
'owner' => 'Registrant:',
'admin' => 'Administrative Contact',
'tech' => 'Technical Contact',
'tech' => 'Technical Contact',
'domain.name' => 'Domain Name:',
'domain.sponsor' => 'Registrar of Record:',
'domain.nserver' => 'Domain servers in listed order:',
'domain.sponsor' => 'Registrar Name....:',
'domain.referrer' => 'Registrar Homepage:',
'domain.nserver' => 'DNS Servers:',
'domain.created' => 'Record created on',
'domain.expires' => 'Record expires on',
'domain.changed' => 'Record last updated on',
'domain.status' => 'Domain status:'
);
//print_r($data_str);
$r = easy_parser($data_str, $items, 'dmy', false, false, true);
if (isset($r['domain']['sponsor']) && is_array($r['domain']['sponsor']))
$r['domain']['sponsor'] = $r['domain']['sponsor'][0];
$r = easy_parser($data_str, $items, 'dmy', false, false, true);
//if (isset($r['domain']['sponsor']) && is_array($r['domain']['sponsor']))
//$r['domain']['sponsor'] = $r['domain']['sponsor'][0];
return ($r);
}
}

View file

@ -42,7 +42,7 @@ class opensrs_handler
'admin' => 'Administrative Contact',
'tech' => 'Technical Contact',
'domain.name' => 'Domain name:',
'domain.sponsor' => 'Registration Service Provider:',
'' => 'Registration Service Provider:',
'domain.nserver' => 'Domain servers in listed order:',
'domain.changed' => 'Record last updated on',
'domain.created' => 'Record created on',

View file

@ -41,6 +41,7 @@ class publicdomainregistry_handler
'owner#' => '(Registrant):',
'admin' => 'Administrative Contact',
'tech' => 'Technical Contact',
'billing' => 'Billing Contact',
'domain.name' => 'Domain name:',
'domain.sponsor' => 'Registration Service Provided By:',
'domain.nserver' => 'Domain servers in listed order:',
@ -48,7 +49,8 @@ class publicdomainregistry_handler
'domain.created' => 'Record created on',
'domain.created#' => 'Creation Date:',
'domain.expires' => 'Record expires on',
'domain.expires#' => 'Expiration Date:'
'domain.expires#' => 'Expiration Date:',
'domain.status' => 'Status:'
);
return easy_parser($data_str, $items, 'mdy', false, true, true);

View file

@ -47,7 +47,9 @@ class register_handler
'zone' => 'Zone',
'domain.sponsor#0' => 'Registrar Name....:',
'domain.sponsor#1' => 'Registration Service Provided By:',
'domain.referrer' => 'Registrar Homepage:',
'domain.nserver' => 'Domain servers in listed order:',
'domain.nserver' => 'DNS Servers:',
'domain.name' => 'Domain name:',
'domain.created#0' => 'Created on..............:',
'domain.created#1' => 'Creation date:',

View file

@ -41,7 +41,8 @@ class rrpproxy_handler
'updated-date:' => 'domain.changed',
'registration-expiration-date:' => 'domain.expires',
'RSP:' => 'domain.sponsor',
'owner-contact:' => 'owner.handle',
'URL:' => 'domain.referrer',
'owner-nom.contact:' => 'owner.handle',
'owner-fname:' => 'owner.name.first',
'owner-lname:' => 'owner.name.last',
'owner-organization:' => 'owner.organization',
@ -52,7 +53,7 @@ class rrpproxy_handler
'owner-phone:' => 'owner.phone',
'owner-fax:' => 'owner.fax',
'owner-email:' => 'owner.email',
'admin-contact:' => 'admin.handle',
'admin-nom.contact:' => 'admin.handle',
'admin-fname:' => 'admin.name.first',
'admin-lname:' => 'admin.name.last',
'admin-organization:' => 'admin.organization',
@ -63,7 +64,7 @@ class rrpproxy_handler
'admin-phone:' => 'admin.phone',
'admin-fax:' => 'admin.fax',
'admin-email:' => 'admin.email',
'tech-contact:' => 'tech.handle',
'tech-nom.contact:' => 'tech.handle',
'tech-fname:' => 'tech.name.first',
'tech-lname:' => 'tech.name.last',
'tech-organization:' => 'tech.organization',
@ -74,7 +75,7 @@ class rrpproxy_handler
'tech-phone:' => 'tech.phone',
'tech-fax:' => 'tech.fax',
'tech-email:' => 'tech.email',
'billing-contact:' => 'bill.handle',
'billing-nom.contact:' => 'bill.handle',
'billing-fname:' => 'bill.name.first',
'billing-lname:' => 'bill.name.last',
'billing-organization:' => 'bill.organization',

View file

@ -43,7 +43,6 @@ class afrinic_handler
'nic-hdl' => 'handle',
'person' => 'name',
'netname' => 'name',
'descr' => 'desc',
'organisation' => 'handle',
'org-name' => 'organization',
'org-type' => 'type'
@ -57,6 +56,12 @@ class afrinic_handler
$r = generic_parser_a($data_str, $translate, $contacts, 'network', 'Ymd');
if (isset($r['network']['descr']))
{
$r['owner']['organization'] = $r['network']['descr'];
unset($r['network']['descr']);
}
if (isset($r['owner']['remarks']) && is_array($r['owner']['remarks']))
while (list($key, $val) = each($r['owner']['remarks']))
{
@ -66,6 +71,9 @@ class afrinic_handler
$r['rwhois'] = strtok(substr($val,$pos),' ');
}
$r = array( 'regrinfo' => $r );
$r['regyinfo']['type'] = 'ip';
$r['regyinfo']['registrar'] = 'African Network Information Center';
return $r;
}

View file

@ -32,51 +32,95 @@ require_once('whois.parser.php');
if(!defined('__APNIC_HANDLER__'))
define('__APNIC_HANDLER__',1);
class apnic_handler {
function parse ($data_str, $query)
{
$translate = array (
'fax-no' => 'fax',
'e-mail' => 'email',
'nic-hdl' => 'handle',
'person' => 'name',
'country' => 'address',
'netname' => 'name',
'descr' => 'desc'
);
$contacts = array (
'admin-c' => 'admin',
'tech-c' => 'tech'
);
$r = generic_parser_a($data_str,$translate,$contacts,'network','Ymd');
if (isset($r['network']['desc']))
class apnic_handler
{
if (is_array($r['network']['desc']))
function parse ($data_str, $query)
{
$r['owner']['organization'] = array_shift($r['network']['desc']);
$r['owner']['address'] = $r['network']['desc'];
$translate = array (
'fax-no' => 'fax',
'e-mail' => 'email',
'nic-hdl' => 'handle',
'person' => 'name',
'country' => 'address',
'netname' => 'name',
'descr' => 'desc',
'aut-num' => 'handle'
);
$contacts = array (
'admin-c' => 'admin',
'tech-c' => 'tech'
);
//$r = generic_parser_a($data_str,$translate,$contacts,'network','Ymd');
$blocks = generic_parser_a_blocks($data_str,$translate,$disclaimer);
if (isset($disclaimer) && is_array($disclaimer)) $r['disclaimer'] = $disclaimer;
if (empty($blocks) || !is_array($blocks['main']))
{
$r['registered'] = 'no';
}
else
{
if (isset($blocks[$query]))
{
$as = true;
$rb = $blocks[$query];
}
else
{
$rb = $blocks['main'];
$as = false;
}
$r['registered'] = 'yes';
while (list($key,$val) = each($contacts))
if (isset($rb[$key]))
{
if (is_array($rb[$key]))
$blk = $rb[$key][count($rb[$key])-1];
else
$blk = $rb[$key];
$blk = strtoupper(strtok($blk,' '));
if (isset($blocks[$blk])) $r[$val] = $blocks[$blk];
unset($rb[$key]);
}
$r['network'] = $rb;
format_dates($r,'Ymd');
if (isset($r['network']['desc']))
{
if (is_array($r['network']['desc']))
{
$r['owner']['organization'] = array_shift($r['network']['desc']);
$r['owner']['address'] = $r['network']['desc'];
}
else
$r['owner']['organization'] = $r['network']['desc'];
unset($r['network']['desc']);
}
if (isset($r['network']['address']))
{
if (isset($r['owner']['address']))
$r['owner']['address'][] = $r['network']['address'];
else
$r['owner']['address'] = $r['network']['address'];
unset($r['network']['address']);
}
}
$r = array( 'regrinfo' => $r );
$r['regyinfo']['type'] ='ip';
$r['regyinfo']['registrar'] = 'Asia Pacific Network Information Centre';
return $r;
}
else
$r['owner']['organization'] = $r['network']['desc'];
unset($r['network']['desc']);
}
if (isset($r['network']['address']))
{
if (isset($r['owner']['address']))
$r['owner']['address'][] = $r['network']['address'];
else
$r['owner']['address'] = $r['network']['address'];
unset($r['network']['address']);
}
return $r;
}
}

View file

@ -40,7 +40,7 @@ class arin_handler
$items = array(
'OrgName:' => 'owner.organization',
'CustName:' => 'owner.organization',
'OrgID:' => 'owner.handle',
'OrgId:' => 'owner.handle',
'Address:' => 'owner.address.street',
'City:' => 'owner.address.city',
'StateProv:' => 'owner.address.state',
@ -54,7 +54,7 @@ class arin_handler
'Comment:' => 'network.desc.',
'RegDate:' => 'network.created',
'Updated:' => 'network.changed',
'ASHandle:' => 'AS.handle',
'ASHandle:' => 'network.handle',
'ASName:' => 'network.name',
'NetHandle:' => 'network.handle',
'NetName:' => 'network.name',
@ -70,20 +70,11 @@ class arin_handler
);
$r = generic_parser_b($data_str, $items, 'ymd', false, true);
if (isset($r['AS']))
{
$ash = $r['AS']['handle'];
$r['AS'] = $r['network'];
$r['AS']['handle'] = $ash;
unset($r['network']);
}
if (isset($r['abuse']['email']))
if (@isset($r['abuse']['email']))
$r['abuse']['email'] = implode(',',$r['abuse']['email']);
return $r;
return array( 'regrinfo' => $r );
}
}
?>

View file

@ -105,6 +105,11 @@ class krnic_handler
$r['abuse'] = generic_parser_b($b['abuse'], $items, 'Ymd', false);
$r = format_dates($r, 'Ymd');
$r = array( 'regrinfo' => $r );
$r['regyinfo']['type'] ='ip';
$r['regyinfo']['registrar'] = 'Korean Network Information Centre';
return ($r);
}

View file

@ -29,8 +29,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
require_once('whois.parser.php');
if (!defined("__LACNIC_HANDLER__"))
define("__LACNIC_HANDLER__", 1);
if (!defined('__LACNIC_HANDLER__'))
define('__LACNIC_HANDLER__', 1);
class lacnic_handler
{
@ -38,40 +38,44 @@ class lacnic_handler
function parse($data_str, $query)
{
$translate = array(
"fax-no" => "fax",
"e-mail" => "email",
"nic-hdl" => "handle",
"person" => "name",
"netname" => "name",
"descr" => "desc",
"country" => "address.country"
'fax-no' => 'fax',
'e-mail' => 'email',
'nic-hdl-br' => 'handle',
'nic-hdl' => 'handle',
'person' => 'name',
'netname' => 'name',
'descr' => 'desc',
'country' => 'address.country'
);
$contacts = array(
"admin-c" => "admin",
"tech-c" => "tech",
"owner-c" => "owner"
'owner-c' => 'owner',
'tech-c' => 'tech',
'abuse-c' => 'abuse',
'admin-c' => 'admin'
);
$r = generic_parser_a($data_str, $translate, $contacts, "network");
$r = generic_parser_a($data_str, $translate, $contacts, 'network');
if (isset($r['network']['nsstat']))
{
unset($r['network']['nsstat']);
unset($r['network']['nslastaa']);
}
unset($r['network']['owner']);
unset($r['network']['ownerid']);
unset($r['network']['responsible']);
unset($r['network']['address']);
unset($r['network']['phone']);
unset($r['network']['aut-num']);
unset($r['network']['nsstat']);
unset($r['network']['nslastaa']);
unset($r['network']['inetrev']);
if (isset($r['network']['owner']))
{
$r['owner']['organization'] = $r['network']['owner'];
unset($r['network']['owner']);
unset($r['network']['responsible']);
unset($r['network']['address']);
unset($r['network']['phone']);
unset($r['network']['inetrev']);
unset($r['network']['ownerid']);
}
if (!empty($r['network']['aut-num']))
$r['network']['handle'] = $r['network']['aut-num'];
if (isset($r['network']['nserver']))
$r['network']['nserver'] = array_unique($r['network']['nserver']);
$r = array( 'regrinfo' => $r );
$r['regyinfo']['type'] ='ip';
$r['regyinfo']['registrar'] = 'Latin American and Caribbean IP address Regional Registry';
return $r;
}

View file

@ -63,20 +63,25 @@ class ip_handler extends WhoisClient
'whois.apnic.net' => 'apnic',
'whois.ripe.net' => 'ripe',
'whois.arin.net' => 'arin',
'whois.registro.br' => 'bripw',
'whois.lacnic.net' => 'lacnic',
'whois.afrinic.net' => 'afrinic'
);
var $more_data = array(); // More queries to get more accurated data
var $done = array();
function parse($data, $query)
{
$result['regrinfo'] = array();
$result['regyinfo'] = array();
$result['regyinfo']['registrar'] = 'American Registry for Internet Numbers (ARIN)';
$result['rawdata'] = array();
if (strpos($query,'.') === false)
$result['regyinfo']['type'] = 'AS';
else
$result['regyinfo']['type'] = 'ip';
if (!$this->deep_whois) return null;
$this->Query = array();
@ -87,204 +92,59 @@ class ip_handler extends WhoisClient
if (empty($rawdata)) return $result;
$orgname = trim($rawdata[0]);
$presults[] = $rawdata;
$ip = ip2long($query);
$done = array();
if ($orgname == '')
$orgname = trim($rawdata[1]);
foreach($this->REGISTRARS as $string => $whois)
if (strstr($orgname, $string) != '')
{
$this->Query['server'] = $whois;
$result['regyinfo']['registrar'] = $string;
break;
}
switch ($this->Query['server'])
while (count($presults) > 0)
{
case 'whois.apnic.net':
$rawdata = $this->GetRawData($query);
if (empty($rawdata)) break;
$rwdata = array_shift($presults);
$found = false;
foreach($rwdata as $line)
{
$p = strpos($line, '(NETBLK-');
while (list($ln, $line) = each($rawdata))
{
if (strstr($line, 'KRNIC whois server at whois.krnic.net') ||
strstr($line, 'KRNIC-KR'))
{
$result = $this->set_whois_info($result);
$this->Query['server'] = 'whois.krnic.net';
$result['regyinfo']['registrar'] = 'Korea Network Information Center (KRNIC)';
$rawdata = $this->GetRawData($query);
break;
}
if ($p === false) $p = strpos($line, '(NET-');
if (strstr($line, 'Japan Network Information Center'))
{
$result = $this->set_whois_info($result);
$this->Query['server'] = 'whois.nic.ad.jp';
$result['regyinfo']['registrar'] = 'Japan Network Information Center';
$rawdata = $this->GetRawData($query.'/e');
break;
}
}
break;
case 'whois.arin.net':
$newquery = '';
while (list($ln, $line) = each($rawdata))
if ($p !== false)
{
$s = strstr($line, '(NETBLK-');
$net = strtok(substr($line,$p+1),') ');
list($low,$high) = explode('-',str_replace(' ','',substr($line,$p+strlen($net)+3)));
if ($s == '')
$s = strstr($line, '(NET-');
if ($s != '')
if (!isset($done[$net]) && $ip >= ip2long($low) && $ip <= ip2long($high))
{
$netname = substr(strtok($s, ') '), 1);
$owner = substr($line,0,$p-1);
if ($newquery == '')
$newquery = $netname;
if (!empty($this->REGISTRARS['owner']))
{
$this->handle_rwhois($this->REGISTRARS['owner'],$query);
break 2;
}
else
$this->more_data[] = array (
'query' => 'n '.$netname,
'server' => 'whois.arin.net',
'handler' => 'arin'
);
{
$this->Query['args'] = 'n '.$net;
$presults[] = $this->GetRawData($net);
$done[$net] = 1;
}
}
$found = true;
}
if ($newquery != '')
{
$result['regyinfo']['netname'] = $newquery;
if (strstr($newquery, 'BRAZIL-BLK'))
{
$this->Query['server'] = 'whois.registro.br';
$result['regyinfo']['registrar'] = 'Comite Gestor da Internet no Brasil';
$rawdata = $this->GetRawData($query);
break;
}
$rawdata = $this->GetRawData('n '.$newquery);
}
else
$rawdata = '';
break;
case 'whois.lacnic.net':
$rawdata = $this->GetRawData($query);
}
if (empty($rawdata)) break;
while (list($ln, $line) = each($rawdata))
{
$s = strstr($line, 'at whois.registro.br or ');
if ($s == '')
$s = strstr($line, 'Copyright registro.br');
if ($s == '')
$s = strstr($line, 'Copyright (c) Nic.br');
if ($s != '')
{
$result = $this->set_whois_info($result);
$this->Query['server'] = 'whois.registro.br';
$result['regyinfo']['registrar'] = 'Comite Gestor da Internet do Brazil';
$rawdata = $this->GetRawData($query);
break;
}
}
break;
case 'whois.ripe.net':
$rawdata = $this->GetRawData($query);
if (empty($rawdata)) break;
while (list($ln, $line) = each($rawdata))
{
if (strstr($line, 'AFRINIC-NET-TRANSFERRED-'))
{
$result = $this->set_whois_info($result);
$this->Query['server'] = 'whois.afrinic.net';
$result['regyinfo']['registrar'] = 'African Network Information Center';
$rawdata = $this->GetRawData($query);
break;
}
}
break;
default:
$rawdata = $this->GetRawData($query);
}
if (empty($rawdata))
$rawdata = $data['rawdata'];
else
$result = $this->set_whois_info($result);
$result['rawdata'] = $rawdata;
if (isset($this->HANDLERS[$this->Query['server']]))
$this->Query['handler'] = $this->HANDLERS[$this->Query['server']];
if (!empty($this->Query['handler']))
{
$this->Query['file'] = sprintf('whois.ip.%s.php', $this->Query['handler']);
$result['regrinfo'] = $this->Process($result['rawdata']);
}
// Arrange inetnum/cdir
if (isset($result['regrinfo']['network']['inetnum']) && strpos($result['regrinfo']['network']['inetnum'], '/') != false)
{
//Convert CDIR to inetnum
$result['regrinfo']['network']['cdir'] = $result['regrinfo']['network']['inetnum'];
$result['regrinfo']['network']['inetnum'] = phpwhois_cidr_conv($result['regrinfo']['network']['cdir']);
}
if (!isset($result['regrinfo']['network']['inetnum']) && isset($result['regrinfo']['network']['cdir']))
{
//Convert CDIR to inetnum
$result['regrinfo']['network']['inetnum'] = phpwhois_cidr_conv($result['regrinfo']['network']['cdir']);
}
// Try to find abuse email address
if (!isset($result['regrinfo']['abuse']['email']))
{
reset($result['rawdata']);
while (list($key, $line) = each($result['rawdata']))
if (!$found)
{
$email_regex = "/([-_\w\.]+)(@)([-_\w\.]+)\b/i";
if (strpos($line,'abuse') !== false && preg_match($email_regex,$line,$matches)>0)
{
$result['regrinfo']['abuse']['email'] = $matches[0];
break;
}
$this->Query['file'] = 'whois.ip.arin.php';
$this->Query['handler'] = 'arin';
$result = $this->parse_results($result,$rwdata,$query,true);
}
}
// Check if Referral rwhois server has been reported
if (isset($result['regrinfo']['rwhois']) && $this->deep_whois)
{
$this->handle_rwhois($result['regrinfo']['rwhois'],$query);
unset($result['regrinfo']['rwhois']);
}
// more queries can be done to get more accurated data
reset($this->more_data);
while (list($key, $srv_data) = each($this->more_data))
unset($this->Query['args']);
while (count($this->more_data) > 0)
{
$srv_data = array_shift($this->more_data);
$this->Query['server'] = $srv_data['server'];
unset($this->Query['handler']);
// Use original query
@ -292,54 +152,26 @@ class ip_handler extends WhoisClient
if (!empty($rwdata))
{
// Merge rawdata results
$result['rawdata'][] = '';
foreach ($rwdata as $line)
$result['rawdata'][] = $line;
$result = $this->set_whois_info($result);
$this->Query['handler'] = $srv_data['handler'];
if (!empty($srv_data['file']))
$this->Query['file'] = $srv_data['file'];
else
$this->Query['file'] = 'whois.'.$this->Query['handler'].'.php';
$rwres = $this->Process($rwdata);
if (isset($rwres['network']))
$result = $this->join_result($result,'network',$rwres);
if (isset($rwres['owner']))
$result = $this->join_result($result,'owner',$rwres);
if (isset($rwres['tech']))
$result = $this->join_result($result,'tech',$rwres);
if (isset($rwres['abuse']))
$result = $this->join_result($result,'abuse',$rwres);
if (isset($rwres['admin']))
$result = $this->join_result($result,'admin',$rwres);
if (isset($rwres['rwhois']) && $this->deep_whois)
if (!empty($srv_data['handler']))
{
$this->handle_rwhois($rwres['rwhois'],$query);
unset($rwres['rwhois']);
$this->Query['handler'] = $srv_data['handler'];
if (!empty($srv_data['file']))
$this->Query['file'] = $srv_data['file'];
else
$this->Query['file'] = 'whois.'.$this->Query['handler'].'.php';
}
$result = $this->parse_results($result,$rwdata,$query,$srv_data['reset']);
$result = $this->set_whois_info($result);
$reset = false;
}
}
// IP or AS ?
// Normalize nameserver fields
if (isset($result['regrinfo']['AS']))
$result['regyinfo']['type'] = 'AS';
else
$result['regyinfo']['type'] = 'ip';
if (isset($result['regrinfo']['network']['nserver']))
if (isset($result['regrinfo']['network']['nserver']))
{
if (!is_array($result['regrinfo']['network']['nserver']))
{
@ -348,33 +180,102 @@ class ip_handler extends WhoisClient
else
$result['regrinfo']['network']['nserver'] = $this->FixNameServer($result['regrinfo']['network']['nserver']);
}
return $result;
}
//-----------------------------------------------------------------
function parse_results($result,$rwdata,$query,$reset)
{
$rwres = $this->Process($rwdata);
if ($result['regyinfo']['type'] == 'AS' && !empty($rwres['regrinfo']['network']))
{
$rwres['regrinfo']['AS'] = $rwres['regrinfo']['network'];
unset($rwres['regrinfo']['network']);
}
if ($reset)
{
$result['regrinfo'] = $rwres['regrinfo'];
$result['rawdata'] = $rwdata;
}
else
{
$result['rawdata'][] = '';
foreach ($rwdata as $line)
$result['rawdata'][] = $line;
foreach($rwres['regrinfo'] as $key => $data)
{
$result = $this->join_result($result,$key,$rwres);
}
}
if ($this->deep_whois)
{
if (isset($rwres['regrinfo']['rwhois']))
{
$this->handle_rwhois($rwres['regrinfo']['rwhois'],$query);
unset($result['regrinfo']['rwhois']);
}
else
if (!@empty($rwres['regrinfo']['owner']['organization']))
switch ($rwres['regrinfo']['owner']['organization'])
{
case 'KRNIC':
$this->handle_rwhois('whois.krnic.net',$query);
break;
case 'African Network Information Center':
$this->handle_rwhois('whois.afrinic.net',$query);
break;
}
}
if (!empty($rwres['regyinfo']))
$result['regyinfo'] = array_merge($result['regyinfo'],$rwres['regyinfo']);
return $result;
}
//-----------------------------------------------------------------
function handle_rwhois($server,$query)
{
// Avoid querying the same server twice
if (!empty($this->more_data[$server])) return;
$parts = parse_url($server);
if (isset($this->HANDLERS[$parts['host']]))
$handler = $this->HANDLERS[$parts['host']];
if (empty($parts['host']))
$host = $parts['path'];
else
$handler = 'rwhois';
$host = $parts['host'];
$this->more_data[$server] =
array (
if (array_key_exists($host,$this->done)) return;
$q = array (
'query' => $query,
'server' => $server,
'handler' => $handler,
'file' => sprintf('whois.ip.%s.php', $handler)
'server' => $server
);
if (isset($this->HANDLERS[$host]))
{
$q['handler'] = $this->HANDLERS[$host];
$q['file'] = sprintf('whois.ip.%s.php', $q['handler']);
$q['reset'] = true;
}
else
{
$q['handler'] = 'rwhois';
$q['reset'] = false;
unset($q['file']);
}
$this->more_data[] = $q;
$this->done[$host] = 1;
}
//-----------------------------------------------------------------
@ -387,7 +288,7 @@ class ip_handler extends WhoisClient
$result['regrinfo'][$key] = array($r);
}
$result['regrinfo'][$key][] = $newres[$key];
$result['regrinfo'][$key][] = $newres['regrinfo'][$key];
return $result;
}
}

View file

@ -77,6 +77,9 @@ class ripe_handler
if (isset($r['admin']['tech-c'])) unset($r['admin']['tech-c']);
if (isset($r['admin']['admin-c'])) unset($r['admin']['admin-c']);
$r = array( 'regrinfo' => $r );
$r['regyinfo']['type'] ='ip';
$r['regyinfo']['registrar'] = 'RIPE Network Coordination Centre';
return $r;
}

View file

@ -103,7 +103,7 @@ class Whois extends WhoisClient
// If query is an ip address do ip lookup
if ($query == long2ip(ip2long($query)) || !strpos($query, '.'))
if ($query == long2ip(ip2long($query)))
{
// Prepare to do lookup via the 'ip' handler
$ip = @gethostbyname($query);
@ -118,6 +118,23 @@ class Whois extends WhoisClient
return $this->GetData('',$this->deep_whois);
}
if (!strpos($query, '.'))
{
// Prepare to do lookup via the 'ip' handler
$ip = @gethostbyname($query);
$this->Query['server'] = 'whois.arin.net';
if (strtolower(substr($ip,0,2)) == 'as')
$as = substr($ip,2);
else
$as = $ip;
$this->Query['args'] = "a $as";
$this->Query['file'] = 'whois.ip.php';
$this->Query['handler'] = 'ip';
$this->Query['query'] = $ip;
$this->Query['tld'] = 'ip';
return $this->GetData('',$this->deep_whois);
}
// Build array of all possible tld's for that domain
$tld = '';

View file

@ -46,8 +46,8 @@ class nl_handler
'domain.nserver' => 'Domain nameservers:',
'domain.created' => 'Date registered:',
'domain.changed' => 'Record last updated:',
'domain.sponsor' => 'Record maintained by:',
'owner' => 'Registrant:',
'domain.sponsor' => 'Record maintained:',
'owner' => 'Registrar:',
'admin' => 'Administrative contact:',
'tech' => 'Technical contact(s):',
'zone' => 'Registrar:'

View file

@ -40,28 +40,25 @@ if (empty($blocks) || !is_array($blocks['main']))
return $ret;
}
$r=$blocks['main'];
$r = $blocks['main'];
$ret['registered'] = 'yes';
$ret['registered']='yes';
while (list($key,$val)=each($contacts))
while (list($key,$val) = each($contacts))
if (isset($r[$key]))
{
if (is_array($r[$key]))
$blk=$r[$key][count($r[$key])-1];
$blk = $r[$key][count($r[$key])-1];
else
$blk=$r[$key];
$blk = $r[$key];
$blk = strtoupper(strtok($blk,' '));
if (isset($blocks[$blk])) $ret[$val] = $blocks[$blk];
unset($r[$key]);
}
if ($main)
$ret[$main]=$r;
if ($main) $ret[$main] = $r;
format_dates($ret,$dateformat);
return $ret;
}
@ -88,33 +85,33 @@ while (list($key,$val)=each($rawdata))
}
if ($val=='')
{
$newblock=true;
$newblock = true;
continue;
}
if ($newblock && $hasdata)
{
$blocks[$gkey]=$block;
$block=array();
$gkey='';
$blocks[$gkey] = $block;
$block = array();
$gkey = '';
}
$dend=true;
$newblock=false;
$k=trim(strtok($val,':'));
$v=trim(substr(strstr($val,':'),1));
$dend = true;
$newblock = false;
$k = trim(strtok($val,':'));
$v = trim(substr(strstr($val,':'),1));
if ($v=='') continue;
if ($v == '') continue;
$hasdata=true;
$hasdata = true;
if (isset($translate[$k]))
{
$k=$translate[$k];
if ($k=='') continue;
if (strstr($k,'.'))
{
eval("\$block".getvarname($k)."=\$v;");
continue;
}
{
$k=$translate[$k];
if ($k=='') continue;
if (strstr($k,'.'))
{
eval("\$block".getvarname($k)."=\$v;");
continue;
}
}
else $k=strtolower($k);
@ -171,7 +168,7 @@ while (list($key,$val) = each($rawdata))
if ($pos !== false)
{
if ($field!='')
if ($field != '')
{
$var = '$r'.getvarname($field);
$itm = trim(substr($val,$pos+strlen($match)));
@ -277,14 +274,17 @@ while (list($key,$val) = each($rawdata))
if ($val == '' || $val == str_repeat($val[0],strlen($val))) continue;
$last = substr($val,-1,1);
if ($last == $endtag) {
/*
if ($last == $endtag)
{
// Another block found
prev($rawdata);
break;
}
if ($endtag == '' || $partial_match)
*/
if ($endtag == '' || $partial_match || $last == $endtag)
{
//Check if this line starts another block
reset($items);
@ -315,7 +315,7 @@ while (list($key,$val) = each($rawdata))
reset($items);
if (empty($block)) continue;
while (list($field, $match)=each($items))
{
$pos = strpos($line,$match);
@ -372,7 +372,7 @@ function get_contact ( $array, $extra_items='', $has_org= false )
if (!is_array($array))
return array();
$items = array (
$items = array (
'fax..:' => 'fax',
'fax.' => 'fax',
'fax -' => 'fax',
@ -382,7 +382,7 @@ $items = array (
'[fax]' => 'fax',
'(fax)' => 'fax',
'fax' => 'fax',
'tel.' => 'phone',
'tel. ' => 'phone',
'tel:' => 'phone',
'phone::' => 'phone',
'phone:' => 'phone',
@ -397,12 +397,19 @@ $items = array (
'language:' => '',
'location:' => 'address.city',
'country:' => 'address.country',
'name:' => 'name'
'name:' => 'name',
'address:' => 'address.',
'last modified:' => 'changed'
);
if ($extra_items)
$items = array_merge($extra_items,$items);
{
foreach($items as $match => $field)
if (!isset($extra_items[$match]))
$extra_items[$match] = $field;
$items = $extra_items;
}
while (list($key,$val)=each($array))
{
$ok=true;
@ -415,7 +422,7 @@ while (list($key,$val)=each($array))
while (list($match,$field) = each($items))
{
$pos = strpos(strtolower($val),$match);
if ($pos === false) continue;
$itm = trim(substr($val,$pos+strlen($match)));
@ -440,10 +447,10 @@ while (list($key,$val)=each($array))
//break;
}
if (preg_match("/([+]*[-0-9\(\)\. x]){7,}/", $val, $matches))
if (preg_match("/([+]*[-\(\)\. x0-9]){7,}/", $val, $matches))
{
$phone = trim(str_replace(' ','',$matches[0]));
if (strlen($phone) > 8 && !preg_match('/[0-9]{5}\-[0-9]{3}/',$phone))
{
if (isset($r['phone']))
@ -472,7 +479,7 @@ while (list($key,$val)=each($array))
}
if (preg_match('/([-0-9a-zA-Z._+&\/=]+@([-0-9a-zA-Z]+[.])+[a-zA-Z]{2,6})/',$val, $matches))
{
{
$r['email'] = $matches[0];
$val = str_replace($matches[0],'',$val);

View file

@ -14,7 +14,7 @@ class pt_handler {
function parse($data, $query)
{
$items = array(
'domain.name' => 'Nome de domínio / Domain Name:',
'domain.name' => ' / Domain Name:',
'domain.created' => 'Data de registo / Creation Date (dd/mm/yyyy):',
'domain.nserver.' => 'Nameserver:',
'domain.status' => 'Estado / Status:',
@ -29,6 +29,7 @@ class pt_handler {
if (empty($r['regrinfo']['domain']['name']))
{
print_r($r['regrinfo']);
$r['regrinfo']['registered'] = 'no';
return $r;
}

View file

@ -53,9 +53,10 @@ class rwhois_handler
);
$res = generic_parser_b($data_str, $items, 'Ymd', false);
unset($res['disclaimer']);
return ($res);
$res = array( 'regrinfo' => $res );
return $res;
}
}
?>

View file

@ -45,7 +45,10 @@ $this->DATA = array(
/* Non UTF-8 servers */
$this->NON_UTF8 = array(
'whois.interdomain.net' => 1
'whois.interdomain.net' => 1,
'pt.whois-servers.net' => 1,
'is.whois-servers.net' => 1,
'whois.lacnic.net' => 1
);
/* If whois Server needs any parameters, enter it here */

View file

@ -31,7 +31,7 @@ nz dnc.org.nz
pl nic.pl
pt dns.pt
ru nic.ru
sc admin.sc
sc nic.sc
se nic-se.se
si arnes.si
su news.su
@ -50,7 +50,7 @@ corenic corenic.com
directnic directnic.com
domainbank domainbank.com
domaincontender domaincontender.com
domaindiscover buydomains.com
afternic buydomains.com
domainpeople domainpeople.com
dotster dotster.com namesdirect.com dotregistrar.com
dreamhost dreamhost.com
@ -67,7 +67,7 @@ melbourneit inww.com
moniker moniker.com
namejuice namejuice.com
nameking nameking.com
names4ever naves4ever.com
names4ever names4ever.com
networksolutions networksolutions.com
nicco nicco.com
nicline nicline.com
@ -114,13 +114,12 @@ apnic 218.165.121.114
arin 207.217.120.54
arin+rwhois 70.84.47.210
arin+whois 63.95.254.3
bripw 200.165.206.74
krnic 210.178.148.129
lacnic 200.44.33.31
lacnic(br) 200.165.206.74
ripe 62.97.102.115 151.99.187.181
// ASN
arin AS220
krnic AS9700

File diff suppressed because one or more lines are too long

View file

@ -1,76 +0,0 @@
<?php
/*
Whois.php PHP classes to conduct whois queries
Copyright (C)1999,2005 easyDNS Technologies Inc. & Mark Jeftovic
Maintained by David Saez (david@ols.es)
For the most recent version of this package visit:
http://www.phpwhois.org
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* bripw.whois 1.0 David Saez 04/04/2003 */
require_once('whois.parser.php');
if (!defined('__BRIPW_HANDLER__'))
define('__BRIPW_HANDLER__', 1);
class bripw_handler
{
function parse($data_str, $query)
{
$translate = array(
'fax-no' => 'fax',
'e-mail' => 'email',
'nic-hdl-br' => 'handle',
'person' => 'name',
'netname' => 'name'
);
$contacts = array(
'owner-c' => 'owner',
'tech-c' => 'tech',
'abuse-c' => 'abuse'
);
$r = generic_parser_a($data_str, $translate, $contacts, 'network');
unset($r['network']['owner']);
unset($r['network']['ownerid']);
unset($r['network']['responsible']);
unset($r['network']['address']);
unset($r['network']['phone']);
$r['network']['handle'] = $r['network']['aut-num'];
unset($r['network']['aut-num']);
unset($r['network']['nsstat']);
unset($r['network']['nslastaa']);
unset($r['network']['inetrev']);
if (isset($r['network']['nserver']))
$r['network']['nserver'] = array_unique($r['network']['nserver']);
return $r;
}
}
?>