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
|
|
@ -104,7 +104,14 @@
|
||||||
var dfd = jQuery.Deferred();
|
var dfd = jQuery.Deferred();
|
||||||
|
|
||||||
$.each(item.files, function(index, file) {
|
$.each(item.files, function(index, file) {
|
||||||
if(data.settings.maxFileSize > 0 && data.settings.maxFileSize < file.size) {
|
var extension = file.name.split('.').pop().toLowerCase();
|
||||||
|
var preConversionTypes = data.settings.preConversionTypes || [];
|
||||||
|
var limit = data.settings.maxFileSize;
|
||||||
|
if (preConversionTypes.length > 0 && preConversionTypes.indexOf(extension) > -1) {
|
||||||
|
limit = data.settings.preConversionSize || limit;
|
||||||
|
}
|
||||||
|
console.log('file size: ' + file.size + ', limit: ' + limit);
|
||||||
|
if (limit > 0 && limit < file.size) {
|
||||||
dfd.reject();
|
dfd.reject();
|
||||||
alert(window.xe.lang.msg_exceeds_limit_size);
|
alert(window.xe.lang.msg_exceeds_limit_size);
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -235,13 +235,17 @@ class EditorModel extends Editor
|
||||||
{
|
{
|
||||||
// Get file upload limits
|
// Get file upload limits
|
||||||
$file_config = FileModel::getUploadConfig();
|
$file_config = FileModel::getUploadConfig();
|
||||||
$file_config->allowed_attach_size = $file_config->allowed_attach_size*1024*1024;
|
$file_config->allowed_attach_size = $file_config->allowed_attach_size * 1048576;
|
||||||
$file_config->allowed_filesize = $file_config->allowed_filesize*1024*1024;
|
$file_config->allowed_filesize = $file_config->allowed_filesize * 1048576;
|
||||||
if (isset($option->allowed_filesize) && $option->allowed_filesize > 0)
|
if (isset($option->allowed_filesize) && $option->allowed_filesize > 0)
|
||||||
{
|
{
|
||||||
$file_config->allowed_attach_size = $option->allowed_filesize;
|
$file_config->allowed_attach_size = $option->allowed_filesize;
|
||||||
$file_config->allowed_filesize = $option->allowed_filesize;
|
$file_config->allowed_filesize = $option->allowed_filesize;
|
||||||
}
|
}
|
||||||
|
if (isset($file_config->pre_conversion_filesize))
|
||||||
|
{
|
||||||
|
$file_config->pre_conversion_filesize = $file_config->pre_conversion_filesize * 1048576;
|
||||||
|
}
|
||||||
|
|
||||||
// Calculate the appropriate chunk size.
|
// Calculate the appropriate chunk size.
|
||||||
$file_config->allowed_chunk_size = min(FileHandler::returnBytes(ini_get('upload_max_filesize')), FileHandler::returnBytes(ini_get('post_max_size')) * 0.95, 64 * 1024 * 1024);
|
$file_config->allowed_chunk_size = min(FileHandler::returnBytes(ini_get('upload_max_filesize')), FileHandler::returnBytes(ini_get('post_max_size')) * 0.95, 64 * 1024 * 1024);
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,8 @@
|
||||||
data-editor-status="{json_encode(FileModel::getInstance()->getFileList($editor_sequence), JSON_UNESCAPED_UNICODE)}"
|
data-editor-status="{json_encode(FileModel::getInstance()->getFileList($editor_sequence), JSON_UNESCAPED_UNICODE)}"
|
||||||
data-max-file-size="{$this->user->isAdmin() ? 0 : $file_config->allowed_filesize}"
|
data-max-file-size="{$this->user->isAdmin() ? 0 : $file_config->allowed_filesize}"
|
||||||
data-max-chunk-size="{$file_config->allowed_chunk_size ?: 0}"
|
data-max-chunk-size="{$file_config->allowed_chunk_size ?: 0}"
|
||||||
|
data-pre-conversion-size="{intval($file_config->pre_conversion_filesize ?? 0)}"
|
||||||
|
data-pre-conversion-types="{implode(',', $file_config->pre_conversion_types ?? [])}"
|
||||||
data-autoinsert-types="{json_encode($editor_autoinsert_types)}"
|
data-autoinsert-types="{json_encode($editor_autoinsert_types)}"
|
||||||
data-autoinsert-position="{$editor_autoinsert_position ?: 'paragraph'}">
|
data-autoinsert-position="{$editor_autoinsert_position ?: 'paragraph'}">
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,8 @@ $(function() {
|
||||||
container.data('instance', container.xeUploader({
|
container.data('instance', container.xeUploader({
|
||||||
maxFileSize: parseInt(data.maxFileSize, 10),
|
maxFileSize: parseInt(data.maxFileSize, 10),
|
||||||
maxChunkSize: parseInt(data.maxChunkSize, 10),
|
maxChunkSize: parseInt(data.maxChunkSize, 10),
|
||||||
|
preConversionSize: parseInt(data.preConversionSize || 0, 10),
|
||||||
|
preConversionTypes: data.preConversionTypes ? data.preConversionTypes.split(',') : [],
|
||||||
autoinsertTypes: data.autoinsertTypes,
|
autoinsertTypes: data.autoinsertTypes,
|
||||||
autoinsertPosition: data.autoinsertPosition,
|
autoinsertPosition: data.autoinsertPosition,
|
||||||
singleFileUploads: true
|
singleFileUploads: true
|
||||||
|
|
|
||||||
|
|
@ -67,9 +67,10 @@ class FileAdminController extends File
|
||||||
{
|
{
|
||||||
// Default settings
|
// Default settings
|
||||||
$config = getModel('module')->getModuleConfig('file') ?: new stdClass;
|
$config = getModel('module')->getModuleConfig('file') ?: new stdClass;
|
||||||
$config->allowed_filesize = Context::get('allowed_filesize');
|
$config->allowed_filesize = intval(Context::get('allowed_filesize'));
|
||||||
$config->allowed_attach_size = Context::get('allowed_attach_size');
|
$config->allowed_attach_size = intval(Context::get('allowed_attach_size'));
|
||||||
$config->allowed_filetypes = Context::get('allowed_filetypes');
|
$config->allowed_filetypes = Context::get('allowed_filetypes');
|
||||||
|
$config->pre_conversion_filesize = intval(Context::get('pre_conversion_filesize')) ?: null;
|
||||||
|
|
||||||
// Image settings
|
// Image settings
|
||||||
$config->image_autoconv = [];
|
$config->image_autoconv = [];
|
||||||
|
|
@ -147,6 +148,28 @@ class FileAdminController extends File
|
||||||
$config->allowed_filetypes = '*.*';
|
$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
|
// Save and redirect
|
||||||
$output = getController('module')->insertModuleConfig('file', $config);
|
$output = getController('module')->insertModuleConfig('file', $config);
|
||||||
$returnUrl = Context::get('success_return_url') ?: getNotEncodedUrl('', 'module', 'admin', 'act', 'dispFileAdminUploadConfig');
|
$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'))
|
if(!Context::get('use_default_file_config'))
|
||||||
{
|
{
|
||||||
$config->use_default_file_config = 'N';
|
$config->use_default_file_config = 'N';
|
||||||
$config->allowed_filesize = Context::get('allowed_filesize');
|
$config->allowed_filesize = intval(Context::get('allowed_filesize'));
|
||||||
$config->allowed_attach_size = Context::get('allowed_attach_size');
|
$config->allowed_attach_size = intval(Context::get('allowed_attach_size'));
|
||||||
$config->allowed_filetypes = Context::get('allowed_filetypes');
|
$config->allowed_filetypes = Context::get('allowed_filetypes');
|
||||||
|
$config->pre_conversion_filesize = intval(Context::get('pre_conversion_filesize')) ?: null;
|
||||||
|
|
||||||
// Check maximum file size
|
// Check maximum file size
|
||||||
if (PHP_INT_SIZE < 8)
|
if (PHP_INT_SIZE < 8)
|
||||||
|
|
@ -274,6 +298,20 @@ class FileAdminController extends File
|
||||||
$download_grant = Context::get('download_grant');
|
$download_grant = Context::get('download_grant');
|
||||||
$config->download_grant = is_array($download_grant) ? array_values($download_grant) : array($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
|
// Update
|
||||||
$oModuleController = getController('module');
|
$oModuleController = getController('module');
|
||||||
foreach(explode(',', Context::get('target_module_srl')) as $module_srl)
|
foreach(explode(',', Context::get('target_module_srl')) as $module_srl)
|
||||||
|
|
|
||||||
|
|
@ -102,6 +102,15 @@ class FileController extends File
|
||||||
$module_config = FileModel::getFileConfig($module_srl);
|
$module_config = FileModel::getFileConfig($module_srl);
|
||||||
$allowed_attach_size = $module_config->allowed_attach_size * 1024 * 1024;
|
$allowed_attach_size = $module_config->allowed_attach_size * 1024 * 1024;
|
||||||
$allowed_filesize = $module_config->allowed_filesize * 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)
|
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_filesize_exceeded = 'The file is too large. The maximum allowed filesize is %s.';
|
||||||
$lang->allowed_attach_size = 'Maximum Attachments';
|
$lang->allowed_attach_size = 'Maximum Attachments';
|
||||||
$lang->allowed_filetypes = 'Allowed extentsions';
|
$lang->allowed_filetypes = 'Allowed extentsions';
|
||||||
|
$lang->pre_conversion_filesize = 'Pre-conversion Grace Size';
|
||||||
$lang->download_short_url = 'Use short URL';
|
$lang->download_short_url = 'Use short URL';
|
||||||
$lang->inline_download_format = 'Open in current window';
|
$lang->inline_download_format = 'Open in current window';
|
||||||
$lang->inline_download_image = 'Image';
|
$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_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_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_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->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_delete_checked_file = 'Delete Selected Item(s)';
|
||||||
$lang->cmd_move_to_document = 'Move to Document';
|
$lang->cmd_move_to_document = 'Move to Document';
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ $lang->allowed_filesize_exceeded = '파일이 너무 큽니다. 용량 제한은
|
||||||
$lang->allowed_attach_size = '문서 첨부 제한';
|
$lang->allowed_attach_size = '문서 첨부 제한';
|
||||||
$lang->allowed_filetypes = '허용 확장자';
|
$lang->allowed_filetypes = '허용 확장자';
|
||||||
$lang->allow_multimedia_direct_download = '멀티미디어 파일 직접 접근 허용';
|
$lang->allow_multimedia_direct_download = '멀티미디어 파일 직접 접근 허용';
|
||||||
|
$lang->pre_conversion_filesize = '변환 전 유예 용량';
|
||||||
$lang->download_short_url = '다운로드시 짧은주소 사용';
|
$lang->download_short_url = '다운로드시 짧은주소 사용';
|
||||||
$lang->inline_download_format = '다운로드시 현재 창 사용';
|
$lang->inline_download_format = '다운로드시 현재 창 사용';
|
||||||
$lang->inline_download_image = '이미지';
|
$lang->inline_download_image = '이미지';
|
||||||
|
|
@ -45,6 +46,7 @@ $lang->about_allowed_filesize_global = '관리자를 포함하여 사이트 전
|
||||||
$lang->about_allowed_attach_size_global = '관리자를 포함하여 사이트 전체에 적용되는 문서당 총 첨부 용량 제한입니다.';
|
$lang->about_allowed_attach_size_global = '관리자를 포함하여 사이트 전체에 적용되는 문서당 총 첨부 용량 제한입니다.';
|
||||||
$lang->about_allowed_size_limits = 'IE9 이하, 구버전 안드로이드 등에서는 php.ini에서 지정한 %sB로 제한됩니다.';
|
$lang->about_allowed_size_limits = 'IE9 이하, 구버전 안드로이드 등에서는 php.ini에서 지정한 %sB로 제한됩니다.';
|
||||||
$lang->about_allowed_filetypes = '업로드를 허용할 확장자 목록입니다. 구 버전의 *.* 문법은 사용하지 않습니다.<br />여러 개 입력시 쉼표(,)을 이용해서 구분해 주세요. 예) doc, zip, pdf';
|
$lang->about_allowed_filetypes = '업로드를 허용할 확장자 목록입니다. 구 버전의 *.* 문법은 사용하지 않습니다.<br />여러 개 입력시 쉼표(,)을 이용해서 구분해 주세요. 예) doc, zip, pdf';
|
||||||
|
$lang->about_pre_conversion_filesize = '변환 대상인 이미지 또는 동영상은 설정한 용량만큼 우선 업로드를 허용하고, 변환 후 용량을 기준으로 다시 확인합니다.<br>설정을 비워 둘 경우, 변환 전후 용량을 동일하게 제한합니다.';
|
||||||
$lang->about_save_changelog = '파일 저장 및 삭제 내역을 DB에 기록합니다.';
|
$lang->about_save_changelog = '파일 저장 및 삭제 내역을 DB에 기록합니다.';
|
||||||
$lang->cmd_delete_checked_file = '선택항목 삭제';
|
$lang->cmd_delete_checked_file = '선택항목 삭제';
|
||||||
$lang->cmd_move_to_document = '문서로 이동';
|
$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>
|
<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>
|
</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">
|
<div class="x_control-group">
|
||||||
<label for="allowed_filetypes" class="x_control-label">{$lang->allowed_filetypes}</label>
|
<label for="allowed_filetypes" class="x_control-label">{$lang->allowed_filetypes}</label>
|
||||||
<div class="x_controls">
|
<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>
|
<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>
|
</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">
|
<div class="x_control-group">
|
||||||
<label for="allowedFiletypes" class="x_control-label">{$lang->allowed_filetypes}</label>
|
<label for="allowedFiletypes" class="x_control-label">{$lang->allowed_filetypes}</label>
|
||||||
<div class="x_controls">
|
<div class="x_controls">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue