checkdnsrr() returns wrong info

不想你离开。 提交于 2019-12-30 07:49:21

问题


$dname = "accurst.com";
$recordexists = checkdnsrr($dname, "ANY");

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

this is an example domain that returns the wrong info. It says its available but the domain is a premium domain name of 2800 dollars is there any way for it to show that it's not available since it is not untied to anyone? in other words if I look up: accurstttt.com now that's available and accurst.com should say : not available i tried different other domain names and it keeps showing they are available while they are premium. any input would be very helpful thank you


回答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:


Unfortunately the function:

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

So "no result" does not really mean anything decisive.

I would also look for A and CNAME records, for example:

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

prints 1



来源:https://stackoverflow.com/questions/15195396/checkdnsrr-returns-wrong-info

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!