From f3761fd93486693b406a0a857c6db72c49902b62 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Thu, 1 Aug 2019 14:35:25 +0900 Subject: [PATCH] Make image auto-conversion apply to the administrator, too --- modules/file/file.controller.php | 24 +++++++++++++++--------- modules/file/lang/en.php | 4 ++-- modules/file/lang/ko.php | 6 +++--- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/modules/file/file.controller.php b/modules/file/file.controller.php index 1848a6f1c..80ff3a83d 100644 --- a/modules/file/file.controller.php +++ b/modules/file/file.controller.php @@ -872,12 +872,13 @@ class fileController extends file $file_info['extension'] = $extension; $file_info['resized'] = false; - // Check file type, size, and other attributes + // Get file module configuration + $oFileModel = getModel('file'); + $config = $oFileModel->getFileConfig($module_srl); + + // Check file type if(!$manual_insert && !$this->user->isAdmin()) { - // Get file module configuration - $oFileModel = getModel('file'); - $config = $oFileModel->getFileConfig($module_srl); // Check file type if(isset($config->allowed_filetypes) && $config->allowed_filetypes !== '*.*') @@ -894,14 +895,20 @@ class fileController extends file throw new Rhymix\Framework\Exception('msg_not_allowed_filetype'); } } - - // Check image type and size + } + + // Check image type and size + if(!$manual_insert) + { if(in_array($extension, array('gif', 'jpg', 'jpeg', 'png', 'webp', 'bmp'))) { $file_info = $this->checkUploadedImage($file_info, $config); } + } - // Check file size + // Check file size + if(!$manual_insert && !$this->user->isAdmin()) + { $file_size = filesize($file_info['tmp_name']); $allowed_filesize = $config->allowed_filesize * 1024 * 1024; $allowed_attach_size = $config->allowed_attach_size * 1024 * 1024; @@ -910,7 +917,6 @@ class fileController extends file throw new Rhymix\Framework\Exception('msg_exceeds_limit_size'); } - // Get total size of all attachements $size_args = new stdClass; $size_args->upload_target_srl = $upload_target_srl; $output = executeQuery('file.getAttachedFileSize', $size_args); @@ -1053,7 +1059,7 @@ class fileController extends file } // Check image size - if($config->max_image_size_action && ($config->max_image_width || $config->max_image_height)) + if($config->max_image_size_action && ($config->max_image_width || $config->max_image_height) && !$this->user->isAdmin()) { $exceeded = false; if ($config->max_image_width > 0 && $image_width > $config->max_image_width) diff --git a/modules/file/lang/en.php b/modules/file/lang/en.php index 430ec89e3..0fdc23d03 100644 --- a/modules/file/lang/en.php +++ b/modules/file/lang/en.php @@ -42,8 +42,8 @@ $lang->about_allowed_filesize_global = 'This is the global limit on the size of $lang->about_allowed_attach_size_global = 'This is the global limit on the combined size of all attachments in one document.'; $lang->about_allowed_size_limits = 'The file size will be limited to the value set in php.ini (%sB) in IE9 and below and older Android browsers.'; $lang->about_allowed_filetypes = 'To allow an extension, use "*.[extention]". To allow multiple extensions, use ";" between each extension. ex) *.* or *.jpg;*.gif; '; -$lang->about_max_image_size = 'You can limit the maximum width and/or height of uploaded images.'; -$lang->about_image_autoconv = 'Automatically convert types of images that often cause trouble or waste disk space into other types.
This also works for WebP images that incorrectly have the JPG extension.'; +$lang->about_max_image_size = 'You can limit the maximum width and/or height of uploaded images.
This limit does not apply to files uploaded by the administrator.'; +$lang->about_image_autoconv = 'Automatically convert types of images that often cause trouble or waste disk space into other types.
This also works for WebP images that incorrectly have the JPG extension.
If enabled, this feature also applies to images uploaded by the administrator.'; $lang->cmd_delete_checked_file = 'Delete Selected Item(s)'; $lang->cmd_move_to_document = 'Move to Document'; $lang->cmd_download = 'Download'; diff --git a/modules/file/lang/ko.php b/modules/file/lang/ko.php index 060db37b9..d24c371e4 100644 --- a/modules/file/lang/ko.php +++ b/modules/file/lang/ko.php @@ -38,12 +38,12 @@ $lang->about_allow_outlink_format = '파일 외부 링크 설정에 상관없이 $lang->about_allow_outlink_site = '파일 외부 링크 설정에 상관없이 허용하는 사이트 주소입니다.
여러 개 입력시 줄을 바꿔서 구분해 주세요. 예) https://www.rhymix.org/'; $lang->about_allowed_filesize = '각 파일의 용량을 제한할 수 있습니다.
관리자에게는 이 게시판의 제한과 파일 모듈의 제한 중 높은 쪽이 적용됩니다.'; $lang->about_allowed_attach_size = '하나의 문서에 첨부할 수 있는 최대 용량을 제한할 수 있습니다.
관리자에게는 이 게시판의 제한과 파일 모듈의 제한 중 높은 쪽이 적용됩니다.'; -$lang->about_allowed_filesize_global = '관리자를 포함하여 사이트 전체에 적용되는 파일 크기 제한입니다.'; +$lang->about_allowed_filesize_global = '관리자를 포함하여 사이트 전체에 적용되는 파일 용량 제한입니다.'; $lang->about_allowed_attach_size_global = '관리자를 포함하여 사이트 전체에 적용되는 문서당 총 첨부 용량 제한입니다.'; $lang->about_allowed_size_limits = 'IE9 이하, 구버전 안드로이드 등에서는 php.ini에서 지정한 %sB로 제한됩니다.'; $lang->about_allowed_filetypes = '"*.확장자"로 지정할 수 있고 ";" 으로 여러 개 지정이 가능합니다. 예) *.* or *.jpg;*.gif;'; -$lang->about_max_image_size = '이미지 파일의 가로세로 크기를 제한할 수 있습니다.
가로세로 중 한 쪽만 제한하거나, 양쪽 모두 제한할 수도 있습니다.'; -$lang->about_image_autoconv = '종종 문제를 일으키거나 용량을 낭비하는 이미지 타입을 다른 타입으로 자동 변환합니다.
WebP 이미지에 JPG 확장자가 잘못 부여된 경우에도 변환할 수 있습니다.'; +$lang->about_max_image_size = '이미지 파일의 가로, 세로, 또는 가로세로 크기를 모두 제한할 수 있습니다.
관리자가 업로드한 파일에는 적용되지 않습니다.'; +$lang->about_image_autoconv = '종종 문제를 일으키거나 용량을 낭비하는 이미지 타입을 다른 타입으로 자동 변환합니다.
WebP 이미지에 JPG 확장자가 잘못 부여된 경우에도 변환할 수 있습니다.
관리자가 업로드한 파일에도 적용됩니다.'; $lang->cmd_delete_checked_file = '선택항목 삭제'; $lang->cmd_move_to_document = '문서로 이동'; $lang->cmd_download = '다운로드';