Some shoutcast php code

fringradio

New Member
I don't know if I can post this here if not I'm sorry!

I have made some little bits of PHP that can help you with your site!

Stream Status message:
PHP:
<?php
$server = "shoutcast.internet-radio.org.uk"; 
$port = "0000"; // port of your internet radio server
$online = "<marquee> <p>We are online! :)</p> </marquee>"; // Online Message
$offline = "<marquee> <p>Sorry we are offline :( </p></marquee>"; // offline Message




// Start Data Collection
 $fp = fsockopen("$server", $port, $errno, $errstr, 30);
      fputs($fp, "GET /7.html HTTP/1.0\r\nUser-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)\r\n\r\n");
      while (!feof($fp)) {
          $content .= fgets($fp,128);
}
      fclose($fp);
// start data processing
      $debut = strpos($content, '<body>') + strlen('<body>');
      $fin = strpos($content, '</body>', $debut);
      $string = substr($content, $debut, $fin - $debut);
      $stats = explode(',', $string);

// Start Image generation
// Dedug Status echo "$stats[1]";
//offline
if ($stats[1] == "0" || !$stats) {
echo("$offline");
}

//online
if ($stats[1] == "1") {
echo("$online");
}


?>

Next is a player that only comes up when you are connected to the server!
PHP:
<?php
$server = "shoutcast.internet-radio.org.uk"; 
$port = "00000"; // port of your internet radio server
$online = "<html>
<head>
<title>Your Radio Station pop up player</title>
  <link href=\"style.css\" type=\"text/css\" rel=\"stylesheet\" />
</title>
</head>
<body>
<OBJECT id=\"VIDEO\" width=\"320\" height=\"240\" 
	style=\"position:absolute; left:0;top:0;\"
	CLASSID=\"CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6\"
	type=\"application/x-oleobject\">
	<PARAM NAME=\"URL\" VALUE=\"http://shoutcast.internet-radio.org.uk: YOUR PORT NUMBER!!!\">
	<PARAM NAME=\"SendPlayStateChangeEvents\" VALUE=\"True\">
	<PARAM NAME=\"AutoStart\" VALUE=\"True\">
	<PARAM name=\"uiMode\" value=\"none\">
	<PARAM name=\"PlayCount\" value=\"9999\">
	<param name=\"ShowControls\" value=\"-1\">
	<PARAM NAME=\"Enabled\" VALUE=\"-1\"> 
	<param name=\"ShowStatusBar\" value=\"True\">


</OBJECT>
</body>
</html> "; 

$offline = "<html>
<head>
<title>Fring Radio Offline</title>
  <link href=\"style.css\" type=\"text/css\" rel=\"stylesheet\" />
</title>
</head>
<body>
<img src=\"http://forum.internet-radio.org.uk/images/offline.gif\" /></body>
</html>"; // offline



// Start Data Collection
 $fp = fsockopen("$server", $port, $errno, $errstr, 30);
      fputs($fp, "GET /7.html HTTP/1.0\r\nUser-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)\r\n\r\n");
      while (!feof($fp)) {
          $content .= fgets($fp,128);
}
      fclose($fp);
// start data processing
      $debut = strpos($content, '<body>') + strlen('<body>');
      $fin = strpos($content, '</body>', $debut);
      $string = substr($content, $debut, $fin - $debut);
      $stats = explode(',', $string);

// Start Image generation
// Dedug Status echo "$stats[1]";
//offline
if ($stats[1] == "0" || !$stats) {
echo("$offline");
}

//online
if ($stats[1] == "1") {
echo("$online");
}
?>

I have one or two more little bits of script of general web development that I can share if anyone wants them!

Callum
 
Last edited:
Hi there can anybody pleasehelp me out

hello there im in urgent need of a bit of help please i have been trying to get this to work for a few days now with absolutely no luck what im in need of is a code that i can put on my site to basically display radio info i.e i would like to display a green image with the words online underneath if we are online and a red image stateing offline if we are off along with now playing track title i have tried several scrits but all return similar results this is how your code looks once it has been edited with my server info ..

