<?php include "core/menu.php" ?>
<center><img src="img/radio.png" />
	<p id='preview'></p><script id='myscript' language='javascript' src='http://flashplayer.listen2myradio.com/getInfo.js?id=2326328bb7ea0a2215651b639c002625778b'></script>
<br><br>
<font color="red">
<h4>Attendre quelques secondes après le lancement de la page.</h4></font><br>
	<?php

/* ---------- General configuration ---------- */

$station_name = "Synarius";

$refresh = "100000000000";  // Page refresh time in seconds. Put 0 for no refresh
$timeout = "100000000000"; // Number of seconds before connecton times out - a higher value will slow the page down if any servers are offline

/* ----------- Server configuration ---------- */

// Note: dont include http://
// Main server: The song title will be taken from this server

$ip[1] = "72.55.149.162"; 
$port[1] = "16342";

/* Relays: Below you can enter more relays / restreams / channels / competitors or anything else */


/* ----- No need to edit below this line ----- */
/* ------------------------------------------- */
$servers = count($ip);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<?php
if ($refresh != "0") 
        {
        print "<meta http-equiv=\"refresh\" content=\"$refresh\">\n";
        }
print "<title>$station_name SHOUTcast Stats</title>\n";
?>
</head>
<body>
<?php
$i = "1";
while($i<=$servers)
        {
        $fp = @fsockopen($ip[$i],$port[$i],$errno,$errstr,$timeout);
        if (!$fp) 
                { 
                $listeners[$i] = "0";
                $msg[$i] = "<span class=\"red\">ERROR [La radio n'est pas en ligne]</span>";
                $error[$i] = "1";
                } 
        else
                { 
                fputs($fp, "GET /7.html HTTP/1.0\r\nUser-Agent: Mozilla\r\n\r\n");
                while (!feof($fp)) 
                        {
                        $info = fgets($fp);
                        }
                $info = str_replace('<HTML><meta http-equiv="Pragma" content="no-cache"></head><body>', "", $info);
                $info = str_replace('</body></html>', "", $info);
                $stats = explode(',', $info);
                if (empty($stats[1]) )
                        {
                        $listeners[$i] = "0";
                        $msg[$i] = "<span class=\"red\">ERROR [La radio n'est pas en ligne]</span>";
                        $error[$i] = "1";
                        }
                else
                        {
                        if ($stats[1] == "1")
                                {
                                $song[$i] = $stats[6];
                                $listeners[$i] = $stats[0];
                                $max[$i] =  $stats[3];
                                $bitrate[$i] = $stats[5];
                                $peak[$i] = $stats[2];
                                if ($stats[0] == $max[$i]) 
                                        { 
                                        $msg[$i] .= "<span class=\"red\">";
                                        }
                 
                                if ($stats[0] == $max[$i]) 
                                        { 
                                        $msg[$i] .= "</span>";
                                        }
                           
                                }
                        else
                                {
                                $listeners[$i] = "0";
                                $msg[$i] = "    <span class=\"red\">ERROR [Cannot get info from server]</span>";
                                $error[$i] = "1";
                                }
                        }
                }
        $i++;
        }
$total_listeners = array_sum($listeners) ;
print "<div id=\"blu\">\n  <div style=\"text-align: center;\">\n    <h1>Il y a $total_listeners auditeurs en ligne</h1>\n  </div>\n</div>\n<div>\n  <div>\n    <p><b>En ce moment :</b> $song[1]</p>\n  </div>\n</div>\n<div>\n";
$i = "1";
while($i<=$servers)
        {
          print "  <div>\n";
if ($max[$i] > 0) 
        {
        $percentage = round(($listeners[$i] / $max[$i] * 100));
        $timesby = (300 / $max[$i]);
        $barlength = round(($listeners[$i] * "$timesby"));
        }

        {
?>
    
<?php
        }

        $i++;
        }



?>
</body>
</html>
	</center>
	</div>
	
					</div>
					<div class="spacer"></div>
				</div>
			</div>

<?php include "core/end.php" ?>