PDA

View Full Version : ShoutCast stats [help]



CFairweather
20-01-2008, 04:27 PM
Hi, me and my friend just cannot get the stats working, can anyone help?
the server is fine its just the script.
+rep to helpers<3

Edited by Aflux (Forum Moderator) - Moved to 'Online Radios'. Please post in the correction section.

Jibbish
20-01-2008, 04:46 PM
Post the error an we might be able to help?

CFairweather
20-01-2008, 04:49 PM
i dont know the error lmao. i just need stats that work x]

H0BJ0B
20-01-2008, 05:16 PM
<?
// ** CONFIGURATION ** - Please enter details within the speech marks
//Radio IP
$scip = "RADIOIP";
//Radio port
$scport = "RADIOPORT";
//Radio password
$scpass = "RADIOPASSWORD";
//If offline, say:
$offlinemsg = "Sorry! The radio is currently offline!";
// ** END CONFIGURATION **
$scfp = fsockopen("$scip", $scport, &$errno, &$errstr, 30);
if(!$scfp) {
$scsuccs=1;
echo $offlinemsg;
}
if($scsuccs!=1){
fputs($scfp,"GET /admin.cgi?pass=$scpass&mode=viewxml HTTP/1.0\r\nUser-Agent: SHOUTcast Song Status (Mozilla Compatible)\r\n\r\n");
while(!feof($scfp)) {
$page .= fgets($scfp, 1000);
}
//define xml elements
$loop = array("STREAMSTATUS", "BITRATE", "SERVERTITLE", "CURRENTLISTENERS", "MAXLISTENERS", "BITRATE");
$y=0;
while($loop[$y]!=''){
$pageed = ereg_replace(".*<$loop[$y]>", "", $page);
$scphp = strtolower($loop[$y]);
$$scphp = ereg_replace("</$loop[$y]>.*", "", $pageed);
if($loop[$y]==SERVERGENRE || $loop[$y]==SERVERTITLE || $loop[$y]==SONGTITLE || $loop[$y]==SERVERTITLE)
$$scphp = urldecode($$scphp);
$y++;
}
//end intro xml elements
//get song info and history
$pageed = ereg_replace(".*<SONGHISTORY>", "", $page);
$pageed = ereg_replace("<SONGHISTORY>.*", "", $pageed);
$songatime = explode("<SONG>", $pageed);
$r=1;
while($songatime[$r]!=""){
$t=$r-1;
$playedat[$t] = ereg_replace(".*<PLAYEDAT>", "", $songatime[$r]);
$playedat[$t] = ereg_replace("</PLAYEDAT>.*", "", $playedat[$t]);
$song[$t] = ereg_replace(".*<TITLE>", "", $songatime[$r]);
$song[$t] = ereg_replace("</TITLE>.*", "", $song[$t]);
$song[$t] = urldecode($song[$t]);
$dj[$t] = ereg_replace(".*<SERVERTITLE>", "", $page);
$dj[$t] = ereg_replace("</SERVERTITLE>.*", "", $pageed);
$r++;
}
//end song info
fclose($scfp);
}
//display stats
if($streamstatus == "1"){
//you may edit the html below, make sure to keep variable intact
echo "
<p align=center><center>
<b>DJ:</b> $servertitle<br>
<b>Listeners:</b> $currentlisteners / $maxlisteners<br>
<b>Current Song:</b> $song[0]</p>
<p><b>Song History</b></p>
<p><b>1.</b> $song[1]<br>
<b>2.</b> $song[2]<br>
<b>3.</b> $song[3]<br>
<b>4.</b> $song[4]<br></p>
";
}
//If radio is offline.
if($streamstatus == "0")
{
echo "<p>$offlinemsg</p>";
}
?>


I made that for my DJ Panel a while ago.
I hope it works :) You only need to change the top bit where it says RADIOIP etc.

Buax
23-01-2008, 06:24 PM
<?
// ** CONFIGURATION ** - Please enter details within the speech marks
//Radio IP
$scip = "RADIOIP";
//Radio port
$scport = "RADIOPORT";
//Radio password
$scpass = "RADIOPASSWORD";
//If offline, say:
$offlinemsg = "Sorry! The radio is currently offline!";
// ** END CONFIGURATION **
$scfp = fsockopen("$scip", $scport, &$errno, &$errstr, 30);
if(!$scfp) {
$scsuccs=1;
echo $offlinemsg;
}
if($scsuccs!=1){
fputs($scfp,"GET /admin.cgi?pass=$scpass&mode=viewxml HTTP/1.0\r\nUser-Agent: SHOUTcast Song Status (Mozilla Compatible)\r\n\r\n");
while(!feof($scfp)) {
$page .= fgets($scfp, 1000);
}
//define xml elements
$loop = array("STREAMSTATUS", "BITRATE", "SERVERTITLE", "CURRENTLISTENERS", "MAXLISTENERS", "BITRATE");
$y=0;
while($loop[$y]!=''){
$pageed = ereg_replace(".*<$loop[$y]>", "", $page);
$scphp = strtolower($loop[$y]);
$$scphp = ereg_replace("</$loop[$y]>.*", "", $pageed);
if($loop[$y]==SERVERGENRE || $loop[$y]==SERVERTITLE || $loop[$y]==SONGTITLE || $loop[$y]==SERVERTITLE)
$$scphp = urldecode($$scphp);
$y++;
}
//end intro xml elements
//get song info and history
$pageed = ereg_replace(".*<SONGHISTORY>", "", $page);
$pageed = ereg_replace("<SONGHISTORY>.*", "", $pageed);
$songatime = explode("<SONG>", $pageed);
$r=1;
while($songatime[$r]!=""){
$t=$r-1;
$playedat[$t] = ereg_replace(".*<PLAYEDAT>", "", $songatime[$r]);
$playedat[$t] = ereg_replace("</PLAYEDAT>.*", "", $playedat[$t]);
$song[$t] = ereg_replace(".*<TITLE>", "", $songatime[$r]);
$song[$t] = ereg_replace("</TITLE>.*", "", $song[$t]);
$song[$t] = urldecode($song[$t]);
$dj[$t] = ereg_replace(".*<SERVERTITLE>", "", $page);
$dj[$t] = ereg_replace("</SERVERTITLE>.*", "", $pageed);
$r++;
}
//end song info
fclose($scfp);
}
//display stats
if($streamstatus == "1"){
//you may edit the html below, make sure to keep variable intact
echo "
<p align=center><center>
<b>DJ:</b> $servertitle<br>
<b>Listeners:</b> $currentlisteners / $maxlisteners<br>
<b>Current Song:</b> $song[0]</p>
<p><b>Song History</b></p>
<p><b>1.</b> $song[1]<br>
<b>2.</b> $song[2]<br>
<b>3.</b> $song[3]<br>
<b>4.</b> $song[4]<br></p>
";
}
//If radio is offline.
if($streamstatus == "0")
{
echo "<p>$offlinemsg</p>";
}
?>
I made that for my DJ Panel a while ago.
I hope it works :) You only need to change the top bit where it says RADIOIP etc.

You also need to change most of the varibles, such as the login infomation and the port.

Want to hide these adverts? Register an account for free!