📄 mail.php
字号:
$playlist_id = addslashes($_POST['playlist_id']);
}
foreach( $song_id as $id ) {
if( $id != '' ) {
$query = "INSERT INTO playlistsong (song_id, playlist_id) VALUES ('".$id."','".$playlist_id."')";
mysql_query($query) or die(mysql_error());
}
}
print("<title>Song Saved - DONE</title>");
print("<br><center><b><strong><u><font color='#000000'>The Songs have been added to your playlist.</p></font></strong></u></b></center>\n");
print("<p style='text-align: center'><input type='button' onClick='window.close()' value='Close Window' ></p>\n");
} else {
print("<title>Add to Playlist</title>");
print("<form name='form' action='".$this->thisfile."?action=playlist&id=".$song_id_raw."&save=yes&create=yes' method='post'>\n");
print("<table style='width: 100%; border: 0px;'>\n");
print("<tr><td colspan='2'>Create and save new playlist</td></tr>\n");
print("<tr><td><b>New Playlist Name</b>:</td><td><input type='text' maxchar='255' name='playlist_name'></td></tr>\n");
print("<tr><td colspan='2' style='text-align:center'><input name='submit' type='submit' value='Create and save in New Playlist' ></td></tr>\n");
print("</table></form>\n");
$query = "SELECT * FROM playlist WHERE username = '".$session->username."' ORDER BY playlist_name ASC";
$result = mysql_query($query) or die(mysql_error());
if( mysql_num_rows($result)>0 ) {
print("<form name='form' action='".$this->thisfile."?action=playlist&id=".$song_id_raw."&save=yes' method='post'>\n");
print("<table style='width: 100%; border: 0px;'>\n");
print("<tr><td colspan='2'>Add to current Playlist</td></tr>\n");
print("<tr><td>Playlist:</td><td><select name='playlist_id'>");
while( $playlist = mysql_fetch_assoc($result) )
{
print("<option value='".$playlist['id']."'>".$playlist['playlist_name']."</option>\n");
}
print("</select></td></tr>\n");
print("<tr><td colspan='2' style='text-align:center'><input name='submit' type='submit' value='Add to Playlist' ></td></tr>\n");
print("</table></form>\n");
}
}
}
function viewAllPlaylists() {
global $session;
/* $query = "SELECT playlist.id as id, playlist.playlist_name, playlist.username FROM playlist, playlistsong WHERE playlist.id = playlistsong.playlist_id GROUP BY playlistsong.playlist_id ORDER BY playlist.playlist_name ASC";
$result = mysql_query($query) or die(mysql_error());
while( $row = mysql_fetch_assoc($result) ) {
// get initial name character
$thischar = $row['playlist_name']{0};
$user = $this->get_info($row['username']);
// Check to see if different than last
if( $lastchar != $thischar ) {
print("<h2>".strtoupper($thischar)."</h2>\n");
if( $lastchar != '' ) {
print("</p>\n<p>\n");
}
}
// Print album Info
print("<a href='".$this->thisfile."?action=viewplaylist&id=".$row['id']."'>".$row['playlist_name']."</a> by ".$user['name']."</a><br>\n");
// Store character
$lastchar = $thischar;
}
if( $session->username!="" ) {
print("<h1>".$session->username."'s Playlists</h1>");
} else {
print("<h1>User Playlists</h1>");
}
$query = "SELECT * FROM playlist ".(($session->username!="")?"WHERE username = '".addslashes($session->username)."'":"")." ORDER BY username, playlist_name";
$result = mysql_query($query) or die(mysql_error());
$i = 0;
$cur_id = -1;
for( ; $row = mysql_fetch_assoc($result) ; $i++ ) {
print("<h2><a href='".$this->url."/".$this->file."?action=viewplaylist&username=".$session->username."'>".$session->username."</a></h2><ul>");
}
print("<li><a href='".$this->url."/".$this->thisfile."?action=viewplaylist&username=".$session->username."'>".$row['playlist_name']."</a></li>");
print("</ul>");
if( $i == 0 ) {
print("<p>No playlists yet created.</p>");
}
*/
}
function showAllPlaylists() {
global $session;
if( $_GET['username']!="" ) {
#$user = $this->get_info($session->username);
print("<h1>".$user['name']."'s Playlists</h1>");
} else {
print("<h1>User Playlists</h1>");
}
$u_query = "SELECT username FROM playlist GROUP BY username";
$u_result = mysql_query($u_query) or die(mysql_error());
while($u_row = mysql_fetch_assoc($u_result))
{
echo "<h3>".$u_row[username]."</h3>";
print("<ul>");
$query = "SELECT * FROM playlist where username='".$u_row[username]."' ORDER BY username, playlist_name ";
$result = mysql_query($query) or die(mysql_error());
$i = 0;
for( ; $row = mysql_fetch_assoc($result) ; $i++ ) {
print("<li><a href='".$this->thisfile."?action=viewplaylist&username=".$row['username']."&id=".$row['id']."'>".$row['playlist_name']."</a></li>");
}
print("</ul>");
}
if( $i == 0 ) {
print("<p>No playlists yet created.</p>");
}
}
function viewPlaylist() {
global $session;
#print("<p style='text-align:center'><a href='".$this->url."/".$this->file."index.php?action=showallplaylists'>View all user playlists.</a></p>");
$id = addslashes($_REQUEST['id']);
$current_playlist = addslashes($_REQUEST['id']);
if($_REQUEST['username'])
{
$username = addslashes($_REQUEST['username']);
}
else
{
$username = addslashes($session->username);
}
if( $current_playlist != "" ) {
$query = "SELECT username FROM playlist WHERE id = '".$current_playlist."'";
$result = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_assoc($result);
$username = $session->username;
}
print("<div id='content'>\n");
$query = "SELECT * FROM playlist WHERE username = '".$session->username."' ORDER BY playlist_name ASC";
$result = mysql_query($query) or die(mysql_error());
print("<table><tr><td>");
if( $username != "" && $username != $session->username ) {
$user = $this->get_info($username);
print("<form action='".$this->thisfile."?action=viewplaylist&username=".$username."' name='sort' method='post'>\n");
print($user['name']."'s playlists: <select name='id' onChange='javascript:document.sort.submit();'>\n");
print("<option value=''>-----</option>\n");
while( $playlist = mysql_fetch_assoc($result) )
{
if($current_playlist == "") { $current_playlist = $playlist['id']; }
print("<option value='".$playlist['id']."'".(($id==$playlist['id'])?" SELECTED":"").">".$playlist['playlist_name']."</option>\n");
if($id==$playlist['id']||$current_playlist==$playlist['id']) {
$playlistname=$playlist['playlist_name'];
}
}
print("</select></form>\n");
} else {
print(" ");
}
print("</td>\n");
print("<td style='text-align: right;'>\n");
if($session->username!="Guest") {
print("<form action='".$this->thisfile."?action=viewplaylist' name='mysort' method='post'>\n");
print("Your playlists: <select name='id' onChange='javascript:document.mysort.submit();'>\n");
$query = "SELECT * FROM playlist WHERE username = '".$session->username."' ORDER BY playlist_name ASC";
$result = mysql_query($query) or die(mysql_error());
print("<option value='' ".($session->username!=$username?"SELECTED":"").">-----</option>\n");
$i=0;
while($playlist = mysql_fetch_assoc($result) )
{
if($current_playlist == "") { $current_playlist = $playlist['id']; }
print("<option value='".$playlist['id']."'".(($id==$playlist['id'])?" SELECTED":"").">".$playlist['playlist_name']."</option>\n");
if($id==$playlist['id']) {
$playlistname=$playlist['playlist_name'];
}
$i++;
}
print("</select></form>\n");
} else {
$query = "SELECT playlist_name FROM playlist where id='".$id."'";
$result = mysql_query($query) or die(mysql_error());
$playlist = mysql_fetch_assoc($result);
$playlistname=$playlist['playlist_name'];
}
print("</td></tr></table>\n");
// List Songs
$query = "SELECT SUM(song.plays) as total_plays, AVG(song.rating/song.num_rating) as average_rating, song.song_name, song.id as song_id, song.lyric_id as lyric_id, artist.id as artist_id, album.id as album_id, album.album_name as album_name, song.lyrics_approved as lyrics, artist.name as artist_name FROM playlistsong, song, album, artist WHERE playlistsong.playlist_id='".$id."' AND playlistsong.song_id = song.id AND song.album_id = album.id AND song.artist_id = artist.id GROUP BY playlistsong.id";
$result = mysql_query($query) or die(mysql_error());
$total=mysql_num_rows($result);
if($playlistname)
{
$playlistname=$playlistname;
}
else
{
$playlistname="All";
}
if($_REQUEST['username'])
{
$username = addslashes($_REQUEST['username']);
}
else
{
$username = addslashes($session->username);
}
print("<form name='listing' action='".$this->thisfile."?action=launch' method='post'>\n");
print("<h1>".$username." playlist - ".$playlistname."</h1>\n");
if($total==0)
{
echo "Please select a playlist from dropdown.";
}
$this->topButtons();
print("<table border='0' cellspacing='1' cellpadding='4'>\n");
$i = 1;
while( $row = mysql_fetch_assoc($result) )
{
print("<tr><td style='width:20px; text-align:center'><input type='checkbox' name='song_id' value='".$row['song_id']."' /></td><td style='font-weight:bold; width:20px; text-align:center'>$i</span></td><td><a href='javascript:playSong(".$row['song_id'].")'>".$row['song_name']."</a> <a href='javascript:rateSong(".$row['song_id'].");'><img src='images/".((round($row['average_rating'])<1)?'1':round($row['average_rating']))."_s.gif' alt='".round($row['average_rating'],2)."' border='0'></td><td><a href='javascript:showLyrics(".$row['lyric_id'].");'>".(($row['lyrics']!=0)?"<img src='images/lyrics_txt.gif' alt='Lyrics' border='0'>":" ")."</a></td><td style='text-align: right;' ><a href='javascript:mailFriend(0,0,".$row['song_id'].",0)'><img src='images/mail.gif' alt='Email this Track' border='0'></a></td></tr>\n");
print("<tr><td colspan='2'> </td><td colspan='3'><span style='font-weight:bold;'>Artist Name:</span> <a href='".$this->thisfile."?action=artist&id=".$row['artist_id']."'>".$row['artist_name']."</a></td></tr>\n");
print("<tr><td colspan='2'> </td><td colspan='3'><span style='font-weight:bold;'>Album Name:</span> <a href='".$this->thisfile."?action=album&id=".$row['album_id']."'>".$row['album_name']."</a></td></tr>\n");
print("<tr><td colspan='2'> </td><td colspan='3'><span>Times Played</span> ".$row['total_plays']." ".(($session->logged_in)?"<a href='javascript:addToPlaylist(".$row['song_id'].")'><font color='#CD238F'>Add to Playlist</font></a> ":"").(($row['lyrics']!=1)?" <a href='".$this->thisfile."?action=addlyrics&song=".$row['song_id']."'><font color='#9A17C5'>Add Lyrics</font></a>":"")."</td></tr>\n");
}
print("</table>\n");
$this->bottomButtons();
print("</form>\n");
print("</div>\n");
}
/********** Mail Friend Functions **********/
function mailFriend() {
$song_id = addslashes($_GET['song']);
$album_id = addslashes($_GET['album']);
$artist_id = addslashes($_GET['artist']);
$genre_id = addslashes($_GET['genre']);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -