Old 7th July 2010, 20:30   #1
tom2k7
Junior Member
 
Join Date: Jul 2010
Posts: 8
help with radio script

hi im writing a radio script to view current listners name from the ipb database but im stuck i was hoping someone could help me
here is my code
code:
<html>
<head>

<BODY STYLE='background-color:transparent'>
<body background='background.jpg'>
<META HTTP-EQUIV="REFRESH" CONTENT='30'>
</head>
<body>
<?php
include("config.php");
include("xml.php");

function ConvertSeconds($seconds) {
$tmpseconds = substr("00".$seconds % 60, -2);
if ($seconds > 59) {
if ($seconds > 3599) {
$tmphours = substr("0".intval($seconds / 3600), -2);
$tmpminutes = substr("0".intval($seconds / 60 - (60 * $tmphours)), -2);

return ($tmphours.":".$tmpminutes.":".$tmpseconds);
} else {
return ("00:".substr("0".intval($seconds / 60), -2).":".$tmpseconds);
}
} else {
return ("00:00:".$tmpseconds);
}
}


if ($shoutcast->openstats()) {
// We got the XML, gogogo!..
if ($shoutcast->GetStreamStatus()) {

echo "<span style='border:1px solid;background:black;padding:0 3xp 0 3px;font-weight:bold;color:RED'>SSDJ radio Online</span><br>\n\n";
echo "<center><span style='border:1px solid;background:black;padding:0 3xp 0 3px;font-weight:bold;color:white'>CURRENT SONG</span></br> <font color='#FF00CC'><font size='5'><b> ".$shoutcast->GetCurrentSongTitle()." </b></font></font><br></center></td>\n\n";
echo "<center><span style='border:1px solid;background:black;padding:0 3xp 0 3px;font-weight:bold;color:white'>LISTENERS: ".$shoutcast->GetCurrentListenersCount()." </span></br></center></td>\n\n";
echo "<center><span style='border:1px solid;background:black;padding:0 3xp 0 3px;font-weight:bold;color:white'>BITRATE ".$shoutcast->GetBitRate()." KBPS</span></br></center></td>\n\n";
echo "<center><span style='border:1px solid;background:black;padding:0 3xp 0 3px;font-weight:bold;color:white'>DJ:</span> <span style='border:1px solid;background:black;padding:0 3xp 0 3px;font-weight:bold;color:5ffb17'> ".$shoutcast->GetServerTitle()."</span></font><br></center></span><br>\n\n";
echo "<center><a href='http://ssdj99.no-ip.org:8014/listen.pls'><img src='winamp.jpg'></img></a> <a href='listen.asx'><img src='wmp.jpg'></img></a></tr></table></center>\n\n";




echo "<b>Listners:</b>\n";
$listeners = $shoutcast->GetListeners();
if (is_array($listeners)) {
for ($i=0;$i<sizeof($listeners);$i++) {

$scip = "".$listeners[$i]["hostname"]."";
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( 'Unable to connect to database');
$query="SELECT `member_name`, `member_id`, `ip_address` FROM ibf_sessions";


$result=mysql_query($query);

$num=mysql_numrows($result);

mysql_close();

$i=0;
while ($i < $num) {
$ip=mysql_result($result,$i,'ip_address');
$r=mysql_result($result,$i,'member_name');
$id=mysql_result($result,$i,'member_id');
if($ip=$scip){
echo "<a href='$host$id'>$r$ip=$scip</a><br>";}


$i++;
}
} } else {
echo "Noone listens right now ";
}
} else {
echo "Server is up, but no Dj Online";
}
} else {
// Ohhh, damnit..
echo $shoutcast->geterror();
}
?>
</table>
</body>
</html>


im trying to get it to match up 2 ip addresses one from database and one from shoutcast xml but atm its jumbling up the member to the ip i was woundering if anyone could help

here is the code when its run
radio link
please could someone help

tom
tom2k7 is offline   Reply With Quote
Old 8th July 2010, 00:52   #2
jaromanda
Forum King
 
Join Date: Jun 2007
Location: Under the bridge
Posts: 2,289
Your problem is most likely the line if($ip=$scip), it should be if($ip==$scip) - note, TWO = !!

One thing I noticed with that code. You're reading the whole ibf_sessions table for every listener in the shoutcast - e.g., 5 listeners, 5 reads of the full table - depending on the size of the table, and number of listeners, that could be a big unnecessary hit on your sql server

"If you don't like DNAS, write your own damn system"

So I did
jaromanda is offline   Reply With Quote
Old 4th August 2010, 00:12   #3
tom2k7
Junior Member
 
Join Date: Jul 2010
Posts: 8
ahhhh thanks for you help its all working, i have sorted the sql bit aswell
tom2k7 is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Shoutcast > Shoutcast Site Design

Tags
ip shoutcast xml online

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump