function 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(".*
", "", $page); //extract data
$page = ereg_replace(".*", ",", $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 = "Radio: ";
$radio .= "Click to Listen";
$radio .= " ";
$radio .= $curlistener." listeners";
$radio .= " ";
$radio .= "Now playing: ".$song;
return $radio;
}