Re-applied David's patch, with some indentation/formatting updates

This commit is contained in:
rossigee 2003-01-17 06:54:50 +00:00
parent c0ec792a9a
commit b3d314b323

View file

@ -37,110 +37,74 @@ if(!defined("__DENIC_HANDLER__")) define("__DENIC_HANDLER__",1);
class denic extends Whois { class denic extends Whois {
function denic($data) { function denic($data) {
$this->result=$this->parse($data); $this->result = $this->parse($data);
} }
function parse ($data_str) { function parse ($data_str) {
$items=array( $convert = array(
"domain" => "domain:", "domain" => "name",
"status" => "status:", "descr" => "desc",
"registrar" => "prov:" "type" => "",
"city" => "address",
"pcode" => "address",
"country" =if (is_array($disclaimer)) $ret["disclaimer"]=$disclaimer;> "address"
); );
$r["rawdata"] = $data_str["rawdata"]; $r = array();
$r["regyinfo"] = array( $newblock = false;
"whois"=>"whois.denic.de" $hasdata = false;
); $block = array();
$gkey = "main";
$r["regrinfo"] = array(); while (list($key,$val) = each($rawdata)) {
$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); $val = trim($val);
if ($val!="") { if (substr($val,0,1) == '%') {
if ((substr($val,0,5) == "descr") && (!$address_ok)) { $disclaimer[] = trim(substr($val,1));
$address_line = 1; continue;
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;
}
}
} }
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;
}
} }
$r["regyinfo"]["address"] = $r["regrinfo"]["owner"]["address"]; if ($hasdata)
$r["regyinfo"]["domain"] = $r["regrinfo"]["domain"]; $blocks[$gkey] = $block;
$r["regyinfo"]["nserver"] = $r["regrinfo"]["ns"];
$r = $blocks;
//if (is_array($disclaimer)) $r["disclaimer"]=$disclaimer;
return($r); return($r);
} }
} }