<?
include("includes/config.php");
$SAMdb->open("SELECT songlist.*, historylist.listeners as listeners, historylist.requestID as requestID, historylist.date_played as starttime FROM historylist, songlist WHERE (historylist.songID = songlist.ID) AND (songlist.songtype='S' OR songlist.songtype='H' OR songlist.songtype='C') ORDER BY historylist.date_played DESC LIMIT 11");
$history = $SAMdb->rows();
reset($history);
$SAMdb->open("SELECT songlist.*, queuelist.requestID as requestID FROM queuelist, songlist WHERE (queuelist.songID = songlist.ID) AND (songlist.songtype='S' OR songlist.songtype='H' OR songlist.songtype='C') ORDER BY queuelist.sortID ASC");
$queue = $SAMdb->rows();
reset($queue);
list($key, $song) = each($history);
$listeners = $song["listeners"];
$starttime = strtotime($song["date_played"]);
$secsRemain = (round($song["duration"] / 1000)-($curtime-$starttime));
function PutSongRowCurrent($song)
{
global $songNew, $SAMdb, $userdata, $user, $cookie, $db, $admin, $pagetitle;
PrepareSong($song);
?>
<table border="0">
<tr>
<td align="right" nowrap>
<font face="Verdana, Arial, Helvetica" size="1" color="#006699">
Artist
<img src="images/spacer.gif" width="15" height="13">
</font>
</td>
<td>
<font face="Verdana, Arial, Helvetica" size="1">
<a href="modules.php?name=Playlist&letter=<? echo $song["artist"]{0}; ?>&artist=<? echo $song["artist"]; ?>" title="Get an album listing of <? echo htmlspecialchars($song["artist"]); ?>"><? echo $song["artist"]; ?></a>
</font>
</td>
</tr>
<tr>
<td align="right" nowrap>
<font face="Verdana, Arial, Helvetica" size="1" color="#006699">
Title
<img src="images/spacer.gif" width="15" height="13">
</font>
</td>
<td>
<font face="Verdana, Arial, Helvetica" size="1">
<a href="modules.php?name=Playlist&file=songinfo&songID=<? echo $song["songID"]; ?>" title="Get information on <? echo htmlspecialchars($song["title"]); ?> by <? echo htmlspecialchars($song["artist"]); ?>"><? echo $song["title"]; ?></a>
<?
if ($song["date_added"] > date("Y-m-d H:i:s",time()-$songNew*24*60*60))
echo "<img src='images/new.gif' title=\"" . htmlspecialchars($song["title"]) . " by " . htmlspecialchars($song["artist"]) . " added ". date('M d, Y', strtotime($song["date_added"])) . "\" border='0'>";
if ($song["requestID"] != 0)
echo " <font color='#FF4500'>~requested~</font> ";
?>
</font>
</td>
</tr>
<tr>
<td align="right" nowrap>
<font face="Verdana, Arial, Helvetica" size="1" color="#006699">
Album
<img src="images/spacer.gif" width="15" height="13">
</font>
</td>
<td>
<font face="Verdana, Arial, Helvetica" size="1">
<a href="modules.php?name=Playlist&letter=<? echo $song["artist"]{0}; ?>&artist=<? echo $song["artist"]; ?>&album=<? echo $song["album"]; ?>" title="Get a track listing of <? echo htmlspecialchars($song["album"]); ?>"><? echo $song["album"]; ?></a>
</font>
</td>
</tr>
<tr>
<td align="right" nowrap>
<font face="Verdana, Arial, Helvetica" size="1" color="#006699">
Track #
<img src="images/spacer.gif" width="15" height="13">
</font>
</td>
<td colspan="2">
<font face="Verdana, Arial, Helvetica" size="1">
<? echo $song["trackno"]; ?>
</font>
</td>
</tr>
<tr>
<td align="right" nowrap>
<font face="Verdana, Arial, Helvetica" size="1" color="#006699">
Year
<img src="images/spacer.gif" width="15" height="13">
</font>
</td>
<td colspan="2">
<font face="Verdana, Arial, Helvetica" size="1">
<? echo $song["albumyear"]; ?>
</font>
</td>
</tr>
<tr>
<td align="right" nowrap>
<font face="Verdana, Arial, Helvetica" size="1" color="#006699">
Genre
<img src="images/spacer.gif" width="15" height="13">
</font>
</td>
<td colspan="2">
<font face="Verdana, Arial, Helvetica" size="1">
<? echo htmlspecialchars($song["genre"]); ?>
</font>
</td>
</tr>
<tr>
<td align="right" nowrap>
<font face="Verdana, Arial, Helvetica" size="1" color="#006699">
Composer
<img src="images/spacer.gif" width="15" height="13">
</font>
</td>
<td colspan="2">
<font face="Verdana, Arial, Helvetica" size="1">
<? echo htmlspecialchars($song["composer"]); ?>
</font>
</td>
</tr>
<tr>
<td align="right" nowrap>
<font face="Verdana, Arial, Helvetica" size="1" color="#006699">
Duration
<img src="images/spacer.gif" width="15" height="13">
</font>
</td>
<td colspan="2">
<font face="Verdana, Arial, Helvetica" size="1">
<? echo $song["mmss"]; ?> (<a id="countDownText"></a>: <a id="countDownTime"></a>)
</font>
</td>
</tr>
<tr>
<td align="right" nowrap>
<font face="Verdana, Arial, Helvetica" size="1" color="#006699">
Tabs
<img src="images/spacer.gif" width="15" height="13">
</font>
</td>
<td colspan="2">
<font face="Verdana, Arial, Helvetica" size="1">
Bass: (<a href="[URL unfurl="true"]http://www.basstabarchive.com/cgi-bin/search.cgi?search=<?[/URL] echo htmlspecialchars($song["title"]); ?>&hits=100" title="Query Bass Tab Archives for <? echo htmlspecialchars($song["title"]); ?> by <? echo htmlspecialchars($song["artist"]); ?>" target="_blank">alt</a>) Guitar: (<a href="[URL unfurl="true"]http://www.olga.net/dynamic/search.php?search=<?[/URL] echo htmlspecialchars($song["title"]); ?>" title="Query the OnLine Guitar Archive (OLGA) for <? echo htmlspecialchars($song["title"]); ?> by <? echo htmlspecialchars($song["artist"]); ?>" target="_blank">alt</a>) Drum: (<a href="[URL unfurl="true"]http://www.tabarchive.co.uk/drumtabs.php?area=search&type=song&input=<?[/URL] echo htmlspecialchars($song["title"]); ?>&hits=100" title="Query the Drum Tab Archive for <? echo htmlspecialchars($song["title"]); ?> by <? echo htmlspecialchars($song["artist"]); ?>" target="_blank">alt</a>)
</font>
</td>
</tr>
<tr>
<td align="right" nowrap>
<font face="Verdana, Arial, Helvetica" size="1" color="#006699">
# Plays
<img src="images/spacer.gif" width="15" height="13">
</font>
</td>
<td colspan="2">
<font face="Verdana, Arial, Helvetica" size="1">
<? echo $song["count_played"]; ?>
</font>
</td>
</tr>
<tr>
<td align="right" nowrap>
<font face="Verdana, Arial, Helvetica" size="1" color="#006699">
# Requests
<img src="images/spacer.gif" width="15" height="13">
</font>
</td>
<td colspan="2">
<font face="Verdana, Arial, Helvetica" size="1">
<?
$SAMdb->open("SELECT count(*) as cnt FROM requestlist where requestlist.songID = " . $song["songID"] . " and requestlist.status = 'played'");
$numberRequests = $SAMdb->row();
echo $numberRequests["cnt"];
?>
</font>
</td>
</tr>
<?//////////////////////////////////////////////////////////////////////////////////////////////////////////?>
<?
if ($userdata['user_id'] == 1) {
echo ("<tr>");
echo (" <td align='right' nowrap>");
echo (" <font face='Verdana, Arial, Helvetica' size='1' color='#006699'>");
echo (" # Listens");
echo (" <img src='images/spacer.gif' width='15' height='13'>");
echo (" </font>");
echo (" </td>");
echo (" <td>");
echo (" <font face='Verdana, Arial, Helvetica' size='1'>");
echo $song["count_performances"] . " (avg ";
if ($song["count_played"] > 0)
echo round($song["count_performances"] / $song["count_played"], 2);
else
echo "0";
echo ")";
echo " (now ". $song["listeners"] . ")";
echo (" </font>");
echo (" </td>");
echo (" <td></td>");
echo (" <td></td>");
echo ("</tr>");
}
?>
<tr>
<td align="right" nowrap>
<font face="Verdana, Arial, Helvetica" size="1" color="#006699">
Rating (all)
<img src="images/spacer.gif" width="15" height="13">
</font>
</td>
<td colspan="2">
<font face="Verdana, Arial, Helvetica" size="1">
<?
if ($song["songtype"] == 'S') {
if ($song["rating"] == 0)
$rating_image = "images/stars-0-0.gif";
else {
if ($song["rating"] < 1)
echo " (Error)";
else if (($song["rating"] >= 1) && ($song["rating"] < 1.5))
$rating_image = "images/stars-1-0.gif";
else if (($song["rating"] >= 1.5) && ($song["rating"] < 2))
$rating_image = "images/stars-1-5.gif";
else if (($song["rating"] >= 2) && ($song["rating"] < 2.5))
$rating_image = "images/stars-2-0.gif";
else if (($song["rating"] >= 2.5) && ($song["rating"] < 3))
$rating_image = "images/stars-2-5.gif";
else if (($song["rating"] >= 3) && ($song["rating"] < 3.5))
$rating_image = "images/stars-3-0.gif";
else if (($song["rating"] >= 3.5) && ($song["rating"] < 4))
$rating_image = "images/stars-3-5.gif";
else if (($song["rating"] >= 4) && ($song["rating"] < 4.5))
$rating_image = "images/stars-4-0.gif";
else if (($song["rating"] >= 4.5) && ($song["rating"] < 5))
$rating_image = "images/stars-4-5.gif";
else if ($song["rating"] == 5)
$rating_image = "images/stars-5-0.gif";
else
echo " (Error)";
}
if ($song["songtype"] == 'S') {
if ($song["rating"] == 0)
$song["rating_saying"] = "n/a (no votes)";
else {
if ($song["rating"] < 1)
echo " (Error)";
else if (($song["rating"] >= 1) && ($song["rating"] < 1.5))
$song["rating_saying"] = " (Bad)";
else if (($song["rating"] >= 2) && ($song["rating"] < 2.5))
$song["rating_saying"] = " (Poor)";
else if (($song["rating"] >= 3) && ($song["rating"] < 3.5))
$song["rating_saying"] = " (Ok)";
else if (($song["rating"] >= 4) && ($song["rating"] < 4.5))
$song["rating_saying"] = " (Good)";
else if ($song["rating"] == 5)
$song["rating_saying"] = " (Excellent)";
else
echo " (Error)";
}}
?>
<img src="<? echo "$rating_image"; ?>" title="<? echo $song["rating"]; ?> <? echo $song["rating_saying"]; ?>" width="64" height="12"/>
<?
echo " out of " . $song["votes"];
if ($song["votes"] == 1)
echo " vote";
else
echo " votes";
}
else
echo "This cannot be rated";
?>
</font>
</td>
</tr>
<tr>
<?
if (($song["songtype"] == 'S') && ($userdata['user_id'])) {
echo "<form name=\"theForm\" method=\"POST\" action=\"modules.php?name=Playlist&file=do_rating\">";
echo "<input type=\"hidden\" name=\"songID\" value=\"". $song["songID"] . "\">";
}
?>
<td align="right" nowrap>
<font face="Verdana, Arial, Helvetica" size="1" color="#006699">
Rating (you)
<img src="images/spacer.gif" width="15" height="13">
</font>
</td>
<td colspan="2">
<font face="Verdana, Arial, Helvetica" size="1">
<?
if ($userdata["user_id"] >= 1) {
if ($song["songtype"] == 'S') {
$SAMdb->open("SELECT song_rating.rating FROM song_rating where song_rating.songID = " . $song["songID"] . " AND song_rating.userID = " . $userdata['user_id']);
$the_rating = $SAMdb->row();
if ($the_rating["rating"] == null)
$my_rating = 0;
else
$my_rating = $the_rating["rating"];
InputComboRating("rating",$my_rating,0,'0, 1, 2, 3, 4, 5');
}
else
echo "This cannot be rated";
}
else
echo "Please <strong>login</strong> or <strong>register</strong> to use this feature.";
?>
</font>
</td>
<?
if (($song["songtype"] == 'S') && ($userdata['user_id'] >= 0)) {
echo "</form>";
}
?>
</tr>
<?//////////////////////////////////////////////////////////////////////////////////////////////////////////?>
</table>
<? } ?>
<?
function PutSongRowRecent($song)
{
global $rc, $songNew, $picture_dir;
PrepareSong($song);
$rc++;
?>
<tr bgcolor="<? echo $bgcolor; ?>">
<td>
<font face="Verdana, Arial, Helvetica" size="1">
<a href="modules.php?name=Playlist&letter=<? echo $song["artist"]{0}; ?>&artist=<? echo $song["artist"]; ?>" title="Get an album listing of <? echo htmlspecialchars($song["artist"]); ?>"><? echo $song["artist"]; ?></a>
</font>
</td>
<td>
<img src="images/spacer.gif" width="15" height="13">
</td>
<td>
<a href="<? echo $song["buycd"]; ?>" target="_blank"><img width="30" height="30" src="<? echo $picture_dir . rawurlencode($song["picture"]); ?>" title="Buy <? echo htmlspecialchars($song["album"]); ?> by <? echo htmlspecialchars($song["artist"]); ?> from Amazon.com. A percentage of your purchase goes to FesterHead Radio!" border=0></a>
</td>
<td>
<img src="images/spacer.gif" width="15" height="13">
</td>
<td>
<font face="Verdana, Arial, Helvetica" size="1">
<a href="modules.php?name=playlist&letter=<? echo $song["artist"]{0}; ?>&artist=<? echo $song["artist"]; ?>&album=<? echo $song["album"]; ?>" title="Get a track listing of <? echo htmlspecialchars($song["album"]); ?>"><? echo $song["album"]; ?></a>
</font>
</td>
<td>
<img src="images/spacer.gif" width="15" height="13">
</td>
<td>
<font face="Verdana, Arial, Helvetica" size="1">
<a href="modules.php?name=Playlist&file=songinfo&songID=<? echo $song["songID"]; ?>" title="Get information on <? echo htmlspecialchars($song["title"]); ?> by <? echo htmlspecialchars($song["artist"]); ?>"><? echo $song["title"]; ?></a>
<?
if ($song["date_added"] > date("Y-m-d H:i:s",time()-$songNew*24*60*60))
echo "<img src='images/new.gif' title=\"" .
htmlspecialchars($song["title"]) . " by " . htmlspecialchars($song["artist"]) . " added ". date('M d, Y', strtotime($song["date_added"])) . "\" border='0'>";
if ($song["requestID"] != 0)
echo " <font color='#FF4500'>~requested~</font> ";
?>
</font>
</td>
<td>
<img src="images/spacer.gif" width="15" height="13">
</td>
<td>
<font face="Verdana, Arial, Helvetica" size="1">
<? echo $song["mmss"]; ?>
</font>
</td>
</tr>
<?
}//PutSongRow
/* ## ===================================================================== ## */
?>
<br>
<br>
<? Preparesong($song); ?>
<? OpenTable(); ?>
<tr>
<td valign="middle" bgcolor="#006699">
<font face="Verdana, Arial, Helvetica" color="#F5DEB3" size="2">
<b>
<?
// Exercise the select statement to get what is currently playing
$SAMdb->open("SELECT * from currentshow");
// Populate the song variable with the result
$theshow = $SAMdb->row();
reset($theshow);
// Show text1
echo $theshow["text1"];
?>
</b>
</font>
</td>
<td align="left" valign="middle" bgcolor="#006699">
<font face="Verdana, Arial, Helvetica" color="#F5DEB3" size="1">
<?
// Show text1
echo $theshow["text2"];
?>
</font>
</td>
</tr>
<tr>
<td colspan="2">
<table border="0" width="100%">
<tr>
<td align="center" valign="middle">
<a href="<? echo $song["buycd"]; ?>" target="_blank"><img src="<? echo $picture_dir . rawurlencode($song["picture"]); ?>" title="Buy <? echo htmlspecialchars($song["album"]); ?> by <? echo htmlspecialchars($song["artist"]); ?> from Amazon.com. A percentage of your purchase goes to FesterHead Radio!" border=0></a>
<br>
<a href="<? echo $song["buycd"]; ?>" target="_blank"><img src="images/amazon.gif" title="Buy <? echo htmlspecialchars($song["album"]); ?> by <? echo htmlspecialchars($song["artist"]); ?> from Amazon.com. A percentage of your purchase goes to FesterHead Radio!" border=0></a>
</td>
<td valign="top">
<? PutSongRowCurrent($song); ?>
</td>
</tr>
</table>
</td>
</tr>
<? CloseTable(); ?>
<script language="JavaScript">
var countDownTime = <? echo $secsRemain; ?> + 1;
var countDownR = <? if ($userdata['user_id'] == 1) echo 10; else echo rand (30, 120); ?> + 1;
if (document.all||document.getElementById)
countDown();
else
window.onload = countDown;
function countDown() {
if (document.all)
document.all.countDownText.innerText = "Time left";
else if (document.getElementById)
document.getElementById("countDownText").innerHTML = "Time left";
countDownTime--;
if (countDownTime == 0) {
countDownRe();
return;
}
else if (countDownTime < 0)
countDownTime = 30;
if (document.all)
document.all.countDownTime.innerText = secsToMins(countDownTime);
else if (document.getElementById)
document.getElementById("countDownTime").innerHTML = secsToMins(countDownTime);
counter = setTimeout("countDown()", 1000);
}
function countDownRe() {
if (document.all)
document.all.countDownText.innerText = "Reload in";
else if (document.getElementById)
document.getElementById("countDownText").innerHTML = "Reload in";
countDownR--;
if (countDownR == 0) {
window.location.reload();
return;
}
else if (countDownR < 0)
countDownR = 30;
if (document.all)
document.all.countDownTime.innerText = secsToMins(countDownR);
else if (document.getElementById)
document.getElementById("countDownTime").innerHTML = secsToMins(countDownR);
counter = setTimeout("countDownRe()", 1000);
}
function secsToMins(theValue) {
var theMin = Math.floor(theValue / 60);
var theSec = (theValue % 60);
if (theSec < 10)
theSec = "0" + theSec;
return(theMin + ":" + theSec);
}
function openReview(thePage, w, h) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars=yes,resizable';
win = window.open(thePage, 'l', winprops);
if (parseInt(navigator.appVersion) >= 4)
win.window.focus();
}
function openLyrics(thePage, w, h) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars=yes,resizable';
win = window.open(thePage, 'k', winprops);
if (parseInt(navigator.appVersion) >= 4)
win.window.focus();
}
</script>
<?
if(count($queue) > 0) {
echo "<table><tr><td nowrap>";
echo "<font face='Verdana, Arial, Helvetica' size='1'>";
echo "Coming up: ";
echo "</font></td><td>";
echo "<font face='Verdana, Arial, Helvetica' size='1'>";
if ($userdata['user_id'] < 1)
echo("Please <strong>login</strong> or <strong>register</strong> to use this feature.");
else {
$i = 0;
$j = 1;
$tempArtist = '';
$requestTag = false;
while((list($key, $song) = each($queue)) && ($i < 4)) {
if ($tempArtist != $song["artist"]) {
if ($j > 1)
echo " (" . $j . ")";
if ($i > 0)
echo ", ";
$j = 1;
$i++;
?><a href="modules.php?name=Playlist&letter=<? echo $song["artist"]{0}; ?>&artist=<? echo $song["artist"]; ?>" title="Get an album listing of <? echo htmlspecialchars($song["artist"]); ?>"><? echo $song["artist"]; ?></a><?
$tempArtist = $song["artist"];
$requestTag = false;
}
else
$j++;
if ($song["requestID"] != 0)
echo " <font color='#FF4500'>~requested~</font> ";
}
}
echo "</font>";
echo "</td></tr></table>";
}
?>
<br>
<? OpenTable(); ?>
<tr bgcolor="#006699">
<td colspan="9" nowrap>
<p align="center">
<font face="Verdana, Arial, Helvetica" size="2" color="#F5DEB3">
<b>Recently played songs</b>
</font>
</td>
</tr>
<?
if ($userdata['user_id'] < 1) {
echo("<tr><td colspan='7'>");
echo("Please <strong>login</strong> or <strong>register</strong> to use this feature.");
echo("</td></tr>");
}
else {
$rc=0;
while(list($key, $song) = each($history))
PutSongRowRecent($song);
}
?>
<? CloseTable(); ?>