4

PHPドメインの可用性チェックスクリプト

問題:

チェックする70以上のドメイン拡張があります。

私が探している解決策

index.php <option>+ .com / .com.br / .net / .orgでクライアントが選択した拡張子のみを確認する必要があります。クライアントが特定のオプションを選択した場合でも、これら4つの拡張子は常に検証されます。

実例: http: //redehost.com.br/registro-de-dominio

私はこれに本当に似たものを探しています/\

index.php

<html>

<head>
<title>99points.info : ajax domain name check</title>

<link href="main.css" rel="stylesheet" />
        <script src="http://www.google.com/jsapi" type="text/javascript"></script>
<script src="http://code.jquery.com/jquery-1.8.3.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('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>
</head>
<body>

<center>


    
    <form method="post" action="./" id="form"> 
            <div id="registro_box_bg">
            <div id="registro_box">
            <div id="www">www. </div>
                <input type="text" autocomplete="off" id="Search" name="domain">
                
                    <div id="select" style="background-color: rgb(229, 229, 229);">
                    <select id="extensao" name="Extensao"><option value="com">.com</option>
                        <option value="com.br">.com.br</option>
                        <option value="net">.net</option>
                        <option value="org">.org</option>
                        <option value="info">.info</option>
                        <option value="biz">.biz</option>
                        <option value="tv">.tv</option>
                        <option value="name">.name</option>
                        <option value="ws">.ws</option>
                        <option value="cc">.cc</option>
                        <option value="blog.br">.blog.br</option>
                        <option value="flog.br">.flog.br</option>
                        <option value="vlog.br">.vlog.br</option>
                        <option value="wiki.br">.wiki.br</option>
                        <option value="adm.br">.adm.br</option>
                        <option value="adv.br">.adv.br</option>
                        <option value="agr.br">.agr.br</option>
                        <option value="am.br">.am.br</option>
                        <option value="arq.br">.arq.br</option>
                        <option value="art.br">.art.br</option>
                        <option value="ato.br">.ato.br</option>
                        <option value="bio.br">.bio.br</option>
                        <option value="bmd.br">.bmd.br</option>
                        <option value="cim.br">.cim.br</option>
                        <option value="cng.br">.cng.br</option>
                        <option value="cnt.br">.cnt.br</option>
                        <option value="coop.br">.coop.br</option>
                        <option value="ecn.br">.ecn.br</option>
                        <option value="edu.br">.edu.br</option>
                        <option value="eng.br">.eng.br</option>
                        <option value="esp.br">.esp.br</option>
                        <option value="etc.br">.etc.br</option>
                        <option value="eti.br">.eti.br</option>
                        <option value="far.br">.far.br</option>
                        <option value="fm.br">.fm.br</option>
                        <option value="fnd.br">.fnd.br</option>
                        <option value="fot.br">.fot.br</option>
                        <option value="fst.br">.fst.br</option>
                        <option value="g12.br">.g12.br</option>
                        <option value="ggf.br">.ggf.br</option>
                        <option value="gov.br">.gov.br</option>
                        <option value="imb.br">.imb.br</option>
                        <option value="ind.br">.ind.br</option>
                        <option value="inf.br">.inf.br</option>
                        <option value="jor.br">.jor.br</option>
                        <option value="lel.br">.lel.br</option>
                        <option value="mat.br">.mat.br</option>
                        <option value="med.br">.med.br</option>
                        <option value="mil.br">.mil.br</option>
                        <option value="mus.br">.mus.br</option>
                        <option value="net.br">.net.br</option>
                        <option value="nom.br">.nom.br</option>
                        <option value="not.br">.not.br</option>
                        <option value="ntr.br">.ntr.br</option>
                        <option value="odo.br">.odo.br</option>
                        <option value="org.br">.org.br</option>
                        <option value="ppg.br">.ppg.br</option>
                        <option value="pro.br">.pro.br</option>
                        <option value="psc.br">.psc.br</option>
                        <option value="psi.br">.psi.br</option>
                        <option value="qsl.br">.qsl.br</option>
                        <option value="rec.br">.rec.br</option>
                        <option value="slg.br">.slg.br</option>
                        <option value="srv.br">.srv.br</option>
                        <option value="tmp.br">.tmp.br</option>
                        <option value="trd.br">.trd.br</option>
                        <option value="tur.br">.tur.br</option>
                        <option value="tv.br">.tv.br</option>
                        <option value="vet.br">.vet.br</option>
                        <option value="zlg.br">.zlg.br</option>
                        </select>
                            </div>
        <input type="submit" id="Submit" value="Submit">
                <!-- falta add 
                
                                            <option value="biz">.biz</option>
                        <option value="tv">.tv</option>
                        <option value="name">.name</option>
                        <option value="ws">.ws</option>
                        <option value="cc">.cc</option> -->
    
    </form>


    <div id="loading">Please wait...<img src="load.gif"></img></div>
        
     <div id="results" style="width:420px; height:600px;" align="left">
        
     </div> 
</div>
        </div>
 
 
 </center>
 </body>
 </html>
 

process.php

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

