Dynadot

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.
Great script modifications! Any chance that you might release your version to the public?

I've made a few changes and released it online.
A few improvements are:

- Upload a domain list (good when the list is too big);
- Over 100 available TLD's;
- Whois link next to the domains already taken.

Soon I'll be adding Alexa, PR and Yahoo Backlinks count.
Please post your feedback!

Home - Domain Hammer
 
0
•••
0
•••
Good to see this still being put to good use.
 
0
•••
Woah, this thread is still on-going‽ This is one of the few things I actually remember from when I frequently used NP…

I'm sure I contributed a WHOIS class at some point to this script :)
 
0
•••
I've made a few changes and released it online.
A few improvements are:

- Upload a domain list (good when the list is too big);
- Over 100 available TLD's;
- Whois link next to the domains already taken.

Soon I'll be adding Alexa, PR and Yahoo Backlinks count.
Please post your feedback!

Home - Domain Hammer
Great improvement but I found the availability issue. I've checked random 170 LLLL.com and 17 names available. I never see the same result from original version.
 
1
•••
I've been using this script a lot and just tonight I got some errors. It appears that whois.crsnic.net is now limiting requests that cause a timeout error.

I tried using other serviers and increasing the "sleep" function to 10 seconds but it didn't work. Is there another server that can be used? I do think that all users of this script should limit it's use so it doesn't get blocked, or would someone like to provide the data access for a small fee...???? :)
 
0
•••
The way that the script currently works, it outputs the text "DOMAIN.COM is available!" or "DOMAIN.COM is taken!," depending on its availability. I only need it to output a domain if it's available (if it's taken, I don't want any text to appear on the screen telling me the domain or its 'taken' status). I know I can accomplish this with the 'save' feature but I need to see the results in real-time. Anyone think they can mod the index.php script to do this for me? I know very little PHP and dunno how to go about this :p
 
0
•••
Can you send me a copy of the script? I think I can make that change in a couple of minutes for you...
 
1
•••
Sure. PM me your email address and I'll send a .zip your way

Can you send me a copy of the script? I think I can make that change in a couple of minutes for you...
 
0
•••
Wow this script is great! Can i have it, too?
 
0
•••
Here's a copy of my own revision, consider it revision 7 :)

Thanks and get it.Good and clean script for 2 php files only.
Maybe integrate with my current rank checking script.

But thinking about the handling of ob_start() & ob_flush()
as for html header() requirement.
Also like using xml for dnsserver listing.(easier to cope with ajax/mysql/flash)


:)
 
Last edited:
0
•••
Pretty impressed with the amount of work people have put in to developing my originally simple script. Apologies to all who have contacted me regarding work on this or any other project, I dropped out of the development loop somewhat a couple of years ago and don't do much nowadays due to being at Uni etc.
 
0
•••
Thanks for sharing this with us. I use the script a lot, it is a real time-saver!
 
0
•••
I used Matthew and eric 's script,but both it did't work for some extensions properly,such as ".se",every ".se" domain is return "taken",where is the problem?

PS, can anyone added ".co" in this script? I tryed,but it works as ".se",returns "taken" everytime.
 
0
•••
I used Matthew and eric 's script,but both it did't work for some extensions properly,such as ".se",every ".se" domain is return "taken",where is the problem?

PS, can anyone added ".co" in this script? I tryed,but it works as ".se",returns "taken" everytime.

To search for .co add this to the script:

'co' => array('whois.nic.co', 'Not found'),

PS: Domain Hammer does .co among most other TLDs.
 
0
•••
I edited the script as your opinion,it works now!!!
hoho,I don't understand PHP language,so little question spend my big time.
for somepeople want to add new domain extionsions: seemed the reason is that every management has diffrent"return word",so add a new extension,you need know the"return word" of this domain management.
thanks for your opinion! and thanks the writer!

To search for .co add this to the script:

'co' => array('whois.nic.co', 'Not found'),

PS: Domain Hammer does .co among most other TLDs.
 
0
•••
I edited the script as your opinion,it works now!!!
hoho,I don't understand PHP language,so little question spend my big time.
for somepeople want to add new domain extionsions: seemed the reason is that every management has diffrent"return word",so add a new extension,you need know the"return word" of this domain management.
thanks for your opinion! and thanks the writer!

This happens because there's not a default response for all the Whois servers out there, and we have to probe each one of they to know how they work D-:
 
0
•••
en,was same means.I just can't express it exactly,and im poor in english ..:red:

This happens because there's not a default response for all the Whois servers out there, and we have to probe each one of they to know how they work D-:
 
0
•••
where can i get this script? Thnx
 
0
•••
0
•••
where can i get this script? Thnx

Goto previous page & you should find a few zip files to download, read all the posts carefully

cheers
 
0
•••
After installing the files on my server, i am getting "Internal Server Error".

Please reply.
 
0
•••
I'm sorry you are getting that error. I don't think anyone can help you if all you can provide is that error message. It could be the script, something that you did when you installed it, or a different problem with your site or server.

If you don't know how to find out what the specific problem is, you should contact your hosting provider and ask them to look at it for you. They won't fix problems with the script, but at least you will know for sure where you need to look for an answer.
 
0
•••
I'm sorry you are getting that error. I don't think anyone can help you if all you can provide is that error message. It could be the script, something that you did when you installed it, or a different problem with your site or server.

If you don't know how to find out what the specific problem is, you should contact your hosting provider and ask them to look at it for you. They won't fix problems with the script, but at least you will know for sure where you need to look for an answer.

This is the error :

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, [email protected] and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request"

Thanks for your input.
 
0
•••
Thanks, but the error message already tells you what you should do. :)

Most servers are not configured to show specific information when they have a 500 Error. The server admin will have to look at the server logs to see what happened and let you know.

Your only other option is to remove what you added and see if the error still exists. If not, you know there is something wrong with the code. Since you are using verycheapwebhosting your account may not have what is needed to run this script correctly.
 
Last edited:
0
•••
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back