PDA

View Full Version : Radio Stat's



krazyhouse
31-01-2006, 09:18 PM
Anyone know the coding for radio stats for shoutcast???

I tried this but it wont work :( Any help would be appreciated :D



<script>

<!--



/*

Auto Refresh Page with Time script

By JavaScript Kit (javascriptkit.com)

Over 200+ free scripts here!

*/



//enter refresh time in "minutes:seconds" Minutes should range from 0 to inifinity. Seconds should range from 0 to 59

var limit="0:30"



if (document.images){

var parselimit=limit.split(":")

parselimit=parselimit[0]*60+parselimit[1]*1

}

function beginrefresh(){

if (!document.images)

return

if (parselimit==1)

window.location.reload()

else{

parselimit-=1

curmin=Math.floor(parselimit/60)

cursec=parselimit%60

if (curmin!=0)

curtime=curmin+" minutes and "+cursec+" seconds left until page refresh!"

else

curtime=cursec+" seconds left until page refresh!"

window.status=curtime

setTimeout("beginrefresh()",1000)

}

}



window.onload=beginrefresh

//-->

</script><?php

// Shoutcast Server Stats

// Parses shoutcasts xml to make an effective stats thing for any website

// ©2004-2005 Daniel Brown http://www.gmtt.co.uk (http://www.gmtt.co.uk/)

// Please refer to the readme file for use.

include('config_radio.php'); //you may edit this path to fit your server environment otherwise leave it alone

$scfp = fsockopen("$scip", $scport, &$errno, &$errstr, 30);

if(!$scfp) {

$scsuccs=1;

echo''.$scdef.' is Offline';

}

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);

}

################################################## ################################################## ##################

/////////////////////////part 1 \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

//define xml elements

$loop = array("STREAMSTATUS", "BITRATE", "SERVERTITLE", "CURRENTLISTENERS");

$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);



// uncomment the next line to see all variables

//echo'$'.$scphp.' = '.$$scphp.'<br>';

$y++;

}

//end intro xml elements

################################################## ################################################## ##################

################################################## ################################################## ##################

/////////////////////////part 2\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

//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'

<html>

<title>'.$scdef.'</title>

</head>



<body text="" bgcolor="">









<p align="center"><center>



<font face="arial" size="2"><b>&nbsp;Tuned Into: </b>&nbsp;'.$servertitle.'</font>

<font face="arial" size="2"><b>&nbsp;<br> With </b>&nbsp;'.$currentlisteners.' Listeners</font></p>



<font face="arial" size="2" color=""><b>



Song:</b> '.$song[0].'</font></p><

<b>





<p><font face="arial" size="2">

Other Songs:</font></b>

<font color=""><font face="arial" size="2">

<p align="center">

<b>1.</b> '.$song[1].'<BR>

<b>2.</b> '.$song[2].'<BR>

<b>3.</b> '.$song[3].'<BR>

<b>4.</b> '.$song[4].'<BR>

<b>5.</b> '.$song[5].'<BR>

</font>

<BR>

</p></p>

</body>



</html>';

}

if($streamstatus == "0")

{

//you may edit the html below, make sure to keep variable intact

echo'

<html>



<head>

<meta name="GENERATOR" content="Microsoft FrontPage 5.0">

<meta name="ProgId" content="FrontPage.Editor.document">

<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">

<META HTTP-EQUIV="REFRESH" CONTENT="30;URL=radio_stats1.php">

<link rel=stylesheet href="" type="text/css">

<title>Radio Server Is Offline</title>

</head>



<body text= "#000000" bgcolor="#215DDE">

<center><b><font style="tahoma">No One Is Djing. <br>

</body>





</html>';

}

?><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </p>


I've put this into a code box for you as it's easier to read through :).
- mat64 (Forum moderator)

Coding4Newbs
01-02-2006, 06:11 AM
you must not be editing it properly :rolleyes:

---MAD---
01-02-2006, 09:35 AM
check the config_radio.php and check if your configurations (pass, port ip etc) are correct.

Coding4Newbs
01-02-2006, 09:44 AM
remeber edit the bit where it says username 'edit here'!
not the comments // user name here

Jamie.
01-02-2006, 03:27 PM
Don't know if this will help but go to the tutorials section theres one in there.

krazyhouse
01-02-2006, 05:22 PM
Thanks for all the info, But still wont work :(, All the info such as radio IP and port are correct.
The parse.php wont work, Is anyone willing to help me out if i give you the details needed please???

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