########### Extensions to be checked
$extensions = array(
        '.com'      => array('whois.crsnic.net','No match for'),
        '.com.br'   => array('whois.registro.br','No match'),
        '.net'      => array('whois.crsnic.net','No match for'),
        '.org'  => array('whois.pir.org','NOT FOUND'),
    '.info'     => array('whois.afilias.net','NOT FOUND'),
        '.br'   => array('whois.registro.br','No match'),
            '.blog.br'  => array('whois.registro.br','No match'),
            '.flog.br'  => array('whois.registro.br','No match'),
            '.vlog.br'  => array('whois.registro.br','No match'),
            '.wiki.br'  => array('whois.registro.br','No match'),
            '.adm.br'   => array('whois.registro.br','No match'),
            '.adv.br'   => array('whois.registro.br','No match'),
            '.agr.br'   => array('whois.registro.br','No match'),
            '.am.br'    => array('whois.registro.br','No match'),
            '.arq.br'   => array('whois.registro.br','No match'),
            '.ato.br'   => array('whois.registro.br','No match'),
            '.bio.br'   => array('whois.registro.br','No match'),
            '.bmd.br'   => array('whois.registro.br','No match'),
            '.cim.br'   => array('whois.registro.br','No match'),
            '.cng.br'   => array('whois.registro.br','No match'),
            '.cnt.br'   => array('whois.registro.br','No match'),
            '.coop.br'  => array('whois.registro.br','No match'),
            '.ecn.br'   => array('whois.registro.br','No match'),
            '.edu.br'   => array('whois.registro.br','No match'),
            '.eng.br'   => array('whois.registro.br','No match'),
            '.esp.br'   => array('whois.registro.br','No match'),
            '.etc.br'   => array('whois.registro.br','No match'),
            '.eti.br'   => array('whois.registro.br','No match'),
            '.far.br'   => array('whois.registro.br','No match'),
            '.fm.br'    => array('whois.registro.br','No match'),
            '.fnd.br'   => array('whois.registro.br','No match'),
            '.fot.br'   => array('whois.registro.br','No match'),
            '.fst.br'   => array('whois.registro.br','No match'),
            '.g12.br'   => array('whois.registro.br','No match'),
            '.ggf.br'   => array('whois.registro.br','No match'),
        '.gov.br'   => array('whois.registro.br','No match'),
        '.imb.br'   => array('whois.registro.br','No match'),
        '.ind.br'   => array('whois.registro.br','No match'),
        '.inf.br'   => array('whois.registro.br','No match'),
        '.jor.br'   => array('whois.registro.br','No match'),
        '.lel.br'   => array('whois.registro.br','No match'),
        '.mat.br'   => array('whois.registro.br','No match'),
        '.med.br'   => array('whois.registro.br','No match'),
        '.mil.br'   => array('whois.registro.br','No match'),
        '.mus.br'   => array('whois.registro.br','No match'),
        '.net.br'   => array('whois.registro.br','No match'),
        '.nom.br'   => array('whois.registro.br','No match'),
        '.not.br'   => array('whois.registro.br','No match'),
        '.ntr.br'   => array('whois.registro.br','No match'),
        '.odo.br'   => array('whois.registro.br','No match'),
        '.org.br'   => array('whois.registro.br','No match'),
        '.ppg.br'   => array('whois.registro.br','No match'),
        '.pro.br'   => array('whois.registro.br','No match'),
        '.psc.br'   => array('whois.registro.br','No match'),
        '.psi.br'   => array('whois.registro.br','No match'),
        '.qsl.br'   => array('whois.registro.br','No match'),
        '.rec.br'   => array('whois.registro.br','No match'),
        '.slg.br'   => array('whois.registro.br','No match'),
        '.srv.br'   => array('whois.registro.br','No match'),
        '.tmp.br'   => array('whois.registro.br','No match'),
        '.trd.br'   => array('whois.registro.br','No match'),
        '.trd.br'   => array('whois.registro.br','No match'),
        '.tur.br'   => array('whois.registro.br','No match'),
        '.tv.br'    => array('whois.registro.br','No match'),
        '.vet.br'   => array('whois.registro.br','No match'),
        '.zlg.br'   => array('whois.registro.br','No match'),
    
    
);
###########

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('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 '<h4 class="available"><span>Available</span>' . $domain. '<b>' . $extension .'</b> is Available</h4>';
            }
            else
            {
                echo '<h4 class="taken"><span>Taken</span>' . $domain . '<b>' .$extension .'</b> is Taken</h4>';
            }
            echo '<br />';  
            
            ob_flush();
            flush();
            sleep(0.3);
            
        }
    }
    else
    {
        echo 'Please enter the domain name';
    }
}
?>
4

1 に答える 1

1

選択した拡張機能をデータサービスに投稿しません(process.php)。

$.post('process.php?domain=' + escape($('#Search').val())

する必要があります

$.post('process.php', { domain: escape($('#Search').val()), extension: $('#extensao').val() })

また、チェックインする拡張機能を定義しprocess.php、このリストにない拡張機能をスキップする必要があります。

// Add all extensions we need to check to an array
$extensionsToCheck = array('.com', '.com.br', '.net', '.org');
if (isset($_POST['extension']) && !empty($_POST['extension']))
{
    $extensionsToCheck[] = $_POST['extension'];
}   

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

    if(strlen($domain) > 0)
    {
        foreach($extensions as $extension => $who)
        {
            // Check if we need to check this extensions. Skip if not
            if (!in_array($extension, $extensionsToCheck))
            {
                continue;
            }

このようなことをする必要があります。テストされていません

于 2013-02-22T20:32:09.520 に答える