Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Потрепаться";
Текущий архив: 2003.12.19;
Скачать: [xml.tar.bz2];

Вниз

Если Мастера Delphi не могут дать ответа по Delphi,будут про PHP   Найти похожие ветки 

 
undert   (2003-11-23 17:35) [0]

1. Кто может подсказать Whois сервер (именно сервер, а не форму в WWW), который поддерживает домены .ru, .net, .org, .spb.ru, .msk.ru и т.д.
2. Дайте плиз пример оптимального кода для Whois на PHP. Мой, вернее которым я пользуюсь, виснет, если проверять более 5 доменов за раз:
<?
class domain{
var $domain="";

/*******************************
* Initializing server variables
* array(top level domain,whois_Server,not_found_string or MAX number of CHARS: MAXCHARS:n)
**/
var $servers=array(
array("biz","whois.biz","Not found"),
array("com","whois.verisign-grs.net","No match"),
array("com.ru","whois.ripn.ru","No entries found"),
array("fi","whois.ripe.net","No entries found"),
array("msk.ru","whois.relcom.ru","entries found"),
array("net","whois.verisign-grs.net","No match"),
array("net.au","whois.aunic.net","No Data Found"),
array("net.br","whois.nic.br","No match"),
array("ru","whois.ripn.ru","No entries found"),
);

/**
* Constructor of class domain
* @param string $str_domainame the full name of the domain
* @desc Constructor of class domain
*/
function domain($str_domainname){
$this->domain=$str_domainname;
}

/**
* Returns the whois data of the domain
* @return string $whoisdata Whois data as string
* @desc Returns the whois data of the domain
*/
function info(){
if($this->is_valid()){

$tldname=$this->get_tld();
$domainname=$this->get_domain();
$whois_server=$this->get_whois_server();

// If tldname have been found
if($whois_server!=""){
// Getting whois information
$fp = fsockopen($whois_server,43);

$dom=$domainname.".".$tldname;
fputs($fp, "$dom\r\n");

// Getting string
$string="";
while(!feof($fp)){
$string.=fgets($fp,128);
}
fclose($fp);
return $string;
}else{
return "No whois server for this tld in list!";
}
}else{
return "Domainname isn"t valid!";
}
}

/**
* Returns the whois data of the domain in HTML format
* @return string $whoisdata Whois data as string in HTML
* @desc Returns the whois data of the domain in HTML format
*/
function html_info(){
return nl2br($this->info());
}

/**
* Returns name of the whois server of the tld
* @return string $server the whois servers hostname
* @desc Returns name of the whois server of the tld
*/
function get_whois_server(){
$found=false;
$tldname=$this->get_tld();
for($i=0;$i<count($this->servers);$i++){
if($this->servers[$i][0]==$tldname){
$server=$this->servers[$i][1];
$full_dom=$this->servers[$i][3];
$found=true;
}
}
return $server;
}

/**
* Returns the tld of the domain without domain name
* @return string $tldname the tlds name without domain name
* @desc Returns the tld of the domain without domain name
*/
function get_tld(){
// Splitting domainname
$domain=split("\.",$this->domain);
if(count($domain)>2){
$domainname=$domain[0];
for($i=1;$i<count($domain);$i++){
if($i==1){
$tldname=$domain[$i];
}else{
$tldname.=".".$domain[$i];
}
}
}else{
$domainname=$domain[0];
$tldname=$domain[1];
}
return $tldname;
}

/**
* Returns all tlds which are supported by the class
* @return array $tlds all tlds as array
* @desc Returns all tlds which are supported by the class
*/
function get_tlds(){
$tlds="";
for($i=0;$i<count($this->servers);$i++){
$tlds[$i]=$this->servers[$i][0];
}
return $tlds;
}

/**
* Returns the name of the domain without tld
* @return string $domain the domains name without tld name
* @desc Returns the name of the domain without tld
*/
function get_domain(){
// Splitting domainname
$domain=split("\.",$this->domain);
return $domain[0];
}

/**
* Returns the string which will be returned by the whois server of the tld if a domain is avalable
* @return string $notfound the string which will be returned by the whois server of the tld if a domain is avalable
* @desc Returns the string which will be returned by the whois server of the tld if a domain is avalable
*/
function get_notfound_string(){
$found=false;
$tldname=$this->get_tld();
for($i=0;$i<count($this->servers);$i++){
if($this->servers[$i][0]==$tldname){
$notfound=$this->servers[$i][2];
}
}
return $notfound;
}

/**
* Returns if the domain is available for registering
* @return boolean $is_available Returns 1 if domain is available and 0 if domain isn"t available
* @desc Returns if the domain is available for registering
*/
function is_available(){
$whois_string=$this->info(); // Gets the entire WHOIS query from registrar
$not_found_string=$this->get_notfound_string(); // Gets 3rd item from array
$domain=$this->domain; // Gets current domain being queried

$whois_string2=ereg_replace("$domain","",$whois_string);

$whois_string = preg_replace("/\s+/"," ",$whois_string); //Replace whitespace with single space

$array=split(":",$not_found_string);

if($array[0]=="MAXCHARS"){
if(strlen($whois_string2)<=$array[1]){
return true;
}else{
return false;
}
}else{
if(preg_match("/".$not_found_string."/i",$whois_string)){
return true;
}else{
return false;
}
}
}


/**
* Returns if the domain name is valid
* @return boolean $is_valid Returns 1 if domain is valid and 0 if domain isn"t valid
* @desc Returns if the domain name is valid
*/
function is_valid(){
if(ereg("^[a-zA-Z0-9\-]{3,}$",$this->get_domain()) && !preg_match("/--/",$this->get_domain())){
return true;
}else{
return false;
}
}
}
?>


 
SkyRanger   (2003-11-24 03:49) [1]

Не нада быть таким жадным... Наверняка он начинает ждать тайм аута от 5 серверов вот и виснет...
Или же проверяй менее 5 за раз, по порядку, PHP енто позоляет, а потом выводи результат общий...
PHP тебе все таки не CGI он интерпретирует код под одним процессом, так что надо ему скармливать данные по порядку и не перегружать...
Эффективне будет все енто на CGI написать тоды летать будет, а PHP он в основном язык для верстки RUN-time так что надо иметь это в виду коды пишешь и подстраиваться под реалии...


 
ИМХО   (2003-11-24 04:53) [2]

Удалено модератором
Примечание: Offtopic


 
имя   (2003-11-24 11:46) [3]

Удалено модератором
Примечание: Предупреждение тебе.


 
Undert   (2003-11-24 15:51) [4]

А за что ему предупреждение ?


 
Undert   (2003-11-24 15:52) [5]

По вышеуказанному - любопытно о чём написал


> Эффективне будет все енто на CGI написать тоды летать будет,
> а PHP он в основном язык для верстки RUN-time так что надо
> иметь это в виду коды пишешь и подстраиваться под реалии...


Нету возможности использовать цги, только пхп.
Должен же буть сервер, который содержит хуиз по большенству зон...



Страницы: 1 вся ветка

Форум: "Потрепаться";
Текущий архив: 2003.12.19;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.47 MB
Время: 0.011 c
1-62103
Санек
2003-12-08 13:39
2003.12.19
компонент Tanimate


3-61989
2511
2003-11-25 15:51
2003.12.19
альтернатива файла *.cdbf для delphi


3-61960
gestern
2003-11-27 01:33
2003.12.19
IBQuery и IBUpdateSQL


1-62135
MCFire
2003-12-07 21:00
2003.12.19
Как достучаться до динамической формы???


1-62086
lena19
2003-12-08 23:50
2003.12.19
перезапуск компа





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский