http://www.web-radio.at/status2.php
hab mir in google ein scrite gesucht für shoutcast .. funkt leider nicht:
kann ma wer sagen was da nit stimmt?
hab mir in google ein scrite gesucht für shoutcast .. funkt leider nicht:
PHP-Code:
<?php
/*
Shoutcast stats through XML
By Rayeh
<a href="http://rayeh.sytes.net" target="_blank">[url]http://rayeh.sytes.net[/url]</a>
*/
$host = "80.109.43.159"; //Hostname, or ip address of server. IE blah.com or xx.xx.xx.xx
$port = "8000"; //Port server is running on. IE 8000
$password = "********"; //Password of server, can be normal or admin. Doesn't matter.
//Configuration Finished
//Runs each time an XML element starts
function StartHandler(&$Parser, &$Elem, &$Attr) {
global $Data, $CData;
/* Start with empty CData array. */
$CData = array();
/* Put each attribute into the Data array. */
while ( list($Key, $Val) = each($Attr) ) {
$Data["$Elem:$Key"] = trim($Val);
// debug //
echo "$Elem:$Key = " . $Data["$Elem:$Key"] . "\n";
}
}
//Runs each time XML character data is encountered
function CharacterHandler(&$Parser, &$Line) {
global $CData;
/*
* Place lines into an array because elements
* can contain more than one line of data.
*/
$CData[] = $Line;
}
//Runs each time an XML element ends
function EndHandler(&$Parser, &$Elem) {
global $Data, $CData, $listeners, $server, $song, $dj, $wee;
//Mush all of the CData lines into a string and put it into the $Data array.
$Data[$Elem] = trim( implode('', $CData) );
//echo "$Elem = " . $Data[$Elem] . "<br>\n";
switch ($Elem){
//for each case, we are putting some data into a variable.
case 'CURRENTLISTENERS':
$listeners['CURRENT'] = $Data['CURRENTLISTENERS'];
break;
case 'PEAKLISTENERS':
$listeners['PEAK'] = $Data['PEAKLISTENERS'];
break;
case 'MAXLISTENERS':
$listeners['MAX'] = $Data['MAXLISTENERS'];
break;
case 'AVERAGETIME':
$listeners['AVERAGETIME'] = $Data['AVERAGETIME'];
break;
case 'SERVERGENRE':
$server['GENRE'] = $Data['SERVERGENRE'];
case 'SERVERURL':
$server['URL'] = $Data['SERVERURL'];
break;
case 'SERVERTITLE':
$server['TITLE'] = $Data['SERVERTITLE'];
break;
case 'SERVERURL':
$server['SERVERURL'] = $Data['SERVERURL'];
break;
case 'SONGTITLE':
$song['TITLE'] = $Data['SONGTITLE'];
break;
case 'ICQ':
$dj['ICQ'] = $Data['ICQ'];
break;
case 'AIM':
$dj['AIM'] = $Data['AIM'];
break;
case 'BITRATE':
$server['BITRATE'] = $Data['BITRATE'];
break;
case 'SONG':
$wee = $wee+1;
break;
case 'PLAYEDAT':
$song[$wee]['PLAYEDAT'] = $Data['PLAYEDAT'];
break;
case 'TITLE':
$song[$wee]['TITLE'] = $Data['TITLE'];
break;
}
}
//open connection
$fp = fsockopen("$host", $port, &$errno, &$errstr, 30);
if (!$fp) {
echo "Connection to server could not be established! <BR>";
}
else {
//request xml
fputs($fp,"GET /admin.cgi?pass=".$password."&mode=viewxml&page=0 HTTP/1.0\nUser-Agent: Mozilla Compatible\n\n");
while(!feof($fp)) {
//put xml into $Data
$Contents .= fgets($fp, 1000);
}
}
//close connection
fclose($fp);
$Contents = str_replace('HTTP/1.0 200 OK','', $Contents);
$Contents = str_replace('Content-Type:text/xml','', $Contents);
$Contents = str_replace("\n",'', $Contents);
$Contents = str_replace("\r",'', $Contents);
$Contents = preg_replace('/(&|&)/i', '&', $Contents);
$Contents = preg_replace('/[^x20-x7Ex09x0Ax0D]/', "\n", $Contents);
$Data = array();
// Initialize the parser.
$Parser = xml_parser_create('ISO-8859-1');
xml_set_element_handler($Parser, 'StartHandler', 'EndHandler');
xml_set_character_data_handler($Parser, 'CharacterHandler');
//Pass the content string to the parser.
if (!xml_parse($Parser, $Contents)) {
$Probs[] = "$URI$Sym\n Had problem parsing file:\n "
. xml_error_string(xml_get_error_code($Parser));
}
if (isset($Probs)) {
echo implode("\n", $Probs);
}
//Output
$listeners['AVERAGETIME'] = $listeners[AVERAGETIME]/60;
$wee = $wee -1;
echo "
<table width=600 border=0>
<tr><td colspan=2><strong>Current</strong></td></tr>
<tr><td>Stream title:</td><td>$server[TITLE]</td></tr>\n
<tr><td>Song:</td><td>$song[TITLE]</td></tr>\n
<tr><td>Listeners:</td><td>$listeners[CURRENT]/$listeners[MAX]</td></tr>\n
<tr><td>Bitrate:</td><td>$server[BITRATE]Kbit</td></tr>\n
<tr><td colspan=2><strong>DJ</strong></td></tr>\n
<tr><td>AIM:</td><td>$dj[AIM]</td></tr>\n
<tr><td>ICQ</td><td>$dj[ICQ]</td></tr>\n
<tr><td colspan=2><strong>Records</strong></td></tr>\n
<tr><td>Peak listeners:</td><td>$listeners[PEAK]</td></tr>\n
<tr><td>Average Time:</td><td>$listeners[AVERAGETIME] Mins</td></tr>\n
<tr><td colspan=2><strong>Last $wee</strong></td><tr>\n
";
while($i < $wee) {
$i = $i+1;
echo "<tr><td colspan=2>$i. ".$song[$i][TITLE]."</td></tr>\n";
}
?>
Kommentar