Dynadot โ€” .com Transfer

PHP: Bulk domain availability check!

Spacemail by SpaceshipSpacemail by 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.
AfternicAfternic
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
•••
Thanks, but the error message already tells you what you should do. :)

But i really did not understand what to do :D

Please help.
 
0
•••
I'm not sure how to make what I am saying and what is in the error message more clear. Do this part:
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.
Contact your hosting provider about the problem.

If YOU are the webmaster, then you need to contact the hosting company. If you are the hosting company, then you need to contact someone that provides you with technical support. If you are the one that provides technical support, you need to look at the server logs. If you don't know how to look at the server logs, you need to find someone that can help you with that. :)
 
0
•••
I'm not sure how to make what I am saying and what is in the error message more clear. Do this part:Contact your hosting provider about the problem.

If YOU are the webmaster, then you need to contact the hosting company. If you are the hosting company, then you need to contact someone that provides you with technical support. If you are the one that provides technical support, you need to look at the server logs. If you don't know how to look at the server logs, you need to find someone that can help you with that. :)

Thanks friend ;)
 
0
•••
Hey guys,

Came across this for an application I was brewing up that needs to process massive amounts of domain ability checks. The original check functionality which attempts to connect to the appropriate whois server couldn't handle the amount of data I was throwing at it so I resorted to checking for nameservers first. If there is nameserver information then the domain is definitely registered. If there is no nameserver information then double check by using the original code. For my application it is only imperative that I am positive that the domain is registered so the second step has not proven necessary. With this there is no need to sleep as I do not believe there is a restriction on nameserver queries. So far so good I can plug away at a pace of around 45,000 checks per hour.

Code :

Code:
$dnsRecord = @dns_get_record($domain, DNS_ANY);
                        
if( empty($dnsRecord) )
{ 
    // No nameserver info found
    // Consider double checking with original fsock code
}
else
{
    // Nameserve info found, domain is registered
}

Many thanks to Matt and all the other contributors. Hope that helps!

Mark
 
0
•••
Mark,

Genius! Doing a nameserver pre-check should speed up the operation and remove some load from nameservers. I've never been blocked, but I don't run many names at one time. A couple times a month I update some lists and each is about 1,000 domains.

I think this is a great addition to the script. I can't quickly add this to the script, would someone mind helping with this?

Also, I love this damn thing. I don't know if Matt is still folling this thread but I will try to contact him. I would like to put up a site that can host the script as open source, if it's ok with Matt.

Comments? Feedback?
 
0
•••
Appraise.net
Escrow.com
Spaceship
Rexus Domain
CryptoExchange.com
Domain Recover
CatchDoms
DomainEasy โ€” Live Options
DomDB
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back