[icecast] get status.xml's variable using a php file

Phi Tran phitran at myrealbox.com
Tue Dec 23 00:05:01 UTC 2003



hi everyone

i'm trying to get the variables from status.xml using php  (based on the Shoutcast status file from casterclub.com)

here is my file

<?php

$ip = "xxx.yyy.zzz";              
$port = "xxxx";             
$password = "xxxx";

<p>////////////////start the parsin action\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
//opening socket
$fp = fsockopen("$ip", $port, &$errno, &$errstr, 30); //open connection
if(!$fp) {
 $success=2;  //set if no connection

//edit html to fit your stations site, this display is for offline status
echo "server is offline ";
}

<p><p>if($success!=2){ //if connection
 fputs($fp,"GET http://$password@$ip:$port/admin/stats.xml"); //get stats.xml
 while(!feof($fp)) {
  $page .= fgets($fp, 1000);
 }
 
 
 $loop = array("client_connections","source_connections"); //define all the variables to get (delte any ones you don't want)
 $y=0; //dummy variable for while loop
 
  while($loop[$y]!=''){ //while there are things in loop
  $pageed = ereg_replace(".*<$loop[$y]>", "", $page); // extract data
  $phpname = strtolower($loop[$y]); //make names in loop lowercase for variable names
  $$phpname = ereg_replace("</$loop[$y]>.*", "", $pageed); //finish extracting data
  if($loop[$y]==SERVERGENRE || $loop[$y]==SERVERTITLE || $loop[$y]==SONGTITLE) //if for code clean-up (if you have problems with variables with URL encoding (i.e. %20 for space put them in this loop)
   $$phpname = urldecode($$phpname); // replace URL code with regular text (i.e. %20 = space)
 
 ##More stuff that prints##
echo ('$'.$phpname.' = '.$$phpname.' <BR>');
 ##Stop here. Your server will be upset if you comment out the next line of code ($y++;).##

  $y++; //update dummy variable for while loop
 }
 
 fclose($fp); //close connection
 echo "$client_connection";
}

?>

<p><p>but here is what i get instead for the output:

$client_connections = MountPoint,Connections,Stream Name,Current Listeners,Description,Currently Playing,Stream URL Global,Client:83075 Source: 184.....

exactly like the file status2.xsl

can anyone show me what is wrong w/ the code above?

thx a lot

<p>--- >8 ----
List archives:  http://www.xiph.org/archives/
icecast project homepage: http://www.icecast.org/
To unsubscribe from this list, send a message to 'icecast-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the Icecast mailing list