I got it all figured out except for one thing. Flash stops reading in the variables at the ' sign. but here is the code incase you are wondering how to do this for your site.
PHP Code save as "config_radio.php"
PHP Code:
<?php
$scdef = "";//Keep as is it was for a message
$scip = "IP";//IP adress
$scport = "port";//port #
$scpass = "changeme";//stream admin Password if you dident change it it is changeme
?>
PHP Code save as "radio_stats.php"
PHP Code:
<?php
// Shoutcast Server Stats
// Parses shoutcasts xml to make an effective stats thing for any website
// ©2004-2005 Daniel Brown [url]http://www.gmtt.co.uk[/url]
// Please refer to the readme file for use.
// Add-On MAXLISTNERS insead of the / 10 MAXLISTENERS which was set, and the BITRATE add-on.
// Online and Offline graphics, and add-on code.
// Better HTML Script.
// Do Not Try To Edit This Only Unless You Know What You're Doing!!!!!!!
include('config_radio.php');
$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", "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);
// 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
/*-------------
On Air status
-------------*/
if($streamstatus == "1"){
echo '&air= 1';//this is what i used as a variable to determine that the station was on
echo '&clisten= '.$currentlisteners.'';//current listeners
echo '&mlisten= '.$maxlisteners.'';//Maximum listeners
echo "&cs= $song[0]";//current song
}
/*-------------
Off Air status
-------------*/
if($streamstatus == "0")
{
echo '&air= 0';//this is what i used as a variable to determine that the station was off
echo '&clisten= '.$currentlisteners.'';//current listeners should be 0 since it is off
echo '&mlisten= '.$maxlisteners.'';//Maximum listeners should be 0 since it is off
echo "&cs= $song[0]";//current song should be 0 since it is off
/*--------------------------------------------------------------------------------
Current song for more just add another echo like echo="&s1= $song[1]"; just
keep adding one to them your input variable in flash will be myLoadVars_lv.s1
and so on incrementing by one.
--------------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------------
As for the time played you will also have to input then using another echo command
this would be echo="t0= $playedat[0]"; for current song and just add one to those
for previous songs. Reminder your input variable in flash will be myLoadVars_lv.t0
for the first one and so on incrementing by one.
--------------------------------------------------------------------------------*/
}
?>
And for the flash I also have 2 codes one for frame 1 and the other for frame 360 which is 30 seconds into it. You can adjust that to whatever you want for the refresh. Your FPS times seconds. This refresh dose not work in IE but it dose in FireFox.
Frame 1 code
code:
/*--------------------------------
creates a variable to load in the
PHP variables
---------------------------------*/
var myLoadVars_lv = new LoadVars();
/*--------------------------------
What happens if it loads the
variables in successfully
---------------------------------*/
myLoadVars_lv.onLoad = function( success )
{
/*--------------------------------
One last chance to load the variables
---------------------------------*/
if (myLoadVars_lv.air==0){
myLoadVars_lv.load("radio_stats.php");
}
/*--------------------------------
Display message if on air the <B> and
</B> makes the text bold if they are
read in as HTML
---------------------------------*/
if (myLoadVars_lv.air==1){
air = "<B>ONLINE 24/7/365</B>";
/*--------------------------------
Display listeners message if on air the
Listeners: current / max
---------------------------------*/
listen= "<B>Listeners: " + myLoadVars_lv.clisten +" / "+ myLoadVars_lv.mlisten + "</B>";
/*--------------------------------
Display Current song if on air the
Currrent Song: current song
---------------------------------*/
cs="<B>Currrent Song: " + myLoadVars_lv.cs + "</B>";
/*--------------------------------
Display Current song if off air the
you get the picture
---------------------------------*/
} else{
air = "<B>Temporarily Offline</B>";
listen= " ";
cs=" ";
}
}
/*--------------------------------
Loads in the variables
---------------------------------*/
myLoadVars_lv.load("radio_stats.php");
Frame 360 Code
code:
/*----------------------------------------
This code is just to make the status blank
before it reloads variables on frame one
----------------------------------------*/
air = "";
listen= " ";
cs=" ";
gotoAndPlay(1);
Oh ya a working version of this will be at
http://www.theattitude.org/