// This function tries to open a TCP connection to $server on port $port.
// If it fails, it will call mail(BLABLABLA).
// Return value: true if connection was successful, false if not.
function is_online($server='localhost',$port=80,$timeout=2) {
$fp = @fsockopen($server, $port, &$errno, &$errstr, $timeout);
if (!$fp) {
fclose($fp);
echo "Offline";
mail(BLABLABLA);
return false;
}
fclose($fp);
echo "Online";
return true;
}
?>
@@HTTP