2 require_once("always.php");
3 require_once("Session.php");
5 unset($a); if ( isset($_GET['a']) ) $a = $_GET['a'];
6 unset($l); if ( isset($_GET['l']) ) $a = $_GET['l'];
8 require_once("PlayTracks.php");
10 $title = $system_name;
11 require_once("header.php");
13 if ( "$error_loc$error_msg" == "" ) {
15 function track_link( $trk, $link_title, $row_class = "" ) {
18 $track_link_url = sprintf( "?l=%s&a=%s&t=%s", urlencode($trk->album
), urlencode($trk->artist
), urlencode($trk->title
) );
19 $safe_title = htmlspecialchars($link_title);
20 $duration = preg_replace( "/^[0:]{1,4}/", "", $trk->duration
);
21 $last_played = ($trk->last_played
== '-infinity'?
"-":substr($trk->last_played
,0,10));
23 <tr class="track$row_class">
24 <td class="track$row_class">
25 <a class="track$row_class" href="artist.php$track_link_url$letter_get" title="$trk->path_name">$safe_title</a>
27 <td class="track$row_class"> $last_played </td>
28 <td class="track$row_class"> $duration </td>
29 <th class="track$row_class">
30 <a class="alphabetica" href="edit_track.php$track_link_url" title="Edit Track Info">E</a>
40 echo "<table width=\"100%\"><tr valign=\"top\">\n";
42 echo "<td width=\"50%\">\n";
44 $qa = "SELECT artist, album, title, tracknum, path_name, duration::interval(0), ";
45 $qa .= "extract( EPOCH FROM duration)::int AS secs, quality, get_last_played(hash_key) AS last_played ";
46 $qa .= "FROM tracks WHERE lower(artist) = lower('" . addslashes($a) . "') ";
47 $qa .= "ORDER BY lower(album), setpart, tracknum; ";
48 $res = awm_pgexec( $dbconn, $qa, "db");
49 if ( $res && pg_NumRows($res) > 0 ) {
50 echo "<h3>".htmlspecialchars($a)."</h3>\n";
52 for ( $i = 0; $i < pg_NumRows($res); $i++
) {
53 $track = pg_Fetch_Object( $res, $i );
54 if ( $track->album
!= "" && $track->album
!= $last_album ) {
55 if ( $i > 1 ) echo "</table>";
56 echo "<br><table width=100% cellspacing=0 cellpadding=0><tr class=th4><td width=71% class=th4>";
57 echo "<a class=th4 href=\"artist.php?a=" . urlencode($track->artist
) . "&l=" . urlencode($track->album
) . "$letter_get\">".htmlspecialchars($track->album
)."</a></td>\n";
58 echo "<td width=15% class=th4> </td>";
59 echo "<td width=10% class=th4> </td>";
60 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>";
61 $last_album = $track->album
;
64 echo "<br><table width=100%><tr><td width=96% class=h4>";
65 echo "<h4>Unkown Album</h4></td><td width=4%> </td></tr>\n";
67 // echo track_link($track, ($track->tracknum > 0 ? "$track->tracknum: " : "") . "$track->title", " bgcolor=" . $colors["bg".($i%2)] );
68 echo track_link($track, ($track->tracknum
> 0 ?
"$track->tracknum: " : "") . "$track->title", $i %
2 );
73 else if ( isset( $l ) ) {
74 $qa = "SELECT artist, album, title, tracknum, path_name, duration::interval(0), ";
75 $qa .= "extract( EPOCH FROM duration)::int AS secs, quality, get_last_played(hash_key) AS last_played ";
76 $qa .= "FROM tracks WHERE album = '" . addslashes($l) . "' ";
77 $qa .= "ORDER BY album, setpart, tracknum; ";
78 $res = awm_pgexec( $dbconn, $qa, "db");
79 if ( $res && pg_NumRows($res) > 0 ) {
80 echo "<h3><a class=th4 href=\"artist.php?play=1&l=" . urlencode($l) . "$letter_get\">$l</a></h3>\n";
82 for ( $i = 0; $i < pg_NumRows($res); $i++
) {
83 $track = pg_Fetch_Object( $res, $i );
84 if ( $track->artist
!= "" && $track->artist
!= $last_artist ) {
85 echo "<br><table width=100% cellspacing=0 cellpadding=0><tr class=th4><td width=71% class=th4>";
86 echo "<a class=h4 href=\"artist.php?a=" . urlencode($track->artist
) . "&l=" . urlencode($track->album
) . "$letter_get\">$track->artist</a></td>\n";
87 echo "<td width=15% class=th4> </td>";
88 echo "<td width=10% class=th4> </td>";
89 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>";
90 $last_artist = $track->artist
;
93 echo "<br><table width=100%><tr><td width=96% class=h4>";
94 echo "<h4>Unkown Album</h4></td><td width=4%> </td></tr>\n";
96 echo track_link($track, ($track->tracknum
> 0 ?
"$track->tracknum: " : "") . "$track->title", $i %
2 );
106 echo "<td width=\"50%\">\n";
107 echo "<h3>Artists</h3>\n<p>";
108 if ( isset($altr) ||
isset($search) ) {
109 $altr = trim("$altr");
110 if ( isset($search) ) {
111 $sql = "SELECT distinct ON ( lower(artist)) artist FROM tracks ";
112 $sql .= "WHERE artist ~* ? OR album ~* ? OR title ~* ? OR path_name ~* ? ";
113 $sql .= "ORDER BY lower(artist);";
114 $qry = new PgQuery( $sql, $search, $search, $search, $search );
117 $qry = new PgQuery( "SELECT distinct ON ( lower(artist)) artist FROM tracks WHERE artist ~* ? ORDER BY lower(artist);", "^$altr");
119 if ( $qry->Exec('artist') && $qry->rows
> 0 ) {
120 while ( $artist = $qry->Fetch() ) {
121 $display = htmlspecialchars($artist->artist
);
122 if ( trim($display) == "" ) $display = "«unknown»";
123 echo " <a href=\"artist.php?a=" . urlencode($artist->artist
) . "$letter_get\" class=\"artist\">$display</a>\n";
129 echo "</tr></table>\n";
132 include("footers.php");