This is a function that can check the status of a server.
It needs fsockopen() enabled.
<?php
function server_status($server, $port, $timeout = 5){
if (!fsockopen ($server, $port, $errno, $errstr, $timeout)) {
$status = "Offline"; // If NOT successful
} else {
$status = "Online"; // If successful
}
return $status; // return to $status
}
// The script:
// echo server_status(url string, port int, timeout int [optional]);
?>