Example #1
0
 /**
  * Set attachment information (for administrator)
  *
  * @return Object
  */
 function dispFileAdminConfig()
 {
     $oFileModel = getModel('file');
     $config = $oFileModel->getFileConfig();
     Context::set('config', $config);
     $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', FileHandler::filesize($iniMinSize));
     // Set a template file
     $this->setTemplatePath($this->module_path . 'tpl');
     $this->setTemplateFile('adminConfig');
 }
Example #2
0
 /**
  * Return configurations of the attachement (it automatically checks if an administrator is)
  *
  * @return object Returns a file configuration of current module. If user is admin, returns PHP's max file size and allow all file types.
  */
 function getUploadConfig()
 {
     $logged_info = Context::get('logged_info');
     $module_srl = Context::get('module_srl');
     // Get the current module if module_srl doesn't exist
     if (!$module_srl) {
         $current_module_info = Context::get('current_module_info');
         $module_srl = $current_module_info->module_srl;
     }
     $file_config = $this->getFileConfig($module_srl);
     if ($logged_info->is_admin == 'Y') {
         $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;
         $file_config->allowed_filetypes = '*.*';
     }
     return $file_config;
 }
 /**
  * Add file information for each module
  *
  * @return void
  */
 function procFileAdminInsertModuleConfig()
 {
     // Get variables
     $module_srl = Context::get('target_module_srl');
     // In order to configure multiple modules at once
     if (preg_match('/^([0-9,]+)$/', $module_srl)) {
         $module_srl = explode(',', $module_srl);
     } else {
         $module_srl = array($module_srl);
     }
     $download_grant = Context::get('download_grant');
     $file_config = new stdClass();
     $file_config->allow_outlink = Context::get('allow_outlink');
     $file_config->allow_outlink_format = Context::get('allow_outlink_format');
     $file_config->allow_outlink_site = Context::get('allow_outlink_site');
     $file_config->allowed_filesize = Context::get('allowed_filesize');
     $file_config->allowed_attach_size = Context::get('allowed_attach_size');
     $file_config->allowed_filetypes = str_replace(' ', '', Context::get('allowed_filetypes'));
     if (!is_array($download_grant)) {
         $file_config->download_grant = explode('|@|', $download_grant);
     } else {
         $file_config->download_grant = $download_grant;
     }
     //관리자가 허용한 첨부파일의 사이즈가 php.ini의 값보다 큰지 확인하기 - by ovclas
     $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) {
         return new Object(-1, 'input size over than config in php.ini');
     }
     $oModuleController = getController('module');
     for ($i = 0; $i < count($module_srl); $i++) {
         $srl = trim($module_srl[$i]);
         if (!$srl) {
             continue;
         }
         $oModuleController->insertModulePartConfig('file', $srl, $file_config);
     }
     $this->setError(-1);
     $this->setMessage('success_updated', 'info');
     $returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispBoardAdminContent');
     $this->setRedirectUrl($returnUrl);
 }