Показать сообщение отдельно
  #14  
Старый 22.05.2006, 18:43
dualhost dualhost вне форума
Дипломник
 
Регистрация: 22.05.2006
Сообщений: 27
По умолчанию

Продолжение whois.php

var $TLD;
var
$RAWINFO;
var
$DNSINFO;
//обращение к WHOIS серверу
function connect ($server)
{
while(
$this->RETRY <= $this->MAX_RETRIES)
{
$ptr=fsockopen($server, $this->port);
if(
$ptr>0)
{
$this->ERROR=0;
return(
$ptr);
}else
{
$this->ERROR++;
$this->RETRY++;
sleep($this->SLEEP_VAL);
}
}
}

//Получает данные и загружает их в массив
function rawlookup ($query)
{
$array=array();
$this->FOUND=1;
$query=strtolower(trim($query));
if(
strlen($query)<=2)
{
$this->ERROR=1;
return(
$array);
}
//устанавливаем сервер по умолчанию
$server=$this->DEFAULT_SERVER;
//пытаемся переназначить его
if($this->QUERY_TYPE=="domain")
{
ereg(".+\.(.+)\.{0,1}",$query,$backrefs);
if(isset(
$backrefs[1]) && strlen($backrefs[1])>0 && isset($this->SERVER[$backrefs[1]]))
{
$this->TLD=$backrefs[1];
$server=$this->SERVER[$this->TLD];
}

}
$ptr=$this->connect($server);
if(
$ptr)
{
$query .= "\n";
fputs($ptr, $query);
$i=0;
while(!
feof($ptr))
{
$array[$i]=fgets($ptr,$this->MAXLEN);
$this->DATA_COUNT+=strlen(trim($array[$i]));
if(
eregi("No match for", $array[$i]) || eregi("Not found", $array[$i]) || eregi("No entries found for", $array[$i]))
{
$this->FOUND=0;
break;
}
if(
eregi("WHOIS database is down",$array[$i]) || eregi("Please wait a while and try again",$array[$i]))
{
$this->ERROR=1;
$this->FOUND=0;
break;
}
$i++;
}
fclose($ptr);
if(
$this->DATA_COUNT>$this->DATA_MIN && $this->ERROR==0 && $this->FOUND==1)
{
return(
$array);
}
}
//в случае ошибки возвращаем пустой массив
return (array());
}


// парсинг результатов
function parsezone ($array)
{
$result=array();
if(!isset(
$array) || !is_array($array) || count($array)<=3)
{
$this->FOUND=0;
return
$result;
}
$cnt=count($array);
$rescnt=0;
$i=0;
$isinfo=true;
while(
$i<$cnt)
{
if(!
$isinfo)
{
$str=trim($array[$i]);
$result[$rescnt]=$str;
//Извлекаем настройки DNS
if(eregi("NAME SERVER", $str) || eregi("NSERVER", $str))
{
$str=trim(substr($str, strpos($str, ":")+1));
if(
$pos=strpos($str, " "))
{
$str=substr($str, 0, $pos);
}
if(
substr($str, -1)==".")
{
$str=substr($str, 0, -1);
}
$this->DNS_NAME[]=strtolower($str);
}
$rescnt++;
}
if(
trim($array[$i])=="" && $isinfo)
{
$isinfo=false;
}
$i++;
}
return
$result;
}

function
zonelookup ($query)
{
$query=trim($query);
$this->RAWINFO=$this->rawlookup($query);
if(
$this->FOUND)
{
$this->RAWINFO=$this->parsezone($this->RAWINFO);
}
if(
$this->FOUND==0)
{
return;
}
if(
$this->dns_lookup($query))
{
$this->IP=gethostbyname($query);
$this->build_dns($query);
}
}

function
build_dns($query)
{
$cnt=0;
// $temp=dns_get_record($query, "NS");
foreach($this->DNS_NAME AS $dns)
{
$this->DNSINFO[$cnt]="NS: ".$dns."\tinternet address = ".gethostbyname($dns);
$cnt++;
}
if(
getmxrr($query, $temp))
{
foreach(
$temp AS $dns)
{
$this->DNSINFO[$cnt]="MX: ".$dns."\tinternet address = ".gethostbyname($dns);
$cnt++;
}
}

}
function
dns_lookup($query)
{
return
checkdnsrr($query,"ANY");
}


};

?>
__________________
Верные слова неизящны, изящные слова неверны
Хостинг
Ответить с цитированием