| while ($awake){ code(); } Name: Eric Location: Kentucky Join Date: Mar 2005
Posts: 4,116
NP$: 259.00 ( Donate)
| Made a few changes...
index.php PHP Code: <?php
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.
*/
require_once('./inc/dnservers.php');
function save_file($status)
{
global $filename, $domain, $extension;
$domain = trim($domain);
// Let's try to chmod ourselves, before warning them they need to do so
if (!($file_handle = @fopen($filename . "_$status.txt", 'a+')))
{
@touch($filename . "_$status.txt");
@chmod($filename . "_$status.txt", 0666);
// Try again..
if (!($file_handle = @fopen($filename . "_$status.txt", 'a+')))
{
trigger_error('Cannot open or create file (chmod?)', E_USER_WARNING);
}
}
$status .= ($status == 'invalid' AND $extension == 'org') ? ' (.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);
return;
}
function return_status($domain, $status)
{
global $extension, $filename;
$domain = trim($domain);
if (isset($_POST['save']))
{
save_file($status);
}
else
{
$color = ($status == 'available') ? '55BB11' : 'E51417';
$status .= ($status == 'invalid' AND $extension == 'org') ? ' (.org WHOIS prevents request)' : '';
echo "<div style=\"color: #$color;\">$domain is $status!</div>";
}
return;
}
if (isset($_POST['submit']))
{
if (version_compare(PHP_VERSION, '4.2.0', '<='))
{
mt_srand((double)microtime() * 1000000);
}
$filename = 'saves/' . mt_rand(5, mt_getrandmax());
if (strlen($_POST['domains']) > 0)
{
$domains = preg_split("#\n#", trim($_POST['domains']), -1, PREG_SPLIT_NO_EMPTY);
$domains = array_map('trim', $domains);
echo '<h1>Checking ' . count($domains) . ' domains</h1><br />';
echo (isset($_POST['save'])) ? 'Preparing results, please wait...<br /><br />' : '';
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 AND array_key_exists(".$extension", $ext))
{
$server = $ext[".$extension"][0];
$sock = fsockopen($server, 43) or trigger_error("Error Connecting To Server: $server", E_USER_ERROR);
fputs($sock, "$domain\r\n");
while (!feof($sock))
{
$buffer .= fgets($sock, 128);
}
fclose($sock);
if ($extension == 'org')
{
echo nl2br($buffer);
}
return_status($domain, (ereg($ext[".$extension"][1], $buffer) ? 'available' : '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']) AND 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
}
?> http://www.phpsociety.com/dbulk/ |