Ich bin am verzweifeln... weiss nicht mehr weiter, an was dass denn liegen könnte.. bin eigentlich nen neuanfänger was dies angeht.... Soll eigentlich eine art playlist werden, wo man die letzten 10 titel sieht....
hier mal der code:
radio.class:
hier mal der code:
radio.class:
<?php
class radio{
function init(){ // Initialisierung und erzeugung des Arrays mit den Werten
$x_xml = $this->get_xml();
$this->parse_xml($x_xml);
}
function get_xml(){ // XML Status auslesen und alles unn�tige entfernen
// return implode(file("icecast2.xml")); // Auskommentieren beim Einsatz, nur f�r Testzwecke
$sp = @fsockopen($this->host, $this->port, &$errno, &$errstr, 10);
if (!$sp)
die('Error while connecting to Server.');
else{
set_socket_blocking($sp, false);
if($this->serv == "shoutcast"){
fputs($sp, "GET /admin.cgi?pass=" . $this->pass . "&mode=viewxml HTTP/1.1\nUser-Agent: Mozilla\n\n");
}
else if($this->serv == "icecast"){
fputs($sp, "GET /admin/stats.xml HTTP/1.1\nUser-Agent: Mozilla\n");
fputs($sp, "Host: " . $this->host . "\n");
fputs($sp, "Authorization: Basic " . base64_encode("admin:" . $this->pass) . "\n\n");
}
else
die('There is no Server selected. Please select \"shoutcast\" or \"icecast\".');
for($i = 0; $i < 30; $i++) {
if(feof($sp))
break;
$sp_data .= fread($sp, 31337);
usleep(500000);
}
}
if($this->serv == "shoutcast")
$sp_data = ereg_replace("^.*<SHOUTCASTSERVER", "<SHOUTCASTSERVER", $sp_data);
if($this->serv == "icecast")
$sp_data = ereg_replace("^.*<icestats", "<icestats", $sp_data);
return $sp_data;
}
function set_host($host){ // Host schreiben
$this->host = $host;
}
function set_port($port){ // Port schreiben
$this->port = $port;
}
function set_pass($pass){ // Passwort schreiben
$this->pass = $pass;
}
function set_serv($serv){ // Serverart schreiben
$this->serv = $serv;
}
function parse_xml($x_xml){ // XML Baum verarbeiten, Array mit Tags und Werten, Array mit Songhistory (Shoutcast) und Array mit H�rern (shoutcast) erzeugen
$x_data_flag = FALSE;
$x_parser = xml_parser_create();
xml_parse_into_struct($x_parser, $x_xml, $x_vals, $x_index);
xml_parser_free($x_parser);
$this->x_vals = $x_vals;
$this->x_index = $x_index;
if($this->serv == "shoutcast"){
$this->status = $x_vals[$x_index['STREAMSTATUS'][0]]['value'];
$this->current_listeners = $x_vals[$x_index['CURRENTLISTENERS'][0]]['value'];
$this->peak_listeners = $x_vals[$x_index['PEAKLISTENERS'][0]]['value'];
$this->max_listeners = $x_vals[$x_index['MAXLISTENERS'][0]]['value'];
$this->average_time = $x_vals[$x_index['AVERAGETIME'][0]]['value'];
$this->server_genre = $x_vals[$x_index['SERVERGENRE'][0]]['value'];
$this->server_url = $x_vals[$x_index['SERVERURL'][0]]['value'];
$this->server_title = $x_vals[$x_index['SERVERTITLE'][0]]['value'];
$x_title = explode(" - ", $x_vals[$x_index['SONGTITLE'][0]]['value']);
$this->artist = $x_title[0];
$this->title = $x_title[1];
$this->song_url = $x_vals[$x_index['SONGURL'][0]]['value'];
$this->irc = $x_vals[$x_index['IRC'][0]]['value'];
$this->aim = $x_vals[$x_index['AIM'][0]]['value'];
$this->icq = $x_vals[$x_index['ICQ'][0]]['value'];
$this->version = $x_vals[$x_index['VERSION'][0]]['value'];
$this->listeners();
$this->song_history();
}
else if($this->serv == "icecast"){
$x_count = 0;
$xa_count = 0;
while($x_index['SOURCE'][$x_count]){
if($x_vals[$x_index['SOURCE'][$x_count]]['type'] == "open"){
$x_array[] = $x_index['SOURCE'][$x_count];
$this->mounts[$xa_count]['mount'] = $x_vals[$x_index['SOURCE'][$x_count]]['attributes']['MOUNT'];
$this->mounts[$xa_count]['artist'] = $x_vals[$x_index['ARTIST'][$xa_count]]['value'];
$this->mounts[$xa_count]['audio_bitrate'] = $x_vals[$x_index['AUDIO_BITRATE'][$xa_count]]['value'];
$this->mounts[$xa_count]['audio_channels'] = $x_vals[$x_index['AUDIO_CHANNELS'][$xa_count]]['value'];
$this->mounts[$xa_count]['audio_info'] = $x_vals[$x_index['AUDIO_INFO'][$xa_count]]['value'];
$this->mounts[$xa_count]['audio_samplerate'] =
class radio{
function init(){ // Initialisierung und erzeugung des Arrays mit den Werten
$x_xml = $this->get_xml();
$this->parse_xml($x_xml);
}
function get_xml(){ // XML Status auslesen und alles unn�tige entfernen
// return implode(file("icecast2.xml")); // Auskommentieren beim Einsatz, nur f�r Testzwecke
$sp = @fsockopen($this->host, $this->port, &$errno, &$errstr, 10);
if (!$sp)
die('Error while connecting to Server.');
else{
set_socket_blocking($sp, false);
if($this->serv == "shoutcast"){
fputs($sp, "GET /admin.cgi?pass=" . $this->pass . "&mode=viewxml HTTP/1.1\nUser-Agent: Mozilla\n\n");
}
else if($this->serv == "icecast"){
fputs($sp, "GET /admin/stats.xml HTTP/1.1\nUser-Agent: Mozilla\n");
fputs($sp, "Host: " . $this->host . "\n");
fputs($sp, "Authorization: Basic " . base64_encode("admin:" . $this->pass) . "\n\n");
}
else
die('There is no Server selected. Please select \"shoutcast\" or \"icecast\".');
for($i = 0; $i < 30; $i++) {
if(feof($sp))
break;
$sp_data .= fread($sp, 31337);
usleep(500000);
}
}
if($this->serv == "shoutcast")
$sp_data = ereg_replace("^.*<SHOUTCASTSERVER", "<SHOUTCASTSERVER", $sp_data);
if($this->serv == "icecast")
$sp_data = ereg_replace("^.*<icestats", "<icestats", $sp_data);
return $sp_data;
}
function set_host($host){ // Host schreiben
$this->host = $host;
}
function set_port($port){ // Port schreiben
$this->port = $port;
}
function set_pass($pass){ // Passwort schreiben
$this->pass = $pass;
}
function set_serv($serv){ // Serverart schreiben
$this->serv = $serv;
}
function parse_xml($x_xml){ // XML Baum verarbeiten, Array mit Tags und Werten, Array mit Songhistory (Shoutcast) und Array mit H�rern (shoutcast) erzeugen
$x_data_flag = FALSE;
$x_parser = xml_parser_create();
xml_parse_into_struct($x_parser, $x_xml, $x_vals, $x_index);
xml_parser_free($x_parser);
$this->x_vals = $x_vals;
$this->x_index = $x_index;
if($this->serv == "shoutcast"){
$this->status = $x_vals[$x_index['STREAMSTATUS'][0]]['value'];
$this->current_listeners = $x_vals[$x_index['CURRENTLISTENERS'][0]]['value'];
$this->peak_listeners = $x_vals[$x_index['PEAKLISTENERS'][0]]['value'];
$this->max_listeners = $x_vals[$x_index['MAXLISTENERS'][0]]['value'];
$this->average_time = $x_vals[$x_index['AVERAGETIME'][0]]['value'];
$this->server_genre = $x_vals[$x_index['SERVERGENRE'][0]]['value'];
$this->server_url = $x_vals[$x_index['SERVERURL'][0]]['value'];
$this->server_title = $x_vals[$x_index['SERVERTITLE'][0]]['value'];
$x_title = explode(" - ", $x_vals[$x_index['SONGTITLE'][0]]['value']);
$this->artist = $x_title[0];
$this->title = $x_title[1];
$this->song_url = $x_vals[$x_index['SONGURL'][0]]['value'];
$this->irc = $x_vals[$x_index['IRC'][0]]['value'];
$this->aim = $x_vals[$x_index['AIM'][0]]['value'];
$this->icq = $x_vals[$x_index['ICQ'][0]]['value'];
$this->version = $x_vals[$x_index['VERSION'][0]]['value'];
$this->listeners();
$this->song_history();
}
else if($this->serv == "icecast"){
$x_count = 0;
$xa_count = 0;
while($x_index['SOURCE'][$x_count]){
if($x_vals[$x_index['SOURCE'][$x_count]]['type'] == "open"){
$x_array[] = $x_index['SOURCE'][$x_count];
$this->mounts[$xa_count]['mount'] = $x_vals[$x_index['SOURCE'][$x_count]]['attributes']['MOUNT'];
$this->mounts[$xa_count]['artist'] = $x_vals[$x_index['ARTIST'][$xa_count]]['value'];
$this->mounts[$xa_count]['audio_bitrate'] = $x_vals[$x_index['AUDIO_BITRATE'][$xa_count]]['value'];
$this->mounts[$xa_count]['audio_channels'] = $x_vals[$x_index['AUDIO_CHANNELS'][$xa_count]]['value'];
$this->mounts[$xa_count]['audio_info'] = $x_vals[$x_index['AUDIO_INFO'][$xa_count]]['value'];
$this->mounts[$xa_count]['audio_samplerate'] =
Comment