Posted 29/06/2009, 16:13
tenta aew
esse e um simples:
[codebox]<?
function lookup($domain)
{
exec("host -t ns $domain",$hasil);
if (ereg("host not found.",strtolower(trim($hasil[0]))))
// It possible only 1 ns or not found
{
return false;
} else
{
$hasilstr="";
for ($i=0;$i<=count($hasil);$i++)
{
$hasilstr.=ereg_replace("$domain name server","<LI>",$hasil[$i])."<BR>";
}
return $hasilstr;
}
}
?>
[/codebox]
Mais completo:
[codebox]
<?php
class domain_finder
{
var $alternative_tlds=array("com","co.uk","me.uk","ws","org","org.uk","net","net.uk");
var $head_tags=array("<h2>","</h2>");
var $result;
function domain_finder($domain="")
{
if ($domain=="") return true;
$cleaned_domain=$this->clean($domain);
$buf=$this->head_tags[0].$this->domain_exists_pretty_print($cleaned_domain).$this->head_tags[1];
$buf.=$this->check_alternative_domains($cleaned_domain);
$this->result=$buf;
}
function domain_exists_pretty_print($domain)
{
$buf="$domain is ";
if ($result=$this->domain_exists($domain)) $buf.= "not ";
$buf.="available.";
return $buf;
}
function domain_exists($domain)
{
exec("host -t ns $domain",$host_result);
if (preg_match("/host.*not found/",strtolower($host_result[0]))) return false;
return true;
}
function check_alternative_domains($domain)
{
$buf="<p>Alternative domains:</p>\r\n<ul>\r\n";
$d=substr($domain,0,strpos($domain,".")+1); //remove everything after last .
foreach($this->alternative_tlds as $tld)
$buf.="<li>".$this->domain_exists_pretty_print($d.$tld)."</li>";
$buf.="</ul>";
return $buf;
}
function clean($domain)
{
$buf=strtolower($domain);
//remove leading www.
if (preg_match("/^www\./",$domain)) $buf=substr($buf,4);
return $buf;
}
}
?>[/codebox]