rendered paste body<!-- Macgeeks PHP -->
<?php
// SHOUTstat 1.0.1
// © 2006 farhnware
// http://farhnware.homelinux.com/software/shoutstat.php
//
// Changlog:
// 10/14/06 - Project created based on http://farhnware.homelinux.com/radio/current.php to be released to the public
// - Fixed rather large bug that kept script from working
//
// Fill in the following lines with your own information
$url="thefeuerfrei.com"; // SHOUTcast server address
$port="8000"; // SHOUTcast server port
$station_name="Imagination"; // SHOUTcast station name
$track_color="adfcff"; // CSS color for the current song title
$artist_color="DDDDDD"; // CSS color for the current song artist
$offline_on_nothing=true; // if true it says the server is offline if no song is playing
// Now let the script work its magic!
$open = @fsockopen($url,$port);
if ($open) {
fputs($open,"GET /7.html HTTP/1.1\nUser-Agent:Mozilla\n\n");
while(!feof($open)) {
$data.=fread($open,1000);
}
// I suck at regex, so the the next two lines were grabbed from
// http://www.curtisfamily.org.uk/wp_shoutcast.zip
// thanks, Chris Curtis ;)
$data=ereg_replace("^.*<body>","",$data);
$data=ereg_replace("</body>.*","",$data);
list($listeners,$status,$peak,$max,$reported,$bitrate,$track)=explode(",",$data,7);
if($status=='0') {
if($offline_on_nothing==true) {
echo "<center>".$station_name." is currently offline <br /> Check show times</center>";
} else {
echo '<center>'.$station_name.' is <a href="http://www.thefeuerfrei.com/radio.m3u">online</a> ';
echo '('.$listeners.'/'.$max.' listeners)<br />Playing nothing';
}
} else {
// thanks to Qtax_ in #regex on irc.freenode.net for this first expression
preg_match("/- (.*?)$/",$track,$matches);
$song='<strong style="color:#'.$track_color.';">'.$matches[1].'</strong>';
// I'm so proud I figured out the next one by myself :D
preg_match("/^(.*?) -/",$track,$matches);
$song.='<br /> by <strong style="color:#'.$artist_color.';">'.$matches[1].'</strong>';
echo '<center>'.$station_name.' is <a href="http://www.thefeuerfrei.com/radio.m3u">online</a> ';
echo '('.$listeners.'/'.$max.' listeners)<br />Playing '.$song.'<center>';
}
} else {
echo '<span style="color: red;"><center>ERROR 01: Server Down</center></span>';
}
?>
<!-- End macgeeks PHP -->