Domain Search Tool Encoding

I coded a domain check and really stuck with php. This is what I still have:

<?php
set_time_limit(0);
ob_start();
$domain = $_GET['domain'];
########### Extensions to be checked
$extensions = array(
    '.com'      => array('whois.crsnic.net','No match for'),
    '.info'     => array('whois.afilias.net','NOT FOUND'),  
    '.net'      => array('whois.crsnic.net','No match for'),
    '.co.uk'    => array('whois.nic.uk','No match'),        
    '.nl'       => array('whois.domain-registry.nl','not a registered domain'),
    '.ca'       => array('whois.cira.ca', 'AVAIL'),
    '.name'     => array('whois.nic.name','No match'),
    '.ws'       => array('whois.website.ws','No Match'),
    '.be'       => array('whois.ripe.net','No entries'),
    '.org'      => array('whois.pir.org','NOT FOUND'),
    '.biz'      => array('whois.biz','Not found'),
    '.tv'       => array('whois.nic.tv', 'No match for'),
);
###########

if(isset($domain))
{
    $newdomain = str_replace(array('www.', 'http://'), NULL, $domain);
    $finaldomain = str_replace($extensions, NULL, $newdomain);

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

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

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

            fclose($sock);

            if(eregi($who[1], $buffer))
            {
                echo '<h4 class="available"><span>Available</span>' . $finaldomain. '<b>' . $extension .'</b> is Available</h4>';
            }
            else
            {
                echo '<h4 class="taken"><span>Taken</span>' . $finaldomain . '<b>' .$extension .'</b> is Taken</h4>';
            }
            echo '<br />';  

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

        }
    }
    else
    {
        echo 'Please enter the domain name';
    }
}
?>

The problem I am facing is that I do not know how to remove the extension from the transferred domain.

Then, when it returns the results, I want the extension that they typed to be the first in the list of results.

I am new to php, but I need this project. All help was appreciated.

Thanks joe

+3
source share
2 answers

First of all, the extension is called a top-level domain (abbreviated TLD). Secondly, .co.ukit is not a top level domain, .ukis. It also has other subdomains, such as .org.uk, .gov.uketc.

, / , pathinfo:

$tld = pathinfo('helloworld.co.uk', PATHINFO_EXTENSION);
echo $tld;   // uk

, , , , :

$tld = '.' . pathinfo('helloworld.co.uk', PATHINFO_EXTENSION);
$whois_server = $extensions[$tld];
+1

, Whois TLD, TLD.whois-servers.net.

Wikipedia:

whois-servers.net DNS (CNAME) TLD WHOIS .whois-servers.net. GNU WHOIS whois-servers.net.

+1

Source: https://habr.com/ru/post/1792636/


All Articles