Merge pull request #1182 from YJSoft/develop

php.ini의 파일 업로드 용량을 잘못 불러오는 문제 수정
This commit is contained in:
bnu 2015-01-30 17:12:34 +09:00
commit 3cf0f0466f
5 changed files with 27 additions and 19 deletions

View file

@ -178,23 +178,6 @@ class fileAdminController extends file
else $_SESSION['file_management'][$output->file_srl] = true;
}
}
/**
* Change value from human readable to byte unit
*
* @param string $size_str Size string
* @return int The byte value for input
*/
function _changeBytes($size_str)
{
switch (substr ($size_str, -1))
{
case 'M': case 'm': return (int)$size_str * 1048576;
case 'K': case 'k': return (int)$size_str * 1024;
case 'G': case 'g': return (int)$size_str * 1073741824;
default: return $size_str;
}
}
}
/* End of file file.admin.controller.php */
/* Location: ./modules/file/file.admin.controller.php */

View file

@ -217,6 +217,10 @@ class fileAdminView extends file
$oFileModel = getModel('file');
$config = $oFileModel->getFileConfig();
Context::set('config',$config);
$iniPostMaxSize = $this->_changeBytes(ini_get('post_max_size'));
$iniUploadMaxSize = $this->_changeBytes(ini_get('upload_max_filesize'));
$iniMinSize = min($iniPostMaxSize, $iniUploadMaxSize);
Context::set('upload_max_filesize',$this->_changeBytes($iniMinSize / 1048576));
// Set a template file
$this->setTemplatePath($this->module_path.'tpl');
$this->setTemplateFile('adminConfig');

View file

@ -150,6 +150,25 @@ class file extends ModuleObject
function recompileCache()
{
}
/**
* Change value from human readable to byte unit
*
* @param string $size_str Size string
* @return int The byte value for input
*/
function _changeBytes($size_str)
{
$unit = strtoupper(substr($size_str, -1));
$size_str = (int)$size_str;
switch ($unit)
{
case 'G': $size_str *= 1024;
case 'M': $size_str *= 1024;
case 'K': $size_str *= 1024;
}
return $size_str;
}
}
/* End of file file.class.php */
/* Location: ./modules/file/file.class.php */

View file

@ -238,7 +238,9 @@ class fileModel extends file
if($logged_info->is_admin == 'Y')
{
$size = preg_replace('/[a-z]/is', '', ini_get('upload_max_filesize'));
$iniPostMaxSize = $this->_changeBytes(ini_get('post_max_size'));
$iniUploadMaxSize = $this->_changeBytes(ini_get('upload_max_filesize'));
$size = min($iniPostMaxSize, $iniUploadMaxSize) / 1048576;
$file_config->allowed_attach_size = $size;
$file_config->allowed_filesize = $size;
$file_config->allowed_filetypes = '*.*';

View file

@ -34,7 +34,7 @@
<div class="x_control-group">
<label for="filesize" class="x_control-label">{$lang->allowed_filesize} <a class="x_icon-question-sign" href="./admin/help/index.html#UMAN_config_file_size" target="_blank">{$lang->help}</a></label>
<div class="x_controls">
<input type="number" id="filesize" name="allowed_filesize" value="{$config->allowed_filesize}" /> MB/{ini_get('upload_max_filesize')}
<input type="number" id="filesize" name="allowed_filesize" value="{$config->allowed_filesize}" /> MB/{$upload_max_filesize}MB
</div>
</div>
<div class="x_control-group">