<?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_song1$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>";

?>