\n");
$alternateColor = FALSE;
}
else
{
print("|
\n");
}
print("\n");
$this->bottomButtons();
$review_status=review_admin_val(4);
if($review_status)
{
$guest_review=review_admin_val(1);
if($guest_review || $session->logged_in){display_review($album[id]); }
}
print("\n");
}
function listalbums() {
global $HTTP_POST_VARS,$HTTP_GET_VARS,$HTTP_SERVER_VARS,$HTTP_SESSION_VARS,$HTTP_COOKIE_VARS,$HTTP_POST_FILES;
$sortby = $HTTP_POST_VARS['sort'];
/**
* Only list 5 newest albums if this is the homepage
*/
if (!$HTTP_GET_VARS)
$query = "SELECT TO_DAYS(now())-TO_DAYS(album.post_date)as date_diff, album.album_name, artist.name as artist_name, album.album_photo, album.album_info, album.id as album_id, artist.id as artist_id FROM album, artist WHERE album.artist_id = artist.id ORDER BY album.post_date DESC LIMIT 5";
else
$query = "SELECT TO_DAYS(now())-TO_DAYS(album.post_date)as date_diff, album.album_name, artist.name as artist_name, album.album_photo, album.album_info, album.id as album_id, artist.id as artist_id FROM album, artist WHERE album.artist_id = artist.id ORDER BY album.post_date DESC LIMIT 5";
$result = mysql_query($query) or die(mysql_error());
print(" |
|
5 Newest Albums |
");
print("".PGTITLE."");
print("\n");
$lastchar = '';
while( $album = mysql_fetch_assoc($result) )
{
// get initial name character
if( $sortby == 'album' ) {
$thischar = $album['album_name']{0};
$display = $album['album_name']." - ".$album['artist_name'];
} else {
$thischar = $album['artist_name']{0};
$display = $album['artist_name']." - ".$album['album_name'];
}
// Check to see if different than last
if( $lastchar != $thischar ) {
if( $lastchar != '' ) {
print("");
}
}
// Print album Info
print(" \n");
print("".$display." ".(($album['date_diff']<14)?"":"")." {$album['album_info']} ".buy_link($album[album_id],"album")." ".calculate_price($album[album_id])." |
");
// Store character
$lastchar = $thischar;
}
print(" | | ");
}
/********** Genre Functions **********/
function genre() {
global $HTTP_POST_VARS,$HTTP_GET_VARS,$HTTP_SERVER_VARS,$HTTP_SESSION_VARS,$HTTP_COOKIE_VARS,$HTTP_POST_FILES;
$genre = $HTTP_GET_VARS['id'];
if( $genre != '' ) {
$this->displayGenre($genre);
} else {
$this->listGenres();
}
}
function displayGenre( $id )
{
global $HTTP_POST_VARS,$HTTP_GET_VARS,$HTTP_SERVER_VARS,$HTTP_SESSION_VARS,$HTTP_COOKIE_VARS,$HTTP_POST_FILES;
$sortby = $HTTP_POST_VARS['sort'];
if( $id == 'all' ) {
$query = "SELECT * FROM genre WHERE 1";
} else {
$query = "SELECT * FROM genre WHERE id = '".$id."'";
}
$result = mysql_query($query);
$genre = mysql_fetch_assoc($result);
$query = "SELECT TO_DAYS(now())-TO_DAYS(album.post_date)as date_diff, album.id as album_id, album.album_name, album.album_photo, artist.name as artist_name FROM album, artist WHERE ".(($id!='all')?"album.genre_id = '".$id."' AND ":"")."album.artist_id = artist.id ORDER BY ".(($sortby=='album')?'album.album_name':'artist.name')." ASC";
$result = mysql_query($query) or die(mysql_error());
// Genre
print("".$genre['genre']."");
print("
| ".$genre['genre']." |
\n");
print("");
$lastchar = '';
while( $album = mysql_fetch_assoc($result) )
{
// get initial name character
if( $sortby == 'album' ) {
$thischar = $album['album_name']{0};
$display = $album['album_name']." - ".$album['artist_name'];
} else {
$thischar = $album['artist_name']{0};
$display = $album['artist_name']." - ".$album['album_name'];
}
// Check to see if different than last
if( $lastchar != $thischar ) {
print(" ");
if( $lastchar != '' ) {
}
}
// Print album Info
if (++$counter == 1)
{
print("");
}
print(" ");
print("".$display." ".(($album['date_diff']<14)?"":"")." | ");
if ($counter == 2)
{
print("");
$counter = 0;
}
// Store character
$lastchar = $thischar;
}
if (!($counter % 2))
{
print("");
}
print("");
}
function listGenres() {
global $HTTP_POST_VARS,$HTTP_GET_VARS,$HTTP_SERVER_VARS,$HTTP_SESSION_VARS,$HTTP_COOKIE_VARS,$HTTP_POST_FILES;
$query = "SELECT * FROM genre";
$result = mysql_query($query);
print("");
while( $genre = mysql_fetch_assoc($result) )
{
print(" ".$genre['genre']."");
}
print(" ");
}
/********** Lyrics Functions **********/
function lyrics() {
global $HTTP_POST_VARS,$HTTP_GET_VARS,$HTTP_SERVER_VARS,$HTTP_SESSION_VARS,$HTTP_COOKIE_VARS,$HTTP_POST_FILES;
$song_id = $HTTP_GET_VARS['song'];
$rights=get_prv($_SESSION['username']);
$query = "SELECT SUM(song.plays) as total_plays, AVG(song.rating/song.num_rating) as average_rating, album.album_name as album, album.id as album_id, artist.id as artist_id, artist.name AS artist_name, lyric.lyrics, song.song_name, song.id as song_id FROM song, album, artist, lyric WHERE album.id = song.album_id AND artist.id = song.artist_id AND lyric.id = song.lyric_id AND lyric.id = '".$song_id."' GROUP BY song.id";
$result = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_assoc($result);
print("Lyrics - ".$row['song_name']."");
print("\n");
}
function addlyrics() {
global $HTTP_POST_VARS,$HTTP_GET_VARS,$HTTP_SERVER_VARS,$HTTP_SESSION_VARS,$HTTP_COOKIE_VARS,$HTTP_POST_FILES,$session;
$rights=get_prv($_SESSION['username']);
$song_id = $HTTP_GET_VARS['song'];
$save = $HTTP_GET_VARS['save'];
if( $save == 'yes' ) {
$query = "INSERT INTO lyric (lyrics) VALUES ('".$HTTP_POST_VARS['lyrics']."')";
mysql_query($query) or die(mysql_error());
$query = "SELECT * FROM lyric WHERE lyrics = '".$HTTP_POST_VARS['lyrics']."'";
$result = mysql_query($query) or die(mysql_error());
$lyrics = mysql_fetch_assoc($result);
$query = "UPDATE song SET lyric_id = '".$lyrics['id']."' WHERE id = '".$song_id."'";
#print("$query ");
mysql_query($query) or die(mysql_error());
print("| Lyrics will be approved shortly by administrator |
|---|
");
}
$query = "SELECT SUM(song.plays) as total_plays, AVG(song.rating/song.num_rating) as average_rating, album.album_name, album.id as album_id, artist.id as artist_id, artist.name AS artist_name, song.song_name, song.id as song_id FROM song, album, artist WHERE album.id = song.album_id AND artist.id = song.artist_id AND song.id = '".$song_id."' GROUP BY song.id";
$result = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_assoc($result);
print("");
print("
|