Domain Empire

PHP: Bulk domain availability check!

Spaceship Spaceship
Watch
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(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.
 
Last edited:
17
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
Cheers YesBrilliant, mattjewell.com is being a little slow right now so it might be acting a bit crap ;)

mtorregiani, i read your post and then forgot about it sorry. I can't seem to find a whois server for .com.es or .es, so i can't add support sorry :(
 
0
•••
0
•••
Can't work with that sorry :P

There is no whois server listed on any site i can find and whois services like whois.sc d not even give a full whois report so i can only assume it doesn't have one :td:
 
0
•••
this is just what i was looking for,i can't thank you enough!

btw...can you make a bulk GOOGLE PageRank checker?
 
0
•••
Don't mention it signor.

That's actually an interesting idea you havce, i may look into doing that some time in the future, depends when i get some time.

Matt
 
0
•••
Matthew. said:
Don't mention it signor.

That's actually an interesting idea you havce, i may look into doing that some time in the future, depends when i get some time.

Matt


yes off course :] :] :]
 
0
•••
Id it possible to add the .mobi extension?
 
0
•••
.mobi support is already a feature in the last revision mtorregiani :)
 
0
•••
0
•••
Matthew, *.pt domains that are registered show as available, hmm can you try to fix it :)?
 
0
•••
w1ww said:
Matthew, *.pt domains that are registered show as available, hmm can you try to fix it :)?

Hmm, no in short :(

Seems .pt does not actually have a whois server, must be in the list by mistake :|

Sorry, all i can do is remove support for it :) (will upload updated version in a while)
 
0
•••
Great, simple install - just download and upload both files
 
0
•••
Matthew the whois server for .pt is 'whois.dns.pt'
 
0
•••
w1ww said:
Matthew the whois server for .pt is 'whois.dns.pt'

Ah - Well then i take that back. I searched for it myself but wasn't able to find one coming to the conclusion it was one of the ccTLDs without one.

Give me a couple of minutes I'll update the script.

Edit: Script updated! .pt support fixed!
 
Last edited:
0
•••
It is working :), great job! You may want to add support to *.com.pt it uses the same whois server !
 
0
•••
w1ww said:
It is working :), great job! You may want to add support to *.com.pt it uses the same whois server !

Awesome ;) I'll be sure to add that later tonight!
 
0
•••
if you need to know other whois servers, i can help.

i have a commercial prog that gives you a list of all whois servers as far as i know.
 
0
•••
I'll be sure to let you know if i need any manofgames, most are available on the internet though :)
 
0
•••
0
•••
Good stuff mtorregiani ;)

Note: I am aware of the problem with .ORG domains in <= the latest version, i do not have time to investigate this now however will get round to it in the next few days.

(They results are inaccurate after 4 domains when checking all .ORG).

Matt
 
0
•••
Very good script. I was searching for something like that. But I think we need a proxy integration or random whois server system to the script
 
0
•••
Hi SNaReX,

I don't see the need for it as of now as i have had no problems nor any reports of IP banning from the whois servers because of this. :)

Thanks for the comments

http://www.namepros.com/1744713-post62.html (i will look at this when i find time :))
Matt
 
0
•••
Thanks a lot again.... This is very helpful update. .in names are very hot nowadays.
 
0
•••
.ORG Support have been removed as multiple requests are blocked from the WHOIS server (PIR).

A solution would to be add a proxy into the script however i am just too busy to do anymore to it.

All other extensions are fine.

Matt
 
0
•••
Thank you for the script. I have been using it for the last few days. I hate to report, but the whois look up on "info" whois.afilias.net has a limit that I exceeded. I don't know what the limit is and I don't know if the limit is restored after an amount of time, but woudl like to report that aspect of "info" look'up's.
 
0
•••
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back