2013-03-04 129 views
0
$dname = "accurst.com"; 
$recordexists = checkdnsrr($dname, "ANY"); 

if ($recordexists) 
    echo $dname." is taken. Sorry!<br>"; 
else 
    echo $dname." is available!<br>"; 

这是返回错误信息的示例域。它说它的可用但 该域名是一个2800美元的高级域名 有没有什么方法可以表明它不可用,因为它没有解开任何人? 换句话说,如果我抬头:accurstttt.com现在可用 和accurst.com应该说:不可用 我尝试了不同的其他域名,它不断显示他们可用,而他们是溢价。任何投入将是非常有帮助谢谢checkdnsrr()返回错误信息

+0

是您的服务器Linux的服务器?你可以运行exec命令吗? – MIIB 2013-03-04 06:18:03

+0

是的,我可以和它的基于Linux的 – cppit 2013-03-04 16:43:47

回答

2
<?php 

function checkDomainAvailability($domain_name){ 

$server = 'whois.crsnic.net'; 

// Open a socket connection to the whois server 
$connection = fsockopen($server, 43); 
if (!$connection) return false; 

// Send the requested doman name 
fputs($connection, $domain_name."\r\n"); 

// Read and store the server response 
$response_text = ' :'; 
while(!feof($connection)) { 
$response_text .= fgets($connection,128); 
} 

// Close the connection 
fclose($connection); 

// Check the response stream whether the domain is available 
if (strpos($response_text, 'No match for')) return true; 
else return false; 
} 


$domainname = 'accurst.com'; 

if(checkDomainAvailability($domainname)) echo 'Domain : '.$domainname.' is Available'; 
else echo 'Domain : '.$domainname.' is Already Taken'; 

?> 
1

不幸的功能:

returns FALSE if no records were found or if an error occurred. 

所以“没有结果”并不真正意味着什么决定性的。

我还要找一个和CNAME记录,例如:

$dname = "accurst.com"; 
echo checkdnsrr($dname, "A"); 

打印1

+0

任何其他方式来找出一个域是否可用? – cppit 2013-03-04 06:08:35

+0

您可能会尝试直接查询whois服务。由于传播速度,它仍然不可能100%准确。例如:http://stackoverflow.com/questions/36817/who-provides-a-whois-api – 2013-03-04 16:13:01