[advanced search]
Next Live Event: NamePros Live Auction, May 23rd at 6PM EDT
Results from the May 8th live auction are here.
16 members in the live chat room. Join Chat!
Register Rules & FAQ NP$ Store Active Threads Mark Forums Read
Go Back   NamePros.Com > Design and Development > Programming > CODE
User Name
Password

Reply
 
Thread Tools
Old 01-13-2007, 06:42 PM   · #1
Matthew.
Stud Sausage
 
Location: England
Trader Rating: (25)
Join Date: Dec 2006
Posts: 1,539
NP$: 33.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 Blog

My NamePros Tools
(firefox plugin, google gadget etc)

Last edited by Matthew. : 02-18-2007 at 08:05 AM.
Matthew. is offline   Reply With Quote
Old 01-13-2007, 08:01 PM   · #2
kleszcz
 
kleszcz's Avatar
 
Trader Rating: (201)
Join Date: Jul 2006
Posts: 3,032
NP$: 1011.50 (Donate)
kleszcz has a reputation beyond reputekleszcz has a reputation beyond reputekleszcz has a reputation beyond reputekleszcz has a reputation beyond reputekleszcz has a reputation beyond reputekleszcz has a reputation beyond reputekleszcz has a reputation beyond reputekleszcz has a reputation beyond reputekleszcz has a reputation beyond reputekleszcz has a reputation beyond reputekleszcz has a reputation beyond repute
Marrow Donor Program Multiple Sclerosis
Hey, that's cool! Install and comment later.
__________________
Share your photos, tags and links!
LLLL.com - *NOT* going cheap!
Dictionary Word .info Domains
kleszcz is offline   Reply With Quote
Old 01-14-2007, 09:53 AM   · #3
Matthew.
Stud Sausage
 
Location: England
Trader Rating: (25)
Join Date: Dec 2006
Posts: 1,539
NP$: 33.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
Originally Posted by kleszcz
Hey, that's cool! Install and comment later.



Great, simple install - just download and upload both files
__________________
My Blog

My NamePros Tools
(firefox plugin, google gadget etc)
Matthew. is offline   Reply With Quote
Old 01-14-2007, 09:57 AM   · #4
ahtum
DNOA Member
 
ahtum's Avatar
 
Name: Vlad
Location: Romania
Trader Rating: (55)
Join Date: May 2006
Posts: 1,227
NP$: 1726.33 (Donate)
ahtum has much to be proud ofahtum has much to be proud ofahtum has much to be proud ofahtum has much to be proud ofahtum has much to be proud ofahtum has much to be proud ofahtum has much to be proud ofahtum has much to be proud ofahtum has much to be proud ofahtum has much to be proud of
Ethan Allen Fund Find Marrow Donors!
Originally Posted by Matthew.
Great, simple install - just download and upload both files



And rename them from .txt to .php
ahtum is offline   Reply With Quote
Old 01-14-2007, 09:59 AM   · #5
Matthew.
Stud Sausage
 
Location: England
Trader Rating: (25)
Join Date: Dec 2006
Posts: 1,539
NP$: 33.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
Originally Posted by ahtum
And rename them from .txt to .php



true, I forgot i renamed them actually. NP wouldn't allow me to upload .php obviously
__________________
My Blog

My NamePros Tools
(firefox plugin, google gadget etc)
Matthew. is offline   Reply With Quote
Old 01-18-2007, 10:54 AM   · #6
mtorregiani
Senior Member
 
Name: Martin
Location: Montevideo, Uruguay
Trader Rating: (24)
Join Date: Jul 2006
Posts: 1,402
NP$: 265.00 (Donate)
mtorregiani is a name known to allmtorregiani is a name known to allmtorregiani is a name known to allmtorregiani is a name known to allmtorregiani is a name known to allmtorregiani is a name known to all
Cancer Survivorship
Thanks
It rock!!!

