NameSilo

PHP: Bulk domain availability check!

Located in Source Code started by Matthew., Jan 14, 2007.

Replies:
246
Views:
148,388

  1. Matthew.

    Matthew. VIP Member VIP ★★★★★★★★★★

    Posts:
    1,652
    Likes Received:
    93
    PHP: Bulk domain availability check! [UPDATED]

    This is something i was going to start however i don't really have time, so i have whipped up a quick script for you guys to use on your own site or just for personal use.

    The script has been tested quickly tonight as i want to go to bed lol. I hope it is of some use.

    Demo: Now offline sorry.


    UPDATED CODE (Revision 6): (18/02/07)


    Download everything here!

    .ORG support removed due to a block from the WHOIS server (PIR)

    - .pt support fixed!

    - Added "save results as text file" feature - requested.

    - Code shortened

    - Added .in support
    - Bug fixes

    - Added .tv domain support - requested

    - Other bug fixes (again ;))

    - Will now output result before checking next domain (much faster)
    - Added .mobi support - requested

    - Other bug fixes

    PHP:
    <?php
    set_time_limit
    (0);
    ob_start();
    /*     --------    Bulk domain availablity check script (Revision 4) ------------        
    [                                                                                    
    [     Created by "Matthew." (#45276) @ http://namepros.com / http://toomanylines.com        
    [    Feel free to modify/use however you wish,                                        
    [    but keep credit comments in upon distribution.                                
    */

    include 'inc/dnservers.php';

    function 
    save_file($status
    {
        global 
    $filename$domain$extension;
        
        
    $domain trim($domain);
        
        
    $file_handle fopen($filename "_$status.txt"'a+') or trigger_error('Cannot open or create file (chmod?)'E_USER_WARNING);
        
        if(
    $status == 'invalid' && $extension == 'org') { $status .= ' (.org WHOIS prevents request)'; }
                    
        if(!
    fwrite($file_handle$domain " is $status\n"))
        {
            
    trigger_error('Results for ' $domain ' could not be written.'E_USER_WARNING);
        }
        
        
    fclose($file_handle);    
    }

    function 
    return_status($domain$status)
    {    
        global 
    $extension$filename;

        
        
    $file $filename;
        
    $domain trim($domain);
        
        if(isset(
    $_POST['save']))
        {
                
    save_file$status );
        }
        else
        {    
            
    $color = ($status == 'available') ? 'green' 'red';
            if(
    $status == 'invalid' && $extension == 'org') { $status .= ' (.org WHOIS prevents request)'; }    
                
            echo 
    "<div style=\"color: $color\">$domain is $status!</div>";
        }
    }    
        
    if(isset(
    $_POST['submit']))
    {
        
    $filename 'saves/' mt_rand(59999999999);
            
        if(
    strlen($_POST['domains']) > 0)
        {

            
    $domains explode("\n"$_POST['domains']);
            
            echo 
    '<h1>Checking ' count($domains) . ' domains</h1><br />';
            echo (isset(
    $_POST['save'])) ? 'Preparing results, please wait...<br /><br />' null;
            
            foreach(
    $domains as $domain)
            {
                unset(
    $buffer); // clean buffer - prevents problems
                        
                // (replaced str_replace)    
                
    preg_match('@^(http://www\.|http://|www\.)?([^/]+)@i'$domain$matches);
                
    $domain $matches[2];
                
                
    $tld explode('.'$domain2);
                
    $extension strtolower(trim($tld[1]));
                
                if(
    strlen($domain) > && array_key_exists('.' $extension$ext))
                {
                    
    $server $ext['.' .$extension][0];
                    
                    
    $sock fsockopen($server43) or die('Error Connecting To Server:' $server);
                    
    fputs($sock"$domain\r\n");
                    
                    while( !
    feof($sock) )
                    {
                          
    $buffer .= fgets($sock,128);
                    }
                
                    
    fclose($sock);
                    if(
    $extension == 'org') echo nl2br($buffer);
                    
                    if(
    eregi($ext['.' $extension][1], $buffer)) { return_status($domain'available'); }
                    
                    else { 
    return_status($domain'taken'); }
                }
                else
                {
                    if(
    strlen($domain) > 0)     { return_status($domain'invalid'); }
                }
            
                
    ob_flush(); // output before checking next domain
                
    flush();
                
    sleep(0.1);
            }
            
            if(isset(
    $_POST['save']) && count($domains) > 0)
            {
                echo 
    'Check completed, your results can be found below:';
            
                if(
    file_exists($filename '_available.txt'))
                {
                    echo 
    '<br /><a href="' $filename '_available.txt">Available domains</a>';
                }
                
                if(
    file_exists($filename '_taken.txt'))
                {
                    echo 
    '<br /><a href="' $filename '_taken.txt">Taken domains</a>';
                }
                else
                {
                    echo 
    '<br />0 taken domains found';
                }
                
                if(
    file_exists($filename '_invalid.txt'))
                {
                    echo 
    '<br /><a href="' $filename '_invalid.txt">Invalid domains (could not be checked)</a>';
                }
            }    
        }
        else
        {
            echo 
    'You need to enter one or more domains!';
        }

    else
    {
        
    ?>
    <div style="text-align: center">
        <form action="index.php" method="post">
            <textarea name="domains" cols="100" rows="20"></textarea>
            <br /><input type="checkbox" name="save" value="save" /> Save results as text file?<br />
            <br /><input type="submit" name="submit" value="Check Availability" style="font-size: 30pt;" />
            
        </form>
    </div>
        <?php
    }
    ?>

    Instructions:

    Unzip, Upload, CHMOD "saves" to 777, use!



    Supported extensions are:

    .com
    .net
    .biz
    .info
    .co.uk
    .co.ug
    .or.ug
    .nl
    .tv
    .mobi
    .in

    .ro
    .com.au
    .ca
    .org.uk
    .name
    .us
    .ac.ug
    .ne.ug
    .sc.ug
    .ws
    .be
    .com.cn
    .net.cn
    .org.cn
    .no
    .se
    .nu
    .com.tw
    .net.tw
    .org.tw
    .cc
    .pl
    .pt

    It is not coded well but this was started very early in the morning so i have an excuse lol. It works so hey ;)

    Enjoy.
     
    Last edited: Jan 22, 2011
    The views expressed on this page by users and staff are their own, not those of NamePros.
  2. kleszcz

    kleszcz Top Member VIP ★★★★★★★★★★

    Posts:
    4,739
    Likes Received:
    122
    Hey, that's cool! Install and comment later.
     
  3. Matthew.

    Matthew. VIP Member VIP ★★★★★★★★★★

    Posts:
    1,652
    Likes Received:
    93
    Great, simple install - just download and upload both files :)
     
  4. ahtum

    ahtum Top Member VIP ★★★★★★★★★★

    Posts:
    1,534
    Likes Received:
    68
    And rename them from .txt to .php :p
     
  5. Matthew.

    Matthew. VIP Member VIP ★★★★★★★★★★

    Posts:
    1,652
    Likes Received:
    93
    :tu: true, I forgot i renamed them actually. NP wouldn't allow me to upload .php obviously :)
     
  6. mtorregiani

    mtorregiani Established Member ★★★★★★★★★★

    Posts:
    1,642
    Likes Received:
    40
    Thanks
    It rock!!!

    Rep Added
    PS: Can I use it on my blog? You'll get a free link... PM me if interested
     
  7. kleszcz

    kleszcz Top Member VIP ★★★★★★★★★★

    Posts:
    4,739
    Likes Received:
    122
    Thanks. Really useful script. :)
     
  8. Matthew.

    Matthew. VIP Member VIP ★★★★★★★★★★

    Posts:
    1,652
    Likes Received:
    93
    Thanks mtorregiani, You may use it wherever you want! No link required :)
     
  9. Matthew.

    Matthew. VIP Member VIP ★★★★★★★★★★

    Posts:
    1,652
    Likes Received:
    93
    Code has been updated!

    The code now outputs the result of the domain check before checking the next one which means real time results!


    Demo: http://www.mattjewell.com/dnlookup/index.php

    Thanks to those who have rep'd, appreciated :)

    Example list to check:
     
  10. Kenny

    Kenny Member Services, NamePros Super Moderator Gold Account VIP ★★★★★★★★★★

    Posts:
    14,382
    Likes Received:
    15,432
    Matthew, OUTSTANDING share!!!! Rep up'd

    EDIT: Sorry I'm at my limit giving rep for today, but I'll catch up tomorrow.
     
  11. Matthew.

    Matthew. VIP Member VIP ★★★★★★★★★★

    Posts:
    1,652
    Likes Received:
    93
    Thanks ~ Cyberian ~, truly appreciated :) (im not fussed about the rep, whenever :D)
     
  12. deu12000

    deu12000 VIP Member VIP ★★★★★★★★★★

    Posts:
    1,502
    Likes Received:
    18
    This is a great script! Rep given. Thanks.
     
  13. Matthew.

    Matthew. VIP Member VIP ★★★★★★★★★★

    Posts:
    1,652
    Likes Received:
    93
    Thanks!

    Code updated, bug fixed.
     
  14. Matthew.

    Matthew. VIP Member VIP ★★★★★★★★★★

    Posts:
    1,652
    Likes Received:
    93
    Update to dnservers.txt (attached file)

    .MOBI Support added!
     
  15. champ_rock

    champ_rock VIP Member VIP ★★★★★★★★★★

    Posts:
    2,964
    Likes Received:
    99
    is there any way so that the result will be added to a text file automatically?
     
  16. Matthew.

    Matthew. VIP Member VIP ★★★★★★★★★★

    Posts:
    1,652
    Likes Received:
    93
    Sure thing, i am now going out for the day however if you will wait until about 7/8 GMT then i will get it up for you :)
     
  17. champ_rock

    champ_rock VIP Member VIP ★★★★★★★★★★

    Posts:
    2,964
    Likes Received:
    99
    thanks

    plus one more suggestion.. you can add 2 text files.. one for the taken domains and the other for the available ones.. if it is not too much of a coding task..

    adding some reps
     
  18. DJ

    DJ Senior Member VIP ★★★★★★★★★★

    Posts:
    1,421
    Likes Received:
    27
    Matt, excellent script, been looking for this for ages!

    One tiny suggestion, please add support for .tv :D

    Thanks again and rep coming your way!
     
  19. champ_rock

    champ_rock VIP Member VIP ★★★★★★★★★★

    Posts:
    2,964
    Likes Received:
    99
    i just checked about 2000domains in abou 2 minutes .. :) :) thanks a lot
     
  20. vincenzo

    vincenzo VIP Member VIP ★★★★★★★★★★

    Posts:
    799
    Likes Received:
    16
    May I kindly suggest this be an option rather than default - i.e. 'download output as text file link' please?

    Also, another vote for .TV support

    Wicked little script Matthew, well done.
    Rep added.

    - Vince
     
  21. tansks

    tansks VIP Member VIP ★★★★★★★★★★

    Posts:
    935
    Likes Received:
    40
    You are great. rep added.
     
  22. Matthew.

    Matthew. VIP Member VIP ★★★★★★★★★★

    Posts:
    1,652
    Likes Received:
    93
    Wow this topic took off while i was away lol.

    Okeysss,
    Sure thing, this will hopefully get done tonight, it's only a small adjustment however I'm a little tired out and have work to do :( But I'll try my best!

    Awesome :tu: I haven't tried how many it can handle, theoretically it's unlimited however depending on config the server will end the script at some point.

    Wouldn't dream of anything else :)

    I will look into adding .TV support as well :)

    Thanks for all the kind comments and rep guys :tu:
     
  23. vincenzo

    vincenzo VIP Member VIP ★★★★★★★★★★

    Posts:
    799
    Likes Received:
    16
    Hi Matthew,
    Just one last thing. As the list of tld's is quite long, and to save alittle on server processing, why not have them as tickboxes?

    Many people would only be interested in checking a few of those tld's anyway?

    Many thanks again.

    - Vince
     
  24. champ_rock

    champ_rock VIP Member VIP ★★★★★★★★★★

    Posts:
    2,964
    Likes Received:
    99
    the script rocks n its current stage only.

    i seem to be giving suggestions and suggestions only.. here go a few more to make it a dream script kind of a thing.. they all will require more advanced editing..

    1. take input also from a text file.. use cronjobs to schedule checking
    2. mailing the available domain list so that the script mails me when some domain becomes available for reggin ..
    3. ad proxy support which will automatically switch proxie after some 100-200 domains checks.. that way the ip will not get banned :)
     
  25. Matthew.

    Matthew. VIP Member VIP ★★★★★★★★★★

    Posts:
    1,652
    Likes Received:
    93
    Hi vincenzo,
    The server list is long however the script does not check each extension. It will use the appropriate array key (and in this array since it is a multidimensional array the array array key) so check only the whois server for the domain with that extension.

    champ_rock,
    I like the first half of that idea, but the second would require greater input from the user and goes out of the bounds of this script :)

    I think i'll leave it as it is, if someone wants to do that they can but i don't have any time to spend on this anymore as i loose a whole day of work tomorrow. I will get some suggestions put in (i.e. text files and .tv support) but not extensive ones :)
     

Want to reply or ask your own question?

It only takes a minute to sign up – and it's free!
NameWorth
  1. NamePros uses cookies and similar technologies. By using this site, you are agreeing to our privacy policy, terms, and use of cookies.
    Dismiss Notice
Loading...