Dynadot

PHP: Bulk domain availability check!

NameSilo
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.
I tried installing the "download.zip" shared in the middle of PAGE 6 of this thread. It doesn't work as expected :(. Getting 404 error. I'm a neophyte in web development but knows HTML very well. Please help !
Thanks.

404 error is completely managed by your web server since the script itself does not introduce any simplest routing to respond with 404 or any other code. hence you need to take a look at your Apache (clean it out and get Lighttpd or Nginx instead if you have time) settings.. its really tough to say anything useful unless you know server config.. script is pretty simple and straightforward to work out of the box with almost any generic lamp installation.

---------- Post added at 07:37 PM ---------- Previous post was at 07:34 PM ----------

Thanks I will try to read and digest that a bit later this evening ! :)

---------- Post added at 06:04 PM ---------- Previous post was at 05:27 PM ----------

Tried adding (to the include PHP file) just,

'co.in' => array('whois.inregistry.net', 'NOT FOUND'),

Removed any alteration and they still come out as invalid domains ?

send me your code, i'll check it out :)
 
0
•••
send me your code, i'll check it out :)

Getting 404 also and this error - Error 139 (net::ERR_TEMPORARILY_THROTTLED): Requests to the server have been temporarily throttled.
 
0
•••
Getting 404 also and this error - Error 139 (net::ERR_TEMPORARILY_THROTTLED): Requests to the server have been temporarily throttled.


1. 404 basically means your web server could not find URL you requested. as the script URL is "index.php" it should be served by your server (apache/nginx/lighttpd/etc - i have no the slightest idea of MS servers thou) automatically on most (default) configurations. if not - check your system paths and .htaccess... or just put "<?php echo "Hello"; ?> into your index.php (strip off everything else) - if nothing happens and you still get 404 you have to deal with webserver config or consult your hosting provider, thats all individual stuff

2. Error 139 (net::ERR_TEMPORARILY_THROTTLED) - are you on Google Chrome? :)
 
0
•••
Well I know what a 404 is and yes I am using Google Chrome. :)

Its my own server - is there something in the index.php that needs to be changed???
 
Last edited:
0
•••
Well I know what a 404 is and yes I am using Google Chrome. :)

Its my own server - is there something in the index.php that needs to be changed???

Error 139 (net::ERR_TEMPORARILY_THROTTLED) - could you please try this and test the script again:
http://www.jsiegel.com/2011/12/howto-disable-chromes-request.html

..no, nothing needs to be changed in index.php.
test you server config with <?php echo 'Hello'; ?> in index.php - if it doesnt work after you turned off request throttling in Chrome (or just switch to Firefox for a moment) the problem is not with the script...
 
0
•••
Hi guys,

I installed the script on my VPS, but it seems to not be working. It gets stuck after domain number 20 and just pauses with no results being shown. I am thinking perhaps its due to my host provider but not quite sure.
 
0
•••
I'll be graduating shortly and will be looking, in my more plentiful free time, to build a fully featured version of this, so hang tight.

Although I am no longer active in developing this (first posted it 5 years ago!), I'm happy to hear requests for any new version.
 
0
•••
Hey,

This looks great. But the download link is not working? Anywhere I can download this?

Thanks
 
0
•••
Found download link but it says all are taken even though they are not some. Solution to this, anybody?
 
0
•••
What extension are you searching?

Found download link but it says all are taken even though they are not some. Solution to this, anybody?
 
0
•••
I am searching .se (Swedish extension).

Now when you say it I noticed it works for .com, .nu etc but not .se. So it's only for the .se domain.
 
0
•••
The script doesn't support .se.
 
0
•••
I guess it's possible to implement, but thanks.
 
0
•••
tldavailability.com

I like the service of tldavailability.com

They have a Bulk version and an API that returns the tld availability information in JSON format.
 
0
•••
I like the service of tldavailability.com

They have a Bulk version and an API that returns the tld availability information in JSON format.

Lightning fast and useful.




God Bless,
Marcia Sue
 
0
•••
Hi all,

Can you please someone tell me how I can install this on my machine? I don't quite get the meaning of -
Remember to CHMOD "saves" to 777 under *nix servers.

Thank you!
 
0
•••
0
•••
#1 help me. Download Link not Found
please fix now
 
0
•••
If you take the time to read the thread, the actual code has been posted.
 
0
•••
loook like can't download it ?
 
0
•••
The code is in a post. You just have to copy and paste it.
 
0
•••
I own a website. I recently built. Its a domain name generator that generates domains name for business startups.

It works fine but it is not 100% accurate. I mean that there are some domains that are taken but this tool shows these as available. Such as separated.com is a domain that is actually not available but if you check it with this tool then it will display as available. Check here: Namobot.com

What can I do to make it work 100% accurate? Any suggestions will be appropriated.

Thanks.
 
0
•••
Back