<?php
$server = "orange.citrus3.com";
$port = "8284"; // port of your internet radio server
$online = "<marquee> <p>We are online! :)</p> </marquee>"; // Online Message
$offline = "<marquee> <p>Sorry we are offline :( </p></marquee>"; // offline Message




// Start Data Collection
$fp = fsockopen("$server", $port, $errno, $errstr, 30);
fputs($fp, "GET /7.html HTTP/1.0\r\nUser-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)\r\n\r\n");
while (!feof($fp)) {
$content .= fgets($fp,128);
}
fclose($fp);
// start data processing
$debut = strpos($content, '<body>') + strlen('<body>');
$fin = strpos($content, '</body>', $debut);
$string = substr($content, $debut, $fin - $debut);
$stats = explode(',', $string);

// Start Image generation
// Dedug Status echo "$stats[1]";
//offline
if ($stats[1] == "0" || !$stats) {
echo("$offline");
}

//online
if ($stats[1] == "1") {
echo("$online");
}


?>

this displays a white page with error codes
Warning: fsockopen() [function.fsockopen]: unable to connect to orange.citrus3.com:8284 (Connection timed out) in /home/frontlin/public_html/stream.php on line 11

Warning: fputs() expects parameter 1 to be resource, boolean given in /home/frontlin/public_html/stream.php on line 12

Warning: feof() expects parameter 1 to be resource, boolean given in /home/frontlin/public_html/stream.php on line 13

Warning: fgets() expects parameter 1 to be resource, boolean given in /home/frontlin/public_html/stream.php on line 14

Warning: feof() expects parameter 1 to be resource, boolean given in /home/frontlin/public_html/stream.php on line 13

Warning: fgets() expects parameter 1 to be resource, boolean given in /home/frontlin/public_html/stream.php on line 14

Warning: feof() expects parameter 1 to be resource, boolean given in /home/frontlin/public_html/stream.php on line 13

Warning: fgets() expects parameter 1 to be resource, boolean given in /home/frontlin/public_html/stream.php on line 14

Warning: feof() expects parameter 1 to be resource, boolean given in /home/frontlin/public_html/stream.php on line 13

Warning: fgets() expects parameter 1 to be resource, boolean given in /home/frontlin/public_html/stream.php on line 14




now i have tried a few different codes from different sites all with the same results .

my shoutcast server is with citrus3.com full adresse is orange.citrus3.com:8284

now i have tried this also with a free shoutcast plan from s3.myradiostream.com as they provide a javascript code for doing this and it worked a treat 100% only problem is i really want this to work with my paid shoutcast as with the free 1 it disconects my listeners and i have to display ads from them too here is the codes that work with free account


Song Title
<script type="text/javascript" src="http://shoutcast.mixstream.net/js/song/uk3-free:70450">
You appear to have javascript turned off.
</script>

Online/offline image
<img src="http://shoutcast.mixstream.net/status/uk3-free:70450.gif" alt="Stream status" width="17" height="17" align="absmiddle">

online off line txt
<script type="text/javascript" src="http://shoutcast.mixstream.net/js/status/uk3-free:70450">
You appear to have javascript turned off.
</script>

no of listeners
<script type="text/javascript" src="http://shoutcast.mixstream.net/js/status/uk3-free:70450">
You appear to have javascript turned off.
</script>
 
Last edited:

Support

Level 1 Support
Staff member
Hi frontlineradiouk

We have tested your code and it works fine. This implies to us that your webhosting company has some sort of firewall in place blocking your requests. You need to email them and get them to open up access to orange.citrus3.com:8284. Then it should work fine. 8)
 

JohnH01

New Member
can anyone help me with a stat bar code? one that says station name: On Air DJ Name: Currently Playing: Song info
 

Support

Level 1 Support
Staff member
What's the issue that you are having please JohnH01 ?

Do you host your station with us?
 

Support

Level 1 Support
Staff member
Depending on who is your service provider, they will most likely use the Centova Cast control panel. If so, you can get the widget code for this directly from within your servers control panel under "Widgets".
 

Support

Level 1 Support
Staff member
Sorry that we cannot help you much more than this, but this support forum is mainly for our own clients who host their stations with us on our own servers. We do however do our best to help out others as well where we can.

You should just ask your own server provider for some help with this in that case ;)
 
Top