Hello all again:
We are constantly working to improve my sight, but before I get too carried away, let me try to explain why I think a DB may be the answer, but the one caveat is I have never made a MySQL DB so I would need a lot of coaching... so other ideas are welcome!
First, let me just say that this forum has been helpful getting the site this far! We are a webcasting sight using Shoutcast and have a custom "class" that parses XML from the SC server. We have taken that data and put it in tables and made it look very nice indeed! Now our focus is on our error messages which currently display by array position of an array called shoutcast[0] which is server 1, and shoutcast[1] which is server 2. While the SC server is up there is one error which states that there is no stream. Like:
"There is no stream on Server 0"
which goes onto the webpage when the DSP is not pushing songdata or the stream name etc.
Then if the SC server is completely offline, we have a similar error message.
It would be immensely cool if we could retain the name of the server stream at the very least and put it someplace... cross reference when the server comes back up (ie one of the dynamic parts of the site is that we can change the stream name and have it reflect on the site without manual updating) against a DB or the like and then if the name had changed from what is stored, then it updates the records. The end result of this whole situation would be that we could then put the following by querying the DB into the webpage:
RadioTeal Obscure 80's is down for maintenance (for offline) or RadioTeal Obscure 80's is currently not streaming for the lesser error. In both cases the data is gone from the class file because the server doesn't supply any of the data that the DSP does. This is where songhistory, bitrate, genre, etc comes from. It would be nice to eventually get it to where all the data is there even if the SC server is down but not offer the listen button or request button or song history information for example.
I am clueless how to set this up in either PHP or MySQL, though the DB is probably not very complex.
just for reference, you can view the page we are working with and since my server is offline currently, the error situation we are working on at http://radioteal.no-ip.com
Your help is VERY appreciated.
Thanks,
Help with MySQL and PHP with my project
Moderator: General Moderators
-
irishmike2004
- Forum Contributor
- Posts: 119
- Joined: Mon Nov 15, 2004 3:54 pm
- Location: Lawrence, Kansas
-
irishmike2004
- Forum Contributor
- Posts: 119
- Joined: Mon Nov 15, 2004 3:54 pm
- Location: Lawrence, Kansas
Found the site is running slow, PHP code for page follows
Sorry the site is running very slowly tonight. Here is the site PHP code for the page that shows the server information. We would want to for now save the information from $scname, $bitrate, and $genre so we could construct a similar table to when the servers are running. Hope someone can help!
obviously for security reason, the ips and passwords were removed from the live page
obviously for security reason, the ips and passwords were removed from the live page
Code: Select all
<?php
include("shoutcast.class.php");
// setup servers
$shoutcast = array();
$shoutcastї] = new ShoutCast(); // server1
$shoutcastї] = new ShoutCast(); // server2
// add more instances of ShoutCast class to support more servers
// server1 data
$shoutcastї0]->host = "servername"; // no 'http://'
$shoutcastї0]->port = 8000;
$shoutcastї0]->passwd = "password";
// server2 data
$shoutcastї1]->host = "servername";
$shoutcastї1]->port = 8000;
$shoutcastї1]->passwd = "password";
echo '
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv=refresh content=45>
<title>bottom frame</title>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->
</script>
<style type="text/css">
<!--
.style1 {color: #FF0000}
-->
</style>
</head>
<body>
<h3 align="center">Available Streams </h3>
';
// array for table creation
$svrTables = array();
// array for request mechanisms
$requests = array();
$requestsї0] = 'tba.htm';
$requestsї1] = 'http://rtealdev.no-ip.com:81/playlist.cgi';
for($i=0; $i<count($shoutcast); $i++) {
if ($shoutcastї$i]->openstats()) {
// format the output to suit your particular needs
if ($shoutcastї$i]->GetStreamStatus()) {
//new code begin
$scname = $shoutcastї$i]->GetServerTitle();
$currentSong = $shoutcastї$i]->GetCurrentSongTitle();
$bitRate = $shoutcastї$i]->GetBitRate();
$listeners = $shoutcastї$i]->GetCurrentListenersCount();
$scport = $shoutcastї$i]->port;
$servip = $shoutcastї$i]->host;
$history = $shoutcastї$i]->GetSongHistory();
$genre = $shoutcastї$i]->GetServerGenre();
$peakListeners = $shoutcastї$i]->GetPeakListenersCount();
$reqLink = $requestsї$i];
$svrTable = '
<table width="100%" height="246" border="0">
<tr>
<td><table width="100%">
<tr>
<td align="center"><FORM METHOD="LINK" ACTION="http://'.$servip.':'.$scport.'/listen.pls">
<INPUT TYPE="submit" VALUE="LISTEN">
</FORM></td> <td align="center"><FORM METHOD="LINK" target="_blank" ACTION="'.$reqLink.'">
<INPUT TYPE="submit" VALUE="REQUEST">
</FORM></td>
</tr></table>
</td>
</tr>
<tr>
<td><a href="http://'.$servip.':'.$scport.'/listen.pls"><img src="images/smallspeaker.jpg" border="0">
<strong>'.$scname.'</strong></a> ('.$bitRate.' Bit Stream)</td>
</tr>
<tr>
<td align="center">(Listeners: <font size="+1" color="#FF0000">'.$listeners.'</font> Peak: <font size="+1" color="#FF0000">'.$peakListeners.'</font>) </td>
</tr>
<tr>
<td><strong>Genre:</strong> '.$genre.' </td>
</tr>
<tr>
<td height="57"><p><strong>Currently Playing: </strong></p>
<p>'.$currentSong.'</p></td>
</tr>
<tr>
<td><strong>Recently Played: </strong></td>
</tr>
';
if (is_array($history)) {
for ($j=0;$j<sizeof($history);$j++) {
$songї$j] = $historyї$j]ї"title"];
//echo $songї$j].'<br>';
$bgColor = ($j % 2) ? '#00CCCC' : '#FFFFFF';
$svrTable .= '<tr><td bgcolor="'.$bgColor.'">'.$songї$j].'</td></tr>';
}
} else {
$svrTable .= '<tr><td bgcolor="#FFFFFF">No Song History Available</td></tr>';
}
} else {
$svrTable = '<table><tr><td bgcolor="#FFFFFF"><font color="#FF0000">No Stream Available on Server '.$i.'</font></td></tr>';
}
} else {
$svrTable = '<table><tr><td bgcolor="#FFFFFF"><font color="#FF0000">Server '.$i.' Down for Scheduled Maintenance</font></td></tr>';
}
// insert array at end of FOR loop
$svrTablesї$i] = $svrTable;
}
echo '
<p align="center">
<table width="85%" height="252" border="1" mm_noconvert="TRUE">
<tr>
<td width="50%"> '.$svrTablesї0].'</table></td>
<td width="50%"> '.$svrTablesї1].'</table></td>
</tr>
</table>
</p>
<p align=center>©2004 Teal Communications, J. Mike Needham & R.L. Paul</p>
</body>
</html>';
?>