View Single Post
Old 01-13-2007, 06:42 PM   · #1
Matthew.
Stud Sausage
 
Location: England
Trader Rating: (25)
Join Date: Dec 2006
Posts: 1,545
NP$: 32.41 (Donate)
Matthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud of
Adoption Breast Cancer Breast Cancer Cancer Survivorship
Thumbs up 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: http://www.mattjewell.com/namepros/dnlookup/index.php


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 Code:
<?php
set_time_limit
(0);
ob_start();
/*     --------    Bulk domain availablity check script (Revision 4) ------------        
[                                                                                    
[     Created by "Matthew." (45276) @ http://namepros.com / http://mattjewell.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(5, 9999999999);
        
    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('.', $domain, 2);
            
$extension = strtolower(trim($tld[1]));
            
            if(
strlen($domain) > 0 && array_key_exists('.' . $extension, $ext))
            {
                
$server = $ext['.' .$extension][0];
                
                
$sock = fsockopen($server, 43) 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.


Please register or log-in into NamePros to hide ads
__________________
My NamePros Tools
(firefox plugin, google gadget etc)
Matthew. is offline   Reply With Quote
Site Sponsors
http://www.mobisitetrader.com/ Build your NameBrand Buy Flash Arcade Game Script
Advertise your business at NamePros
All times are GMT -7. The time now is 03:37 PM.


Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.