NameSilo

PHP: Bulk domain availability check!

SpaceshipSpaceship
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.
GoDaddyGoDaddy
I have Revision 6 in my HDD. Revision number of index.php is 4 but this is Revision 6 script. Not tested recently, whois servers and PHP5.

I'd love to grab this but I'm being told to log in every time I try to download :(
I have the Revision 4 script, so this update would be welcomed.

stu
 
0
•••
0
•••
Here's a copy of my own revision, consider it revision 7 :)
 

Attachments

  • bdac.zip
    4.3 KB · Views: 806
Last edited:
0
•••
Here's a copy of my own revision, consider it revision 7 :)

Thank you Eric, your version works great for me. Thanks too to Matthew as the original poster. Happy turkey day +1 to Canucks

_\|/_
 
0
•••
0
•••
/**
* Changes by "Eric" (Eric Sizemore)
*
* Revision 7, October 13th, 2009
* -------------------------------------
* - Added blank index pages in the saves and inc directory.
* - Minor enhancements to the php code, to hopefully improve speed.
* - Should be valid HTML now.
*/
 
0
•••
Still both .org and .info don't work but faster scanning for .com. Eric, thanks for the update. ;)
 
0
•••
Wonderful script! how do you add additional cctld whois servers? what are those "not a registered domain","No data Found","No entries found" on dnservers.php? where can i get those infos?
 
0
•••
Still both .org and .info don't work but faster scanning for .com. Eric, thanks for the update. ;)

.info seems to work for me.

---------- Post added at 05:46 PM ---------- Previous post was at 05:43 PM ----------

Wonderful script! how do you add additional cctld whois servers? what are those "not a registered domain","No data Found","No entries found" on dnservers.php? where can i get those infos?
Code:
'.extension' => array('whois server', 'text if domain is available')
 
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
 
0
•••
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
•••
Appraise.net
Escrow.com
Spaceship
Rexus Domain
CryptoExchange.com
Domain Recover
CatchDoms
NameMaxi - Your Domain Has Buyers
DomDB
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back