diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2007-01-07 20:35:49 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2007-01-07 20:35:49 +0000 |
commit | b6cfe134badb2d4393e9081b13b2dfca011ed736 (patch) | |
tree | 4f6213e626fa90b4b280b5e663e791559c4a7f8f /lib | |
parent | 90d2acbc54b24b6e8207e12f1cabcbc7541ca447 (diff) | |
download | ampache-b6cfe134badb2d4393e9081b13b2dfca011ed736.tar.gz ampache-b6cfe134badb2d4393e9081b13b2dfca011ed736.tar.bz2 ampache-b6cfe134badb2d4393e9081b13b2dfca011ed736.zip |
* Re-worked Main page of Ampache, adding Album of the moment.
* Moved stats to /stats.php page
* Fixed logic error in resize that could cause nothign to display
if resize was on, but it still failed
* Fixed Upload Album art from Find Album Art
* Added Menu to the TV page
* Fixed logic error that showed localplay if user had access
regardless of global config
* Changed default action of browse.php to song browse
Diffstat (limited to 'lib')
-rw-r--r-- | lib/album.lib.php | 24 | ||||
-rw-r--r-- | lib/class/album.class.php | 3 | ||||
-rw-r--r-- | lib/class/catalog.class.php | 200 | ||||
-rw-r--r-- | lib/ui.lib.php | 8 |
4 files changed, 67 insertions, 168 deletions
diff --git a/lib/album.lib.php b/lib/album.lib.php index d01691b2..134e040e 100644 --- a/lib/album.lib.php +++ b/lib/album.lib.php @@ -59,4 +59,28 @@ function get_image_from_source($data) { } // get_image_from_source +/** + * get_random_albums + * This returns a random number of albums from the catalogs + * this is used by the index to return some 'potential' albums to play + */ +function get_random_albums($count='') { + + if (!$count) { $count = 5; } + + $count = sql_escape($count); + + $sql = "SELECT id FROM album ORDER BY RAND() LIMIT $count"; + $db_results = mysql_query($sql,dbh()); + + $results = array(); + + while ($r = mysql_fetch_assoc($db_results)) { + $results[] = $r['id']; + } + + return $results; + +} // get_random_albums + ?> diff --git a/lib/class/album.class.php b/lib/class/album.class.php index 24f4fac3..6358f489 100644 --- a/lib/class/album.class.php +++ b/lib/class/album.class.php @@ -155,11 +155,12 @@ class Album { $this->f_name = "<a href=\"$web_path/albums.php?action=show&album=" . $this->id . "\" title=\"" . scrub_out($this->name) . "\">" . $name . "</a>"; $this->f_link = "<a href=\"$web_path/albums.php?action=show&album=" . scrub_out($this->id) . "\" title=\"" . scrub_out($this->name) . "\">" . $name . "</a>"; $this->f_songs = "<div align=\"center\">" . $this->songs . "</div>"; + if ($this->artist_count == '1') { $this->f_artist = "<a href=\"$web_path/artists.php?action=show&artist=" . $this->artist_id . "\">" . $artist . "</a>"; } else { - $this->f_artist = _("Various"); + $this->f_artist = _('Various'); } if ($this->year == '0') { diff --git a/lib/class/catalog.class.php b/lib/class/catalog.class.php index 311cf457..db60e18c 100644 --- a/lib/class/catalog.class.php +++ b/lib/class/catalog.class.php @@ -1252,10 +1252,11 @@ class Catalog { */ $this->clean_albums(); $this->clean_artists(); - $this->clean_stats(); $this->clean_playlists(); $this->clean_flagged(); $this->clean_genres(); + $this->clean_stats(); + $this->clean_ext_info(); /* Return dead files, so they can be listed */ if ($verbose) { @@ -1326,25 +1327,6 @@ class Catalog { */ function clean_genres() { - /* Mysql 3.23 doesn't support our cool query so we have to do it a different way */ - if (preg_match("/^3\./",mysql_get_server_info())) { - $sql = "SELECT genre.id FROM genre LEFT JOIN song ON song.genre = genre.id WHERE song.id IS NULL"; - $db_results = mysql_query($sql, dbh()); - - $results = array(); - - while ($r = mysql_fetch_row($db_results)) { - $results[] = $r; - } - - foreach ($results as $dead) { - - $sql = "DELETE FROM genre WHERE id='$dead[0]'"; - $db_results = mysql_query($sql,dbh()); - } - return true; - } - /* Do a complex delete to get albums where there are no songs */ $sql = "DELETE FROM genre USING genre LEFT JOIN song ON song.genre = genre.id WHERE song.id IS NULL"; $db_results = mysql_query($sql, dbh()); @@ -1359,25 +1341,6 @@ class Catalog { */ function clean_albums() { - /* Mysql 3.23 doesn't support our cool query so we have to do it a different way */ - if (preg_match("/^3\./",mysql_get_server_info())) { - $sql = "SELECT album.id FROM album LEFT JOIN song ON song.album = album.id WHERE song.id IS NULL"; - $db_results = mysql_query($sql, dbh()); - - $results = array(); - - while ($r = mysql_fetch_row($db_results)) { - $results[] = $r; - } - - foreach ($results as $dead) { - - $sql = "DELETE FROM album WHERE id='$dead[0]'"; - $db_results = mysql_query($sql,dbh()); - } - return true; - } - /* Do a complex delete to get albums where there are no songs */ $sql = "DELETE FROM album USING album LEFT JOIN song ON song.album = album.id WHERE song.id IS NULL"; $db_results = mysql_query($sql, dbh()); @@ -1390,24 +1353,6 @@ class Catalog { */ function clean_flagged() { - /* Mysql 3.23 doesn't support our cool query so we have to do it a different way */ - if (preg_match("/^3\./",mysql_get_server_info())) { - $sql = "SELECT flagged.id FROM flagged LEFT JOIN song ON song.id=flagged.song WHERE song.id IS NULL"; - $db_results = mysql_query($sql, dbh()); - - $results = array(); - - while ($r = mysql_fetch_row($db_results)) { - $results[] = $r; - } - - foreach ($results as $dead) { - $sql = "DELETE FROM flagged WHERE id='$dead[0]'"; - $db_results = mysql_query($sql, dbh()); - } - return true; - } - /* Do a complex delete to get flagged items where the songs are now gone */ $sql = "DELETE FROM flagged USING flagged LEFT JOIN song ON song.id = flagged.song WHERE song.id IS NULL"; $db_results = mysql_query($sql, dbh()); @@ -1422,26 +1367,6 @@ class Catalog { */ function clean_artists() { - /* Mysql 3.23 doesn't support our cool query so we have to do it a different way */ - if (preg_match("/^3\./",mysql_get_server_info())) { - $sql = "SELECT artist.id FROM artist LEFT JOIN song ON song.artist = artist.id WHERE song.id IS NULL"; - $db_results = mysql_query($sql, dbh()); - - $results = array(); - - while ($r = mysql_fetch_row($db_results)) { - $results[] = $r; - } - - foreach ($results as $dead) { - - $sql = "DELETE FROM artist WHERE id='$dead[0]'"; - $db_results = mysql_query($sql,dbh()); - } - return true; - } - - /* Do a complex delete to get artists where there are no songs */ $sql = "DELETE FROM artist USING artist LEFT JOIN song ON song.artist = artist.id WHERE song.id IS NULL"; $db_results = mysql_query($sql, dbh()); @@ -1455,30 +1380,28 @@ class Catalog { */ function clean_playlists() { - /* Mysql 3.23 doesn't support our cool query so we have to do it a different way */ - if (preg_match("/^3\./",mysql_get_server_infO())) { - $sql = "SELECT playlist_data.song FROM playlist_data LEFT JOIN song ON song.id = playlist_data.song WHERE song.file IS NULL"; - $db_results = mysql_query($sql, dbh()); - - $results = array(); - - while ($r = mysql_fetch_row($db_results)) { - $results[] = $r; - } - - foreach ($results as $dead) { - $sql = "DELETE FROM playlist_data WHERE song='$dead[0]'"; - $db_results = mysql_query($sql, dbh()); - } - return true; - } - /* Do a complex delete to get playlist songs where there are no songs */ $sql = "DELETE FROM playlist_data USING playlist_data LEFT JOIN song ON song.id = playlist_data.song WHERE song.file IS NULL"; $db_results = mysql_query($sql, dbh()); + // Clear TMP Playlist information as well + $sql = "DELETE FROM tmp_playlist_data USING tmp_playlist_data LEFT JOIN song ON tmp_playlist_data.object_id = song.id WHERE song.id IS NULL"; + $db_results = mysql_query($sql,dbh()); + } // clean_playlists + /** + * clean_ext_info + * This function clears any ext_info that no longer has a parent + */ + function clean_ext_info() { + + // No longer accounting for MySQL 3.23 here, so just run the query + $sql = "DELETE FROM song_ext_data USING song_ext_data LEFT JOIN song ON song.id = song_ext_data.song_id WHERE song.id IS NULL"; + $db_results = mysql_query($sql, dbh()); + + } // clean_ext_info + /*! @function clean_stats @discussion This functions removes stats for songs/albums that no longer exist @@ -1488,83 +1411,28 @@ class Catalog { $version = mysql_get_server_info(); - /* Mysql 3.23 doesn't support our cool query so we have to do it a different way */ - if (preg_match("/^3\./",$version)) { - $sql = "SELECT object_count.id FROM object_count LEFT JOIN song ON song.id = object_count.object_id WHERE object_type='song' AND song.id IS NULL"; - $db_results = mysql_query($sql, dbh()); - - $results = array(); - - while ($r = mysql_fetch_row($db_results)) { - $results[] = $r; - } - - foreach ($results as $dead) { - - $sql = "DELETE FROM object_count WHERE id='$dead[0]'"; - $db_results = mysql_query($sql,dbh()); - } - - } - // We assume this will be 4.0+ - else { - /* Crazy SQL Mojo to remove stats where there are no songs */ - $sql = "DELETE FROM object_count USING object_count LEFT JOIN song ON song.id=object_count.object_id WHERE object_type='song' AND song.id IS NULL"; - $db_results = mysql_query($sql, dbh()); - } - - /* Mysql 3.23 doesn't support our cool query so we have to do it a different way */ - if (preg_match("/^3\./",$version)) { - $sql = "SELECT object_count.id FROM object_count LEFT JOIN album ON album.id = object_count.object_id WHERE object_type='album' AND album.id IS NULL"; - $db_results = mysql_query($sql, dbh()); - - $results = array(); - - while ($r = mysql_fetch_row($db_results)) { - $results[] = $r; - } - - foreach ($results as $dead) { - - $sql = "DELETE FROM object_count WHERE id='$dead[0]'"; - $db_results = mysql_query($sql,dbh()); - } - } - // We assume 4.0+ Here - else { - /* Crazy SQL Mojo to remove stats where there are no albums */ - $sql = "DELETE FROM object_count USING object_count LEFT JOIN album ON album.id=object_count.object_id WHERE object_type='album' AND album.id IS NULL"; - $db_results = mysql_query($sql, dbh()); - } + // Crazy SQL Mojo to remove stats where there are no songs + $sql = "DELETE FROM object_count USING object_count LEFT JOIN song ON song.id=object_count.object_id WHERE object_type='song' AND song.id IS NULL"; + $db_results = mysql_query($sql, dbh()); - /* Mysql 3.23 doesn't support our cool query so we have to do it a different way */ - if (preg_match("/^3\./",$version)) { - $sql = "SELECT object_count.id FROM object_count LEFT JOIN artist ON artist.id = object_count.object_id WHERE object_type='artist' AND artist.id IS NULL"; - $db_results = mysql_query($sql, dbh()); - - $results = array(); - - while ($r = mysql_fetch_row($db_results)) { - $results[] = $r; - } - - foreach ($results as $dead) { + // Crazy SQL Mojo to remove stats where there are no albums + $sql = "DELETE FROM object_count USING object_count LEFT JOIN album ON album.id=object_count.object_id WHERE object_type='album' AND album.id IS NULL"; + $db_results = mysql_query($sql, dbh()); + + // Crazy SQL Mojo to remove stats where ther are no artists + $sql = "DELETE FROM object_count USING object_count LEFT JOIN artist ON artist.id=object_count.object_id WHERE object_type='artist' AND artist.id IS NULL"; + $db_results = mysql_query($sql, dbh()); - $sql = "DELETE FROM object_count WHERE id='$dead[0]'"; - $db_results = mysql_query($sql,dbh()); - } - } - // We assume 4.0+ here - else { - /* Crazy SQL Mojo to remove stats where ther are no artists */ - $sql = "DELETE FROM object_count USING object_count LEFT JOIN artist ON artist.id=object_count.object_id WHERE object_type='artist' AND artist.id IS NULL"; - $db_results = mysql_query($sql, dbh()); - } + // Delete genre stat information + $sql = "DELETE FROM object_count USING object_count LEFT JOIN genre ON genre.id=object_count.object_id WHERE object_type='genre' AND genre.id IS NULL"; + $db_results = mysql_query($sql,dbh()); + // Delete the live_stream stat information + $sql = "DELETE FROM object_count USING object_count LEFT JOIN live_stream ON live_stream.id=object_count.object_id WHERE object_type='live_stream' AND live_stream.id IS NULL"; + $db_results = mysql_query($sql,dbh()); } // clean_stats - /*! @function verify_catalog @discussion This function compares the DB's information with the ID3 tags diff --git a/lib/ui.lib.php b/lib/ui.lib.php index af9bca40..bc87289f 100644 --- a/lib/ui.lib.php +++ b/lib/ui.lib.php @@ -619,6 +619,9 @@ function img_resize($image,$size,$type){ } $src = imagecreatefromstring($image); + + if (!$src) { return false; } + $width = imagesx($src); $height = imagesy($src); @@ -626,7 +629,10 @@ function img_resize($image,$size,$type){ $new_h = $size['height']; $img = imagecreatetruecolor($new_w,$new_h); - imagecopyresampled($img,$src,0,0,0,0,$new_w,$new_h,$width,$height); + + if (!imagecopyresampled($img,$src,0,0,0,0,$new_w,$new_h,$width,$height)) { + return false; + } // determine image type and send it to the client switch ($type) { |