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.
thanks

plus one more suggestion.. you can add 2 text files.. one for the taken domains and the other for the available ones.. if it is not too much of a coding task..

adding some reps
 
0
•••
Matt, excellent script, been looking for this for ages!

One tiny suggestion, please add support for .tv :D

Thanks again and rep coming your way!
 
0
•••
i just checked about 2000domains in abou 2 minutes .. :) :) thanks a lot
 
0
•••
champ_rock said:
is there any way so that the result will be added to a text file automatically?

May I kindly suggest this be an option rather than default - i.e. 'download output as text file link' please?

Also, another vote for .TV support

Wicked little script Matthew, well done.
Rep added.

- Vince
 
0
•••
You are great. rep added.
 
0
•••
Wow this topic took off while i was away lol.

Okeysss,
plus one more suggestion.. you can add 2 text files.. one for the taken domains and the other for the available ones.. if it is not too much of a coding task..

Sure thing, this will hopefully get done tonight, it's only a small adjustment however I'm a little tired out and have work to do :( But I'll try my best!

i just checked about 2000domains in abou 2 minutes ..
Awesome :tu: I haven't tried how many it can handle, theoretically it's unlimited however depending on config the server will end the script at some point.

May I kindly suggest this be an option rather than default - i.e. 'download output as text file link' please?
Wouldn't dream of anything else :)

I will look into adding .TV support as well :)

Thanks for all the kind comments and rep guys :tu:
 
0
•••
Hi Matthew,
Just one last thing. As the list of tld's is quite long, and to save alittle on server processing, why not have them as tickboxes?

Many people would only be interested in checking a few of those tld's anyway?

Many thanks again.

- Vince
 
0
•••
the script rocks n its current stage only.

i seem to be giving suggestions and suggestions only.. here go a few more to make it a dream script kind of a thing.. they all will require more advanced editing..

1. take input also from a text file.. use cronjobs to schedule checking
2. mailing the available domain list so that the script mails me when some domain becomes available for reggin ..
3. ad proxy support which will automatically switch proxie after some 100-200 domains checks.. that way the ip will not get banned :)
 
0
•••
Hi vincenzo,
Just one last thing. As the list of tld's is quite long, and to save alittle on server processing, why not have them as tickboxes?

Many people would only be interested in checking a few of those tld's anyway?

The server list is long however the script does not check each extension. It will use the appropriate array key (and in this array since it is a multidimensional array the array array key) so check only the whois server for the domain with that extension.

champ_rock,
1. take input also from a text file.. use cronjobs to schedule checking
2. mailing the available domain list so that the script mails me when some domain becomes available for reggin ..

I like the first half of that idea, but the second would require greater input from the user and goes out of the bounds of this script :)

3. ad proxy support which will automatically switch proxie after some 100-200 domains checks.. that way the ip will not get banned

I think i'll leave it as it is, if someone wants to do that they can but i don't have any time to spend on this anymore as i loose a whole day of work tomorrow. I will get some suggestions put in (i.e. text files and .tv support) but not extensive ones :)
 
0
•••
ya nno problem.. it was just a recommendation .. anyways thanks for sharing such a gr8 script

------------

i decided to test the limits of my server as well as the limits of the registrar before it blocks ur Ip

this script has successfully tested about 10976 domains.. :)

to test further i have placed about 45000 domains.. when the results come i will definately inform

update:
while checking the 15000 domains of the second lot i recieved this error
Fatal error: Maximum execution time of 30 seconds exceeded in /home/champroc/public_html/dc/index.php on line 43

i think that if u own the server then u can increase this time which will make this script invincible
 
Last edited:
0
•••
Fatal error: Maximum execution time of 30 seconds exceeded in /home/champroc/public_html/dc/index.php on line 43

Fixed!

CODE UPDATED!
- Added "save results as text file" feature - requested.
- Added .tv domain support - requested

