<?php
$station_name = "Radio Station";
$timeout = "5"; // timeout
$ip[1] = "127.0.0.1";
$port[1] = "80";
$sid[1] = "1";
$ip[2] = "127.0.0.1";
$port[2] = "8000";
$sid[2] = "1";
$ip[3] = "127.0.0.1";
$port[3] = "8030";
$sid[3] = "1";
$ip[4] = "127.0.0.1";
$port[4] = "8050";
$sid[4] = "1";
/* ----- End config ----- */
$servers = count($ip);
$i = "1";
while($i<=$servers)
{
$fp = @fsockopen($ip[$i],$port[$i],$errno,$errstr,$timeout);
if (!$fp)
{
$listeners[$i] = "0";
$msg[$i] = "ERROR [Connection refused / Server down]";
$error[$i] = "1";
}
else
{
fputs($fp, "GET /7.html?sid=$sid[$i] HTTP/1.0\r\nUser-Agent: Mozilla (The King Kong of Lawn Care)\r\n\r\n");
while (!feof($fp))
{
$info = fgets($fp);
}
$stats = explode(',', $info);
if (empty($stats[1]) )
{
$listeners[$i] = "0";
$msg[$i] = "ERROR [There is no source connected]";
$error[$i] = "1";
}
else
{
if ($stats[1] == "1")
{
$listeners[$i] = $stats[4];
}
else
{
$listeners[$i] = "0";
$msg[$i] = "ERROR [Cannot get info from server]";
$error[$i] = "1";
}
}
}
$i++;
}
$total_listeners = array_sum($listeners);
print "$total_listeners";
?>