rendered paste body// This is the function....
function sc_status($server, $port, $file) {
$cont = "";
$ip = gethostbyname($server);
$fp = fsockopen($ip, $port);
if (!$fp)
{
return "Unknown";
}
else
{
$com = "GET $file HTTP/1.1\r\nAccept: */*\r\nAccept-Language: de-ch\r\nAccept-Encoding: gzip, deflate\r\nUser-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)\r\nHost: $server:$port\r\nConnection: Keep-Alive\r\n\r\n";
fputs($fp, $com);
while (!feof($fp))
{
$cont .= fread($fp, 500);
}
fclose($fp);
$cont = substr($cont, strpos($cont, "\r\n\r\n") + 4);
//return $cont;
}
$parts = explode(',', $cont);
$status = $parts['1'];
if ($status == '0') {
return "<img src='offair.gif' alt='Server is DOWN'>";
} else {
return "<img src='onair.gif' alt='Server is UP'>";
}
}
// This is what you would call...
echo sc_status('ip_address', 'server_port', '/radio.html');