Go back to page one or download here: http://mattjewell.com/dnlookup/download.zip

Live demo updated:
http://mattjewell.com/dnlookup/

My apolagies for the lazy coding, i just can't spend a large amount of time on this right now.

edit: having problems with demo for some reason, will fix asap.

Script bug found and fixed! :)
 
Last edited:
0
•••
u rock !!!

will add some more reps to you when VB permits..

whenever u get time please add the email and cronjobs to be implemented!!
 
0
•••
champ_rock said:
u rock !!!

will add some more reps to you when VB permits..

whenever u get time please add the email and cronjobs to be implemented!!

Thanks ;)

I'm going to leave that for someone who wants it to do themselves, it's a bit out of this scripts job if you get me. Maybe my next script will do that ;)

edit: Another bug found/fixed.
 
Last edited:
0
•••
How about have checkbox for each extension?
 
0
•••
tansks said:
How about have checkbox for each extension?
Tansks, this has already been asked. You guys are killing him. He customs out a script, shares it, changes it to suit some requests, mentions he is tired, also that he is missing work, takes the time and fixes some bugs, clearly states he is leaving further modding to the next guy, and still.....

Anyways Matthew, thanks for a job well done!

With your permission we will be adding this into the DNOA Members Toolbox interface, with all props to you of course.

Peace,
Cyberian
 
0
•••
well mathew, you will be happy to know that i just checked about 45000 domains successfully..

also, this script uses very very less bandwidth.. it had used about 7 mb for searching about 60000domains... :) :)
 
0
•••
~ Cyberian ~ said:
Tansks, this has already been asked. You guys are killing him. He customs out a script, shares it, changes it to suit some requests, mentions he is tired, also that he is missing work, takes the time and fixes some bugs, clearly states he is leaving further modding to the next guy, and still.....

Anyways Matthew, thanks for a job well done!

With your permission we will be adding this into the DNOA Members Toolbox interface, with all props to you of course.

Peace,
Cyberian

Oops, sorry (to Matthew).
 
0
•••
Don't worry about it tansks :)

Tansks, this has already been asked. You guys are killing him. He customs out a script, shares it, changes it to suit some requests, mentions he is tired, also that he is missing work, takes the time and fixes some bugs, clearly states he is leaving further modding to the next guy, and still.....

Anyways Matthew, thanks for a job well done!

With your permission we will be adding this into the DNOA Members Toolbox interface, with all props to you of course.

No problems :) You may use it however you wish, no credits required :) It's all free.
 
0
•••
0
•••
Thanks ashokuh.


Code updated!

- Added .in support
- Fixed .mobi support (i removed it by accident)
- Fixed/Replaced URL grabber:
PHP:
// From:
str_replace(array('http://', 'www.'), null, $domain); / (would break domains such as freewww.com)

// To:
preg_match('@^(http://www\.|http://|www\.)?([^/]+)@i', $domain, $matches);
 
0
•••
ok

i am a complete newbie to php.. i have not even read the first page of php tutorial anywhere.. so please dont think that this script that i am uploading is perfect

i have added email support (copied the emailing script from the net) :) which works only when u have enabled the option to save as a text file

if anyone has some spare time then please refine this script as follows: (mathews i am not asking uto do it as u r busy)
current bug that i know exist but cannot rectify because of my limited knowledge:

if the "availability" file does not exist but the "taken file" exists then it gives a error.


also, i would want to ad a text box on the script page where the user can specify which email id does he want the email to be sent to.. {this one should not be difficult}

thanks for all ur help
 
0
•••
Code has been updated once more.

Changes are only to code organization. (script shortened)
 
0
•••
Suggestion: Transform the entered urls to lowercase ;)

edit: you have already done that, sorry not paying attention lol
 
0
•••
I don't want to bother, but... can you add the .es and .com.es ext?
 
0
•••
Excellent script!

Thanks a lot for sharing.

Repd!
 
0
•••
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back