Webmaster общности: Predpriemach.com | SearchEngines.bg

    Whois търсачка

    Автор: SandPrince

    Ровейки се ин нета случайно попаднах на едно скриптче за whois търсачка. нека да обясня за какво служи въпреки че някои знаят за какво се иползва. Тя служи за проверка дали даден домейн е зает или не.Урока е много лесен и простичук и не изисква кой знае какви познания.

    Имаме да създадем два документа:

    1. style.css – тои отговаря за външния вид на търсачката
    #main {
    margin: auto;
    border: 1px solid #cccccc;
    width: 400px;
    background: #F1F3F5;
    font-family: Arial, Helvetica, sans-serif;
    font-weight:bold;
    font-size : 12px;
    }
    
    form {
    margin-left: 100px;
    border: 1px solid #cccccc;
    width: 250px;
    background: #E9ECEF;
    font-family: Arial, Helvetica, sans-serif;
    font-weight:bold;
    font-size : 12px;
    padding:5px;
    margin-bottom:10px;
    }
    
    #result {
    margin-left: 100px;
    border: 1px solid #cccccc;
    width: 250px;
    background: #E9ECEF;
    font-family: Arial, Helvetica, sans-serif;
    font-weight:bold;
    font-size : 12px;
    padding:5px;
    margin-bottom:50px;
    }
    
    .text {
    border: 1px solid #cccccc;
    }
    
    input {
    border: 0px solid #cccccc;
    }
    
    
    #caption{
    font-family: Arial, Helvetica, sans-serif;
    font-weight:bold;
    margin:10px;
    font-size : 14px;
    color:#C64934;
    }
    
    #icon{
    width:100px;
    height:100px;
    float:left;
    background-image:url(icon.gif);
    background-repeat: no-repeat;
    background-position:center center;
    }
    #icon2{
    width:100px;
    height:100px;
    float:left;
    background-image:url(icon2.gif);
    background-repeat: no-repeat;
    background-position:center center;
    }
    
    #source{
    text-align:right;
    align:right;
    padding-right:10px;
    font-family: Arial, Helvetica, sans-serif;
    font-weight:normal;
    font-size : 10px;
    color:#CCCCCC;
    }

    и докумнта който е самата търсачка – microWhois.php

    <?php
    function checkDomain($domain,$server,$findText){
    // Open a socket connection to the whois server
    $con = fsockopen($server, 43);
    if (!$con) return false;
    
    // Send the requested doman name
    fputs($con, $domain."\r\n");
    
    // Read and store the server response
    $response = ' :';
    while(!feof($con)) {
    $response .= fgets($con,128);
    }
    
    // Close the connection
    fclose($con);
    
    // Check the response stream whether the domain is available
    if (strpos($response, $findText)){
    return true;
    }
    else {
    return false;
    }
    }
    
    function showDomainResult($domain,$server,$findText){
    if (checkDomain($domain,$server,$findText)){
    echo "<tr><td>$domain</td><td>AVAILABLE</td></tr>";
    }
    else echo "<tr><td>$domain</td><td>TAKEN</td></tr>";
    }
    ?>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
    <html>
    <head>
    <title>MicroWhois domain checker</title>
    <link href="style.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
    <div id="main">
    <div id="caption">DOMAIN LOOKUP</div>
    <div id="icon"> </div>
    <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="domain" id="domain">
    Domain name:
    <table>
    <tr><td><input class="text" name="domainname" type="text" size="36"/></td></tr>
    <tr>
    <td>
    <input type="checkbox" name="all" checked />All
    <input type="checkbox" name="com"/>.com
    <input type="checkbox" name="net"/>.net
    <input type="checkbox" name="org"/>.org
    <input type="checkbox" name="info"/>.info
    </td></tr>
    <tr><td align="center"><br/><input class="text" type="submit" name="submitBtn" value="Check domain"/></td></tr>
    </table>
    </form>
    <?php
    if (isset($_POST['submitBtn'])){
    $domainbase = (isset($_POST['domainname'])) ? $_POST['domainname'] : '';
    $d_all = (isset($_POST['all'])) ? 'all' : '';
    $d_com = (isset($_POST['com'])) ? 'com' : '';
    $d_net = (isset($_POST['net'])) ? 'net' : '';
    $d_org = (isset($_POST['org'])) ? 'org' : '';
    $d_info = (isset($_POST['info'])) ? 'info' : '';
    
    // Check domains only if the base name is big enough
    if (strlen($domainbase)>2){
    ?>
    <div id="caption">RESULT</div>
    <div id="icon2"> </div>
    <div id="result">
    <table width="100%">
    <?php
    if (($d_com != '') || ($d_all != '') ) showDomainResult($domainbase.".com",'whois.crsnic.net','No match for');
    if (($d_net != '') || ($d_all != '') ) showDomainResult($domainbase.".net",'whois.crsnic.net','No match for');
    if (($d_org != '') || ($d_all != '') ) showDomainResult($domainbase.".org",'whois.publicinterestregistry.net','NOT FOUND');
    if (($d_info != '') || ($d_all != '') ) showDomainResult($domainbase.".info",'whois.afilias.net','NOT FOUND');
    ?>
    </table>
    </div>
    <?php
    }
    }
    ?>
    <div id="source">Micro Whois 1.1</div>
    </div>
    </body>