Here's my result (real numbers)
571010111718181818182022242626
5 is the first number.
2 is the second number.
Add those together you get 7.
3 is the third number.
You get 10.
0 is the fourth number.
You get 10.
and so on...
16 numbers total...
Code Used:
$max = "$currentlisteners-";
$max2 = explode("-", $max);
for($i = 0; $i< count($max2); $i++)
$addMax += $max2[$i];
echo $addMax;
I'm going to explain what I'm extactly doing.
$fp = @fsockopen("".$data["hostname"]."", "".$data["port"]."", $errno, $errstr, 100);
if(!$fp) {
echo "<td align=\"center\"><font class='black10' color=red><b><a href=\"http://".$data["hostname"].":".$data["port"]."\" target=\"_blank\">Offline</a></b></font></td>";
}
else {
if($scsuccs!=1){
fputs($fp,"GET /admin.cgi?pass=APASS&mode=viewxml HTTP/1.0\r\nUser-Agent: SHOUTcastPRO (Mozilla Compatible)\r\n\r\n");
while(!feof($fp)) {
$page .= fgets($fp, 1000);
}
}
$loop = array("AVERAGETIME", "MAXLISTENERS", "SERVERGENRE", "SERVERURL", "STREAMSTATUS", "SERVERTITLE", "BITRATE", "SONGTITLE", "IRC", "ICQ", "AIM", "CURRENTLISTENERS");
$y=0;
while($loop[$y]!=''){
$pageed = ereg_replace(".*<$loop[$y]>", "", $page);
$scphp = strtolower($loop[$y]);
$$scphp = ereg_replace("</$loop[$y]>.*", "", $pageed);
if($loop[$y]==SERVERGENRE || $loop[$y]==SERVERTITLE || $loop[$y]==SONGTITLE || $loop[$y]==SERVERTITLE)
$$scphp = urldecode($$scphp);
$y++;
}
$pageed = ereg_replace(".*<SONGHISTORY>", "", $page);
$pageed = ereg_replace("<SONGHISTORY>.*", "", $pageed);
$songatime = explode("<SONG>", $pageed);
$r=1;
while($songatime[$r]!=""){
$t=$r-1;
$playedat[$t] = ereg_replace(".*<PLAYEDAT>", "", $songatime[$r]);
$playedat[$t] = ereg_replace("</PLAYEDAT>.*", "", $playedat[$t]);
$song[$t] = ereg_replace(".*<TITLE>", "", $songatime[$r]);
$song[$t] = ereg_replace("</TITLE>.*", "", $song[$t]);
$song[$t] = urldecode($song[$t]);
$dj[$t] = ereg_replace(".*<SERVERTITLE>", "", $page);
$dj[$t] = ereg_replace("</SERVERTITLE>.*", "", $pageed);
$r++;
}
fclose($fp);
}
if($fp) {
if($streamstatus=="1") {
echo "<td align=\"center\"><font class='black10' color=red><b><a href=\"http://".$data["hostname"].":".$data["port"]."\" target=\"_blank\">Online</a></b></font></td>
<td align='center'>".$song[0]."</font></td>
<td align='center'>".$currentlisteners."/".$maxlisteners."</font></td>";
$max = "$currentlisteners-";
$max2 = explode("-", $max);
for($i = 0; $i< count($max2); $i++)
$addMax += $max2[$i];
echo $addMax;
}
}
I have 16 Shoutcast Ports and I'm trying to use the $currentlisteners varablie to ADD all 16+ current listeners we have total, Once get that working I'll be using the same for $maxlisteners.
If we add more Shoutcast Ports it will calculate the new ones as well once the page is loaded.
As for the count function, I was planning on doing that once I figured out how to get them added...but seems as it's not working.