Jump to content

Easy shoutcast listener count script


Recommended Posts

Another script weve been playing around with at baldyradio is this one that shows Multiple server listener stats.


Runs on Php modified from the original script at mediacast1.com


First off you Need this config_stats.php just change the shoutcast info!



// Configuration file //
// Shoutcast server ip, port number and password
$host = "Shoutcast IP";
$port = "SC PORT";
$password = "changeme";
// End shoutcast server config
// Default configuration if server is down
$title = "#";  // Title of radio station, use same as shoutcast dsp plug-in
$cstmsg = "Our server is temporarily down, please stop back soon!!"; // Custom message you want to tell your listeners if server is offline
// End
// Config for look and feel
$bgrnd = "000000";          // Color of page background
$text = "ffffff";           // Text Color
$link = "E3690F";           // Link color
$vlink = "FF0000";          // Visited link color
$alink = "800080";          // Active link color
$tblhdr = "333333";         // Table header color
$cell = "767676";           // Table cell color for body
$hdrtext = "2";             // Size of text in header
$bdytext = "1";             // Size of text in the rest of the page
// End
// Misc Config
$reset = "2";               // How often in days are stats (SERVER) reset, default is 3
$detailed = "1";            // Detailed stats on or off (1=on) (0=off)

$refresh = "30";            // How often in seconds should the pages refresh themselves

Next u will need scastxml.php nothing needs editing in this section!


// Author: dstjohn@mediacast1.com
include ("config_stats.php");
$listenlink = 'http://'.$host.':'.$port.'/listen.pls';  //make link to stream
$fp = @fsockopen("$host", $port, &$errno, &$errstr, 30); //open connection
if(!$fp) {
   $success=2;  //set if no connection
if($success!=2){ //if connection
fputs($fp,"GET /7.html HTTP/1.0\r\nUser-Agent: SHOUTcast stats XML Parser (Mozilla Compatible)\r\n\r\n"); //get 7.html
while(!feof($fp)) {
 $page .= fgets($fp, 1000);
@fclose($fp); //close connection
$page = ereg_replace(".*", "", $page); //extract data
$page = ereg_replace(".*", ",", $page); //extract data
$numbers = explode(",",$page); //extract data
$currentlisteners=$numbers[0]; //set variable
$connected=$numbers[1]; //set variable

if($connected==1) //if DSP is connected
 $wordconnected="yes"; //set variable
else //if no DSP connection
 $wordconnected="no"; //set variable
$peaklisteners=$numbers[2]; //set variable
$maxlisteners=$numbers[3]; //set variable
$reportedlisteners=$numbers[4]; //set variable



and Finally the page that sorts the output save this as online.php


include ("config_stats.php");
include ("scastxml.php");
  ' . $currentlisteners .' of ' . $maxlisteners . ' listeners


To get this working on the area of you site where you want to show current listener stats just use this

 require ("online.php") ?>

If you run Multiple servers and need to show more stats just change the config_stats.php and rename it to config_stats2.php and change scastxml.php to scastxml2.php and copy the first section of online.php and change the Incude statements to point to the modified second pages!


Hope this has been another useful script if anyone needs help with coding it to include Tune in links let me know!:thumbup:

My Blog https://djgarybaldy.blogspot.com

User of RadioDJ FREE radio playout software since 2010.

How to Install RadioDJ: https://djgarybaldy.blogspot.com/2020/08/how-to-install-radiodj-free-radio.html

RadioDJ is my FAVOURITE piece of software it works when I need It



Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...