phpWhois.org/denic.whois
2002-10-11 12:54:55 +00:00

146 lines
4.2 KiB
Text

<?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);
}
}