All pastes #11427 Raw Copy code Copy link Edit

shoutcastscript

public unlisted php v1 · immutable
#11427 ·published 2005-05-10 18:13 UTC
rendered paste body
function shoutcast ($host, $port, $station, $showaudience) {	// Connect to server	$fp=@fsockopen($host,$port,$errno,$errstr,10);	if($fp) 	{		// Get data from server		fputs($fp,"GET /7 HTTP/1.1\nUser-Agent:Mozilla\n\n");		for($i=0;$i<4;$i++) $fp_data=fgets($fp);		// Strip useless junk from source data		$fp_data=preg_replace("/<.+>(.+?)<.+>/","\\1",$fp_data);				// Place values from source into variable names		list($current,$status,$peak,$max,$reported,$bit,$song) = explode(",", $fp_data, 7);				/*		current = current listener		status = 1 (online); 0 (offline)		peak = listener peak		max = max listener allowed		reported = unique current listener		bit = bitrate		song = song title		*/				if($status) 		{			echo "<div class=\"radio\"><div class=\"station\">$station</div>".			"<div class=\"playing\">Sta trasmettendo:<br />".			"<a href=\"http://$host:$port/listen.pls\">$song</a><br />";			if($showaudience) echo "Ascoltatori: $current";				echo "</div></div>\n";		}	}}