Hello, anyone has an idea how to modify this code to work in shoutcast 2?
Apparently "@ fsockopen" expects a host and port but does not acepted the Sid shoutcast 2.
Any information is appreciated!
Apparently "@ fsockopen" expects a host and port but does not acepted the Sid shoutcast 2.
Any information is appreciated!
Code:
<? header("Content-Type: text/plain; charset=ISO-8859-1"); ?>
<html><body leftmargin="5" topmargin="5" marginwidth="0" marginheight="0">
<div align="Left">
<strong>
<?php
$host = "http://s1.radioboss.fm"; // ip or url of shoutcast server
$port = "9036"; // port of shoutcast server
$fp = @fsockopen("$host", $port, $errno, $errstr, 30);
if($fp)
{
fputs($fp,"GET /7.html HTTP/1.0\r\nUser-Agent: GET SEVEN (Mozilla Compatible)\r\n\r\n");
while(!feof($fp))
{
$data .= fgets($fp, 1000);
}
fclose($fp);
$data = ereg_replace(".*<body>", "", $data);
$data = ereg_replace("</body>.*", ",", $data);
$data_array = explode(",",$data);
$listeners = $data_array[0];
$status = $data_array[1];
$peak_listeners = $data_array[2];
$maximum_listeners = $data_array[3];
$unique_listeners = $data_array[4];
$bitrate = $data_array[5];
$track = $data_array[6];
}
$title = chop($track);
$select = explode(" - ",$title);
$artist = chop($select[0]);
$title = chop($select[1]);
if($status == 1)
{
//...title only
//print 'document.getElementById("title").innerHTML = "' . $title . '";';
}
echo "<p> <font color=Black font face='Arial' size='4pt'>$artist</br>";
echo "<p> <font color=Black font face='Arial' size='2.5pt'>$title</p>";?>
</strong></font>
</div>
</body>
</html>