Rep Added
PS: Can I use it on my blog? You'll get a free link... PM me if interested
__________________
Save your money DomainCoupons.com Save your money
☻∙DN Chat Group∙☻
GFXLounge.com | Spanish Olive Oil
mtorregiani is offline   Reply With Quote
Old 01-19-2007, 01:24 AM   · #7
kleszcz
 
kleszcz's Avatar
 
Trader Rating: (201)
Join Date: Jul 2006
Posts: 3,032
NP$: 1011.50 (Donate)
kleszcz has a reputation beyond reputekleszcz has a reputation beyond reputekleszcz has a reputation beyond reputekleszcz has a reputation beyond reputekleszcz has a reputation beyond reputekleszcz has a reputation beyond reputekleszcz has a reputation beyond reputekleszcz has a reputation beyond reputekleszcz has a reputation beyond reputekleszcz has a reputation beyond reputekleszcz has a reputation beyond repute
Marrow Donor Program Multiple Sclerosis
Thanks. Really useful script.
__________________
Share your photos, tags and links!
LLLL.com - *NOT* going cheap!
Dictionary Word .info Domains
kleszcz is offline   Reply With Quote
Old 01-19-2007, 04:43 AM   · #8
Matthew.
Stud Sausage
 
Location: England
Trader Rating: (25)
Join Date: Dec 2006
Posts: 1,539
NP$: 33.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
Originally Posted by mtorregiani
Thanks
It rock!!!

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



Thanks mtorregiani, You may use it wherever you want! No link required
__________________
My Blog

My NamePros Tools
(firefox plugin, google gadget etc)
Matthew. is offline   Reply With Quote
Old 01-19-2007, 12:36 PM   · #9
Matthew.
Stud Sausage
 
Location: England
Trader Rating: (25)
Join Date: Dec 2006
Posts: 1,539
NP$: 33.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
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:
Quote:
falchion.info
unworthy.info
grandpiano.cc
cannibal.cc
hotwings.cc
newtestament.biz
charityfund.info
channelzero.info
zinfandel.cc
tophost.cc
roadconditions.biz
newtestament.cc
boombox.cc
hyperactive.cc
rejected.cc
babytalk.cc
playhouse.cc
mooncycles.info
restitution.cc
nightmares.cc
doorprize.net
doorprizes.net

__________________
My Blog

My NamePros Tools
(firefox plugin, google gadget etc)
Matthew. is offline   Reply With Quote
Old 01-19-2007, 02:39 PM   · #10
~ Cyberian ~
CyberianDomains
 
~ Cyberian ~'s Avatar
 
Name: Cy
Location: SoCal
Trader Rating: (58)
Join Date: Apr 2004
Posts: 3,479
NP$: 104.00 (Donate)
~ Cyberian ~ has a reputation beyond repute~ Cyberian ~ has a reputation beyond repute~ Cyberian ~ has a reputation beyond repute~ Cyberian ~ has a reputation beyond repute~ Cyberian ~ has a reputation beyond repute~ Cyberian ~ has a reputation beyond repute~ Cyberian ~ has a reputation beyond repute~ Cyberian ~ has a reputation beyond repute~ Cyberian ~ has a reputation beyond repute~ Cyberian ~ has a reputation beyond repute~ Cyberian ~ has a reputation beyond repute
Member of the Month
January 2006Member of the Month
July 2006
Matthew, OUTSTANDING share!!!! Rep up'd

EDIT: Sorry I'm at my limit giving rep for today, but I'll catch up tomorrow.
__________________
Sign -db-'s Come Home Soon Card
>>> 1-800-Timothy.com <<<

iMoDo
Share your knowledge, it's a way to achieve Immortality.
~ Cyberian ~ is offline  
  Reply With Quote
Old 01-19-2007, 02:46 PM   · #11
Matthew.
Stud Sausage
 
Location: England
Trader Rating: (25)
Join Date: Dec 2006
Posts: 1,539
NP$: 33.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
Originally Posted by ~ Cyberian ~
Matthew, OUTSTANDING share!!!! Rep up'd

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



