rendered paste body<?php
// obtener cancion de shoutcast
// por matias nahuel carballo
// basado en Shoutcast Molok por Molok
$server="200.32.8.172";
$puerto="8102";
header('Content-type: text/javascript');
// v0.2 - evitamos que se cachee la respuesta :/
header( 'Expires: Mon, 26 Jul 1997 05:00:00 GMT' );
header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' );
header( 'Cache-Control: no-store, no-cache, must-revalidate' );
header( 'Cache-Control: post-check=0, pre-check=0', false );
header( 'Pragma: no-cache' );
$fp = fsockopen($server, $puerto, &$errno, &$errstr, 30);
if(!$fp) {
die('document.writeln(\'La radio se encuentra <font color="red">OFFLINE</font>.\');');
} else {
fputs($fp,"GET /7 HTTP/1.1\n");
fputs($fp,"User-Agent: Mozilla eats Internet Explorer\n");
fputs($fp,"Host: $server\n");
fputs($fp,"Connection: Close\n\n");
$datos=fread($fp,8192 );
fclose($fp);
}
$datos=ereg_replace("^.*<body>","",$datos);
$datos=ereg_replace("</body>.*","",$datos);
list($oyentes,$estado,$tope,$maximos,$reportado,$kbps,$cancion) = explode(",", $datos, 7);
echo 'document.writeln(unescape(\''.str_replace("+", "%20",urlencode($cancion)).'\'));';
?>