checkdnsrr() returns wrong info

前端 未结 2 1589
时光取名叫无心
时光取名叫无心 2021-01-07 14:39
$dname = \"accurst.com\";
$recordexists = checkdnsrr($dname, \"ANY\");

if ($recordexists) 
  echo $dname.\" is taken. Sorry!
\"; else echo $dname.\" is
相关标签:
2条回答
  • 2021-01-07 15:10
    <?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';
    
    ?>
    
    0 讨论(0)
  • 2021-01-07 15:11

    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

    0 讨论(0)
提交回复
热议问题