Thanks ~ Cyberian ~, truly appreciated (im not fussed about the rep, whenever )
__________________
My Blog

My NamePros Tools
(firefox plugin, google gadget etc)
Matthew. is offline   Reply With Quote
Old 01-19-2007, 03:17 PM   · #12
deu12000
Senior Member
 
deu12000's Avatar
 
Trader Rating: (123)
Join Date: Jun 2004
Posts: 1,453
NP$: 2365.40 (Donate)
deu12000 has a brilliant futuredeu12000 has a brilliant futuredeu12000 has a brilliant futuredeu12000 has a brilliant futuredeu12000 has a brilliant futuredeu12000 has a brilliant futuredeu12000 has a brilliant futuredeu12000 has a brilliant futuredeu12000 has a brilliant futuredeu12000 has a brilliant futuredeu12000 has a brilliant future
This is a great script! Rep given. Thanks.
deu12000 is offline   Reply With Quote
Old 01-19-2007, 03:44 PM   · #13
Matthew.
Stud Sausage
 
Location: England
Trader Rating: (25)
Join Date: Dec 2006
Posts: 1,539
NP$: 33.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
Originally Posted by deu12000
This is a great script! Rep given. Thanks.



Thanks!

Code updated, bug fixed.
__________________
My Blog

My NamePros Tools
(firefox plugin, google gadget etc)
Matthew. is offline   Reply With Quote
Old 01-20-2007, 01:24 AM   · #14
Matthew.
Stud Sausage
 
Location: England
Trader Rating: (25)
Join Date: Dec 2006
Posts: 1,539
NP$: 33.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
Update to dnservers.txt (attached file)

.MOBI Support added!
__________________
My Blog

My NamePros Tools
(firefox plugin, google gadget etc)
Matthew. is offline   Reply With Quote
Old 01-20-2007, 01:43 AM   · #15
champ_rock
Senior Member
 
champ_rock's Avatar
 
Name: Akshay Jain
Location: http://uck.in
Trader Rating: (91)
Join Date: Oct 2006
Posts: 2,665
NP$: 12439.80 (Donate)
champ_rock has a brilliant futurechamp_rock has a brilliant futurechamp_rock has a brilliant futurechamp_rock has a brilliant futurechamp_rock has a brilliant futurechamp_rock has a brilliant futurechamp_rock has a brilliant futurechamp_rock has a brilliant futurechamp_rock has a brilliant futurechamp_rock has a brilliant futurechamp_rock has a brilliant future
is there any way so that the result will be added to a text file automatically?
champ_rock is online now   Reply With Quote
Old 01-20-2007, 01:46 AM   · #16
Matthew.
Stud Sausage
 
Location: England
Trader Rating: (25)
Join Date: Dec 2006
Posts: 1,539
NP$: 33.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
Originally Posted by champ_rock
is there any way so that the result will be added to a text file automatically?



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
__________________
My Blog

My NamePros Tools
(firefox plugin, google gadget etc)
Matthew. is offline   Reply With Quote
Old 01-20-2007, 01:52 AM   · #17
champ_rock
Senior Member
 
champ_rock's Avatar
 
Name: Akshay Jain
Location: http://uck.in
Trader Rating: (91)
Join Date: Oct 2006
Posts: 2,665
NP$: 12439.80 (Donate)
champ_rock has a brilliant futurechamp_rock has a brilliant futurechamp_rock has a brilliant futurechamp_rock has a brilliant futurechamp_rock has a brilliant futurechamp_rock has a brilliant futurechamp_rock has a brilliant futurechamp_rock has a brilliant futurechamp_rock has a brilliant futurechamp_rock has a brilliant futurechamp_rock has a brilliant future
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
champ_rock is online now   Reply With Quote
Old 01-20-2007, 04:22 AM   · #18
DJ
Senior Member
 
DJ's Avatar
 
Location: .be
Trader Rating: (45)
Join Date: Dec 2004
Posts: 1,289
NP$: 152.12 (Donate)
DJ is a splendid one to beholdDJ is a splendid one to behold