some improvments
This commit is contained in:
parent
535c954c3c
commit
46f226b848
|
@ -1,3 +1,8 @@
|
|||
2002/12/16 David Saez <david@ols.es>
|
||||
- updated aunic.whois
|
||||
- improved generic.whois & generic2.whois
|
||||
- fixed uninitialized variable in utils.whois
|
||||
|
||||
2002/10/16 David Saez <david@ols.es>
|
||||
- Updated uknic handler to new Nominet UK whois output
|
||||
- Added handler for .biz
|
||||
|
|
26
aunic.whois
26
aunic.whois
|
@ -26,12 +26,14 @@
|
|||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* aunic.whois 2.0 by David Saez <david@ols.es> */
|
||||
/* aunic.whois 2.1 by David Saez <david@ols.es> update detection schema*/
|
||||
/* aunic.whois 2.0 by David Saez <david@ols.es> common object model */
|
||||
/* aunic.whois 1.0 by Edi Wibowo <edi@ausnik-it.com,http://www.ausnik-it.com> */
|
||||
/* check with telstra.com.au */
|
||||
|
||||
if(!defined("__AUNIC_HANDLER__")) define("__AUNIC_HANDLER__",1);
|
||||
|
||||
include_once("generic.whois");
|
||||
include_once("generic2.whois");
|
||||
|
||||
class aunic extends Whois {
|
||||
|
||||
|
@ -41,15 +43,27 @@ class aunic extends Whois {
|
|||
|
||||
function parse ($data_str) {
|
||||
|
||||
$items = array( "domain.name" => "Domain Name:",
|
||||
"domain.changed" => "Last Modified:",
|
||||
"domain.sponsor" => "Registrar Name:",
|
||||
"domain.status" => "Status:",
|
||||
"domain.handle" => "Domain ROID:",
|
||||
"owner.organization" => "Registrant:",
|
||||
"owner.handle" => "Registrant ID:",
|
||||
"owner.email" => "Registrant Email:",
|
||||
"owner.name" => "Registrant Contact Name:",
|
||||
"tech.name" => "Tech Name:",
|
||||
"tech.email" => "Tech Email:",
|
||||
"tech.handle" => "Tech ID:",
|
||||
"domain.nserver." => "Name Server:"
|
||||
);
|
||||
|
||||
$r["rawdata"] = $data_str["rawdata"];
|
||||
$r["regyinfo"] = array("whois"=>"whois.aunic.net",
|
||||
"referrer"=>"http://www.aunic.net",
|
||||
"registrar"=>"AU-NIC");
|
||||
|
||||
$r["regrinfo"] = generic_whois($data_str["rawdata"]);
|
||||
|
||||
$r["regrinfo"]["owner"]["organization"] = $r["regrinfo"]["owner"]["address"][0];
|
||||
|
||||
$r["regrinfo"] = generic_whois($data_str["rawdata"],$items);
|
||||
return $r;
|
||||
}
|
||||
}
|
||||
|
|
248
denic.whois
248
denic.whois
|
@ -1,146 +1,102 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
Whois2.php PHP classes to conduct whois queries
|
||||
|
||||
Copyright (C)1999,2000 easyDNS Technologies Inc. & Mark Jeftovic
|
||||
|
||||
Maintained by Mark Jeftovic <markjr@easydns.com>
|
||||
|
||||
For the most recent version of this package:
|
||||
|
||||
http://www.easydns.com/~markjr/whois2/
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
/* denic.whois 0.2 by Elmar K. Bins <elmi@4ever.de> */
|
||||
/* based upon brnic.whois by Marcelo Sanches <msanches@sitebox.com.br> */
|
||||
/* and atnic.whois by Martin Pircher <martin@pircher.net> */
|
||||
|
||||
/* this version does not yet deliver contact data, but handles only */
|
||||
|
||||
if(!defined("__DENIC_HANDLER__")) define("__DENIC_HANDLER__",1);
|
||||
|
||||
class denic extends Whois {
|
||||
|
||||
function denic($data) {
|
||||
$this->result=$this->parse($data);
|
||||
}
|
||||
|
||||
function parse ($data_str) {
|
||||
$items=array(
|
||||
"domain" => "domain:",
|
||||
"status" => "status:",
|
||||
"registrar" => "prov:"
|
||||
);
|
||||
|
||||
$r["rawdata"] = $data_str["rawdata"];
|
||||
$r["regyinfo"] = array(
|
||||
"whois"=>"whois.denic.de"
|
||||
);
|
||||
|
||||
$r["regrinfo"] = array();
|
||||
$r["regrinfo"]["owner"] = array();
|
||||
$r["regrinfo"]["owner"]["address"] = array();
|
||||
$r["regrinfo"]["ns"] = array();
|
||||
$r["regrinfo"]["admin"] = array();
|
||||
$r["regrinfo"]["tech"] = array();
|
||||
$r["regrinfo"]["zone"] = array();
|
||||
|
||||
$address_ok = FALSE;
|
||||
$nserver_ok = FALSE;
|
||||
$created_ok = FALSE;
|
||||
$changed_ok = FALSE;
|
||||
$org_ok = FALSE;
|
||||
|
||||
while (list($key, $val) = each($data_str["rawdata"])) {
|
||||
$val = trim($val);
|
||||
if ($val!="") {
|
||||
if ((substr($val,0,5) == "descr") && (!$address_ok)) {
|
||||
$address_line = 1;
|
||||
do {
|
||||
$address = split("descr:",$val);
|
||||
if (!$org_ok)
|
||||
{
|
||||
$r["regrinfo"]["owner"]["organization"] = trim($address[1]);
|
||||
$r["regrinfo"]["organization"] = trim($address[1]);
|
||||
$org_ok = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
$address_array = 'address'. $address_line;
|
||||
$r["regrinfo"]["owner"]["address"][$address_array] = trim($address[1]);
|
||||
$address_line += 1;
|
||||
}
|
||||
list($key, $val) = each($data_str["rawdata"]);
|
||||
$val = trim($val);
|
||||
} while ((substr($val,0,5) == "descr") && (!$address_ok));
|
||||
$address_ok = TRUE;
|
||||
}
|
||||
|
||||
if ((substr($val,0,7) == "nserver") && (!$nserver_ok)) {
|
||||
$n_counter = 1;
|
||||
do {
|
||||
$nserver = split("nserver:",$val);
|
||||
$val = $nserver[1];
|
||||
if ($val == "") break;
|
||||
$val = trim($val);
|
||||
list($v1,$v2) = preg_split("/\s+/",$val);
|
||||
|
||||
$r["regrinfo"]["ns"][$v1] = "$v2";
|
||||
|
||||
list($key, $val) = each($data_str["rawdata"]);
|
||||
$val = trim($val);
|
||||
|
||||
$n_counter += 1;
|
||||
} while ((substr($val,0,7) == "nserver"));
|
||||
$nserver_ok = TRUE;
|
||||
}
|
||||
|
||||
if ((substr($val,0,7) == "changed") && (!$changed_ok)) {
|
||||
$changed = split("changed:",$val);
|
||||
$r["regrinfo"]["changed"] = trim($changed[1]);
|
||||
list($key, $val) = each($data_str["rawdata"]);
|
||||
$val = trim($val);
|
||||
$changed_ok = TRUE;
|
||||
}
|
||||
|
||||
// handles for admin-c, tech-c, zone-c
|
||||
if (substr($val,0,7) == "admin-c")
|
||||
{ $r["regrinfo"]["admin"]["handle"] = trim(substr($val,10)); }
|
||||
if (substr($val,0,6) == "tech-c")
|
||||
{ $r["regrinfo"]["tech"]["handle"] = trim(substr($val,10)); }
|
||||
if (substr($val,0,6) == "zone-c")
|
||||
{ $r["regrinfo"]["zone"]["handle"] = trim(substr($val,10)); }
|
||||
|
||||
|
||||
reset($items);
|
||||
while (list($field, $match) = each($items)) {
|
||||
if (strstr($val,$match))
|
||||
{ $r["regrinfo"][$field] = trim(substr($val,strlen($match)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$r["regyinfo"]["address"] = $r["regrinfo"]["owner"]["address"];
|
||||
$r["regyinfo"]["domain"] = $r["regrinfo"]["domain"];
|
||||
$r["regyinfo"]["nserver"] = $r["regrinfo"]["ns"];
|
||||
|
||||
return($r);
|
||||
}
|
||||
}
|
||||
<?php
|
||||
/*
|
||||
Whois2.php PHP classes to conduct whois queries
|
||||
|
||||
Copyright (C)1999,2000 easyDNS Technologies Inc. & Mark Jeftovic
|
||||
|
||||
Maintained by Mark Jeftovic <markjr@easydns.com>
|
||||
|
||||
For the most recent version of this package:
|
||||
|
||||
http://www.easydns.com/~markjr/whois2/
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
/* denic.whois 0.2 by Elmar K. Bins <elmi@4ever.de> */
|
||||
/* based upon brnic.whois by Marcelo Sanches <msanches@sitebox.com.br> */
|
||||
/* and atnic.whois by Martin Pircher <martin@pircher.net> */
|
||||
|
||||
/* this version does not yet deliver contact data, but handles only */
|
||||
|
||||
if(!defined("__DENIC_HANDLER__")) define("__DENIC_HANDLER__",1);
|
||||
|
||||
class denic extends Whois {
|
||||
|
||||
function denic($data) {
|
||||
$this->result=$this->parse($data);
|
||||
}
|
||||
|
||||
function parse ($data_str)
|
||||
{
|
||||
$convert=array("domain"=>"name", "descr"=>"desc",
|
||||
"type"=>"", "city"=>"address",
|
||||
"pcode"=>"address", "country"=if (is_array($disclaimer)) $ret["disclaimer"]=$disclaimer;>"address");
|
||||
$r=array();
|
||||
$newblock=false;
|
||||
$hasdata=false;
|
||||
$block=array();
|
||||
$gkey="main";
|
||||
|
||||
while (list($key,$val)=each($rawdata))
|
||||
{ $val=trim($val);
|
||||
if (substr($val,0,1)=='%')
|
||||
{ $disclaimer[]=trim(substr($val,1));
|
||||
continue;
|
||||
}
|
||||
if ($val=="")
|
||||
{ $newblock=true;
|
||||
continue;
|
||||
}
|
||||
if ($newblock && $hasdata)
|
||||
{ $blocks[$gkey]=$block;
|
||||
$block=array();
|
||||
$gkey="";
|
||||
}
|
||||
if ($newblock)
|
||||
{ $gkey=str_replace("]["," ",$gkey);
|
||||
$gkey=str_replace("]","",$gkey);
|
||||
$gkey=str_replace("[","",$gkey);
|
||||
}
|
||||
$newblock=false;
|
||||
$hasdata=true;
|
||||
$k=str_tolower(trim(strtok($val,":")));
|
||||
$v=trim(substr(strstr($val,":"),1));
|
||||
|
||||
if (isset($convert[$k]))
|
||||
{ $k=$convert($k);
|
||||
if ($k=="") continue;
|
||||
}
|
||||
|
||||
if (is_array($block[$k]))
|
||||
$block[$k][]=$v;
|
||||
else if ($block[$k]=="")
|
||||
$block[$k]=$v;
|
||||
else { $x=$block[$k];
|
||||
unset($block[$k]);
|
||||
$block[$k][]=$x;
|
||||
$block[$k][]=$v;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ($hasdata) $blocks[$gkey]=$block;
|
||||
|
||||
$r=$blocks;
|
||||
|
||||
//if (is_array($disclaimer)) $r["disclaimer"]=$disclaimer;
|
||||
return($r);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,11 +7,12 @@ $newblock=false;
|
|||
$hasdata=false;
|
||||
$block=array();
|
||||
$gkey="main";
|
||||
$dend=false;
|
||||
|
||||
while (list($key,$val)=each($rawdata))
|
||||
{ $val=trim($val);
|
||||
if (substr($val,0,1)=='%')
|
||||
{ $disclaimer[]=trim(substr($val,1));
|
||||
if ($val[0]=='%')
|
||||
{ if (!$dend) $disclaimer[]=trim(substr($val,1));
|
||||
continue;
|
||||
}
|
||||
if ($val=="")
|
||||
|
@ -22,7 +23,8 @@ while (list($key,$val)=each($rawdata))
|
|||
{ $blocks[$gkey]=$block;
|
||||
$block=array();
|
||||
$gkey="";
|
||||
}
|
||||
}
|
||||
$dend=true;
|
||||
$newblock=false;
|
||||
$hasdata=true;
|
||||
$k=trim(strtok($val,":"));
|
||||
|
@ -65,27 +67,27 @@ $r=$blocks["main"];
|
|||
|
||||
$ret["registered"]="yes";
|
||||
|
||||
if ($r["admin-c"]!="")
|
||||
if (isset($r["admin-c"]))
|
||||
{ $ret["admin"]=$blocks[$r["admin-c"]];
|
||||
unset($r["admin-c"]);
|
||||
}
|
||||
|
||||
if ($r["tech-c"]!="")
|
||||
if (isset($r["tech-c"]))
|
||||
{ $ret["tech"]=$blocks[$r["tech-c"]];
|
||||
unset($r["tech-c"]);
|
||||
}
|
||||
|
||||
if ($r["zone-c"]!="")
|
||||
if (isset($r["zone-c"]))
|
||||
{ $ret["zone"]=$blocks[$r["zone-c"]];
|
||||
unset($r["zone-c"]);
|
||||
}
|
||||
|
||||
if ($r["billing-c"]!="")
|
||||
if (isset($r["billing-c"]))
|
||||
{ $ret["billing"]=$blocks[$r["billing-c"]];
|
||||
unset($r["billing-c"]);
|
||||
}
|
||||
|
||||
if ($r["owner-c"]!="")
|
||||
if (isset($r["owner-c"]))
|
||||
{ $ret["owner"]=$blocks[$r["owner-c"]];
|
||||
unset($r["owner-c"]);
|
||||
}
|
||||
|
|
|
@ -4,11 +4,19 @@ function generic_whois ( $rawdata, $items )
|
|||
|
||||
{
|
||||
$r="";
|
||||
$disok=true;
|
||||
|
||||
while (list($key,$val)=each($rawdata))
|
||||
{ if (trim($val)!="")
|
||||
{ reset($items);
|
||||
$ok=0;
|
||||
if ($val[0]=='%' && $disok)
|
||||
{ $r['disclaimer'][]=trim(substr($val,1));;
|
||||
$disok=true;
|
||||
continue;
|
||||
}
|
||||
|
||||
$disok=false;
|
||||
|
||||
while (list($field, $match)=each($items))
|
||||
{ if (strstr($val,$match))
|
||||
|
|
629
main.whois
629
main.whois
|
@ -1,314 +1,315 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
Whois2.php PHP classes to conduct whois queries
|
||||
|
||||
Copyright (C)1999,2000 easyDNS Technologies Inc. & Mark Jeftovic
|
||||
|
||||
Maintained by Mark Jeftovic <markjr@easydns.com>
|
||||
|
||||
For the most recent version of this package:
|
||||
|
||||
http://www.easydns.com/~markjr/whois2/
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
class Whois {
|
||||
// Full code and data version string (e.g. 'Whois2.php v3.01:16')
|
||||
var $VERSION;
|
||||
|
||||
// This release of the package
|
||||
var $CODE_VERSION = "3.0.1";
|
||||
|
||||
// Network Solutions registry server
|
||||
var $NSI_REGISTRY = "whois.nsiregistry.net";
|
||||
|
||||
// Network Solutions registrar server (?)
|
||||
var $NSI_REGISTRAR = "whois.networksolutions.com";
|
||||
|
||||
// Default WHOIS port
|
||||
var $PORT = 43;
|
||||
|
||||
// Maximum number of retries on connection failure
|
||||
var $RETRY = 0;
|
||||
|
||||
// Time to wait between retries
|
||||
var $SLEEP = 2;
|
||||
|
||||
// Read buffer size (0 == char by char)
|
||||
var $BUFFER = 0;
|
||||
|
||||
// Status response codes
|
||||
var $STAT = array(
|
||||
-1 => "error",
|
||||
0 => "ready",
|
||||
1 => "ok"
|
||||
);
|
||||
|
||||
// Array to contain all query variables
|
||||
var $Query = array(
|
||||
"tld" => "",
|
||||
"type" => "domain",
|
||||
"string" => "",
|
||||
"status",
|
||||
"server"
|
||||
);
|
||||
|
||||
// Various hacks. In a perfect world we don't need these.
|
||||
var $HACKS = array(
|
||||
// force "dom" keywork
|
||||
"nsi_force_dom" => 1,
|
||||
// set if nsiregistry gives wrong whois server for netsol
|
||||
"nsi_referral_loop" => 0,
|
||||
// ???
|
||||
"wrong_netsol_whois" => "rs.internic.net",
|
||||
// ???
|
||||
"real_netsol_whois" => "whois.networksolutions.com",
|
||||
// force english output on .jp for us ethnocentric types, unset or comment out for Japanese output
|
||||
"force_slash_e" => "whois.nic.ad.jp",
|
||||
// whois.nic.cx hangs forever
|
||||
"cx_is_broken" => 1
|
||||
);
|
||||
|
||||
// List of servers and handlers (loaded from servers.whois)
|
||||
var $DATA = array();
|
||||
|
||||
/*
|
||||
* Constructor function
|
||||
*/
|
||||
function Whois ($query = "") {
|
||||
// Load DATA array
|
||||
require("servers.whois");
|
||||
|
||||
// Set version
|
||||
$this->VERSION = sprintf("Whois2.php v%s:%s", $this->CODE_VERSION, $this->DATA_VERSION);
|
||||
|
||||
// If domain to query was not set
|
||||
if(!isSet($query)) {
|
||||
// Configure to use default whois server
|
||||
$this->Query["server"] = $this->NSI_REGISTRY;
|
||||
return;
|
||||
}
|
||||
|
||||
// Set domain to query in query array
|
||||
$this->Query["string"] = strtolower($query);
|
||||
|
||||
// Determine top level whois server
|
||||
$tld = $this->GetTld($this->Query["string"]);
|
||||
if($tld) {
|
||||
// If found, set tld and whois server in query array
|
||||
$this->Query["server"] = $this->DATA[$tld][0];
|
||||
$this->Query["tld"] = $tld;
|
||||
|
||||
// If a handler exists for the tld
|
||||
if(isSet($this->DATA[$tld][1])) {
|
||||
// Set fle/handler in query array
|
||||
$handler = $this->DATA[$tld][1];
|
||||
$this->Query["file"] = sprintf("%s.whois", $handler);
|
||||
$this->Query["handler"] = $handler;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// If top level domain not known, check availability in DNS
|
||||
if(checkdnsrr($query, "A")) {
|
||||
// Prepare to do lookup via the 'ipw' handler
|
||||
$ip = gethostbyname($query);
|
||||
$this->Query["server"] = "whois.arin.net";
|
||||
$this->Query["host_ip"] = $ip;
|
||||
$this->Query["file"] = "ipw.whois";
|
||||
$this->Query["handler"] = "ipw";
|
||||
$this->Query["string"] = $ip;
|
||||
$this->Query["tld"] = "ipw";
|
||||
|
||||
// If query was an IP, determine the hostname
|
||||
if ($query==$ip)
|
||||
$this->Query["host_name"] = gethostbyaddr($ip);
|
||||
else
|
||||
$this->Query["host_name"] = $query;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// If tld not known, and domain not in DNS, return error
|
||||
unset($this->Query["server"]);
|
||||
$this->Query["status"] = -1;
|
||||
$this->Query["errstr"][] = $this->Query["string"]." domain is not supported";
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Open a socket to the whois server.
|
||||
*
|
||||
* Returns a socket connection pointer on success, or -1 on failure.
|
||||
*/
|
||||
function Connect () {
|
||||
// Fail if server not set
|
||||
if(!isSet($this->Query["server"]))
|
||||
return(-1);
|
||||
|
||||
// Enter connection attempt loop
|
||||
$server = $this->Query["server"];
|
||||
$retry = 0;
|
||||
while($retry <= $this->RETRY) {
|
||||
// Set query status
|
||||
$this->Query["status"] = "ready";
|
||||
|
||||
// Connect to whois port
|
||||
$ptr = fsockopen($server, $this->PORT);
|
||||
if($ptr > 0) {
|
||||
$this->Query["status"]="ok";
|
||||
return($ptr);
|
||||
}
|
||||
|
||||
// Failed this attempt
|
||||
$this->Query["status"] = "error";
|
||||
$retry++;
|
||||
|
||||
// Sleep before retrying
|
||||
sleep($this->SLEEP);
|
||||
}
|
||||
|
||||
// If we get this far, it hasn't worked
|
||||
return(-1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Post-process result with handler class. On success, returns the result
|
||||
* from the handler. On failure, returns passed in result unaltered.
|
||||
*/
|
||||
function Process (&$result) {
|
||||
// Disable error reporting temporarily (probably not necessary)
|
||||
$old_val = error_reporting(FALSE);
|
||||
|
||||
// If the handler has not already been included somehow, include it now
|
||||
$HANDLER_FLAG = sprintf("__%s_HANDLER__", strtoupper($this->Query["handler"]));
|
||||
if(!defined($HANDLER_FLAG))
|
||||
include($this->Query["file"]);
|
||||
|
||||
// Restore error reporting
|
||||
error_reporting($old_val);
|
||||
|
||||
// If the handler has still not been included, append to query errors list and return
|
||||
if(!defined($HANDLER_FLAG)) {
|
||||
$this->Query["errstr"][] = "Can't find ".$this->Query["tld"]." handler: ".$this->Query["file"];
|
||||
return($result);
|
||||
}
|
||||
|
||||
// Pass result to handler
|
||||
$object = $this->Query["handler"];
|
||||
$handler = new $object($result, $this->Query);
|
||||
|
||||
// If handler returned an error, append it to the query errors list
|
||||
if(isSet($handler->Query["errstr"]))
|
||||
$this->Query["errstr"][] = $handler->Query["errstr"];
|
||||
|
||||
// Return the result
|
||||
return($handler->result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Perform lookup. Returns an array. The 'rawdata' element contains an
|
||||
* array of lines gathered from the whois query. If a top level domain
|
||||
* handler class was found for the domain, other elements will have been
|
||||
* populated too.
|
||||
*/
|
||||
function Lookup ($query = "") {
|
||||
// If domain to query passed in, use it, otherwise use domain from initialisation
|
||||
$string = !empty($query) ? $query : $this->Query["string"];
|
||||
|
||||
// If the '.cx' whois server is broken, return an error now (saves attempting and timing out)
|
||||
if($this->HACKS["cx_is_broken"] && $this->Query["tld"] == "cx") {
|
||||
$this->Query["errstr"][] = ".cx doesn't work. Turn off HACKS[\"cx_is_broken\"] if ".$this->Query["server"]." finally got fixed.";
|
||||
return("");
|
||||
}
|
||||
|
||||
// Connect to whois server, or return if failed
|
||||
$ptr = $this->Connect();
|
||||
if($ptr < 0) {
|
||||
$this->Query["status"] = -1;
|
||||
$this->Query["errstr"][] = "Connect failed to: ".$this->Query["server"];
|
||||
return(array());
|
||||
}
|
||||
|
||||
// Determining on server/hacks in operation, send appropriate request
|
||||
if(($this->Query["server"] == $this->NSI_REGISTRY || $this->Query["server"] == $this->NSI_REGISTRAR) && $this->HACKS["nsi_force_dom"]) {
|
||||
fputs($ptr, sprintf("dom %s\r\n", trim($string)));
|
||||
}
|
||||
elseif($this->Query["server"] == $this->HACKS["force_slash_e"]) {
|
||||
fputs($ptr, sprintf("%s/e\r\n", trim($string)));
|
||||
}
|
||||
else {
|
||||
fputs($ptr, sprintf("%s\r\n", trim($string)));
|
||||
}
|
||||
|
||||
// Prepare to receive result
|
||||
$raw = "";
|
||||
$output = array();
|
||||
while(!feof($ptr)) {
|
||||
// If a buffer size is set, fetch line-by-line into an array
|
||||
if($this->BUFFER)
|
||||
$output[] = fgets($ptr, $this->BUFFER);
|
||||
// If not, fetch char-by-char into a string
|
||||
else
|
||||
$raw .= fgetc($ptr);
|
||||
}
|
||||
|
||||
// If captured char-by-char, convert to an array of lines
|
||||
if(!$this->BUFFER)
|
||||
$output = explode("\n", $raw);
|
||||
|
||||
// Drop empty last line
|
||||
unset($output[count($output)-1]);
|
||||
|
||||
// Create result and set 'rawdata'
|
||||
$result = array();
|
||||
$result['rawdata'] = $output;
|
||||
|
||||
// If we have a handler, post-process it with that
|
||||
if(isSet($this->DATA[$this->Query["tld"]][1]))
|
||||
$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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
<?php
|
||||
|
||||
/*
|
||||
Whois2.php PHP classes to conduct whois queries
|
||||
|
||||
Copyright (C)1999,2000 easyDNS Technologies Inc. & Mark Jeftovic
|
||||
|
||||
Maintained by Mark Jeftovic <markjr@easydns.com>
|
||||
|
||||
For the most recent version of this package:
|
||||
|
||||
http://www.easydns.com/~markjr/whois2/
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
class Whois {
|
||||
// Full code and data version string (e.g. 'Whois2.php v3.01:16')
|
||||
var $VERSION;
|
||||
|
||||
// This release of the package
|
||||
var $CODE_VERSION = "3.0.1";
|
||||
|
||||
// Network Solutions registry server
|
||||
var $NSI_REGISTRY = "whois.nsiregistry.net";
|
||||
|
||||
// Network Solutions registrar server (?)
|
||||
var $NSI_REGISTRAR = "whois.networksolutions.com";
|
||||
|
||||
// Default WHOIS port
|
||||
var $PORT = 43;
|
||||
|
||||
// Maximum number of retries on connection failure
|
||||
var $RETRY = 0;
|
||||
|
||||
// Time to wait between retries
|
||||
var $SLEEP = 2;
|
||||
|
||||
// Read buffer size (0 == char by char)
|
||||
var $BUFFER = 0;
|
||||
|
||||
// Status response codes
|
||||
var $STAT = array(
|
||||
-1 => "error",
|
||||
0 => "ready",
|
||||
1 => "ok"
|
||||
);
|
||||
|
||||
// Array to contain all query variables
|
||||
var $Query = array(
|
||||
"tld" => "",
|
||||
"type" => "domain",
|
||||
"string" => "",
|
||||
"status",
|
||||
"server"
|
||||
);
|
||||
|
||||
// Various hacks. In a perfect world we don't need these.
|
||||
var $HACKS = array(
|
||||
// force "dom" keywork
|
||||
"nsi_force_dom" => 1,
|
||||
// set if nsiregistry gives wrong whois server for netsol
|
||||
"nsi_referral_loop" => 0,
|
||||
// ???
|
||||
"wrong_netsol_whois" => "rs.internic.net",
|
||||
// ???
|
||||
"real_netsol_whois" => "whois.networksolutions.com",
|
||||
// force english output on .jp for us ethnocentric types, unset or comment out for Japanese output
|
||||
"force_slash_e" => "whois.nic.ad.jp",
|
||||
// whois.nic.cx hangs forever
|
||||
"cx_is_broken" => 1
|
||||
);
|
||||
|
||||
// List of servers and handlers (loaded from servers.whois)
|
||||
var $DATA = array();
|
||||
|
||||
/*
|
||||
* Constructor function
|
||||
*/
|
||||
function Whois ($query = "") {
|
||||
// Load DATA array
|
||||
|
||||
require("servers.whois");
|
||||
|
||||
// Set version
|
||||
$this->VERSION = sprintf("Whois2.php v%s:%s", $this->CODE_VERSION, $this->DATA_VERSION);
|
||||
|
||||
// If domain to query was not set
|
||||
if(!isSet($query)) {
|
||||
// Configure to use default whois server
|
||||
$this->Query["server"] = $this->NSI_REGISTRY;
|
||||
return;
|
||||
}
|
||||
|
||||
// Set domain to query in query array
|
||||
$this->Query["string"] = strtolower($query);
|
||||
|
||||
// Determine top level whois server
|
||||
$tld = $this->GetTld($this->Query["string"]);
|
||||
if($tld) {
|
||||
// If found, set tld and whois server in query array
|
||||
$this->Query["server"] = $this->DATA[$tld][0];
|
||||
$this->Query["tld"] = $tld;
|
||||
|
||||
// If a handler exists for the tld
|
||||
if(isSet($this->DATA[$tld][1])) {
|
||||
// Set fle/handler in query array
|
||||
$handler = $this->DATA[$tld][1];
|
||||
$this->Query["file"] = sprintf("%s.whois", $handler);
|
||||
$this->Query["handler"] = $handler;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// If top level domain not known, check availability in DNS
|
||||
if(checkdnsrr($query, "A")) {
|
||||
// Prepare to do lookup via the 'ipw' handler
|
||||
$ip = gethostbyname($query);
|
||||
$this->Query["server"] = "whois.arin.net";
|
||||
$this->Query["host_ip"] = $ip;
|
||||
$this->Query["file"] = "ipw.whois";
|
||||
$this->Query["handler"] = "ipw";
|
||||
$this->Query["string"] = $ip;
|
||||
$this->Query["tld"] = "ipw";
|
||||
|
||||
// If query was an IP, determine the hostname
|
||||
if ($query==$ip)
|
||||
$this->Query["host_name"] = gethostbyaddr($ip);
|
||||
else
|
||||
$this->Query["host_name"] = $query;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// If tld not known, and domain not in DNS, return error
|
||||
unset($this->Query["server"]);
|
||||
$this->Query["status"] = -1;
|
||||
$this->Query["errstr"][] = $this->Query["string"]." domain is not supported";
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Open a socket to the whois server.
|
||||
*
|
||||
* Returns a socket connection pointer on success, or -1 on failure.
|
||||
*/
|
||||
function Connect () {
|
||||
// Fail if server not set
|
||||
if(!isSet($this->Query["server"]))
|
||||
return(-1);
|
||||
|
||||
// Enter connection attempt loop
|
||||
$server = $this->Query["server"];
|
||||
$retry = 0;
|
||||
while($retry <= $this->RETRY) {
|
||||
// Set query status
|
||||
$this->Query["status"] = "ready";
|
||||
|
||||
// Connect to whois port
|
||||
$ptr = fsockopen($server, $this->PORT);
|
||||
if($ptr > 0) {
|
||||
$this->Query["status"]="ok";
|
||||
return($ptr);
|
||||
}
|
||||
|
||||
// Failed this attempt
|
||||
$this->Query["status"] = "error";
|
||||
$retry++;
|
||||
|
||||
// Sleep before retrying
|
||||
sleep($this->SLEEP);
|
||||
}
|
||||
|
||||
// If we get this far, it hasn't worked
|
||||
return(-1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Post-process result with handler class. On success, returns the result
|
||||
* from the handler. On failure, returns passed in result unaltered.
|
||||
*/
|
||||
function Process (&$result) {
|
||||
// Disable error reporting temporarily (probably not necessary)
|
||||
$old_val = error_reporting(FALSE);
|
||||
|
||||
// If the handler has not already been included somehow, include it now
|
||||
$HANDLER_FLAG = sprintf("__%s_HANDLER__", strtoupper($this->Query["handler"]));
|
||||
if(!defined($HANDLER_FLAG))
|
||||
include($this->Query["file"]);
|
||||
|
||||
// Restore error reporting
|
||||
error_reporting($old_val);
|
||||
|
||||
// If the handler has still not been included, append to query errors list and return
|
||||
if(!defined($HANDLER_FLAG)) {
|
||||
$this->Query["errstr"][] = "Can't find ".$this->Query["tld"]." handler: ".$this->Query["file"];
|
||||
return($result);
|
||||
}
|
||||
|
||||
// Pass result to handler
|
||||
$object = $this->Query["handler"];
|
||||
$handler = new $object($result, $this->Query);
|
||||
|
||||
// If handler returned an error, append it to the query errors list
|
||||
if(isSet($handler->Query["errstr"]))
|
||||
$this->Query["errstr"][] = $handler->Query["errstr"];
|
||||
|
||||
// Return the result
|
||||
return($handler->result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Perform lookup. Returns an array. The 'rawdata' element contains an
|
||||
* array of lines gathered from the whois query. If a top level domain
|
||||
* handler class was found for the domain, other elements will have been
|
||||
* populated too.
|
||||
*/
|
||||
function Lookup ($query = "") {
|
||||
// If domain to query passed in, use it, otherwise use domain from initialisation
|
||||
$string = !empty($query) ? $query : $this->Query["string"];
|
||||
|
||||
// If the '.cx' whois server is broken, return an error now (saves attempting and timing out)
|
||||
if($this->HACKS["cx_is_broken"] && $this->Query["tld"] == "cx") {
|
||||
$this->Query["errstr"][] = ".cx doesn't work. Turn off HACKS[\"cx_is_broken\"] if ".$this->Query["server"]." finally got fixed.";
|
||||
return("");
|
||||
}
|
||||
|
||||
// Connect to whois server, or return if failed
|
||||
$ptr = $this->Connect();
|
||||
if($ptr < 0) {
|
||||
$this->Query["status"] = -1;
|
||||
$this->Query["errstr"][] = "Connect failed to: ".$this->Query["server"];
|
||||
return(array());
|
||||
}
|
||||
|
||||
// Determining on server/hacks in operation, send appropriate request
|
||||
if(($this->Query["server"] == $this->NSI_REGISTRY || $this->Query["server"] == $this->NSI_REGISTRAR) && $this->HACKS["nsi_force_dom"]) {
|
||||
fputs($ptr, sprintf("dom %s\r\n", trim($string)));
|
||||
}
|
||||
elseif($this->Query["server"] == $this->HACKS["force_slash_e"]) {
|
||||
fputs($ptr, sprintf("%s/e\r\n", trim($string)));
|
||||
}
|
||||
else {
|
||||
fputs($ptr, sprintf("%s\r\n", trim($string)));
|
||||
}
|
||||
|
||||
// Prepare to receive result
|
||||
$raw = "";
|
||||
$output = array();
|
||||
while(!feof($ptr)) {
|
||||
// If a buffer size is set, fetch line-by-line into an array
|
||||
if($this->BUFFER)
|
||||
$output[] = fgets($ptr, $this->BUFFER);
|
||||
// If not, fetch char-by-char into a string
|
||||
else
|
||||
$raw .= fgetc($ptr);
|
||||
}
|
||||
|
||||
// If captured char-by-char, convert to an array of lines
|
||||
if(!$this->BUFFER)
|
||||
$output = explode("\n", $raw);
|
||||
|
||||
// Drop empty last line
|
||||
unset($output[count($output)-1]);
|
||||
|
||||
// Create result and set 'rawdata'
|
||||
$result = array();
|
||||
$result['rawdata'] = $output;
|
||||
|
||||
// If we have a handler, post-process it with that
|
||||
if(isSet($this->DATA[$this->Query["tld"]][1]))
|
||||
$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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -116,6 +116,7 @@ class utils extends Whois {
|
|||
|
||||
function debugObject($obj,$indent=0) {
|
||||
if (is_Array($obj) || is_Object($obj)) {
|
||||
$return = "";
|
||||
while (list($k,$v)=each($obj)) {
|
||||
for ($i=0;$i<$indent;$i++) {
|
||||
$return .= " ";
|
||||
|
|
Loading…
Reference in a new issue