All pastes #73398 Raw Edit

Mine

public text v1 · immutable
#73398 ·published 2006-06-27 20:02 UTC
rendered paste body
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(".*<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>&nbsp;";
	$radio .= "<a href=\"http://".$ip.":".$port."".$mountpoint.".m3u\">Click to Listen</a>";
	$radio .= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
	$radio .= $curlistener." listeners";
	$radio .= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
	$radio .= "<b>Now playing: </b>".$song;

return $radio;
}