| Danltn.com Name: Daniel Neville Location: Danltn.com / Nottingham, UK Join Date: May 2007
Posts: 1,185
NP$: 681.56 ( Donate)
| I just wrote this now.
Cba to sort out port 443 too. Simple change if you want to do it. PHP Code: <?php
/**
* Danltn | http://danltn.com/
* MSN: msn@danltn.com
* Email: daniel@neville.tk
* Started: 12/5/2008 17:25 (UK)
* Tested: No
* PHP 4/5: Both
* No warranty is given to code used
*/
define('TIMEOUT', 5);
define('UP_MESSAGE', '%s resolves.');
define('DOWN_MESSAGE', '%s doesn\'t resolve.');
define('LINE_BREAK', "<br />\n");
define('EXTRA_FLUSH', true);
/* Timeout -> Int
* Up_message -> Str
* Down_message -> Str
* Line Break -> Str
* Extra_flush -> Bool
*/
if (isset($_POST['submit']))
{
$list = (get_magic_quotes_gpc()) ? stripslashes($_POST['list']) : $_POST['list'];
$list = str_replace("\r", '', $list);
$urls = explode("\n", $list);
if (count($urls) > 0)
{
while (list(, $url) = each($urls))
{
if (!$url)
{
continue;
}
if (substr($url, 0, 4) === 'http')
{
$url = preg_replace('https?://', '', $url);
}
if (@fsockopen($url, 80, $errno, $errstr, TIMEOUT))
{
printf(UP_MESSAGE, $url);
}
else
{
printf(DOWN_MESSAGE, $url);
}
echo LINE_BREAK;
if (EXTRA_FLUSH === true)
{
ob_flush();
flush();
}
}
}
die();
}
?>
<form method="post" action="<?php echo $_SERVER['SCRIPT_NAME']; ?>">
<textarea rows="20" cols="60" name="list"></textarea><br />
<input type="submit" name="submit" value="Check" />
</form>
Last edited by Daniel : 05-12-2008 at 09:38 AM.
|