Page 1 sur 1

Nombres d'auditeurs + Titre Onair shoutcast

Posté : 29 juin 2010, 22:21
par diabo852
Script pour webradio (SHOUTCAST) qui affiche le nombre d'auditeurs présent et le titre de la musique.
<?php

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

$station_name = "Nom_de_votre_radio";

$refresh = "1";  // Page refresh time in seconds. Put 0 for no refresh
$timeout = "1"; // 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] = "ip_serveur"; 
$port[1] = "port_serveur";

/* 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";
?>
<style type="text/css">
<!--
body {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 12px;
	color: #333333;
	margin: 5px;
	background-color: #fff;
}
div {
	background-color: #fef9f2;
	border: 1px solid #000;
	padding: 4px;
	margin-bottom: 5px;
	width: 400px;
}
div div {
	margin: 5px;
	border: 0;
	background-color: #fef9f2;
	margin: 5px;
	margin-bottom: 0;
}
h1 {
	font-size: 22px;
	color: #000;
	margin: 2px;
}
h2 {
	font-size: 14px;
	color: #336666;
	margin: 2px;
}
p {
	margin: 5px;
}
a {
	color: #666699;
	text-decoration: none;
}
a:hover {
	color: #993333;
}
div.line {
	border-bottom: 1px dashed #000;
	height: 3px;
	font-size: 1px;
	margin-top: 0;
}
div#blu, div#blu div {
	background-color: #b2bfc0;
}
.red {
	color: #CC0000;
	font-weight: bold;
}
.small {
	font-size: 10px;
}
-->
</style>
</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\">";
					}
				$msg[$i] .= "Server is up at $bitrate[$i] kbps with $listeners[$i] of $max[$i] listeners";
				if ($stats[0] == $max[$i]) 
					{ 
					$msg[$i] .= "</span>";
					}
				$msg[$i] .= "\n    <p><b>Listener peak:</b> $peak[$i]";
				}
			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"));
	}
if ($error[$i] != "1") 
	{
?>
    
<?php
	}

	$i++;
	}



?>

</body>
</html>
Lachez vos commentaires :D

Re: Nombres d'auditeurs + Titre Onair shoutcast

Posté : 13 nov. 2010, 04:27
par stealth35
encore un vieux script tout naze piqué sur un forum tout droit venu des années 90...

Re: Nombres d'auditeurs + Titre Onair shoutcast

Posté : 16 nov. 2010, 16:40
par zeus
Et c'est normal d'être aussi virulent ?

Re: Nombres d'auditeurs + Titre Onair shoutcast

Posté : 16 nov. 2010, 16:46
par stealth35
Et c'est normal d'être aussi virulent ?
C'est mon commentaire, j'insulte personne encore moins l'auteur puisque déjà c'est pas son code. Et si j'avais quelque chose a dire sur l'auteur du sujet c'est d'au moins citer ses sources.

Re: Nombres d'auditeurs + Titre Onair shoutcast

Posté : 16 nov. 2010, 18:08
par zeus
Donc, si tu estimes que ce qu'il raconte, c'est de la merde, tu penses avoir le droit de le traiter de merde ... :shock:

Re: Nombres d'auditeurs + Titre Onair shoutcast

Posté : 16 nov. 2010, 18:20
par stealth35
Donc, si tu estimes que ce qu'il raconte, c'est de la merde, tu penses avoir le droit de le traiter de merde ... :shock:
Comme je l'ai dis j'insulte personne, et je suis pas grossier non plus contrairement à se que t'essayes de faire croire.

Re: Nombres d'auditeurs + Titre Onair shoutcast

Posté : 16 nov. 2010, 21:52
par zeus
OK, je t'accorde que j'ai grossi le trait.

Mais reconnais tout de même que ta 1ere intervention est très loin d'être un compliment.