added support for AfriNIC (ip whois)

This commit is contained in:
sparc 2005-07-27 17:59:08 +00:00
parent b8364ce363
commit d9e7b33029
5 changed files with 199 additions and 124 deletions

View file

@ -7,6 +7,7 @@
- updated README file
- some improvments for AS queries
- some handlers reported zcode instead of pcode
- added support for AfriNIC (ip whois)
2005/07/26 David Saez <david@ols.es>
- added handler for za.org & za.net, thanx to

62
src/whois.ip.afrinic.php Executable file
View file

@ -0,0 +1,62 @@
<?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://phpwhois.sourceforge.net
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.
*/
/* ripe.whois 1.0 David Saez 7/6/2002 */
require_once('whois.parser.php');
if(!defined('__AFRINIC_HANDLER__')) define('__AFRINIC_HANDLER__',1);
class afrinic_handler {
function parse ($data_str,$query)
{
$translate = array (
'fax-no' => 'fax',
'e-mail' => 'email',
'nic-hdl' => 'handle',
'person' => 'name',
'netname' => 'name',
'descr' => 'desc',
'organisation' => 'handle',
'org-name' => 'organization',
'org-type' => 'type'
);
$contacts = array (
'admin-c' => 'admin',
'tech-c' => 'tech',
'org' => 'owner'
);
$r = generic_parser_a($data_str,$translate,$contacts,'network','Ymd');
return $r;
}
}
?>

View file

