also check for network nserver

This commit is contained in:
sparc 2008-09-07 09:00:12 +00:00
parent aafbf006f8
commit 482a2aa512
4 changed files with 84 additions and 62 deletions

View file

@ -527,4 +527,54 @@ class WhoisClient {
return $a1;
}
function FixNameServer($nserver)
{
$dns = array();
foreach($nserver as $val)
{
$val = str_replace( array('[',']','(',')'), '', trim($val));
$val = str_replace("\t", ' ', $val);
$parts = explode(' ', $val);
$host = '';
$ip = '';
foreach($parts as $p)
{
if (substr($p,-1) == '.') $p = substr($p,0,-1);
if ((ip2long($p) == - 1) or (ip2long($p) === false))
{
// Hostname ?
if ($host == '' && preg_match('/^[\w\-]+(\.[\w\-]+)+$/',$p))
{
$host = $p;
}
}
else
// IP Address
$ip = $p;
}
// Valid host name ?
if ($host == '') continue;
// Get ip address
if ($ip == '')
{
$ip = gethostbyname($host);
if ($ip == $host) $ip = '(DOES NOT EXIST)';
}
if (substr($host,-1,1) == '.') $host = substr($host,0,-1);
$dns[strtolower($host)] = $ip;
}
return $dns;
}
}

View file

@ -336,6 +336,16 @@ class ip_handler extends WhoisClient
else
$result['regyinfo']['type'] = 'ip';
if (isset($result['regrinfo']['network']['nserver']))
{
if (!is_array($result['regrinfo']['network']['nserver']))
{
unset($result['regrinfo']['network']['nserver']);
}
else
$result['regrinfo']['network']['nserver'] = $this->FixNameServer($result['regrinfo']['network']['nserver']);
}
return $result;
}

View file

@ -266,7 +266,6 @@ class Whois extends WhoisClient
*/
function FixResult(&$result, $domain)
{
// Add usual fields
$result['regrinfo']['domain']['name'] = $domain;
@ -285,62 +284,17 @@ class Whois extends WhoisClient
$result['regrinfo']['registered'] = 'unknown';
}
if (!isset($result['regrinfo']['domain']['nserver'])) return;
// Normalize nameserver fields
$nserver = $result['regrinfo']['domain']['nserver'];
if (!is_array($result['regrinfo']['domain']['nserver']))
if (isset($result['regrinfo']['domain']['nserver']))
{
unset($result['regrinfo']['domain']['nserver']);
return ;
}
$dns = array();
foreach($nserver as $val)
{
$val = str_replace( array('[',']','(',')'), '', trim($val));
$val = str_replace("\t", ' ', $val);
$parts = explode(' ', $val);
$host = '';
$ip = '';
foreach($parts as $p)
if (!is_array($result['regrinfo']['domain']['nserver']))
{
if (substr($p,-1) == '.') $p = substr($p,0,-1);
if ((ip2long($p) == - 1) or (ip2long($p) === false))
{
// Hostname ?
if ($host == '' && preg_match('/^[\w\-]+(\.[\w\-]+)+$/',$p))
{
$host = $p;
}
}
else
// IP Address
$ip = $p;
unset($result['regrinfo']['domain']['nserver']);
}
// Valid host name ?
if ($host == '') continue;
// Get ip address
if ($ip == '')
{
$ip = gethostbyname($host);
if ($ip == $host) $ip = '(DOES NOT EXIST)';
}
if (substr($host,-1,1) == '.') $host = substr($host,0,-1);
$dns[strtolower($host)] = $ip;
else
$result['regrinfo']['domain']['nserver'] = $this->FixNameServer($result['regrinfo']['domain']['nserver']);
}
$result['regrinfo']['domain']['nserver'] = $dns;
}
}

View file

@ -172,20 +172,28 @@ class utils extends Whois {
$link = $_SERVER['PHP_SELF'].'?'.$params;
$out = preg_replace ($ip_regex, '<a href="'.$link.'">$0</a>', $out);
if (isset($result['regrinfo']['domain']['nserver']))
{
$nserver = $result['regrinfo']['domain']['nserver'];
if (is_array($nserver))
}
else
$nserver = false;
if (isset($result['regrinfo']['network']['nserver']))
{
$nserver = $result['regrinfo']['network']['nserver'];
}
if (is_array($nserver))
{
print_r($nserver);
reset($nserver);
while (list($host, $ip) = each($nserver))
{
reset($nserver);
while (list($host, $ip) = each($nserver))
{
$url = '<a href="'. str_replace('$0',$ip,$link)."\">$host</a>";
$out = str_replace($host, $url, $out);
$out = str_replace(strtoupper($host), $url, $out);
}
$url = '<a href="'. str_replace('$0',$ip,$link)."\">$host</a>";
$out = str_replace($host, $url, $out);
$out = str_replace(strtoupper($host), $url, $out);
}
}
}