- file::_changeBytes()를 FIleHandler::returnBytes()로 대체
This commit is contained in:
bnu 2015-01-30 17:36:14 +09:00
parent ae55711dc4
commit 14ffdbe5f0
6 changed files with 17 additions and 41 deletions

View file

@ -635,18 +635,13 @@ class FileHandler
*/
function returnBytes($val)
{
$last = strtolower(substr(trim($val), -1));
switch ($last)
$unit = strtoupper(substr($val, -1));
$val = (int)$val;
switch ($unit)
{
case 'g':
$val *= 1024 * 1024 * 1024;
break;
case 'm':
$val *= 1024 * 1024;
break;
case 'k':
$val *= 1024;
break;
case 'G': $val *= 1024;
case 'M': $val *= 1024;
case 'K': $val *= 1024;
}
return $val;

View file

@ -134,10 +134,10 @@ class fileAdminController extends file
else $file_config->download_grant = $download_grant;
//관리자가 허용한 첨부파일의 사이즈가 php.ini의 값보다 큰지 확인하기 - by ovclas
$userFileAllowSize = $this->_changeBytes($file_config->allowed_filesize.'M');
$userAttachAllowSize = $this->_changeBytes($file_config->allowed_attach_size.'M');
$iniPostMaxSize = $this->_changeBytes(ini_get('post_max_size'));
$iniUploadMaxSize = $this->_changeBytes(ini_get('upload_max_filesize'));
$userFileAllowSize = FileHandler::returnbytes($file_config->allowed_filesize.'M');
$userAttachAllowSize = FileHandler::returnbytes($file_config->allowed_attach_size.'M');
$iniPostMaxSize = FileHandler::returnbytes(ini_get('post_max_size'));
$iniUploadMaxSize = FileHandler::returnbytes(ini_get('upload_max_filesize'));
$iniMinSzie = min($iniPostMaxSize, $iniUploadMaxSize);
if($userFileAllowSize > $iniMinSzie || $userAttachAllowSize > $iniMinSzie)

View file

@ -201,7 +201,7 @@ class fileAdminView extends file
// Set a template
$security = new Security();
$security->encodeHTML('file_list..');
$security->encodeHTML('module_list..');
$security->encodeHTML('module_list..');
$this->setTemplatePath($this->module_path.'tpl');
$this->setTemplateFile('file_list');
@ -217,10 +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'));
$iniPostMaxSize = FileHandler::returnbytes(ini_get('post_max_size'));
$iniUploadMaxSize = FileHandler::returnbytes(ini_get('upload_max_filesize'));
$iniMinSize = min($iniPostMaxSize, $iniUploadMaxSize);
Context::set('upload_max_filesize',$this->_changeBytes($iniMinSize / 1048576));
Context::set('upload_max_filesize', FileHandler::filesize($iniMinSize));
// Set a template file
$this->setTemplatePath($this->module_path.'tpl');
$this->setTemplateFile('adminConfig');

View file

@ -150,25 +150,6 @@ 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,8 +238,8 @@ class fileModel extends file
if($logged_info->is_admin == 'Y')
{
$iniPostMaxSize = $this->_changeBytes(ini_get('post_max_size'));
$iniUploadMaxSize = $this->_changeBytes(ini_get('upload_max_filesize'));
$iniPostMaxSize = FileHandler::returnbytes(ini_get('post_max_size'));
$iniUploadMaxSize = FileHandler::returnbytes(ini_get('upload_max_filesize'));
$size = min($iniPostMaxSize, $iniUploadMaxSize) / 1048576;
$file_config->allowed_attach_size = $size;
$file_config->allowed_filesize = $size;

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/{$upload_max_filesize}MB
<input type="number" id="filesize" name="allowed_filesize" value="{$config->allowed_filesize}" /> MB/{$upload_max_filesize}
</div>
</div>
<div class="x_control-group">