Online / Offline Status

Hey ,

Could someone guide as to is there any code on how i can show that my radio station is currently online or not! and adding like a picture to show beside when its online or offline.

Thanks
 

fringradio

New Member
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 You can have ANY PHP or HTML in this.
$offline = "<marquee> <p>Sorry we are offline :( </p></marquee>"; // offline Message You can have ANY PHP or HTML in this.




// 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"); 
} 


?>
 
Last edited:

Support

Level 1 Support
Staff member
Thanks for the post fring :)

In your control panel you also have the 'Code Snippets' section which has code to display your station status among other info like listeners and track playing etc...

The 'Code Snippets' are javascript and should be easy to copy and paste into your website. The php code above requires a bit more knowledge of programming to implement so the 'Code Snippets' route is probably the easiest. But if you want to display an image then you will need to use the php code method.

Hope this helps :)
 
Top