rendered paste bodyfunction radio() {
// Simple current song script - written by Saivert 2006
// This only accesse public stats from the IceCast2 server so no authentication is required
//
// configuration
$ip = "radio.tnet.no";
$port = "8000";
$mountpoint = "/dumilum.mp3";
$fp = fsockopen("$ip", $port, $errno, $errstr, 30); //open connection
if(!$fp) {
echo 'Offline';
} else {
fputs($fp,"GET /status2.xsl HTTP/1.0\r\nUser-Agent: Saivert's parser (Mozilla)\r\n\r\n"); //get status2.xsl
$page = ''; // z0mg. ALWAYS initialize varibles ffs!!!11oneoenone
while(!feof($fp)) {
$page .= fgets($fp, 1000);
}
fclose($fp); //close connection
$page = ereg_replace(".*<pre>", "", $page); //extract data
$page = ereg_replace("</pre>.*", ",", $page); //extract data
// Fast-forward to the part where our mountpoint is
$mp = preg_quote($mountpoint, '/');
preg_match("/$mp.*$/", $page, $matches);
$page = $matches[0];
$shit = explode(",",$page);
$song = ereg_replace("^\ -\ ", "", $shit[5]); // Remove prefixing " - " if exists
$song = eregi_replace("-\ Winamp(\ \[Stopped\])?$", "", $song); // Remove Winamp shit
$song = eregi_replace("^[0-9]+\.", "", $song); // Remove prefxing numbers
$curlistener = $shit[3];
}
$radio = "<b>Radio:</b> ";
$radio .= "<a href=\"http://".$ip.":".$port."".$mountpoint.".m3u\">Click to Listen</a>";
$radio .= " ";
$radio .= $curlistener." listeners";
$radio .= " ";
$radio .= "<b>Now playing: </b>".$song;
return $radio;
}