【问题标题】:checkdnsrr() returns wrong infocheckdnsrr() 返回错误信息
【发布时间】:2013-03-04 05:53:10
【问题描述】:
$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 应该说:不可用 我尝试了其他不同的域名,它一直显示它们在高级时可用。任何意见都会非常有帮助,谢谢

【问题讨论】:

  • 您的服务器是基于 linux 的服务器吗?你能运行 exec 命令吗?
  • 是的,我可以,而且它是基于 linux 的

标签: php dns


【解决方案1】:
<?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';

?>

【讨论】:

    【解决方案2】:

    不幸的是函数:

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

    所以“没有结果”并不意味着任何决定性的事情。

    我还会查找 A 和 CNAME 记录,例如:

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

    打印 1

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-12-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-21
    • 2023-04-03
    • 1970-01-01
    相关资源
    最近更新 更多