0

我正在尝试使用以下内容对 .hk、.com.hk 蚀刻使用域检查器。它适用于 .com、.net,但不适用于 .hk 等。请告诉我哪里出错了。您的帮助将不胜感激。我收到以下错误:Warning: fsockopen() [function.fsockopen]: unable to connect to com.hk:43 (Connection timed out) in /home/a2314677/public_html/process.php on line 33

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';
    }
}
?>
4

1 回答 1

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 条目的数组中的第一个条目应该与andwhois.hknic.net.hk不太com.hk相似。检查第一个值的详细信息,您的值是错误的。.com.net

于 2013-07-08T11:08:04.647 回答