AW: Titelanzeige und Digital-Webstream
sorry.....jetzt wo du es so schreibst....fällt es mir auch auf
hier der code der config.php
<?php
/* MusicTicker - XML version 1.4.2 */
/* MAD props to Tom Pepper and Tag Loomis for all their help */
/* --------------------------------------------------------- */
/* SCXML configuration version 0.4.2 */
/* December 01 2004 01:05 EST */
//manditory config items
$host = "server4.digital-webstream.de"; // host or ip of shoutcast server
$port = "17340"; // port of shoutcast server
$password = "********"; // password for shoutcast server
$maxsongs = "1"; // max number of songs to display (max is 20)
$rfrshrate = "60"; // reload rate of page
$timeat = "0"; // display starttime (0) or endtime (1)
//gui config items
$bodybgcolor = "#f0f6fb";
$bodytext = "#000000";
$bodylink = "#708fbe";
$bodyvlink = "#708fbe";
$bordercolor = "#000000";
$csscolor = "#708fbe";
$font = "Arial, Helvetica";
$align = "center";
$adjust = "0"; // change time to correct for server time (hour x 3600)
//master table color scheme
$mstrtext = "#000000";
$mstrbgcolor = "#f0f6fb";
//lead table color scheme
$tbl1bgcolor1 = "#708fbe";
$tbl1bgcolor2 = "#ffffff";
$tbl1text = "#ffffff";
//content table color scheme
$tbl2bgcolor1 = "#708fbe";
$tbl2bgcolor2 = "#ffffff";
$tbl2text1 = "#ffffff";
$tbl2text2 = "#000000";
//error screen color scheme
$errorbgcolor = "#f0f6fb";
$errortext = "#708fbe";
//On screen messages
$pgtitle = "Shoutcast Status Page";
$header = "Shoutcast Status Page";
$timezone = "EST (-0500 GMT)";
$errormsg1 = "Sorry, The Server Is Currently Down";
$errormsg2 = "It Will Be Back Up ASAP !!!";
$dsperror1 = "Sorry, The Server Is Currently Unable To Retreive It's Source";
$dsperror2 = "It Will Be Back Up ASAP !!!";
$error1 = "<html>\n<head>\n</head>\n<body bgcolor=\"$errorbgcolor\">\n<h2>\n<p align=\"center\"><font color=\"$errortext\">$errormsg1</p>\n<br>\n<p align=\"center\">$errormsg2</p>\n</font>\n</h2>\n</body>\n</html>";
$error2 = "<html>\n<head>\n</head>\n<body bgcolor=\"$errorbgcolor\">\n<h2>\n<p align=\"center\"><font color=\"$errortext\">$dsperror1</p>\n<br>\n<p align=\"center\">$dsperror2</p>\n</font>\n</h2>\n</body>\n</html>";
?>
hier nun die scxml.php
<?php
/* MusicTicker - XML version 1.4.2 */
/* MAD props to Tom Pepper and Tag Loomis for all their help */
/* --------------------------------------------------------- */
/* SCXML reference version 0.4.2 */
/* December 01 2004 01:05 EST */
error_reporting (E_ALL ^ E_NOTICE);
require "scxml-obj.php";
require "config.php";
$serv1 = new SCXML;
$serv1->set_host("$host");
$serv1->set_port("$port");
$serv1->set_password("$password");
if (!$serv1->retrieveXML()) DIE ("$error1");
$con_dsp=$serv1->fetchMatchingTag("STREAMSTATUS");
if (!$con_dsp == "1") DIE ("$error2");
$cur_listen=$serv1->fetchMatchingTag("CURRENTLISTENERS");
if ($cur_listen == "") {
$cur_listen = 0;
}
$trackpattern = "/^[0-9][0-9] /";
$trackreplace = "";
$peak_listen=$serv1->fetchMatchingTag("PEAKLISTENERS");
$max_listen=$serv1->fetchMatchingTag("MAXLISTENERS");
$title=$serv1->fetchMatchingTag("SERVERTITLE");
$song_title=$serv1->fetchMatchingTag("SONGTITLE");
$song_title = preg_replace($trackpattern, $trackreplace, $song_title);
$con_hostname=$serv1->fetchMatchingArray("HOSTNAME");
$con_listen=$serv1->fetchMatchingArray("CONNECTTIME");
$con_song=$serv1->fetchMatchingArray("TITLE");
$con_song_print=array_slice($con_song, 1, $maxsongs);
$con_time=$serv1->fetchMatchingArray("PLAYEDAT");
if (preg_match ("/^[0-9]{10}$/", $con_time[0])) {
for ($i=0; $i<count($con_time); $i++) {
$con_time[$i] = $con_time[$i] + $adjust;
$con_time[$i] = date('H:i:s', $con_time[$i]);
}
$playtime = $con_time;
}
else {
$playtime = $con_time;
}
if ($timeat == "0") {
$playat = array_shift ($playtime);
} else {
$playtime = $playtime;
}
echo "<html>\n";
echo "<META HTTP-EQUIV=\"REFRESH\" CONTENT=\"$rfrshrate\">\n";
echo "<head>\n";
echo " <title>$pgtitle</title>\n";
echo " <style type=\"text/css\">";
echo " .SongTitle { color: $csscolor;} A.SongTitle { color: $csscolor; } A:hover.SongTitle { color: $csscolor; }";
echo " </style>";
echo "</head>\n";
echo "\n";
echo "<body bgcolor=\"$bodybgcolor\" text=\"$bodytext\" link=\"$bodylink\" vlink=\"$bodyvlink\">\n";
echo "<p align=\"$align\">\n";
//Start of Master Table
echo " <table width=\"450\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\" bordercolor=\"$bordercolor\">\n";
echo " <tr>\n";
echo " <td>\n";
echo " <center>\n";
echo " <b><font size=\"4\" face=\"$font\" color=\"$mstrtext\">$header</font></b>\n";
echo " </center>\n";
echo " <br>\n";
echo " <center>\n";
echo " <font size=\"2\" face=\"$font\" color=\"$mstrtext\">There are currently $cur_listen out of $max_listen people listening.</font>\n";
echo " </center>\n";
echo " <p>\n";
//Start of Lead Table
echo " <table width=\"100%\" border=\"1\" cellspacing=\"0\" cellpadding=\"2\" bordercolor=\"$bordercolor\">\n";
echo " <tr>\n";
echo " <td bgcolor=\"$tbl1bgcolor1\">\n";
echo " <p align=center>\n";
echo " <b><font face=\"$font\" size=\"2\" color=\"$tbl1text\">Currently playing track:</font></b>\n";
echo " </p>\n";
echo " </td>\n";
echo " </tr>\n";
echo " <tr>\n";
echo " <td bgcolor=\"$tbl1bgcolor2\">\n";
echo " <p align=center>\n";
echo " <font face=\"$font\" size=\"2\"><a href=\"http://$host:$port/listen.pls\" class=\"SongTitle\">$song_title</a></font>\n";
echo " </p>\n";
echo " </td>\n";
echo " </tr>\n";
echo " </table>\n";
//End of Lead Table
echo " <p>\n";
//Start of Content Table
echo " <table width=\"100%\" border=\"1\" cellspacing=\"0\" cellpadding=\"2\" bordercolor=\"$bordercolor\">\n";
echo " <tr>\n";
echo " <td width=\"15%\" bgcolor=\"$tbl2bgcolor1\">\n";
echo " <b><font face=\"$font\" size=\"2\" color=\"$tbl2text1\">Time:</font></b>\n";
echo " </td>\n";
echo " <td width=\"85%\" colspan=\"2\" bgcolor=\"$tbl2bgcolor1\">\n";
echo " <b><font face=\"$font\" size=\"2\" color=\"$tbl2text1\">Last $maxsongs tracks played:</font></b>\n";
echo " </td>\n";
echo " </tr>\n";
while(list($key,$val) = each($con_song_print)) {
$con_song_print[$key] = preg_replace($trackpattern, $trackreplace, $con_song_print[$key]);
echo " <tr>\n";
echo " <td width=\"15%\" bgcolor=\"$tbl2bgcolor2\">\n";
echo " <font face=\"$font\" size=\"2\" color=\"$tbl2text2\">$playtime[$key]</font>\n";
echo " </td>\n";
echo " <td width=\"85%\" bgcolor=\"$tbl2bgcolor2\">\n";
echo " <font face=\"$font\" size=\"2\" color=\"$tbl2text2\">$con_song_print[$key]</font>\n";
echo " </td>\n";
echo " </tr>\n";
}
echo " </table>\n";
//End of Content Table
echo " <br>\n";
echo " <center>\n";
echo " <font color=\"$text\">Times are in $timezone</font>\n";
echo " </center>\n";
echo " </td>\n";
echo " </tr>\n";
echo " </table>\n";
//End of Master Table
echo "<br>\n";
//Start of Shoutcast Logo
echo "<center>\n";
echo " <a href=\"http://www.shoutcast.com/\" target=\"_blank\"><img src=\"pict/sc-small.gif\" border=\"0\" alt=\"Powered by ShoutCast\"></a>\n";
echo "</center>\n";
//End of Shoutcast Logo
echo "</p>\n";
echo "</body>\n";
echo "</html>";
?>
zu guter letzt die scxml-obj.php
<?php
/* MusicTicker - XML version 1.4.2 */
/* MAD props to Tom Pepper and Tag Loomis for all their help */
/* --------------------------------------------------------- */
/* SCXML object version 0.4.2 */
/* December 01 2004 01:05 EST */
error_reporting (E_ALL ^ E_NOTICE);
class SCXML {
var $host="server4.digital-webstream.de"; // host or ip of shoutcast server
var $port="17340"; // port of shoutcast server
var $password="*********"; // password for shoutcast server
/* DO NOT CHANGE ANYTHING FROM THIS POINT ON - THIS MEANS YOU !!! */
var $depth = 0;
var $lastelem= array();
var $xmlelem = array();
var $xmldata = array();
var $stackloc = 0;
var $parser;
function set_host($host) {
$this->host=$host;
}
function set_port($port) {
$this->port=$port;
}
function set_password($password) {
$this->password=$password;
}
function startElement($parser, $name, $attrs) {
$this->stackloc++;
$this->lastelem[$this->stackloc]=$name;
$this->depth++;
}
function endElement($parser, $name) {
unset($this->lastelem[$this->stackloc]);
$this->stackloc--;
}
function characterData($parser, $data) {
$data=trim($data);
if ($data) {
$this->xmlelem[$this->depth]=$this->lastelem[$this->stackloc];
$this->xmldata[$this->depth].=$data;
}
}
function retrieveXML() {
$rval=1;
$sp=@fsockopen($this->host,$this->port,&$errno,&$errstr,10);
if (!$sp) $rval=0;
else {
set_socket_blocking($sp,false);
// request xml data from sc server
fputs($sp,"GET /admin.cgi?pass=$this->password&mode=viewxml HTTP/1.1\nUser-Agent:Mozilla\n\n");
// if request takes > 15s then exit
for($i=0; $i<30; $i++) {
if(feof($sp)) break; // exit if connection broken
$sp_data.=fread($sp,31337);
usleep(500000);
}
// strip useless data so all we have is raw sc server XML data
$sp_data=ereg_replace("^.*<!DOCTYPE","<!DOCTYPE",$sp_data);
// plain xml parser
$this->parser = xml_parser_create();
xml_set_object($this->parser,&$this);
xml_set_element_handler($this->parser, "startElement", "endElement");
xml_set_character_data_handler($this->parser, "characterData");
if (!xml_parse($this->parser, $sp_data, 1)) {
$rval=-1;
}
xml_parser_free($this->parser);
}
return $rval;
}
function debugDump(){
reset($this->xmlelem);
while (list($key,$val) = each($this->xmlelem)) {
echo "$key. $val -> ".$this->xmldata[$key]."\n";
}
}
function fetchMatchingArray($tag){
reset($this->xmlelem);
$rval = array();
while (list($key,$val) = each($this->xmlelem)) {
if ($val==$tag) $rval[]=$this->xmldata[$key];
}
return $rval;
}
function fetchMatchingTag($tag){
reset($this->xmlelem);
$rval = "";
while (list($key,$val) = each($this->xmlelem)) {
if ($val==$tag) $rval=$this->xmldata[$key];
}
return $rval;
}
}
?>
ich hoffe das hilft dir weiter