quote:
the last suggestion on there
The "last" on depends on how you're sorting them, which may well be different to the rest of us.
Here's the code used at backup.tehforum.co.uk - no idea if it's the best or even a good way of doing it, but it works well enough:
php code:
<?php
function ping($host, $port, $timeout)
{
$tB = microtime(true);
$fP = fSockOpen($host, $port, $errno, $errstr, $timeout);
if (!$fP) { return '<strong style="color: red;">failed</strong>'; }
$tA = microtime(true);
return '<strong style="color:green;">success in '.round((($tA - $tB) * 1000), 0).' milliseconds</strong>';
}
?>
<p>Pinging 178.79.137.101... <? echo @ping("178.79.137.101", 80, 10); ?>.</p>
<p>Pinging www.tehforum.co.uk... <? echo @ping("www.tehforum.co.uk", 80, 10); ?>.</p>
<p>Verifying forum is online...<?
if (strpos(strtolower(file_get_contents("http://www.tehforum.co.uk/forum")),'<title>teh forum</title>') !== false)
{
echo '<strong style="color:green;">success</strong>';
}
else
{
echo '<strong style="color:red;">failed</strong>';
}
?>.</p>
EDITED: 16 Nov 2011 00:16 by BOUGHTONP