IT.COM

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.
i am little bit confused with bulk check and black listing...
do you or your IP or server IP get black listed or banned for bulk checking?
is that ture? in that case how came godaddy allow us to do the unilimited bulk search?

is there any limit for bulk search?

little bit confused....and scared to use the script for my website....help me guys....
 
0
•••
That's a good question. I've checked a few hundred thousand at once with this script and was never blocked, so I'm not sure

i am little bit confused with bulk check and black listing...
do you or your IP or server IP get black listed or banned for bulk checking?
is that ture? in that case how came godaddy allow us to do the unilimited bulk search?

is there any limit for bulk search?

little bit confused....and scared to use the script for my website....help me guys....
 
0
•••
i am little bit confused with bulk check and black listing...
do you or your IP or server IP get black listed or banned for bulk checking?
is that ture? in that case how came godaddy allow us to do the unilimited bulk search?

is there any limit for bulk search?

little bit confused....and scared to use the script for my website....help me guys....

Pretty sure a while back I posted the script with changes so that it only does a whois query if a DNS or ping (I cant remember)lookup fails.

So the more names that are available in your list the more whois queries and the more chance you will get blocked.

So if say you did a search of common dictionary words most if not all would be taken so there would actually be very few if any whois queries.
 
0
•••
Pretty sure a while back I posted the script with changes so that it only does a whois query if a DNS or ping (I cant remember)lookup fails.

So the more names that are available in your list the more whois queries and the more chance you will get blocked.

So if say you did a search of common dictionary words most if not all would be taken so there would actually be very few if any whois queries.

would you mind posting that again? Or is there a more current version somewhere?
 
0
•••
0
•••
i am little bit confused with bulk check and black listing...
do you or your IP or server IP get black listed or banned for bulk checking?
is that ture? in that case how came godaddy allow us to do the unilimited bulk search?

is there any limit for bulk search?

little bit confused....and scared to use the script for my website....help me guys....


If you were to hit the servers to such an extent that they felt your usage was inappropriately high (I can't vouch for what criteria these company's might use for that) then it would be your server's IP that would be prevented from using it.

I don't think there has been a report thus far?

GoDaddy are big enough to be able to make their own rules ;)
 
0
•••
0
•••
im getting undefined variable $buffer on line45 on BeZazz modification..

removed the $buffer above line69
 
0
•••
Where do i get xip file

I need full source code for checking the domain availability
 
0
•••
0
•••
0
•••
Wow this thread is ancient yet awesome!

Thanks for this great script mat, which is still being kept alive and updated 3 years later lol. Its truly awesome and just what i needed.

Its a shame mats site is down but thanks to this member for giving a download link here http://www.namepros.com/280961-php-bulk-domain-availability-check-6.html#post3618414 (thanks mate)

And you should update the index.php with this members code http://www.namepros.com/280961-php-bulk-domain-availability-check-8.html#post4092014 (thanks mate)(dont forget you need to remove $buffer from line 67 so that it works though)

Anyway tanks again mat awesome script
 
0
•••
Thanks for this script. However I gave it a trial run last night with 10k domains and it gave false results for several i have checked manually so far. I.e it said some of the domains were taken when they were actually avaliable?

Does anyone know why this is and how to solve the issue? I am a developer but not with PHP.

The domains i tried were .co.uk and i used the version with the changes in the post above. Any help greatly appreciated :)
 
Last edited:
0
•••
The problem might have been from the whois engine for .co.uk I dunno how to fix it but hopefully someone subscribed to this thread knows :)

Thanks for this script. However I gave it a trial run last night with 10k domains and it gave false results for several i have checked manually so far. I.e it said some of the domains were taken when they were actually avaliable?

Does anyone know why this is and how to solve the issue? I am a developer but not with PHP.

The domains i tried were .co.uk and i used the version with the changes in the post above. Any help greatly appreciated :)
 
0
•••
How can we add more TLDs to this script? I tried to search for .it domains but it's invalid..
 
0
•••
Again, you'll need to add the .it engine to it. See my above post.

How can we add more TLDs to this script? I tried to search for .it domains but it's invalid..
 
0
•••
thanks to all the guys that helped make this script great!
I know that this is really old post, i had red all the post already.

I just found this thread and hoping some one can help me out.
i downloaded the latest script from here, and it runs fine.
but only works with 3 or 4 domain at time, if i type more i got the error below.

PHP Warning: feof() expects parameter 1 to be resource, boolean given in on line 143
PHP Warning: fgets() expects parameter 1 to be resource, boolean given in on line 145

line 143: while (!feof($sock))
line 145: $buffer .= fgets($sock, 128)



I hoping some one fixed this issued and want to share.

thanks everyone
 
0
•••
Very Great script! I have just launched a check of 5000 names, and it's thinking. From what I have read so far here, I understood that my server's IP wouldn't get bamed for big checks? Is that so?

Thanks a lot!
 
0
•••
Hello, thanks for that great script!
The best whois script i tried until now.
Although i had to make a little fix to make it work with .tk
Here is what i did
At line 126 change the line
Code:
if (gethostbynamel($domain) !== false) {

with
Code:
if (gethostbynamel($domain) !== false AND $extension !== 'tk') {

and it'll work with tk too!

And something else. Org works just fine.

Thanks again
 
1
•••
Nm
 
Last edited:
0
•••
Working like a charm. Thanks for sharing
 
0
•••
haha,

so if I add

if (gethostbynamel($domain) !== false) {
with
Code:
if (gethostbynamel($domain) !== false AND $extension !== 'xxx, so, it, es') {

all those extensions would work as well ?

---------- Post added at 01:29 AM ---------- Previous post was at 01:27 AM ----------

Also quick question, what if I did this ...


if (gethostbynamel($domain) !== false AND $extension !== 'xxx, .co.in, it, es') {
 
0
•••
haha,

so if I add

if (gethostbynamel($domain) !== false) {
with
Code:
if (gethostbynamel($domain) !== false AND $extension !== 'xxx, so, it, es') {

all those extensions would work as well ?

---------- Post added at 01:29 AM ---------- Previous post was at 01:27 AM ----------

Also quick question, what if I did this ...


if (gethostbynamel($domain) !== false AND $extension !== 'xxx, .co.in, it, es') {



thats strange indeed, what you'll get this way is:

if domain resolves by gethostbynamel (taken) but in one of xxx, .co.in, it, es cctld you proceed with checking whois anyway (which only mkakes sense if you want to gather whois data - that doesnot get saved by the script anyway)

but in fact you never even get there - as none of xxx, .co.in, it, es is in $ext array (in inc/dnservers.php) you'll everytime get invalid status returned earlier, check this condition:
PHP:
if (strlen($domain) > 0 AND isset($ext[".$extension"]))

to check other extensions you need to simply add an entry into inc/dnservers.php with .tld, whois server to check and the string to search for:

'.es' => array('whois server for this tld', 'string that is in server reply when no domain records found')

also <<$extension !== 'xxx, .co.in, it, es'>> should be <<!in_array($extension, array('xxx', 'co.in', 'it', 'es'))>> if you still want to use this condition




:)

---------- Post added at 10:35 AM ---------- Previous post was at 10:31 AM ----------

Although i had to make a little fix to make it work with .tk
Here is what i did
At line 126 change the line
Code:
if (gethostbynamel($domain) !== false) {

with
Code:
if (gethostbynamel($domain) !== false AND $extension !== 'tk') {

and it'll work with tk too!

And something else. Org works just fine.

no it wont
 
0
•••
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 ?
 
0
•••
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.
 
0
•••
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back