Code - amiofforon
<?php
/******************************************************************
Am I off or online?
Simple function to check if your SHOUTcast server has a source connected and
is online.
License, free, use like the wind blows. Be nice and recognize that
it was written by Jay Krivanek of www.radiotoolbox.com ;)
******************************************************************/
function OfforOn($host, $port, $wait_sec)
{
$fp = fsockopen($host, $port, $errstr, $errno, $wait_sec);
if ($fp)
{
fputs($fp, "GET / HTTP/1.0\r\nUser-Agent:AmIoffOrOn\r\n\r\n");
$ret = fgets($fp, 255);
if (ereg("200", $ret))
{
return true;
}
else
{
return false;
}
fclose($fp);
}
else
{
return false;
}
}
?>