关于.hk和其他人的域名检查程序

时间:2013-07-08 11:02:46

标签: php javascript dns

我正在尝试使用以下的.hk,.com.hk etch进行域检查。它适用于.com,.net,但不适用于.hk等。请告诉我哪里出错了。你的帮助将非常感激。 我收到以下错误: 警告:fsockopen()[function.fsockopen]:无法连接到第33行/home/a2314677/public_html/process.php中的com.hk:43(连接超时)

HTML代码: 在头脑中:

<script language="javascript">
$(document).ready(function() {

    var loading;
    var results;

    form = document.getElementById('form');
    loading = document.getElementById('loading');
    results = document.getElementById('results');

    $('#Submit').click( function() {

        if($('#Search').val() == "")
        {alert('please enter your domain');return false;}

        results.style.display = 'none';
        $('#results').html('');
        loading.style.display = 'inline';

        $.post('process.php?domain=' + escape($('#Search').val()),{
        }, function(response){

            results.style.display = 'block';
            $('#results').html(unescape(response)); 
            loading.style.display = 'none';
        });

        return false;
    });

});
</script>
--------------------------------------------------------

In body:

<div class="search_row">
  <div class="domains_search">
    <div class="col-1"></div>
    <div class="col-2">
      <input type="text" name="domain_search" id="Search" name="domain" class="txt_domainsearch" />
    </div>
    <div class="col-3">
      <select name="domain" id="domains" class="domainoption">
        <option selected="selected">.hk</option>  
        <option>.com.hk</option>      
        <option>.net.hk</option>
        <option>.org.hk</option>
        <option>.gov.hk</option>      
        <option>.com</option>
        <option>.net</option>
        <option>.org</option>
      </select>
    </div>
    <div class="col-4">
      <input type="submit" value="Submit" class="searchbtn"  id="Submit"/>
    </div>
  </div>
------------------------------------------------------------------
PHP code:
<?php
/*set_time_limit(0);*/
ob_start();

########### Extensions to be checked
$extensions = array(
    '.hk'           => array("com.hk","whois.hknic.net.hk","No Match for"), 
    '.net.hk'       => array("net.hk","whois.hknic.net.hk","No Match for"),
    '.org.hk'       => array("org.hk","whois.hknic.net.hk","No Match for"),
    '.com.hk'       => array("com.hk","whois.hknic.net.hk","No Match for"),
    '.gov.hk'       => array("gov.hk","whois.hknic.net.hk","No Match for"),
    '.com'          => array('whois.crsnic.net','No match for'),
    '.net'          => array('whois.crsnic.net','No match for'),
    '.org'          => array('whois.pir.org','NOT FOUND'),

);




if(isset($_GET['domain']))
{
    $domain = str_replace(array('www.', 'http://'), NULL, $_GET['domain']);

    if(strlen($domain) > 0)
    {
    echo '<table>
     <th>Domain Name</th>
     <th>Availability</th>';
        foreach($extensions as $extension => $who)
        {

            $sock = fsockopen($who[0], 43) or die('Error Connecting To Server:' . $server);
            fputs($sock, $domain.$extension . "\r\n");

                while( !feof($sock) )
                {
                    $buffer .= fgets($sock,128);
                }

            fclose($sock);

            if(eregi($who[1], $buffer))
            {
                echo '<tr class="available">
     <td>' . $domain. '<b>' . $extension . '</b> </td>
     <td><img src="icon_success.gif"> Available </td>';
                //echo '<h4 class="available"><span>Available</span>' . $domain. '<b>' . $extension .'</b> is Available</h4>';
            }
            else
            {
            echo '<tr  class="not_available">
     <td>' . $domain. '<b>' . $extension . '</b> </td>
     <td><img src="icon_error.gif"> Not Available </td>
     ';
                //echo '<h4 class="taken"><span>Not Available</span><a href="http://www.'. $domain .$extension .'" target="_blank">www.' . $domain . '<b>' .$extension .'</a></b> is <a href="http://whois.asiaregistry.com/displayWhois.php?zone='. $domain.$extension.'" target="_blank">Not Available</a></h4>';
            }



            ob_flush();
            flush();
            sleep(0.3);

        }echo '<br />'; 
        echo ' </tr>
     </table>';
    }
    else
    {
        echo 'Please enter the domain name';
    }
}
?>

1 个答案:

答案 0 :(得分:0)

你的$ extensions数组有问题。

$extensions = array(
    '.hk'           => array("com.hk","whois.hknic.net.hk","No Match for"), 
    '.net.hk'       => array("net.hk","whois.hknic.net.hk","No Match for"),
    '.org.hk'       => array("org.hk","whois.hknic.net.hk","No Match for"),
    '.com.hk'       => array("com.hk","whois.hknic.net.hk","No Match for"),
    '.gov.hk'       => array("gov.hk","whois.hknic.net.hk","No Match for"),
    '.com'          => array('whois.crsnic.net','No match for'),
    '.net'          => array('whois.crsnic.net','No match for'),
    '.org'          => array('whois.pir.org','NOT FOUND'),

);

com.hk条目数组中的第一个条目应该是whois.hknic.net.hk而不是com.hk .com.net。检查第一个值是否有详细信息,您的值是错误的。