whois php (ricerca domini)
-
Salve a tutti,
ho un problema d porvi.
Stavo provando uno script whois per testare se varie estensioni di domini sono libere o meno.
Ecco il codice:<?php $whois_server = $_GET['whois_server']; include("server_list.php"); include("whois_class.php"); $my_whois = new Whois_domain; $my_whois->possible_tlds = array_keys($servers); // this is the array from the included server list if (isset($_POST['submit'])) { $my_whois->tld = $_POST['tld']; $my_whois->domain = $_POST['domain']; $my_whois->free_string = $servers[$_POST['tld']]['free']; $my_whois->whois_server = $servers[$_POST['tld']]['address']; $my_whois->whois_param = $servers[$_POST['tld']]['param']; if ($my_whois->process()) { } } ?> <?php echo ($my_whois->msg != "") ? $my_whois->msg : ""; ?>con la classe associata (whois_class.php):
<?php class Whois_domain { var $possible_tlds; var $whois_server; var $free_string; var $whois_param; var $domain; var $tld; var $compl_domain; var $full_info; var $msg; var $info; var $os_system = "linux"; // switch between "linux" and "win" function Whois_domain() { $this->info = ""; $this->msg = ""; } function process() { if ($this->create_domain()) { if ($this->full_info == "yes") { $this->get_domain_info(); } else { if ($this->check_only() == 1) { $this->msg = "<center><font face=\"Verdana\" size=\"2\" color=\"#000000\">Il dominio: <b>".$this->compl_domain."</b> è libero per procedere alla registrazione: <a href=\"ordini.php?dominio=".$this->compl_domain."\"><strong>clicca qui</strong></a>"; return true; } elseif ($this->check_only() == 0) { $this->msg = "<center>SPIACENTE - Il dominio: <b>".$this->compl_domain."</b> è già stato registrato<br><br><strong>cerca un altro dominio</strong></font></center>"; return false; } else { $this->msg = "Riprova"; } } } else { $this->msg = "<center>Solo lettere, numeri e il carattere - sono utilizzabili!</center>"; }ed il file server_list.php:
<?php $servers['it']['address'] = "whois.nic.it"; $servers['it']['free'] = "No entries found"; $servers['it']['param'] = ""; $servers['com']['address'] = "whois.crsnic.net"; $servers['com']['free'] = "No match for"; $servers['com']['param'] = ""; $servers['net']['address'] = "whois.crsnic.net"; $servers['net']['free'] = "No match for"; $servers['net']['param'] = ""; $servers['org']['address'] = "whois.pir.org"; $servers['org']['free'] = "NOT FOUND"; $servers['org']['param'] = ""; $servers['eu']['address'] = "Whois.eu"; $servers['eu']['free'] = "FREE"; $servers['eu']['param'] = ""; $servers['biz']['address'] = "whois.nic.biz"; $servers['biz']['free'] = "Not found"; $servers['biz']['param'] = ""; $servers['info']['address'] = "whois.afilias.net"; $servers['info']['free'] = "NOT FOUND"; $servers['info']['param'] = ""; $servers['gs']['address'] = "whois.adamsnames.tc"; $servers['gs']['free'] = "not registered"; $servers['gs']['param'] = ""; ?>Funziona tutto correttamente tranne che la ricerca dei domini .IT che indica sempre occupati (anche se non lo sono).
Ho provato a contrallare il server whois, ma mi sembra corretto: whois.nic.it
Attendo gentilmente una vostra risposta.
Grazie e buona giornata a tutti
-
Ciao Helpinweb,
purtroppo in quanto hai postato non vedo la definizione completa delle classi: ad esempio chi sono create_domain() e check_only()? Così è difficile capire dov'è il problema. Comunque per il NIC ti conviene utilizzare il server das.nic.it sulla porta 43, che so per certo funzionare bene...
Facci sapere se e come risolvi!

-
Grazie intanto per la risposta

Ho provato con das.nic.it ma non va comunque.Ti allego l'intera classe, così ci capiamo bene:
<?php class Whois_domain { var $possible_tlds; var $whois_server; var $free_string; var $whois_param; var $domain; var $tld; var $compl_domain; var $full_info; var $msg; var $info; var $os_system = "linux"; // switch between "linux" and "win" function Whois_domain() { $this->info = ""; $this->msg = ""; } function process() { if ($this->create_domain()) { if ($this->full_info == "yes") { $this->get_domain_info(); } else { if ($this->check_only() == 1) { $this->msg = "<center><font face=\"Verdana\" size=\"2\" color=\"#000000\">Il dominio: <b>".$this->compl_domain."</b> è libero per procedere alla registrazione: <a href=\"ordini.php?dominio=".$this->compl_domain."\"><strong>clicca qui</strong></a>"; return true; } elseif ($this->check_only() == 0) { $this->msg = "<center>SPIACENTE - Il dominio: <b>".$this->compl_domain."</b> è già stato registrato<br><br><strong>cerca un altro dominio</strong></font></center>"; return false; } else { $this->msg = "Riprova"; } } } else { $this->msg = "<center>Solo lettere, numeri e il carattere - sono utilizzabili!</center>"; } } function check_entry() { if (preg_match("/^([A-Za-z0-9]+(\-?[A-za-z0-9]*)){2,63}$/", $this->domain)) { return true; } else { return false; } } function create_tld_select() { $menu = "<select name=\"tld\" style=\"margin-left:0;\">\n"; foreach ($this->possible_tlds as $val) { $menu .= " <option value=\"".$val."\""; $menu .= (isset($_POST['tld']) && $_POST['tld'] == $val) ? " selected>" : ">"; $menu .= $val."\n"; } $menu .= "</select>\n"; return $menu; } function create_domain() { if ($this->check_entry()) { $this->domain = strtolower($this->domain); $this->compl_domain = $this->domain.".".$this->tld; return true; } else { return false; } } function check_only() { $data = $this->get_whois_data(); if (is_array($data)) { $found = 0; foreach ($data as $val) { if (eregi($this->free_string, $val)) { $found = 1; } } return $found; } else { $this->msg = "Errore, riprova."; } } function get_domain_info() { if ($this->create_domain()) { $data = ($this->tld == "nl") ? $this->get_whois_data(true) : $this->get_whois_data(); if (is_array($data)) { foreach ($data as $val) { if (eregi($this->free_string, $val)) { $this->msg = "The domain name: <b>".$this->compl_domain."</b> is free."; $this->info = ""; break; } $this->info .= $val; } } else { $this->msg = "Errore, riprova."; } } else { $this->msg = "Solo lettere, numeri e il carattere - sono utilizzabili!"; } } function get_whois_data($empty_param = false) { // the parameter is new since version 1.20 and is used for .nl (dutch) domains only if ($empty_param) { $this->whois_param = ""; } if ($this->tld == "de") $this->os_system = "win"; // this tld must be queried with fsock otherwise it will not work if ($this->os_system == "win") { $connection = @fsockopen($this->whois_server, 43); if (!$connection) { unset($connection); $this->msg = "Problemi nella connessione al server!"; return; } else { sleep(2); fputs($connection, $this->whois_param.$this->compl_domain."\r\n"); while (!feof($connection)) { $buffer[] = fgets($connection, 4096); } fclose($connection); } } else { $string = "whois -h ".$this->whois_server." \"".$this->whois_param.$this->compl_domain."\""; exec($string, $buffer); } if (isset($buffer)) { //print_r($buffer); return $buffer; } else { $this->msg = "Problemi nella connessione al server!"; } } } ?>Grazie ancora

Saluti. -
-
Ciao! Sembra che tu sia interessato a questa conversazione, ma non hai ancora un account.
Stanco di dover scorrere gli stessi post a ogni visita? Quando registri un account, tornerai sempre esattamente dove eri rimasto e potrai scegliere di essere avvisato delle nuove risposte (tramite email o notifica push). Potrai anche salvare segnalibri e votare i post per mostrare il tuo apprezzamento agli altri membri della comunità.
Con il tuo contributo, questo post potrebbe essere ancora migliore 💗
Registrati Accedi