Domain Name Check

Since NetworkSolutions has come under fire for its suspect domain claiming habits, my favorite place for running bulk domain checks has gone away. A friend of mine turned me on to a script by Matt Jewell that allows you to search for open domains with no fuss. Since it’s available for free distribution/implementation and I often find myself looking for new law-related domains, I’ve decided to post it here for more people to find and use.

The PHP code for this has been executed within WordPress using one of the popular plugins available for such things…

set_time_limit(0);
ob_start();
/* -------- Bulk domain availablity check script (Revision 4) ------------
[
[ Created by "Matthew." (45276) @ http://namepros.com / http://mattjewell.com
[ Feel free to modify/use however you wish,
[ but keep credit comments in upon distribution.
*/
$ext = array(
'.com' => array(’whois.crsnic.net’,'No match for’),
‘.net’ => array(’whois.crsnic.net’,'No match for’),
‘.biz’ => array(’whois.biz’,'Not found’),
‘.mobi’ => array(’whois.dotmobiregistry.net’, ‘NOT FOUND’),
‘.tv’ => array(’whois.nic.tv’, ‘No match for’),
‘.in’ => array(’whois.inregistry.net’, ‘NOT FOUND’),
‘.info’ => array(’whois.afilias.net’,'NOT FOUND’),
‘.co.uk’ => array(’whois.nic.uk’,'No match’),
‘.co.ug’ => array(’wawa.eahd.or.ug’,'No entries found’),
‘.or.ug’ => array(’wawa.eahd.or.ug’,'No entries found’),
‘.nl’ => array(’whois.domain-registry.nl’,'not a registered domain’),
‘.ro’ => array(’whois.rotld.ro’,'No entries found for the selected’),
‘.com.au’ => array(’whois.ausregistry.net.au’,'No data Found’),
‘.ca’ => array(’whois.cira.ca’, ‘AVAIL’),
‘.org.uk’ => array(’whois.nic.uk’,'No match’),
‘.name’ => array(’whois.nic.name’,'No match’),
‘.us’ => array(’whois.nic.us’,'Not Found’),
‘.ac.ug’ => array(’wawa.eahd.or.ug’,'No entries found’),
‘.ne.ug’ => array(’wawa.eahd.or.ug’,'No entries found’),
‘.sc.ug’ => array(’wawa.eahd.or.ug’,'No entries found’),
‘.ws’ => array(’whois.website.ws’,'No Match’),
‘.be’ => array(’whois.ripe.net’,'No entries’),
‘.com.cn’ => array(’whois.cnnic.cn’,'no matching record’),
‘.net.cn’ => array(’whois.cnnic.cn’,'no matching record’),
‘.org.cn’ => array(’whois.cnnic.cn’,'no matching record’),
‘.no’ => array(’whois.norid.no’,'no matches’),
‘.se’ => array(’whois.nic-se.se’,'No data found’),
‘.nu’ => array(’whois.nic.nu’,'NO MATCH for’),
‘.com.tw’ => array(’whois.twnic.net’,'No such Domain Name’),
‘.net.tw’ => array(’whois.twnic.net’,'No such Domain Name’),
‘.org.tw’ => array(’whois.twnic.net’,'No such Domain Name’),
‘.cc’ => array(’whois.nic.cc’,'No match’),
‘.nl’ => array(’whois.domain-registry.nl’,'is free’),
‘.pl’ => array(’whois.dns.pl’,'No information about’),
‘.pt’ => array(’whois.dns.pt’,'No match’)
);

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 “

$domain is $status!

“;
}
}

if(isset($_POST['submit']))
{
$filename = ’saves/’ . mt_rand(5, 9999999999);

if(strlen($_POST['domains']) > 0)
{

$domains = explode(”\n”, $_POST['domains']);

echo ‘

Checking ‘ . count($domains) . ‘ domains

‘;
echo (isset($_POST['save'])) ? ‘Preparing results, please wait…

‘ : 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 ‘
Available domains‘;
}

if(file_exists($filename . ‘_taken.txt’))
{
echo ‘
Taken domains‘;
}
else
{
echo ‘
0 taken domains found’;
}

if(file_exists($filename . ‘_invalid.txt’))
{
echo ‘
Invalid domains (could not be checked)‘;
}
}
}
else
{
echo ‘You need to enter one or more domains!’;
}
}
else
{
?>



}
?>

1 comment

Read the comments left by other users below, or:

Get your own gravatar by visiting gravatar.com Matt Jewell
#1. March 11th, 2008, at 10:18 PM.

Hi there,

Cheers for featuring the script! Glad people can get some use out of it.

Leave your comment...

If you want to leave your comment on this article, simply fill out the next form:




You can use these XHTML tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> .