diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index ccf699417b..63688ed157 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -18,6 +18,8 @@ There will probably not be another big change to Ampache 5 as work has moved to * Missing translation on preferences sidebar * Default catalog_filter group could be missing on a new install * Gather genre tags when not an array +* Display webp images +* Check for a valid image extensions when uploading art ## API 5.5.6 diff --git a/public/templates/show_artist_info.inc.php b/public/templates/show_artist_info.inc.php index 86d9762afa..895912aae5 100644 --- a/public/templates/show_artist_info.inc.php +++ b/public/templates/show_artist_info.inc.php @@ -48,8 +48,8 @@
- - + +
diff --git a/resources/sql/ampache.sql b/resources/sql/ampache.sql index ffabbb6da4..7be87b65eb 100644 --- a/resources/sql/ampache.sql +++ b/resources/sql/ampache.sql @@ -18,7 +18,7 @@ -- https://www.phpmyadmin.net/ -- -- Host: 192.168.1.20 --- Generation Time: Nov 19, 2022 at 05:49 PM +-- Generation Time: Dec 08, 2022 at 08:40 AM -- Server version: 10.5.15-MariaDB-0+deb11u1 -- PHP Version: 8.1.11 @@ -34,7 +34,7 @@ SET time_zone = "+00:00"; /*!40101 SET NAMES utf8mb4 */; -- --- Database: `ampache554` +-- Database: `ampache556` -- -- -------------------------------------------------------- diff --git a/src/Module/Art/Collector/FolderCollectorModule.php b/src/Module/Art/Collector/FolderCollectorModule.php index eb59bd50fc..da1183ec10 100644 --- a/src/Module/Art/Collector/FolderCollectorModule.php +++ b/src/Module/Art/Collector/FolderCollectorModule.php @@ -85,16 +85,6 @@ public function collect( $artist_filename = $this->configContainer->get('artist_art_preferred_filename'); $artist_art_folder = $this->configContainer->get('artist_art_folder'); - // Array of valid extensions - $image_extensions = [ - 'bmp', - 'gif', - 'jp2', - 'jpeg', - 'jpg', - 'png' - ]; - $dirs = array(); if ($art->type == 'album') { $media = new Album($art->uid); @@ -154,7 +144,7 @@ public function collect( $extension = $extension['extension'] ?? ''; // Make sure it looks like an image file - if (!in_array($extension, $image_extensions)) { + if (!in_array($extension, Art::VALID_TYPES)) { continue; } diff --git a/src/Module/Playback/Localplay/Mpd/AmpacheMpd.php b/src/Module/Playback/Localplay/Mpd/AmpacheMpd.php index ea857a795e..c43486e5a5 100644 --- a/src/Module/Playback/Localplay/Mpd/AmpacheMpd.php +++ b/src/Module/Playback/Localplay/Mpd/AmpacheMpd.php @@ -374,7 +374,6 @@ public function pause() return $this->_mpd->Pause(); } // pause - /** * volume * This tells MPD to set the volume to the parameter diff --git a/src/Module/Playback/Localplay/Upnp/UPnPDevice.php b/src/Module/Playback/Localplay/Upnp/UPnPDevice.php index 1be51dc687..71f558ba0f 100644 --- a/src/Module/Playback/Localplay/Upnp/UPnPDevice.php +++ b/src/Module/Playback/Localplay/Upnp/UPnPDevice.php @@ -35,7 +35,6 @@ class UPnPDevice "eventURLs" => array() ); - /** * UPnPDevice constructor. * @param $descriptionUrl diff --git a/src/Module/Playback/Localplay/Vlc/VlcPlayer.php b/src/Module/Playback/Localplay/Vlc/VlcPlayer.php index 2b3a81580b..59947940eb 100644 --- a/src/Module/Playback/Localplay/Vlc/VlcPlayer.php +++ b/src/Module/Playback/Localplay/Vlc/VlcPlayer.php @@ -292,7 +292,6 @@ public function fullstate() return $results; } // fullstate - /** * volume_up * This increases the volume of VLC, set to +20 can be changed to your preference diff --git a/src/Module/Playback/Stream_Playlist.php b/src/Module/Playback/Stream_Playlist.php index d856a28d4d..342badf49a 100644 --- a/src/Module/Playback/Stream_Playlist.php +++ b/src/Module/Playback/Stream_Playlist.php @@ -760,7 +760,6 @@ private function create_download() return false; } // create_download - /** * create_ram *this functions creates a RAM file for use by Real Player diff --git a/src/Module/System/Update.php b/src/Module/System/Update.php index 79fc4fc414..7c14cef903 100644 --- a/src/Module/System/Update.php +++ b/src/Module/System/Update.php @@ -2368,8 +2368,6 @@ public static function update_370027(): bool return $retval; } - - /** * update_370028 * diff --git a/src/Repository/Model/Art.php b/src/Repository/Model/Art.php index e5ffffee74..8565792972 100644 --- a/src/Repository/Model/Art.php +++ b/src/Repository/Model/Art.php @@ -49,6 +49,7 @@ class Art extends database_object { protected const DB_TABLENAME = 'art'; + public const VALID_TYPES = array('bmp', 'gif', 'jp2', 'jpeg', 'jpg', 'png', 'webp'); /** * @var integer $id @@ -403,8 +404,12 @@ public function insert($source, $mime = '') /* is the file flac or mp3? */ $apic_typeid = ($fileformat == 'flac' || $fileformat == 'ogg') ? 'typeid' : 'picturetypeid'; $apic_mimetype = ($fileformat == 'flac' || $fileformat == 'ogg') ? 'image_mime' : 'mime'; - $new_pic = array('data' => $source, 'mime' => $mime, - 'picturetypeid' => $current_picturetypeid, 'description' => $description); + $new_pic = array( + 'data' => $source, + 'mime' => $mime, + 'picturetypeid' => $current_picturetypeid, + 'description' => $description + ); if (is_null($apics)) { $ndata['attached_picture'][] = $new_pic; @@ -414,8 +419,12 @@ public function insert($source, $mime = '') $idx = $this->check_for_duplicate($apics, $ndata, $new_pic, $apic_typeid); if (is_null($idx)) { $ndata['attached_picture'][] = $new_pic; - $ndata['attached_picture'][] = array('data' => $apics[0]['data'], 'description' => $apics[0]['description'], - 'mime' => $apics[0]['mime'], 'picturetypeid' => $apics[0]['picturetypeid']); + $ndata['attached_picture'][] = array( + 'data' => $apics[0]['data'], + 'description' => $apics[0]['description'], + 'mime' => $apics[0]['mime'], + 'picturetypeid' => $apics[0]['picturetypeid'] + ); } break; case 2: @@ -428,8 +437,12 @@ public function insert($source, $mime = '') $ndata['attached_picture'][0] = $new_pic; } else { $apicsId = ($idx == 0) ? 1 : 0; - $ndata['attached_picture'][$apicsId] = array('data' => $apics[$apicsId]['data'], 'mime' => $apics[$apicsId][$apic_mimetype], - 'picturetypeid' => $apics[$apicsId][$apic_typeid], 'description' => $apics[$apicsId]['description']); + $ndata['attached_picture'][$apicsId] = array( + 'data' => $apics[$apicsId]['data'], + 'mime' => $apics[$apicsId][$apic_mimetype], + 'picturetypeid' => $apics[$apicsId][$apic_typeid], + 'description' => $apics[$apicsId]['description'] + ); } break; @@ -511,10 +524,10 @@ public static function check_dimensions($dimensions) $height = (int)($dimensions['height']); if ($width > 0 && $height > 0) { - $minw = (AmpConfig::get('album_art_min_width')) ? AmpConfig::get('album_art_min_width') : 0; - $maxw = (AmpConfig::get('album_art_max_width')) ? AmpConfig::get('album_art_max_width') : 0; - $minh = (AmpConfig::get('album_art_min_height')) ? AmpConfig::get('album_art_min_height') : 0; - $maxh = (AmpConfig::get('album_art_max_height')) ? AmpConfig::get('album_art_max_height') : 0; + $minw = AmpConfig::get('album_art_min_width', 0); + $maxw = AmpConfig::get('album_art_max_width', 0); + $minh = AmpConfig::get('album_art_min_height', 0); + $maxh = AmpConfig::get('album_art_max_height', 0); // minimum width is set and current width is too low if ($minw > 0 && $width < $minw) { @@ -627,9 +640,8 @@ private static function write_to_dir($source, $sizetext, $type, $uid, $kind, $mi /** * read_from_images - * @param string $name */ - private static function read_from_images($name = 'blankalbum.png') + private static function read_from_images() { $path = __DIR__ . '/../../../public/images/blankalbum.png'; if (!Core::is_readable($path)) { @@ -926,6 +938,10 @@ public function generate_thumb($image, $size, $mime) imagepng($thumbnail); $mime_type = image_type_to_mime_type(IMAGETYPE_PNG); break; + case 'webp': + imagewebp($thumbnail); + $mime_type = image_type_to_mime_type(IMAGETYPE_WEBP); + break; default: $mime_type = null; } // resized @@ -1498,7 +1514,7 @@ public static function display( $class_name = ObjectTypeToClassNameMapper::map($object_type); $libitem = new $class_name($object_id); echo "
"; - if (Core::get_global('user')->has_access(50) || (Core::get_global('user')->has_access(25) && Core::get_global('user')->id == $libitem->get_user_owner())) { + if ((!empty(Core::get_global('user')) && Core::get_global('user')->has_access(50)) || (Core::get_global('user')->has_access(25) && Core::get_global('user')->id == $libitem->get_user_owner())) { echo ""; diff --git a/src/Repository/Model/Catalog.php b/src/Repository/Model/Catalog.php index 668cfd76f1..36fcc88b7a 100644 --- a/src/Repository/Model/Catalog.php +++ b/src/Repository/Model/Catalog.php @@ -3821,6 +3821,7 @@ public static function garbage_collect_mapping() $sql = "DELETE FROM `catalog_map` WHERE `catalog_id` = 0"; Dba::write($sql); } + /** * Delete catalog filters that might have gone missing */ diff --git a/src/Repository/Model/TVShow_Season.php b/src/Repository/Model/TVShow_Season.php index a8e0964508..f07c07a71e 100644 --- a/src/Repository/Model/TVShow_Season.php +++ b/src/Repository/Model/TVShow_Season.php @@ -115,7 +115,7 @@ private function _get_extra_info() if (parent::is_cached('tvshow_extra', $this->id)) { $row = parent::get_from_cache('tvshow_extra', $this->id); } else { - $sql = "SELECT COUNT(`tvshow_episode`.`id`) AS `episode_count`, `video`.`catalog` AS `catalog_id` FROM `tvshow_episode` LEFT JOIN `video` ON `video`.`id` = `tvshow_episode`.`id` WHERE `tvshow_episode`.`season` = ?GROUP BY `catalog_id`"; + $sql = "SELECT COUNT(`tvshow_episode`.`id`) AS `episode_count`, `video`.`catalog` AS `catalog_id` FROM `tvshow_episode` LEFT JOIN `video` ON `video`.`id` = `tvshow_episode`.`id` WHERE `tvshow_episode`.`season` = ? GROUP BY `catalog_id`"; $db_results = Dba::read($sql, array($this->id)); $row = Dba::fetch_assoc($db_results); diff --git a/src/Repository/Model/Tag.php b/src/Repository/Model/Tag.php index 57a9e6a581..a521e16b31 100644 --- a/src/Repository/Model/Tag.php +++ b/src/Repository/Model/Tag.php @@ -553,7 +553,7 @@ public static function get_top_tags($type, $object_id, $limit = 10) $object_id = (int)($object_id); $limit = (int)($limit); - $sql = "SELECT `tag_map`.`id`, `tag_map`.`tag_id`, `tag`.`name`, `tag_map`.`user` FROM `tag` LEFT JOIN `tag_map` ON `tag_map`.`tag_id`=`tag`.`id` WHERE `tag`.`is_hidden` = false AND `tag_map`.`object_type` = ? AND `tag_map`.`object_id` = ?LIMIT $limit"; + $sql = "SELECT `tag_map`.`id`, `tag_map`.`tag_id`, `tag`.`name`, `tag_map`.`user` FROM `tag` LEFT JOIN `tag_map` ON `tag_map`.`tag_id`=`tag`.`id` WHERE `tag`.`is_hidden` = false AND `tag_map`.`object_type` = ? AND `tag_map`.`object_id` = ? LIMIT $limit"; $db_results = Dba::read($sql, array($type, $object_id)); $results = array(); diff --git a/src/Repository/Model/User.php b/src/Repository/Model/User.php index 19c4cf0ca6..abecdaaa12 100644 --- a/src/Repository/Model/User.php +++ b/src/Repository/Model/User.php @@ -354,7 +354,6 @@ public static function get_user_catalogs($userid) return $catalogs; } // get_catalogs - /** * get_catalogs * This returns the catalogs as an array of ids that this user is allowed to access @@ -365,7 +364,6 @@ public function get_catalogs() return self::get_user_catalogs($this->id); } // get_catalogs - /** * get_preferences * This is a little more complicate now that we've got many types of preferences @@ -1440,8 +1438,11 @@ public function upload_avatar() $path_info = pathinfo($_FILES['avatar']['name']); $upload['file'] = $_FILES['avatar']['tmp_name']; $upload['mime'] = 'image/' . $path_info['extension']; - $image_data = Art::get_from_source($upload, 'user'); + if (!in_array(strtolower($path_info['extension']), Art::VALID_TYPES)) { + return false; + } + $image_data = Art::get_from_source($upload, 'user'); if ($image_data !== '') { return $this->update_avatar($image_data, $upload['mime']); }