@ -43,24 +43,27 @@ class ip_handler extends WhoisClient {
var $HANDLER_VERSION = '1.0';
var $REGISTRARS = array(
'European Regional Internet Registry/RIPE NCC' => 'whois.ripe.net',
'RIPE Network Coordination Centre' => 'whois.ripe.net',
'Asia Pacific Network Information Center' => 'whois.apnic.net',
'Asia Pacific Network Information Centre' => 'whois.apnic.net',
'Latin American and Caribbean IP address Regional Registry' => 'whois.lacnic.net'
'European Regional Internet Registry/RIPE NCC' => 'whois.ripe.net',
'RIPE Network Coordination Centre' => 'whois.ripe.net',
'Asia Pacific Network Information Center' => 'whois.apnic.net',
'Asia Pacific Network Information Centre' => 'whois.apnic.net',
'Latin American and Caribbean IP address Regional Registry' => 'whois.lacnic.net',
'African Network Information Center' => 'whois.afrinic.net'
);
var $HANDLERS = array(
'whois.krnic.net' =>'krnic',
'whois.apnic.net' =>'apnic',
'whois.ripe.net' =>'ripe',
'whois.arin.net' =>'arin',
'whois.krnic.net' =>'krnic',
'whois.apnic.net' =>'apnic',
'whois.ripe.net' =>'ripe',
'whois.arin.net' =>'arin',
'whois.registro.br' =>'bripw',
'whois.lacnic.net' =>'lacnic'
'whois.lacnic.net' =>'lacnic',
'whois.afrinic.net' => 'afrinic'
);
function parse ($data,$query) {
function parse ($data,$query)
{
$this->Query=$query;
unset($this->Query['handler']);
@ -70,128 +73,130 @@ if (!isset($result['rawdata']))
}
$result['regyinfo']=array();
$result["regyinfo"]["registrar"]="American Registry for Internet Numbers (ARIN)";
$result['regyinfo']['registrar']='American Registry for Internet Numbers (ARIN)';
reset($this->REGISTRARS);
$rawdata=$data["rawdata"];
$rawdata=$data['rawdata'];
$orgname=trim($rawdata[0]);
if ($orgname=="") $orgname=trim($rawdata[1]);
if ($orgname=='') $orgname=trim($rawdata[1]);
while (list($string, $whois)=each($this->REGISTRARS))
if (strstr($orgname,$string)!="")
{ $this->Query["server"]=$whois;
$result["regyinfo"]["registrar"]=$string;
break;
}
if (strstr($orgname,$string)!='')
{
$this->Query['server']=$whois;
$result['regyinfo']['registrar']=$string;
break;
}
switch ($this->Query["server"])
{ case "whois.apnic.net":
$rawdata=$this->GetData($this->Query["string"]);
$rawdata=$rawdata["rawdata"];
while (list($ln,$line)=each($rawdata))
{
if (strstr($line,"KRNIC whois server at whois.krnic.net"))
{
$this->Query["server"]="whois.krnic.net";
$result["regyinfo"]["registrar"]="Korea Network Information Center (KRNIC)";
$rawdata=$this->GetData($this->Query["string"]);
$rawdata=$rawdata["rawdata"];
break;
}
}
break;
case "whois.arin.net":
$newquery="";
while (list($ln,$line)=each($rawdata))
{
$s=strstr($line,"(NETBLK-");
if ($s!="")
{
$newquery=substr(strtok($s,") "),1);
break;
}
$s=strstr($line,"(NET-");
if ($s!="")
{
$newquery=substr(strtok($s,") "),1);
break;
}
}
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->GetData($this->Query["string"]);
$rawdata=$rawdata["rawdata"];
$newquery="";
}
if ($newquery!="")
{
$rawdata=$this->GetData("!".$newquery);
$rawdata=$rawdata["rawdata"];
}
break;
case "whois.lacnic.net":
$rawdata=$this->GetData($this->Query["string"]);
$rawdata=$rawdata["rawdata"];
while (list($ln,$line)=each($rawdata))
{
$s=strstr($line,"at whois.registro.br or ");
if ($s!="")
{
$this->Query["server"]="whois.registro.br";
$result["regyinfo"]["registrar"]="Comite Gestor da Internet do Brazil";
$rawdata=$this->GetData($this->Query["string"]);
$rawdata=$rawdata["rawdata"];
break;
}
}
break;
default:
$rawdata=$this->GetData($this->Query["string"]);
if (isset($rawdata["rawdata"])) $rawdata=$rawdata["rawdata"];
}
$result["rawdata"]=$rawdata;
$result["regyinfo"]["whois"]=$this->Query["server"];
if ($this->HANDLERS[$this->Query["server"]]!='')
$this->Query["handler"] = $this->HANDLERS[$this->Query["server"]];
if (!empty($this->Query["handler"]))
switch ($this->Query['server'])
{
$this->Query["file"]=sprintf("whois.ip.%s.php", $this->Query["handler"]);
$result["regrinfo"]=$this->Process($result["rawdata"]);
case 'whois.apnic.net':
$rawdata=$this->GetData($this->Query['string']);
$rawdata=$rawdata['rawdata'];
while (list($ln,$line)=each($rawdata))
{
if (strstr($line,'KRNIC whois server at whois.krnic.net'))
{
$this->Query['server']='whois.krnic.net';
$result['regyinfo']['registrar']='Korea Network Information Center (KRNIC)';
$rawdata=$this->GetData($this->Query['string']);
$rawdata=$rawdata['rawdata'];
break;
}
}
break;
case 'whois.arin.net':
$newquery='';
while (list($ln,$line)=each($rawdata))
{
$s=strstr($line,'(NETBLK-');
if ($s!='')
{
$newquery=substr(strtok($s,') '),1);
break;
}
$s=strstr($line,'(NET-');
if ($s!='')
{
$newquery=substr(strtok($s,') '),1);
break;
}
}
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->GetData($this->Query['string']);
$rawdata=$rawdata['rawdata'];
$newquery='';
}
if ($newquery!='')
{
$rawdata=$this->GetData('!'.$newquery);
$rawdata=$rawdata['rawdata'];
}
break;
case 'whois.lacnic.net':
$rawdata=$this->GetData($this->Query['string']);
$rawdata=$rawdata['rawdata'];
while (list($ln,$line)=each($rawdata))
{
$s=strstr($line,'at whois.registro.br or ');
if ($s!='')
{
$this->Query['server']='whois.registro.br';
$result['regyinfo']['registrar']='Comite Gestor da Internet do Brazil';
$rawdata=$this->GetData($this->Query['string']);
$rawdata=$rawdata['rawdata'];
break;
}
}
break;
default:
$rawdata=$this->GetData($this->Query['string']);
if (isset($rawdata['rawdata'])) $rawdata=$rawdata['rawdata'];
}
$result['rawdata']=$rawdata;
$result['regyinfo']['whois']=$this->Query['server'];
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']);
}
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']=$this->cidr_conv($result['regrinfo']['network']['cdir']);
}
strpos($result['regrinfo']['network']['inetnum'],'/')!==false)
{
//Convert CDIR to inetnum
$result['regrinfo']['network']['cdir']=$result['regrinfo']['network']['inetnum'];
$result['regrinfo']['network']['inetnum']=$this->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']=$this->cidr_conv($result['regrinfo']['network']['cdir']);
}
isset($result['regrinfo']['network']['cdir']))
{
//Convert CDIR to inetnum
$result['regrinfo']['network']['inetnum']=$this->cidr_conv($result['regrinfo']['network']['cdir']);
}
return $result;
}

View file

@ -40,8 +40,8 @@ $translate = array (
"e-mail" => "email",
"nic-hdl" => "handle",
"person" => "name",
"netname" => "name",
"descr" => "desc"
"netname" => "name",
"descr" => "desc"
);
$contacts = array (

View file

@ -400,14 +400,21 @@ reset($res);
while (list($key, $val) = each($res))
{
if (is_array($val))
$res[$key]=format_dates($val,$format);
{
if ($key=='expires' || $key=='created' || $key=='changed')
{
$res[$key]=get_date($val[0],$format);
}
else
$res[$key]=format_dates($val,$format);
}
else
{
if (is_numeric($key)) continue;
if ($key=='expires' || $key=='created' || $key=='changed')
{
$res[$key]=get_date($val,$format);
$res[$key]=get_date($val,$format);
}
}
}