From 239de71bd957204a10bc121cdd93fe5e9cf06136 Mon Sep 17 00:00:00 2001 From: Mirko Date: Mon, 25 Jun 2018 22:29:46 -0700 Subject: [PATCH] Add exif function detection. The server fails silently otherwise. --- php/Modules/Photo.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/php/Modules/Photo.php b/php/Modules/Photo.php index f1613e8..6b11f93 100755 --- a/php/Modules/Photo.php +++ b/php/Modules/Photo.php @@ -42,7 +42,6 @@ final class Photo { * @return string|false ID of the added photo. */ public function add(array $files, $albumID = 0, $returnOnError = false) { - // Check permissions if (hasPermissions(LYCHEE_UPLOADS)===false|| hasPermissions(LYCHEE_UPLOADS_BIG)===false|| @@ -85,6 +84,7 @@ final class Photo { } + // Only process the first photo in the array $file = $files[0]; @@ -131,8 +131,15 @@ final class Photo { Response::error('Photo format not supported!'); } - // Verify image - $type = @exif_imagetype($file['tmp_name']); + // Verify image + if (!function_exists("exif_imagetype")) { + Log::error(Database::get(), __METHOD__, __LINE__, 'EXIF library not loaded. Make sure exif is enabled in php.ini'); + if ($returnOnError===true) return false; + Response::error('EXIF library not loaded on the server!'); + } + + $type = @exif_imagetype($file['tmp_name']); + if (!in_array($type, self::$validTypes, true)) { Log::error(Database::get(), __METHOD__, __LINE__, 'Photo type not supported'); if ($returnOnError===true) return false;