mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-04-02 01:52:10 +09:00
Allow larger images/videos to be uploaded if they are going to be converted
- 변환 대상인 이미지나 동영상 파일은 용량 제한을 더 느슨하게 설정할 수 있도록 함 - 변환 후에 다시 용량을 체크하여 각 게시판의 업로드 정책 적용 - https://rhymix.org/qna/1926104
This commit is contained in:
parent
44cf008ac7
commit
94008fbe9b
10 changed files with 87 additions and 7 deletions
|
|
@ -67,9 +67,10 @@ class FileAdminController extends File
|
|||
{
|
||||
// Default settings
|
||||
$config = getModel('module')->getModuleConfig('file') ?: new stdClass;
|
||||
$config->allowed_filesize = Context::get('allowed_filesize');
|
||||
$config->allowed_attach_size = Context::get('allowed_attach_size');
|
||||
$config->allowed_filesize = intval(Context::get('allowed_filesize'));
|
||||
$config->allowed_attach_size = intval(Context::get('allowed_attach_size'));
|
||||
$config->allowed_filetypes = Context::get('allowed_filetypes');
|
||||
$config->pre_conversion_filesize = intval(Context::get('pre_conversion_filesize')) ?: null;
|
||||
|
||||
// Image settings
|
||||
$config->image_autoconv = [];
|
||||
|
|
@ -147,6 +148,28 @@ class FileAdminController extends File
|
|||
$config->allowed_filetypes = '*.*';
|
||||
}
|
||||
|
||||
// Generate pre-conversion whitelist
|
||||
$config->pre_conversion_types = [];
|
||||
foreach ($config->image_autoconv ?? [] as $source_type => $target_type)
|
||||
{
|
||||
if (!empty($target_type) && $target_type !== true)
|
||||
{
|
||||
$config->pre_conversion_types[] = $source_type;
|
||||
if ($source_type === 'jpg')
|
||||
{
|
||||
$config->pre_conversion_types[] = 'jpeg';
|
||||
}
|
||||
}
|
||||
elseif ($source_type === 'gif2mp4' && $target_type === true)
|
||||
{
|
||||
$config->pre_conversion_types[] = 'gif';
|
||||
}
|
||||
}
|
||||
if ($config->video_autoconv['any2mp4'])
|
||||
{
|
||||
$config->pre_conversion_types = array_merge($config->pre_conversion_types, ['mp4', 'webm', 'ogv', 'avi', 'mkv', 'mov', 'mpg', 'mpe', 'mpeg', 'wmv', 'm4v', 'flv']);
|
||||
}
|
||||
|
||||
// Save and redirect
|
||||
$output = getController('module')->insertModuleConfig('file', $config);
|
||||
$returnUrl = Context::get('success_return_url') ?: getNotEncodedUrl('', 'module', 'admin', 'act', 'dispFileAdminUploadConfig');
|
||||
|
|
@ -206,9 +229,10 @@ class FileAdminController extends File
|
|||
if(!Context::get('use_default_file_config'))
|
||||
{
|
||||
$config->use_default_file_config = 'N';
|
||||
$config->allowed_filesize = Context::get('allowed_filesize');
|
||||
$config->allowed_attach_size = Context::get('allowed_attach_size');
|
||||
$config->allowed_filesize = intval(Context::get('allowed_filesize'));
|
||||
$config->allowed_attach_size = intval(Context::get('allowed_attach_size'));
|
||||
$config->allowed_filetypes = Context::get('allowed_filetypes');
|
||||
$config->pre_conversion_filesize = intval(Context::get('pre_conversion_filesize')) ?: null;
|
||||
|
||||
// Check maximum file size
|
||||
if (PHP_INT_SIZE < 8)
|
||||
|
|
@ -274,6 +298,20 @@ class FileAdminController extends File
|
|||
$download_grant = Context::get('download_grant');
|
||||
$config->download_grant = is_array($download_grant) ? array_values($download_grant) : array($download_grant);
|
||||
|
||||
// Create pre-conversion whitelist
|
||||
$config->pre_conversion_types = [];
|
||||
foreach ($config->image_autoconv ?? [] as $source_type => $target_type)
|
||||
{
|
||||
if ($target_type && $target_type !== true)
|
||||
{
|
||||
$config->pre_conversion_types[] = $source_type;
|
||||
if ($source_type === 'jpg')
|
||||
{
|
||||
$config->pre_conversion_types[] = 'jpeg';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update
|
||||
$oModuleController = getController('module');
|
||||
foreach(explode(',', Context::get('target_module_srl')) as $module_srl)
|
||||
|
|
|
|||
|
|
@ -102,6 +102,15 @@ class FileController extends File
|
|||
$module_config = FileModel::getFileConfig($module_srl);
|
||||
$allowed_attach_size = $module_config->allowed_attach_size * 1024 * 1024;
|
||||
$allowed_filesize = $module_config->allowed_filesize * 1024 * 1024;
|
||||
if (!empty($module_config->pre_conversion_filesize) && !empty($module_config->pre_conversion_types))
|
||||
{
|
||||
$extension = strtolower(array_last(explode('.', $file_info['name'])));
|
||||
if ($extension && in_array($extension, $module_config->pre_conversion_types))
|
||||
{
|
||||
$allowed_attach_size = ($allowed_attach_size - $allowed_filesize) + ($module_config->pre_conversion_filesize * 1024 * 1024);
|
||||
$allowed_filesize = $module_config->pre_conversion_filesize * 1024 * 1024;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($total_size > $allowed_filesize)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ $lang->allowed_filesize = 'Maximum File Size';
|
|||
$lang->allowed_filesize_exceeded = 'The file is too large. The maximum allowed filesize is %s.';
|
||||
$lang->allowed_attach_size = 'Maximum Attachments';
|
||||
$lang->allowed_filetypes = 'Allowed extentsions';
|
||||
$lang->pre_conversion_filesize = 'Pre-conversion Grace Size';
|
||||
$lang->download_short_url = 'Use short URL';
|
||||
$lang->inline_download_format = 'Open in current window';
|
||||
$lang->inline_download_image = 'Image';
|
||||
|
|
@ -45,6 +46,7 @@ $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 = 'Rhymix no longer uses the old *.* syntax. Simply list the extensions you wish to allow.<br />Please use a comma (,) to separate items: e.g. doc, zip, pdf';
|
||||
$lang->about_pre_conversion_filesize = 'If an image or video might be converted as configured below, it will be allowed up to this size, and checked again after conversion.<br>If this configuration is empty, the file must be below the allowed size both before and after conversion.';
|
||||
$lang->about_save_changelog = 'Keep a log of new and deleted files in the database.';
|
||||
$lang->cmd_delete_checked_file = 'Delete Selected Item(s)';
|
||||
$lang->cmd_move_to_document = 'Move to Document';
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ $lang->allowed_filesize_exceeded = '파일이 너무 큽니다. 용량 제한은
|
|||
$lang->allowed_attach_size = '문서 첨부 제한';
|
||||
$lang->allowed_filetypes = '허용 확장자';
|
||||
$lang->allow_multimedia_direct_download = '멀티미디어 파일 직접 접근 허용';
|
||||
$lang->pre_conversion_filesize = '변환 전 유예 용량';
|
||||
$lang->download_short_url = '다운로드시 짧은주소 사용';
|
||||
$lang->inline_download_format = '다운로드시 현재 창 사용';
|
||||
$lang->inline_download_image = '이미지';
|
||||
|
|
@ -45,6 +46,7 @@ $lang->about_allowed_filesize_global = '관리자를 포함하여 사이트 전
|
|||
$lang->about_allowed_attach_size_global = '관리자를 포함하여 사이트 전체에 적용되는 문서당 총 첨부 용량 제한입니다.';
|
||||
$lang->about_allowed_size_limits = 'IE9 이하, 구버전 안드로이드 등에서는 php.ini에서 지정한 %sB로 제한됩니다.';
|
||||
$lang->about_allowed_filetypes = '업로드를 허용할 확장자 목록입니다. 구 버전의 *.* 문법은 사용하지 않습니다.<br />여러 개 입력시 쉼표(,)을 이용해서 구분해 주세요. 예) doc, zip, pdf';
|
||||
$lang->about_pre_conversion_filesize = '변환 대상인 이미지 또는 동영상은 설정한 용량만큼 우선 업로드를 허용하고, 변환 후 용량을 기준으로 다시 확인합니다.<br>설정을 비워 둘 경우, 변환 전후 용량을 동일하게 제한합니다.';
|
||||
$lang->about_save_changelog = '파일 저장 및 삭제 내역을 DB에 기록합니다.';
|
||||
$lang->cmd_delete_checked_file = '선택항목 삭제';
|
||||
$lang->cmd_move_to_document = '문서로 이동';
|
||||
|
|
|
|||
|
|
@ -34,6 +34,13 @@
|
|||
<p class="x_help-block">{sprintf($lang->about_allowed_attach_size, getUrl('', 'module', 'admin', 'act', 'dispFileAdminUploadConfig'))}<br />{sprintf($lang->about_allowed_size_limits, ini_get('upload_max_filesize'))}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="x_control-group">
|
||||
<label for="allowedFiletypes" class="x_control-label">{$lang->pre_conversion_filesize}</label>
|
||||
<div class="x_controls">
|
||||
<input type="number" min="0" name="pre_conversion_filesize" id="pre_conversion_filesize" value="{$config->pre_conversion_filesize ?? ''}" size="7" style="min-width:80px" /> MB
|
||||
<p class="x_help-block">{$lang->about_pre_conversion_filesize}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="x_control-group">
|
||||
<label for="allowed_filetypes" class="x_control-label">{$lang->allowed_filetypes}</label>
|
||||
<div class="x_controls">
|
||||
|
|
|
|||
|
|
@ -23,6 +23,13 @@
|
|||
<p class="x_help-block">{$lang->about_allowed_attach_size_global}<br />{sprintf($lang->about_allowed_size_limits, ini_get('upload_max_filesize'))}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="x_control-group">
|
||||
<label for="allowedFiletypes" class="x_control-label">{$lang->pre_conversion_filesize}</label>
|
||||
<div class="x_controls">
|
||||
<input type="number" min="0" name="pre_conversion_filesize" id="pre_conversion_filesize" value="{$config->pre_conversion_filesize ?? ''}" size="7" style="min-width:80px" /> MB
|
||||
<p class="x_help-block">{$lang->about_pre_conversion_filesize}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="x_control-group">
|
||||
<label for="allowedFiletypes" class="x_control-label">{$lang->allowed_filetypes}</label>
|
||||
<div class="x_controls">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue