2 require_once("always.php");
3 require_once("Session.php");
4 require_once("PlayTracks.php");
7 require_once("header.php");
10 if ( "$error_loc$error_msg" == "" ) {
12 function track_link( $trk, $link_title, $row_class = "" ) {
15 $track_link_url = sprintf( "?l=%s&a=%s&t=%s", urlencode($trk->album
), urlencode($trk->artist
), urlencode($trk->title
) );
16 $safe_title = htmlspecialchars($link_title);
17 $duration = preg_replace( "/^[0:]{1,4}/", "", $trk->duration
);
18 $last_played = ($trk->last_played
== '-infinity'?
"-":substr($trk->last_played
,0,10));
20 <tr class="track$row_class">
21 <td class="track$row_class">
22 <a class="track$row_class" href="artist.php$track_link_url$letter_get" title="$trk->path_name">$safe_title</a>
24 <td class="track$row_class"> $last_played </td>
25 <td class="track$row_class"> $duration </td>
26 <th class="track$row_class">
27 <a class="alphabetica" href="edit_track.php$track_link_url" title="Edit Track Info">E</a>
37 echo "<table width=\"100%\"><tr valign=\"top\">\n";
39 echo "<td width=\"50%\">\n";
41 $qa = "SELECT artist, album, title, tracknum, path_name, duration::interval(0), ";
42 $qa .= "extract( EPOCH FROM duration)::int AS secs, quality, get_last_played(hash_key) AS last_played ";
43 $qa .= "FROM tracks WHERE lower(artist) = lower('" . addslashes($a) . "') ";
44 $qa .= "ORDER BY lower(album), setpart, tracknum; ";
45 $res = awm_pgexec( $dbconn, $qa, "db");
46 if ( $res && pg_NumRows($res) > 0 ) {
47 echo "<h3>".htmlspecialchars($a)."</h3>\n";
49 for ( $i = 0; $i < pg_NumRows($res); $i++
) {
50 $track = pg_Fetch_Object( $res, $i );
51 if ( $track->album
!= "" && $track->album
!= $last_album ) {
52 if ( $i > 1 ) echo "</table>";
53 echo "<br><table width=100% cellspacing=0 cellpadding=0><tr class=th4><td width=71% class=th4>";
54 echo "<a class=th4 href=\"artist.php?a=" . urlencode($track->artist
) . "&l=" . urlencode($track->album
) . "$letter_get\">".htmlspecialchars($track->album
)."</a></td>\n";
55 echo "<td width=15% class=th4> </td>";
56 echo "<td width=10% class=th4> </td>";
57 echo "<td width=4% class=th4><a class=alphabetica class=track href=\"edit_track.php?l=" . urlencode($track->album
) . "&a=" . urlencode($track->artist
) . "\" title=\"Edit Album Info\">E</a></td></tr>";
58 $last_album = $track->album
;
61 echo "<br><table width=100%><tr><td width=96% class=h4>";
62 echo "<h4>Unkown Album</h4></td><td width=4%> </td></tr>\n";
64 // echo track_link($track, ($track->tracknum > 0 ? "$track->tracknum: " : "") . "$track->title", " bgcolor=" . $colors["bg".($i%2)] );
65 echo track_link($track, ($track->tracknum
> 0 ?
"$track->tracknum: " : "") . "$track->title", $i %
2 );
70 else if ( isset( $l ) ) {
71 $qa = "SELECT artist, album, title, tracknum, path_name, duration::interval(0), ";
72 $qa .= "extract( EPOCH FROM duration)::int AS secs, quality, get_last_played(hash_key) AS last_played ";
73 $qa .= "FROM tracks WHERE album = '" . addslashes($l) . "' ";
74 $qa .= "ORDER BY album, setpart, tracknum; ";
75 $res = awm_pgexec( $dbconn, $qa, "db");
76 if ( $res && pg_NumRows($res) > 0 ) {
77 echo "<h3><a class=th4 href=\"artist.php?play=1&l=" . urlencode($l) . "$letter_get\">$l</a></h3>\n";
79 for ( $i = 0; $i < pg_NumRows($res); $i++
) {
80 $track = pg_Fetch_Object( $res, $i );
81 if ( $track->artist
!= "" && $track->artist
!= $last_artist ) {
82 echo "<br><table width=100% cellspacing=0 cellpadding=0><tr class=th4><td width=71% class=th4>";
83 echo "<a class=h4 href=\"artist.php?a=" . urlencode($track->artist
) . "&l=" . urlencode($track->album
) . "$letter_get\">$track->artist</a></td>\n";
84 echo "<td width=15% class=th4> </td>";
85 echo "<td width=10% class=th4> </td>";
86 echo "<td width=4% class=th4><a class=alphabetica class=track href=\"edit_track.php?l=" . urlencode($track->album
) . "&a=" . urlencode($track->artist
) . "\" title=\"Edit Album Info\">E</a></td></tr>";
87 $last_artist = $track->artist
;
90 echo "<br><table width=100%><tr><td width=96% class=h4>";
91 echo "<h4>Unkown Album</h4></td><td width=4%> </td></tr>\n";
93 echo track_link($track, ($track->tracknum
> 0 ?
"$track->tracknum: " : "") . "$track->title", $i %
2 );
103 echo "<td width=\"50%\">\n";
104 echo "<h3>Artists</h3>\n<p>";
105 if ( isset($altr) ||
isset($search) ) {
106 $altr = trim("$altr");
107 if ( isset($search) ) {
108 $sql = "SELECT distinct ON ( lower(artist)) artist FROM tracks ";
109 $sql .= "WHERE artist ~* ? OR album ~* ? OR title ~* ? OR path_name ~* ? ";
110 $sql .= "ORDER BY lower(artist);";
111 $qry = new PgQuery( $sql, $search, $search, $search, $search );
114 $qry = new PgQuery( "SELECT distinct ON ( lower(artist)) artist FROM tracks WHERE artist ~* ? ORDER BY lower(artist);", "^$altr");
116 if ( $qry->Exec('artist') && $qry->rows
> 0 ) {
117 while ( $artist = $qry->Fetch() ) {
118 $display = htmlspecialchars($artist->artist
);
119 if ( trim($display) == "" ) $display = "«unknown»";
120 echo " <a href=\"artist.php?a=" . urlencode($artist->artist
) . "$letter_get\" class=\"artist\">$display</a>\n";
126 echo "</tr></table>\n";
129 include("footers.php");