Ticket #1919: mythmusic_schema_mythweb_schema_only.diff
| File mythmusic_schema_mythweb_schema_only.diff, 7.7 KB (added by Colin Guthrie <mythtv@…>, 6 years ago) |
|---|
-
handler.php
96 96 97 97 /**** If alphalink set, then change offset to new value ****/ 98 98 if ($_GET['alphalink']) { 99 $alphalink = $_GET['alphalink']; 100 $result=mysql_query("select count(1) from musicmetadata where upper(artist) < ".escape($alphalink)); 101 $alphaoffset=mysql_fetch_row($result); 102 $this->offset=$alphaoffset[0]; 103 mysql_free_result($result); 99 $alphalink = mysql_real_escape_string($_GET['alphalink']); 100 101 $result = mysql_query(sprintf("SELECT COUNT(*) FROM music_songs ". 102 "LEFT JOIN music_artists ON music_songs.artist_id=music_artists.artist_id ". 103 "WHERE UPPER(music_artists.artist_name) < %s ". 104 "ORDER BY music_artists.artist_name;", 105 escape($_GET['alphalink']))); 106 if ($result) 107 { 108 $alphaoffset=mysql_fetch_row($result); 109 $this->offset=$alphaoffset[0]; 110 mysql_free_result($result); 111 } 104 112 } 105 113 106 114 if($_GET['filterPlaylist']) … … 193 201 194 202 function prepFilter() 195 203 { 196 $prevFilter=0; 197 $thisFilter=""; 204 $this->filter="1=1"; // A true statement that will always return everything in SQL. 198 205 199 206 if($this->filterPlaylist != "_All_") 200 207 { 201 $playlistResult = mysql_query(" select playlistid,name,songlist,hostname from musicplaylist where playlistid=".escape($this->filterPlaylist));208 $playlistResult = mysql_query("SELECT playlist_id,playlist_name,playlist_songs,hostname FROM music_playlists WHERE playlist_id=".escape($this->filterPlaylist)); 202 209 if($playlistResult) 203 210 { 204 211 if(mysql_num_rows($playlistResult)==1) 205 212 { 206 213 $row=mysql_fetch_row($playlistResult); 207 if($row )214 if($row && !empty($row[2])) 208 215 { 209 210 216 $this->filterSonglist=$row[2]; 211 if($prevFilter==1)212 $this->filter=$this->filter . "and intid in (" . $this->filterSonglist . ")";213 else214 {215 $this->filter="intid in (" . $this->filterSonglist . ")";216 $prevFilter=1;217 }218 217 219 $this-> keepFilters="&filterPlaylist=" . urlencode($this->filterPlaylist);220 218 $this->filter .= " AND song_id IN (" . $this->filterSonglist . ")"; 219 $this->keepFilters .= "&filterPlaylist=" . urlencode($this->filterPlaylist); 221 220 } 222 221 } 223 222 } … … 225 224 226 225 if($this->filterArtist != "_All_" ) 227 226 { 228 if($prevFilter==1) 229 $this->filter=$this->filter . "and artist=".escape($this->filterArtist); 230 else 231 { 232 $this->filter="artist=".escape($this->filterArtist); 233 $prevFilter=1; 234 } 235 236 $this->keepFilters="&filterArtist=" . urlencode($this->filterArtist); 237 227 $this->filter .= " AND artist_name=".escape($this->filterArtist); 228 $this->keepFilters .= "&filterArtist=" . urlencode($this->filterArtist); 238 229 } 230 239 231 if($this->filterAlbum != "_All_") 240 232 { 241 if($prevFilter==1) 242 { 243 $this->filter= $this->filter . "and album=\"" . $this->filterAlbum . "\""; 244 } 245 else 246 { 247 $this->filter="album=\"" . $this->filterAlbum . "\""; 248 $prevFilter=1; 249 } 250 $this->keepFilters =$this->keepFilters . "&filterAlbum=" . urlencode($this->filterAlbum) ; 251 233 $this->filter .= " AND album_name=" . escape($this->filterAlbum); 234 $this->keepFilters .= "&filterAlbum=" . urlencode($this->filterAlbum) ; 252 235 } 236 253 237 if($this->filterGenre != "_All_") 254 238 { 255 if($prevFilter==1) 256 { 257 $this->filter= $this->filter . "and genre=" . $this->filterGenre ; 258 } 259 else 260 { 261 $this->filter="genre=\"" . $this->filterGenre . "\""; 262 $prevFilter=1; 263 } 264 $this->keepFilters =$this->keepFilters . "&filterGenre=" . urlencode($this->filterGenre); 265 239 $this->filter .= " AND genre=" . escape($this->filterGenre); 240 $this->keepFilters .= "&filterGenre=" . urlencode($this->filterGenre); 266 241 } 267 242 268 243 if($this->filterRank != "_All_") 269 244 { 270 if($prevFilter==1) 271 { 272 $this->filter=$this->filter . "and rank=" . $this->filterRank; 273 } 274 else 275 { 276 $this->filter="rank=" . $this->filterRank; 277 $prevFilter=1; 278 } 279 $this->keepFilters =$this->keepFilters . "&filterRank=" . urlencode($this->filterRank); 245 $this->filter .= " AND rank=" . escape($this->filterRank); 246 $this->keepFilters .= "&filterRank=" . urlencode($this->filterRank); 280 247 } 281 282 283 284 248 } 285 249 286 250 function init($maxPerPage) { 287 251 global $db; 288 252 $this->prepFilter(); 289 if (empty($this->filter)) 290 $this->totalCount = $db->query_col('SELECT COUNT(*) FROM musicmetadata'); 291 else 292 $this->totalCount = $db->query_col('SELECT COUNT(*) FROM musicmetadata WHERE '.$this->filter); 253 $query_base = ' FROM music_songs'. 254 ' LEFT JOIN music_artists ON music_songs.artist_id=music_artists.artist_id'. 255 ' LEFT JOIN music_albums ON music_songs.album_id=music_albums.album_id'. 256 ' LEFT JOIN music_genres ON music_songs.genre_id=music_genres.genre_id'. 257 ' WHERE '.$this->filter. 258 ' ORDER BY artist_name,album_name,track'; 259 260 // Cannot use $db->query_col here as the preg_replace kills PHP when using large filterSongList queries 261 $this->totalCount = 0; 262 $result = mysql_query('SELECT COUNT(*)'.$query_base); 263 if ($result) 264 { 265 $row=mysql_fetch_row($result); 266 $this->totalCount=$row[0]; 267 mysql_free_result($result); 268 } 293 269 294 270 if ($this->totalCount > 0) { 295 if($this->offset > 0) { 296 $limitText='LIMIT ' . $this->offset . ',' . $maxPerPage; 297 } 271 if($this->offset > 0) 272 $query_base .= ' LIMIT ' . $this->offset . ',' . $maxPerPage; 298 273 else 299 $limitText='LIMIT ' . $maxPerPage; 300 301 if (empty($this->filter)) 302 $this->result=mysql_query("select intid,artist,album,title,genre,length,rating,filename from musicmetadata order by artist,album,tracknum " . $limitText); 303 else 304 $this->result=mysql_query("select intid,artist,album,title,genre,length,rating,filename from musicmetadata where $this->filter order by artist,album,tracknum $limitText"); 274 $query_base .= ' LIMIT ' . $maxPerPage; 275 276 $this->result = mysql_query('SELECT music_songs.song_id, music_artists.artist_name, music_albums.album_name, music_songs.name, music_genres.genre, music_songs.length, music_songs.rating, music_songs.filename '.$query_base); 305 277 } 306 278 } 307 279 }
