From 696be3a0b3a883bc082952cbbf81b2fb66e12445 Mon Sep 17 00:00:00 2001 From: themohooks <81331307+themohooks@users.noreply.github.com> Date: Wed, 17 Jul 2024 03:58:19 +0300 Subject: [PATCH] add allowgif setting --- app/Controllers/Api/Images/Upload.php | 13 +++++++++++++ ngallery-example.yaml | 1 + views/pages/Photo.php | 4 ++-- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/app/Controllers/Api/Images/Upload.php b/app/Controllers/Api/Images/Upload.php index 08fd516..79dcb6d 100644 --- a/app/Controllers/Api/Images/Upload.php +++ b/app/Controllers/Api/Images/Upload.php @@ -40,6 +40,19 @@ class Upload { if ($_FILES['image']['error'] != 4) { + $finfo = finfo_open(FILEINFO_MIME_TYPE); + $type = finfo_file($finfo, $_FILES['image']['tmp_name']); + if ($type === 'image/gif') { + if (NGALLERY['root']['photo']['upload']['allowgif'] === false) { + echo json_encode( + array( + 'errorcode' => 'FILE_NOTSUPPORTED', + 'error' => 1 + ) + ); + die(); + } + } $exif = new EXIF($_FILES['image']['tmp_name']); $exif = $exif->getData(); $upload = new UploadPhoto($_FILES['image'], 'cdn/img/'); diff --git a/ngallery-example.yaml b/ngallery-example.yaml index e1bb7c5..3f0a2c8 100644 --- a/ngallery-example.yaml +++ b/ngallery-example.yaml @@ -43,6 +43,7 @@ ngallery: allow: true premoderation: true defaultindex: 5.0 + allowgif: true comments: premoderation: false diff --git a/views/pages/Photo.php b/views/pages/Photo.php index 5326d81..1b38ef8 100644 --- a/views/pages/Photo.php +++ b/views/pages/Photo.php @@ -77,9 +77,9 @@ if ($photo->i('id') !== null) { i('moderated') === 0 && $moderated === true) { echo '