PHP Code:
<?
// Broadband stream
// Opens http://ss3.myshoutcastserver.com:8142/7.html
// $text[#] is an array containing: 1,1,14,50,1,128,Sepultura - Amen
// $text[0] = 1 = number of listeners connected
// $text[1] = 1 = stream state 0 = down, 1 = active
// $text[2] = 14 = Highest peak of listeners
// $text[3] = 50 = max number of listeners
// $text[4] = 1 = Unique number of listeners
// $text[5] = 128 = stream bitrate
// $text[6] = Sepultura - Amen = song title
$open = fsockopen("66.90.104.128","8142");
if ($open) {
fputs($open,"GET /7.html HTTP/1.1\nUser-Agent:Mozilla\n\n");
$read = fread($open,1000);
$text = explode("content-type:text/html",$read);
$text = explode(",",$text[1]);
} else { $er="Connection Refused!"; }
// Dialup stream
// Opens http://ss3.myshoutcastserver.com:8140/7.html
// $text2[#] is an array containing: 0,1,14,75,0,24,Sepultura - Amen
// $text2[0] = 0 = number of listeners connected
// $text2[1] = 1 = stream state 0 = down, 1 = active
// $text2[2] = 14 = Highest peak of listeners
// $text2[3] = 75 = max number of listeners
// $text2[4] = 0 = Unique number of listeners
// $text2[5] = 24 = stream bitrate
// $text2[6] = Sepultura - Amen = song title
$open2 = fsockopen("66.90.104.128","8140");
if ($open2) {
fputs($open2,"GET /7.html HTTP/1.1\nUser-Agent:Mozilla\n\n");
$read2 = fread($open2,1000);
$text2 = explode("content-type:text/html",$read2);
$text2 = explode(",",$text2[1]);
} else { $er2="Connection Refused!"; }
if ($text[1]==1) { $state = "Active"; } else { $state = "Down"; } // sets the state of the broadband stream
if ($text2[1]==1) { $state2 = "Active"; } else { $state2 = "Down"; } // sets the state of the dialup stream
Here's the part that gives me problems, and I think it's due to variable type, but I don't really know.
PHP Code:
$dlist = $text2[0];
$blist = $text[0];
$dlist2 = intval($dlist, 10);
$blist2 = intval($blist, 10);
$tlist = ($dlist + $blist);
Then things work fine:
PHP Code:
// Song info and total listeners
echo "<div id='r1'>DJ Name Goes Here (coming soon)</div>"; // DJ's Name - Need to find a way to set this
echo "<div id='r2'>$text[6]</div>"; // Song title
And then right here is where it displays all the wrong info:
PHP Code:
echo "<div id='r3'>$dlist2 $blist2 $tlist/125</div>"; // Total listeners
Then the rest is fine:
PHP Code:
// Broadband stats
if ($er) { echo "<div id='r4'>$er</div>"; } else { echo "<div id='r4'>$state</div>"; } // Stream state
echo "<div id='r5'>$text[0]/$text[3]</div>"; // Listeners
echo "<div id='r6'><a href='http://ss3.myshoutcastserver.com:8142'>128kbps</a>, audio/mpeg</div>"; // URL for Stream
// Dialup stats
if ($er2) { echo "<div id='r7'>$er2</div>"; } else { echo "<div id='r7'>$state2</div>"; } // Stream state
echo "<div id='r8'>$text2[0]/$text2[3]</div>"; // Listeners
echo "<div id='r9'><a href='http://ss3.myshoutcastserver.com:8140'>24kbps</a>, audio/mpeg</div>"; // URL for stream
?>
Bookmarks