0

我有一个检查域名可用性的脚本。该脚本不适用于 .gr,我不知道为什么。这是脚本:

<?php
set_time_limit(0);
ob_start();

$extensions = array(
    '.com'      => array('whois.crsnic.net','No match for'),
    '.gr'       => array('whois.ripe.net','No entries found'),  
    '.net'      => array('whois.crsnic.net','No match for'),
    '.co.uk'    => array('whois.nic.uk','No match'),
    '.edu'      => array('whois.internic.net', 'No match for'),
);
if(isset($_GET['domain']))
{
    $domain = str_replace(array('www.', 'http://'), NULL, $_GET['domain']);

    if(strlen($domain) > 0)
    {
        foreach($extensions as $extension => $who)
        {
            $buffer = NULL;

            $sock = fsockopen($who[0], 43) or die('Σφάλμα σύνδεσης με τον διακομιστή:' . $server);
            fputs($sock, $domain.$extension . "\r\n");

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

            fclose($sock);

            if(eregi($who[1], $buffer))
            {
                echo '<h4 class="available"><span>Διαθέσιμo</span>' . $domain. '<b>' . $extension .'</b> είναι διαθέσιμο</h4>';
            }
            else
            {
                echo '<h4 class="taken"><span>Μη Διαθέσιμo</span>' . $domain . '<b>' .$extension .'</b> δεν είναι διαθέσιμο</h4>';
            }
            echo '<br />';  

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

        }
    }
    else
    {
        echo 'Παρακαλώ εισάγετε ένα Domain Name';
    }
}
?>

和HTML:

<html>
<head>
<script type="text/javascript" src="jquery-1.2.6.min.js"></script>
<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('Παρακαλώ Εισάγετε Ένα Όνομα');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>
</head>
<body>
<center>
    <div id="Heading">Ευρεση Domain</div>
        <form method="post" action="./" id="form"> 
            <input type="text" autocomplete="on" id="Search" name="domain"> 
            <input type="submit" id="Submit" value="Submit">
        </form>
        <div id="loading">
            <img src="load.gif"></img>
        </div>
            <div id="results" style="width:400px;" align="center"></div>
</center>           
 </body>
</html>

在 .gr 中,我认为“未找到条目”不起作用。有什么线索吗?感谢您的回答。

4

1 回答 1

0

它实际上似乎与您的代码有关,或者至少使用我的测试。

我换了

if(eregi($who[1], $buffer))

if(strpos($buffer, $who[1]) !== false)

我的服务器抱怨说,eregi 已贬值,但用 strpos 替换它时,它工作正常。

Not available stackoverflow.com
Available stackoverflow.gr
Not available stackoverflow.net
Not available stackoverflow.co.uk
Available stackoverflow.edu

使用

<?php
    set_time_limit(0);
    ob_start();

    $extensions = array(
        '.com'      => array('whois.crsnic.net','No match for'),
        '.gr'       => array('whois.ripe.net','No entries found'),  
        '.net'      => array('whois.crsnic.net','No match for'),
        '.co.uk'    => array('whois.nic.uk','No match'),
        '.edu'      => array('whois.internic.net', 'No match for'),
    );
    if(isset($_GET['domain']))
    {
        $domain = str_replace(array('www.', 'http://'), NULL, $_GET['domain']);

        if(strlen($domain) > 0)
        {
            foreach($extensions as $extension => $who)
            {
                $buffer = NULL;

                $sock = fsockopen($who[0], 43) or die('Σφάλμα σύνδεσης με τον διακομιστή:' . $server);
                fputs($sock, $domain.$extension . "\r\n");

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

                fclose($sock);

                if(strpos($buffer, $who[1]) !== false)
                {
                    echo '<h4 class="available"><span>Available </span>' . $domain. '<b>' . $extension .'</b></h4>';
                }
                else
                {
                    echo '<h4 class="taken"><span>Not available </span>' . $domain . '<b>' .$extension .'</b></h4>';
                }
                echo '<br />';  

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

            }
        }
        else
        {
            echo 'Παρακαλώ εισάγετε ένα Domain Name';
        }
    }
?>
于 2012-05-18T07:21:12.250 回答