rhymix/modules/install/install.admin.controller.php
Kijin Sung 84e5542d77 Remove unnecessary use of BaseObject
- 트리거 등 반환값이 필요하지 않은 곳에서 new BaseObject()를 반환하는 것 삭제
- 모듈 설치, 업데이트 후 무의미한 new BaseObject()를 반환하는 것 삭제
- 사용자에게 에러 메시지를 돌려주는 용도로 new BaseObject(-1, '에러메시지')를
  사용하는 경우는 대부분 $this->setError()로 변경함. 언어 변환과 sprintf()
  처리까지 한 번에 이루어지므로 이쪽이 더 편리함.
2017-12-01 00:54:51 +09:00

101 lines
3 KiB
PHP

<?php
/* Copyright (C) NAVER <http://www.navercorp.com> */
/**
* @class installAdminController
* @author NAVER (developers@xpressengine.com)
* @brief admin controller class of the install module
*/
class installAdminController extends install
{
/**
* @brief Initialization
*/
function init()
{
}
/**
* @brief Install the module
*/
function procInstallAdminInstall()
{
$module_name = Context::get('module_name');
if(!$module_name) return $this->setError('invalid_request');
$oInstallController = getController('install');
$oInstallController->installModule($module_name, './modules/'.$module_name);
$this->setMessage('success_installed');
}
/**
* @brief Upate the module
*/
function procInstallAdminUpdate()
{
@set_time_limit(0);
$module_name = Context::get('module_name');
if(!$module_name) return $this->setError('invalid_request');
$oModule = getModule($module_name, 'class');
if(!$oModule) return $this->setError('invalid_request');
$output = $oModule->moduleUpdate();
if($output instanceof BaseObject && !$output->toBool())
{
return $output;
}
}
function procInstallAdminRemoveFTPInfo()
{
$ftp_config_file = Context::getFTPConfigFile();
if(file_exists($ftp_config_file)) unlink($ftp_config_file);
if($_SESSION['ftp_password']) unset($_SESSION['ftp_password']);
$this->setMessage('success_deleted');
}
function procInstallAdminSaveFTPInfo()
{
$ftp_info = Context::getFTPInfo();
$ftp_info->ftp_user = Context::get('ftp_user');
$ftp_info->ftp_port = Context::get('ftp_port');
$ftp_info->ftp_host = Context::get('ftp_host');
$ftp_info->ftp_pasv = Context::get('ftp_pasv');
if(!$ftp_info->ftp_pasv) $ftp_info->ftp_pasv = "N";
$ftp_info->sftp = Context::get('sftp');
$ftp_root_path = Context::get('ftp_root_path');
if(substr($ftp_root_path, strlen($ftp_root_path)-1) == "/")
{
$ftp_info->ftp_root_path = $ftp_root_path;
}
else
{
$ftp_info->ftp_root_path = $ftp_root_path.'/';
}
$ftp_info->ftp_password = Context::get('ftp_password');
$buff = '<?php if(!defined("__XE__")) exit();'."\n\$ftp_info = new stdClass;\n";
foreach($ftp_info as $key => $val)
{
if(!$val) continue;
if(preg_match('/(<\?|<\?php|\?>|fputs|fopen|fwrite|fgets|fread|file_get_contents|file_put_contents|exec|proc_open|popen|passthru|show_source|phpinfo|system|\/\*|\*\/|chr\()/xsm', preg_replace('/\s/', '', $val)))
{
continue;
}
$buff .= sprintf("\$ftp_info->%s = '%s';\n", $key, str_replace("'","\\'",$val));
}
$buff .= "?>";
$config_file = Context::getFTPConfigFile();
FileHandler::WriteFile($config_file, $buff);
if($_SESSION['ftp_password']) unset($_SESSION['ftp_password']);
$this->setMessage('success_updated');
$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispAdminConfigFtp');
$this->setRedirectUrl($returnUrl);
}
}
/* End of file install.admin.controller.php */
/* Location: ./modules/install/install.admin.controller.php */