/** * Check whether to use RSS rss url by adding * * @return Object */ function triggerRssUrlInsert() { $oModuleModel = getModel('module'); $total_config = $oModuleModel->getModuleConfig('rss'); $current_module_srl = Context::get('module_srl'); $site_module_info = Context::get('site_module_info'); if (is_array($current_module_srl)) { unset($current_module_srl); } if (!$current_module_srl) { $current_module_info = Context::get('current_module_info'); $current_module_srl = $current_module_info->module_srl; } if (!$current_module_srl) { return new Object(); } // Imported rss settings of the selected module $oRssModel = getModel('rss'); $rss_config = $oRssModel->getRssModuleConfig($current_module_srl); if ($rss_config->open_rss != 'N') { Context::set('rss_url', $oRssModel->getModuleFeedUrl(Context::get('vid'), Context::get('mid'), 'rss')); Context::set('atom_url', $oRssModel->getModuleFeedUrl(Context::get('vid'), Context::get('mid'), 'atom')); } if (Context::isInstalled() && $site_module_info->mid == Context::get('mid') && $total_config->use_total_feed != 'N') { if (Context::isAllowRewrite() && !Context::get('vid')) { $request_uri = Context::getRequestUri(); Context::set('general_rss_url', $request_uri . 'rss'); Context::set('general_atom_url', $request_uri . 'atom'); } else { Context::set('general_rss_url', getUrl('', 'module', 'rss', 'act', 'rss')); Context::set('general_atom_url', getUrl('', 'module', 'rss', 'act', 'atom')); } } return new Object(); }
/** * constructor * * @return void **/ function member() { if (!Context::isInstalled()) { return; } $oModuleModel =& getModel('module'); $member_config = $oModuleModel->getModuleConfig('member'); // Set to use SSL upon actions related member join/information/password and so on if (Context::get('_use_ssl') == 'optional') { Context::addSSLAction('dispMemberModifyPassword'); Context::addSSLAction('dispMemberSignUpForm'); Context::addSSLAction('dispMemberModifyInfo'); Context::addSSLAction('dispMemberModifyEmailAddress'); Context::addSSLAction('dispMemberGetTempPassword'); Context::addSSLAction('dispMemberResendAuthMail'); Context::addSSLAction('dispMemberLoginForm'); Context::addSSLAction('dispMemberFindAccount'); Context::addSSLAction('dispMemberLeave'); Context::addSSLAction('procMemberLogin'); Context::addSSLAction('procMemberModifyPassword'); Context::addSSLAction('procMemberInsert'); Context::addSSLAction('procMemberModifyInfo'); Context::addSSLAction('procMemberFindAccount'); Context::addSSLAction('procMemberModifyEmailAddress'); Context::addSSLAction('procMemberUpdateAuthMail'); Context::addSSLAction('procMemberResendAuthMail'); Context::addSSLAction('procMemberLeave'); //Context::addSSLAction('getMemberMenu'); } }
/** * constructor * * @return void */ function __construct() { if (!Context::isInstalled()) { return; } if (!Context::isExistsSSLAction('dispBoardWrite') && Context::getSslStatus() == 'optional') { $ssl_actions = array('dispBoardWrite', 'dispBoardWriteComment', 'dispBoardReplyComment', 'dispBoardModifyComment', 'dispBoardDelete', 'dispBoardDeleteComment', 'procBoardInsertDocument', 'procBoardDeleteDocument', 'procBoardInsertComment', 'procBoardDeleteComment', 'procBoardVerificationPassword'); Context::addSSLActions($ssl_actions); } }
/** * constructor * * @return void */ function member() { if (!Context::isInstalled()) { return; } $oModuleModel = getModel('module'); $member_config = $oModuleModel->getModuleConfig('member'); // Set to use SSL upon actions related member join/information/password and so on. 2013.02.15 if (!Context::isExistsSSLAction('dispMemberModifyPassword') && Context::getSslStatus() == 'optional') { $ssl_actions = array('dispMemberModifyPassword', 'dispMemberSignUpForm', 'dispMemberModifyInfo', 'dispMemberModifyEmailAddress', 'dispMemberGetTempPassword', 'dispMemberResendAuthMail', 'dispMemberLoginForm', 'dispMemberFindAccount', 'dispMemberLeave', 'procMemberLogin', 'procMemberModifyPassword', 'procMemberInsert', 'procMemberModifyInfo', 'procMemberFindAccount', 'procMemberModifyEmailAddress', 'procMemberUpdateAuthMail', 'procMemberResendAuthMail', 'procMemberLeave', 'procMemberFindAccountByQuestion'); Context::addSSLActions($ssl_actions); } }
/** * @brief FTP 정보 등록 **/ function procInstallFTP() { if (Context::isInstalled()) { return new Object(-1, 'msg_already_installed'); } $ftp_info = Context::gets('ftp_user', 'ftp_password', 'ftp_port'); $ftp_info->ftp_port = (int) $ftp_info->ftp_port; if (!$ftp_info->ftp_port) { $ftp_info->ftp_port = 21; } $buff = '<?php if(!defined("__ZBXE__")) exit();' . "\n"; foreach ($ftp_info as $key => $val) { $buff .= sprintf("\$ftp_info->%s = '%s';\n", $key, str_replace("'", "\\'", $val)); } $buff .= "?>"; // safe_mode 일 경우 if (ini_get('safe_mode')) { if (!$ftp_info->ftp_user || !$ftp_info->ftp_password) { return new Object(-1, 'msg_safe_mode_ftp_needed'); } require_once _XE_PATH_ . 'libs/ftp.class.php'; $oFtp = new ftp(); if (!$oFtp->ftp_connect('localhost', $ftp_info->ftp_port)) { return new Object(-1, 'msg_ftp_not_connected'); } if (!$oFtp->ftp_login($ftp_info->ftp_user, $ftp_info->ftp_password)) { $oFtp->ftp_quit(); return new Object(-1, 'msg_ftp_invalid_auth_info'); } if (!is_dir(_XE_PATH_ . 'files') && !$oFtp->ftp_mkdir(_XE_PATH_ . 'files')) { $oFtp->ftp_quit(); return new Object(-1, 'msg_ftp_mkdir_fail'); } if (!$oFtp->ftp_site("CHMOD 777 " . _XE_PATH_ . 'files')) { $oFtp->ftp_quit(); return new Object(-1, 'msg_ftp_chmod_fail'); } if (!is_dir(_XE_PATH_ . 'files/config') && !$oFtp->ftp_mkdir(_XE_PATH_ . 'files/config')) { $oFtp->ftp_quit(); return new Object(-1, 'msg_ftp_mkdir_fail'); } if (!$oFtp->ftp_site("CHMOD 777 " . _XE_PATH_ . 'files/config')) { $oFtp->ftp_quit(); return new Object(-1, 'msg_ftp_chmod_fail'); } $oFtp->ftp_quit(); } $config_file = Context::getFTPConfigFile(); FileHandler::WriteFile($config_file, $buff); }
function xe_context_init($xe) { // // simplified XE context init method to speed up // // set context variables in $GLOBALS (to use in display handler) $xe->context =& $GLOBALS['__Context__']; $xe->context->_COOKIE = $_COOKIE; $xe->loadDBInfo(); // set session handler if (Context::isInstalled() && $this->db_info->use_db_session == 'Y') { $oSessionModel = getModel('session'); $oSessionController = getController('session'); session_set_save_handler(array(&$oSessionController, 'open'), array(&$oSessionController, 'close'), array(&$oSessionModel, 'read'), array(&$oSessionController, 'write'), array(&$oSessionController, 'destroy'), array(&$oSessionController, 'gc')); } }
/** * @brief 초기화 **/ function init() { // template 경로를 지정 $this->setTemplatePath($this->module_path . 'tpl'); // 설치가 되어 있으면 오류 if (Context::isInstalled()) { return $this->stop('msg_already_installed'); } // 컨트롤러 생성 $oInstallController =& getController('install'); $this->install_enable = $oInstallController->checkInstallEnv(); // 설치 가능한 환경이라면 installController::makeDefaultDirectory() 실행 if ($this->install_enable) { $oInstallController->makeDefaultDirectory(); } }
/** * @brief Initialization */ function init() { // Stop if already installed. if (Context::isInstalled()) { return $this->stop('msg_already_installed'); } // Set the browser title. Context::setBrowserTitle(Context::getLang('introduce_title')); // Specify the template path. $this->setTemplatePath($this->module_path . 'tpl'); // Check the environment. $oInstallController = getController('install'); self::$checkEnv = $oInstallController->checkInstallEnv(); if (self::$checkEnv) { $oInstallController->makeDefaultDirectory(); } }
/** * @brief Initialization */ function init() { // Set browser title Context::setBrowserTitle(Context::getLang('introduce_title')); // Specify the template path $this->setTemplatePath($this->module_path . 'tpl'); // Error occurs if already installed if (Context::isInstalled()) { return $this->stop('msg_already_installed'); } // Install a controller $oInstallController = getController('install'); $this->install_enable = $oInstallController->checkInstallEnv(); // If the environment is installable, execute installController::makeDefaultDirectory() if ($this->install_enable) { $oInstallController->makeDefaultDirectory(); } }
/** * @brief RSS 사용 유무를 체크하여 rss url 추가 **/ function triggerRssUrlInsert() { $oModuleModel =& getModel('module'); $total_config = $oModuleModel->getModuleConfig('rss'); $current_module_srl = Context::get('module_srl'); $site_module_info = Context::get('site_module_info'); if (!$current_module_srl) { $current_module_info = Context::get('current_module_info'); $current_module_srl = $current_module_info->module_srl; } if (!$current_module_srl) { return new Object(); } // 선택된 모듈의 rss설정을 가져옴 $oRssModel =& getModel('rss'); $rss_config = $oRssModel->getRssModuleConfig($current_module_srl); if ($rss_config->open_rss != 'N') { if (Context::isAllowRewrite()) { $request_uri = Context::getRequestUri(); // 가상 사이트 변수가 있고 이 변수가 mid와 다를때. (vid와 mid는 같을 수 없다고 함) if (Context::get('vid') && Context::get('vid') != Context::get('mid')) { Context::set('rss_url', Context::getRequestUri() . Context::get('vid') . '/' . Context::get('mid') . '/rss'); Context::set('atom_url', Context::getRequestUri() . Context::get('vid') . '/' . Context::get('mid') . '/atom'); } else { Context::set('rss_url', $request_uri . Context::get('mid') . '/rss'); Context::set('atom_url', $request_uri . Context::get('mid') . '/atom'); } } else { Context::set('rss_url', getUrl('', 'mid', Context::get('mid'), 'act', 'rss')); Context::set('atom_url', getUrl('', 'mid', Context::get('mid'), 'act', 'atom')); } } if (Context::isInstalled() && $site_module_info->mid == Context::get('mid') && $total_config->use_total_feed != 'N') { if (Context::isAllowRewrite() && !Context::get('vid')) { $request_uri = Context::getRequestUri(); Context::set('general_rss_url', $request_uri . 'rss'); Context::set('general_atom_url', $request_uri . 'atom'); } else { Context::set('general_rss_url', getUrl('', 'module', 'rss', 'act', 'rss')); Context::set('general_atom_url', getUrl('', 'module', 'rss', 'act', 'atom')); } } return new Object(); }
/** * @brief DB를 상속받는 특정 db type의 instance를 생성 후 return **/ function &getInstance($db_type = NULL) { if (!$db_type) { $db_type = Context::getDBType(); } if (!$db_type && Context::isInstalled()) { return new Object(-1, 'msg_db_not_setted'); } if (!$GLOBALS['__DB__']) { $class_name = sprintf("DB%s%s", strtoupper(substr($db_type, 0, 1)), strtolower(substr($db_type, 1))); $class_file = sprintf("%sclasses/db/%s.class.php", _XE_PATH_, $class_name); if (!file_exists($class_file)) { new Object(-1, 'msg_db_not_setted'); } require_once $class_file; $eval_str = sprintf('$GLOBALS[\'__DB__\'][\'' . $db_type . '\'] = new %s();', $class_name); eval($eval_str); } return $GLOBALS['__DB__'][$db_type]; }
/** * @brief constructor **/ function member() { if (!Context::isInstalled()) { return; } $oModuleModel =& getModel('module'); $member_config = $oModuleModel->getModuleConfig('member'); // SSL 사용시 회원가입/정보/비밀번호등과 관련된 action에 대해 SSL 전송하도록 지정 if (Context::get('_use_ssl') == 'optional') { Context::addSSLAction('dispMemberLoginForm'); Context::addSSLAction('dispMemberModifyPassword'); Context::addSSLAction('dispMemberSignUpForm'); Context::addSSLAction('dispMemberModifyInfo'); Context::addSSLAction('dispMemberOpenIDLogin'); Context::addSSLAction('procMemberLogin'); Context::addSSLAction('procMemberModifyPassword'); Context::addSSLAction('procMemberInsert'); Context::addSSLAction('procMemberModifyInfo'); Context::addSSLAction('procMemberOpenIDLogin'); } }
public function checkAdminMenu() { // for admin menu if (Context::isInstalled()) { $oMenuAdminModel = getAdminModel('menu'); $output = $oMenuAdminModel->getMenuByTitle($this->adminMenuName); if (!$output->menu_srl) { $this->createXeAdminMenu(); $output = $oMenuAdminModel->getMenuByTitle($this->adminMenuName); } else { if (!is_readable(FileHandler::getRealPath($output->php_file))) { $oMenuAdminController = getAdminController('menu'); $oMenuAdminController->makeXmlFile($output->menu_srl); } Context::set('admin_menu_srl', $output->menu_srl); } $this->_oldAdminmenuDelete(); $returnObj = new stdClass(); $returnObj->menu_srl = $output->menu_srl; $returnObj->php_file = FileHandler::getRealPath($output->php_file); return $returnObj; } }
<?php /* Copyright (C) NAVER <http://www.navercorp.com> */ if (!defined('__XE__')) { exit; } /** * @file counter.addon.php * @author NAVER (developers@xpressengine.com) * @brief Counter add-on */ // Execute if called_position is before_display_content if ($called_position == 'before_module_init' && Context::get('module') != 'admin' && Context::getResponseMethod() == 'HTML' && Context::isInstalled() && !isCrawler()) { $oCounterController = getController('counter'); $oCounterController->counterExecute(); } /* End of file counter.addon.php */ /* Location: ./addons/counter/counter.addon.php */
/** * @brief Install with received information */ function procInstall($install_config = null) { // Check if it is already installed if (Context::isInstalled()) { return new Object(-1, 'msg_already_installed'); } // Get install parameters. $config = Rhymix\Framework\Config::getDefaults(); if ($install_config) { $install_config = (array) $install_config; $config['db']['master']['type'] = str_replace('_innodb', '', $install_config['db_type']); $config['db']['master']['host'] = $install_config['db_hostname']; $config['db']['master']['port'] = $install_config['db_port']; $config['db']['master']['user'] = $install_config['db_userid']; $config['db']['master']['pass'] = $install_config['db_password']; $config['db']['master']['database'] = $install_config['db_database']; $config['db']['master']['prefix'] = $install_config['db_table_prefix']; $config['db']['master']['charset'] = $install_config['db_charset']; $config['db']['master']['engine'] = strpos($install_config['db_type'], 'innodb') !== false ? 'innodb' : (strpos($install_config['db_type'], 'mysql') !== false ? 'myisam' : null); $config['use_rewrite'] = $install_config['use_rewrite'] === 'Y' ? true : false; $config['url']['ssl'] = $install_config['use_ssl'] ?: 'none'; $time_zone = $install_config['time_zone']; $user_info = new stdClass(); $user_info->email_address = $install_config['email_address']; $user_info->password = $install_config['password']; $user_info->nick_name = $install_config['nick_name']; $user_info->user_id = $install_config['user_id']; } else { $config['db']['master']['type'] = str_replace('_innodb', '', $_SESSION['db_config']->db_type); $config['db']['master']['host'] = $_SESSION['db_config']->db_host; $config['db']['master']['port'] = $_SESSION['db_config']->db_port; $config['db']['master']['user'] = $_SESSION['db_config']->db_user; $config['db']['master']['pass'] = $_SESSION['db_config']->db_pass; $config['db']['master']['database'] = $_SESSION['db_config']->db_database; $config['db']['master']['prefix'] = $_SESSION['db_config']->db_prefix; $config['db']['master']['charset'] = $_SESSION['db_config']->db_charset; $config['db']['master']['engine'] = strpos($_SESSION['db_config']->db_type, 'innodb') !== false ? 'innodb' : (strpos($_SESSION['db_config']->db_type, 'mysql') !== false ? 'myisam' : null); $config['use_rewrite'] = $_SESSION['use_rewrite'] === 'Y' ? true : false; $config['url']['ssl'] = Context::get('use_ssl') ?: 'none'; $time_zone = Context::get('time_zone'); $user_info = Context::gets('email_address', 'password', 'nick_name', 'user_id'); } // Fix the database table prefix. $config['db']['master']['prefix'] = rtrim($config['db']['master']['prefix'], '_'); if ($config['db']['master']['prefix'] !== '') { $config['db']['master']['prefix'] .= '_'; } // Create new crypto keys. $config['crypto']['encryption_key'] = Rhymix\Framework\Security::getRandom(64, 'alnum'); $config['crypto']['authentication_key'] = Rhymix\Framework\Security::getRandom(64, 'alnum'); $config['crypto']['session_key'] = Rhymix\Framework\Security::getRandom(64, 'alnum'); // Set the default language. $config['locale']['default_lang'] = Context::getLangType(); $config['locale']['enabled_lang'] = array($config['locale']['default_lang']); // Set the default time zone. if (strpos($time_zone, '/') !== false) { $config['locale']['default_timezone'] = $time_zone; $user_timezone = null; } else { $user_timezone = intval(Rhymix\Framework\DateTime::getTimezoneOffsetByLegacyFormat($time_zone ?: '+0900') / 3600); switch ($user_timezone) { case 9: $config['locale']['default_timezone'] = 'Asia/Seoul'; break; case 0: $config['locale']['default_timezone'] = 'Etc/UTC'; break; default: $config['locale']['default_timezone'] = 'Etc/GMT' . ($user_timezone > 0 ? '-' : '+') . abs($user_timezone); } } // Set the internal time zone. if ($config['locale']['default_timezone'] === 'Asia/Seoul') { $config['locale']['internal_timezone'] = 32400; } elseif ($user_timezone !== null) { $config['locale']['internal_timezone'] = $user_timezone * 3600; } else { $config['locale']['internal_timezone'] = 0; } // Set the default URL. $config['url']['default'] = Context::getRequestUri(); // Set the default umask. $config['file']['umask'] = Rhymix\Framework\Storage::recommendUmask(); // Load the new configuration. Rhymix\Framework\Config::setAll($config); Context::loadDBInfo($config); // Check DB. $oDB = DB::getInstance(); if (!$oDB->isConnected()) { return $oDB->getError(); } // Assign a temporary administrator while installing. foreach ($user_info as $key => $val) { Context::set($key, $val, true); } $user_info->is_admin = 'Y'; Context::set('logged_info', $user_info); // Install all the modules. try { $oDB->begin(); $this->installDownloadedModule(); $oDB->commit(); } catch (Exception $e) { $oDB->rollback(); return new Object(-1, $e->getMessage()); } // Execute the install script. $scripts = FileHandler::readDir(_XE_PATH_ . 'modules/install/script', '/(\\.php)$/'); if (count($scripts)) { sort($scripts); foreach ($scripts as $script) { $script_path = FileHandler::getRealPath('./modules/install/script/'); $output = (include $script_path . $script); } } // Apply site lock. if (Context::get('use_sitelock') === 'Y') { $user_ip_range = getView('install')->detectUserIPRange(); Rhymix\Framework\Config::set('lock.locked', true); Rhymix\Framework\Config::set('lock.message', 'This site is locked.'); Rhymix\Framework\Config::set('lock.allow', array('127.0.0.1', $user_ip_range)); } // Save the new configuration. Rhymix\Framework\Config::save(); // Unset temporary session variables. unset($_SESSION['use_rewrite']); unset($_SESSION['db_config']); // Redirect to the home page. $this->setMessage('msg_install_completed'); $returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : RX_BASEURL; $this->setRedirectUrl($returnUrl); return new Object(); }
function session() { if (Context::isInstalled()) { $this->session_started = true; } }
/** * @brief Set FTP Information */ function procInstallFTP() { if (Context::isInstalled()) { return new Object(-1, 'msg_already_installed'); } $ftp_info = Context::gets('ftp_host', 'ftp_user', 'ftp_password', 'ftp_port', 'ftp_root_path'); $ftp_info->ftp_port = (int) $ftp_info->ftp_port; if (!$ftp_info->ftp_port) { $ftp_info->ftp_port = 21; } if (!$ftp_info->ftp_host) { $ftp_info->ftp_host = '127.0.0.1'; } if (!$ftp_info->ftp_root_path) { $ftp_info->ftp_root_path = '/'; } $buff = array('<?php if(!defined("__XE__")) exit();'); $buff[] = "\$ftp_info = new stdClass();"; foreach ($ftp_info as $key => $val) { $buff[] = sprintf("\$ftp_info->%s='%s';", $key, str_replace("'", "\\'", $val)); } // If safe_mode if (ini_get('safe_mode')) { if (!$ftp_info->ftp_user || !$ftp_info->ftp_password) { return new Object(-1, 'msg_safe_mode_ftp_needed'); } require_once _XE_PATH_ . 'libs/ftp.class.php'; $oFtp = new ftp(); if (!$oFtp->ftp_connect($ftp_info->ftp_host, $ftp_info->ftp_port)) { return new Object(-1, sprintf(Context::getLang('msg_ftp_not_connected'), $ftp_info->ftp_host)); } if (!$oFtp->ftp_login($ftp_info->ftp_user, $ftp_info->ftp_password)) { $oFtp->ftp_quit(); return new Object(-1, 'msg_ftp_invalid_auth_info'); } if (!is_dir(_XE_PATH_ . 'files') && !$oFtp->ftp_mkdir($ftp_info->ftp_root_path . 'files')) { $oFtp->ftp_quit(); return new Object(-1, 'msg_ftp_mkdir_fail'); } if (!$oFtp->ftp_site("CHMOD 777 " . $ftp_info->ftp_root_path . 'files')) { $oFtp->ftp_quit(); return new Object(-1, 'msg_ftp_chmod_fail'); } if (!is_dir(_XE_PATH_ . 'files/config') && !$oFtp->ftp_mkdir($ftp_info->ftp_root_path . 'files/config')) { $oFtp->ftp_quit(); return new Object(-1, 'msg_ftp_mkdir_fail'); } if (!$oFtp->ftp_site("CHMOD 777 " . $ftp_info->ftp_root_path . 'files/config')) { $oFtp->ftp_quit(); return new Object(-1, 'msg_ftp_chmod_fail'); } $oFtp->ftp_quit(); } FileHandler::WriteFile(Context::getFTPConfigFile(), join(PHP_EOL, $buff)); }
/** * call a trigger * @param string $trigger_name trigger's name to call * @param string $called_position called position * @param object $obj an object as a parameter to trigger * @return Object * */ public static function triggerCall($trigger_name, $called_position, &$obj) { // skip if not installed if (!Context::isInstalled()) { return new Object(); } $oModuleModel = getModel('module'); $triggers = $oModuleModel->getTriggers($trigger_name, $called_position); if (!$triggers) { $triggers = array(); } //store before trigger call time $before_trigger_time = microtime(true); foreach ($triggers as $item) { $module = $item->module; $type = $item->type; $called_method = $item->called_method; // todo why don't we call a normal class object ? $oModule = getModule($module, $type); if (!$oModule || !method_exists($oModule, $called_method)) { continue; } // do not call if module is blacklisted if (Context::isBlacklistedPlugin($oModule->module)) { continue; } $before_each_trigger_time = microtime(true); $output = $oModule->{$called_method}($obj); $after_each_trigger_time = microtime(true); if ($trigger_name !== 'common.flushDebugInfo') { $trigger_target = $module . ($type === 'class' ? '' : $type) . '.' . $called_method; Rhymix\Framework\Debug::addTrigger(array('name' => $trigger_name . '.' . $called_position, 'target' => $trigger_target, 'target_plugin' => $module, 'elapsed_time' => $after_each_trigger_time - $before_each_trigger_time)); } if (is_object($output) && method_exists($output, 'toBool') && !$output->toBool()) { return $output; } unset($oModule); } $trigger_functions = $oModuleModel->getTriggerFunctions($trigger_name, $called_position); foreach ($trigger_functions as $item) { $before_each_trigger_time = microtime(true); $output = $item($obj); $after_each_trigger_time = microtime(true); if ($trigger_name !== 'common.writeSlowlog') { if (is_string($item)) { $trigger_target = $item; } elseif (is_array($item) && count($item)) { if (is_object($item[0])) { $trigger_target = get_class($item[0]) . '.' . strval($item[1]); } else { $trigger_target = implode('.', $item); } } else { $trigger_target = 'closure'; } Rhymix\Framework\Debug::addTrigger(array('name' => $trigger_name . '.' . $called_position, 'target' => $trigger_target, 'target_plugin' => null, 'elapsed_time' => $after_each_trigger_time - $before_each_trigger_time)); } if (is_object($output) && method_exists($output, 'toBool') && !$output->toBool()) { return $output; } } return new Object(); }
/** * @brief 모듈의 action에 해당하는 method를 실행 * * $act값에 의해서 $action_list에 선언된 것들을 실행한다 **/ function proc() { // stop_proc==true이면 그냥 패스 if ($this->stop_proc) { return false; } // addon 실행(called_position 를 before_module_proc로 하여 호출) $called_position = 'before_module_proc'; $oAddonController =& getController('addon'); $addon_file = $oAddonController->getCacheFilePath(); if (file_exists($addon_file)) { @(include $addon_file); } if (isset($this->xml_info->action->{$this->act}) && method_exists($this, $this->act)) { // 권한 체크 if (!$this->grant->access) { return $this->stop("msg_not_permitted_act"); } // 모듈의 스킨 정보를 연동 (스킨 정보의 테이블 분리로 동작대상 모듈에만 스킨 정보를 싱크시키도록 변경) $oModuleModel =& getModel('module'); $oModuleModel->syncSkinInfoToModuleInfo($this->module_info); Context::set('module_info', $this->module_info); // 실행 $output = $this->{$this->act}(); // act이 없으면 action_forward에서 해당하는 act가 있는지 찾아서 대신 실행 } else { if (Context::isInstalled()) { $oModuleModel =& getModel('module'); $forward = null; // 현재 요청된 action의 대상 모듈을 찾음 // 1. action이름으로 검색 (DB검색 없이 하기 위함) if (preg_match('/^([a-z]+)([A-Z])([a-z0-9\\_]+)(.*)$/', $this->act, $matches)) { $module = strtolower($matches[2] . $matches[3]); $xml_info = $oModuleModel->getModuleActionXml($module); if ($xml_info->action->{$this->act}) { $forward->module = $module; $forward->type = $xml_info->action->{$this->act}->type; $forward->act = $this->act; } } // 2. 1번에서 찾지 못하면 action forward를 검색 if (!$forward) { $forward = $oModuleModel->getActionForward($this->act); } // 찾아진 forward 모듈이 있으면 실행 if ($forward->module && $forward->type && $forward->act && $forward->act == $this->act) { $kind = strpos(strtolower($forward->act), 'admin') !== false ? 'admin' : ''; $oModule =& getModule($forward->module, $forward->type, $kind); $xml_info = $oModuleModel->getModuleActionXml($forward->module); $oModule->setAct($forward->act); $oModule->init(); if ($oModule->stop_proc) { return $this->stop($oModule->getMessage()); } $oModule->setModuleInfo($this->module_info, $xml_info); if (isset($xml_info->action->{$forward->act}) && method_exists($oModule, $forward->act)) { $output = $oModule->{$forward->act}(); } else { return $this->stop("msg_module_is_not_exists"); } // forward 모듈의 실행 결과 검사 if ($oModule->stop_proc) { return $this->stop($oModule->getMessage()); } $this->setTemplatePath($oModule->getTemplatePath()); $this->setTemplateFile($oModule->getTemplateFile()); if ($oModule->getLayoutFile()) { $this->setLayoutFile($oModule->getLayoutFile()); } $this->adds($oModule->getVariables()); // forward 모듈을 찾지 못했다면 원 모듈의 default index action을 실행 } else { if ($this->xml_info->default_index_act && method_exists($this, $this->xml_info->default_index_act)) { Context::set('act', $this->act = $this->xml_info->default_index_act); $output = $this->{$this->xml_info->default_index_act}(); } else { return false; } } } else { return false; } } // addon 실행(called_position 를 after_module_proc로 하여 호출) $called_position = 'after_module_proc'; $oAddonController =& getController('addon'); $addon_file = $oAddonController->getCacheFilePath(); if (file_exists($addon_file)) { @(include $addon_file); } if (is_a($output, 'Object') || is_subclass_of($output, 'Object')) { $this->setError($output->getError()); $this->setMessage($output->getMessage()); return false; } // view action이고 결과 출력이 XMLRPC 또는 JSON일 경우 해당 모듈의 api method를 실행 if ($this->module_info->module_type == 'view') { if (Context::getResponseMethod() == 'XMLRPC' || Context::getResponseMethod() == 'JSON') { $oAPI = getAPI($this->module_info->module, 'api'); if (method_exists($oAPI, $this->act)) { $oAPI->{$this->act}($this); } } } return true; }
/** * returns instance of certain db type * @param string $db_type type of db * @return DB return DB object instance */ function &getInstance($db_type = NULL) { if (!$db_type) { $db_type = Context::getDBType(); } if (!$db_type && Context::isInstalled()) { return new Object(-1, 'msg_db_not_setted'); } if (!isset($GLOBALS['__DB__'])) { $GLOBALS['__DB__'] = array(); } if (!isset($GLOBALS['__DB__'][$db_type])) { $class_name = 'DB' . ucfirst($db_type); $class_file = _XE_PATH_ . "classes/db/{$class_name}.class.php"; if (!file_exists($class_file)) { return new Object(-1, 'msg_db_not_setted'); } // get a singletone instance of the database driver class require_once $class_file; $GLOBALS['__DB__'][$db_type] = call_user_func(array($class_name, 'create')); $GLOBALS['__DB__'][$db_type]->db_type = $db_type; } return $GLOBALS['__DB__'][$db_type]; }
/** * call a trigger * @param string $trigger_name trigger's name to call * @param string $called_position called position * @param object $obj an object as a parameter to trigger * @return Object * */ function triggerCall($trigger_name, $called_position, &$obj) { // skip if not installed if (!Context::isInstalled()) { return new Object(); } $oModuleModel = getModel('module'); $triggers = $oModuleModel->getTriggers($trigger_name, $called_position); if (!$triggers || count($triggers) < 1) { return new Object(); } //store before trigger call time $before_trigger_time = NULL; if (__LOG_SLOW_TRIGGER__ > 0) { $before_trigger_time = microtime(true); } foreach ($triggers as $item) { $module = $item->module; $type = $item->type; $called_method = $item->called_method; // todo why don't we call a normal class object ? $oModule = getModule($module, $type); if (!$oModule || !method_exists($oModule, $called_method)) { continue; } $before_each_trigger_time = microtime(true); $output = $oModule->{$called_method}($obj); $after_each_trigger_time = microtime(true); $elapsed_time_trigger = $after_each_trigger_time - $before_each_trigger_time; $slowlog = new stdClass(); $slowlog->caller = $trigger_name . '.' . $called_position; $slowlog->called = $module . '.' . $called_method; $slowlog->called_extension = $module; if ($trigger_name != 'XE.writeSlowlog') { writeSlowlog('trigger', $elapsed_time_trigger, $slowlog); } if (is_object($output) && method_exists($output, 'toBool') && !$output->toBool()) { return $output; } unset($oModule); } return new Object(); }
/** * call a trigger * @param string $trigger_name trigger's name to call * @param string $called_position called position * @param object $obj an object as a parameter to trigger * @return Object * */ function triggerCall($trigger_name, $called_position, &$obj) { // skip if not installed if (!Context::isInstalled()) { return new Object(); } $oModuleModel = getModel('module'); $triggers = $oModuleModel->getTriggers($trigger_name, $called_position); if (!$triggers || count($triggers) < 1) { return new Object(); } foreach ($triggers as $item) { $module = $item->module; $type = $item->type; $called_method = $item->called_method; // todo why don't we call a normal class object ? $oModule = getModule($module, $type); if (!$oModule || !method_exists($oModule, $called_method)) { continue; } $output = $oModule->{$called_method}($obj); if (is_object($output) && method_exists($output, 'toBool') && !$output->toBool()) { return $output; } unset($oModule); } return new Object(); }
/** * @brief SSO URL이 설정되어 있고 아직 SSO URL검사를 하지 않았다면 return true **/ function checkSSO() { // GET 접속이 아니거나 설치가 안되어 있으면 패스 if (Context::getRequestMethod() != 'GET' || !Context::isInstalled() || in_array(Context::get('act'), array('rss', 'atom'))) { return true; } // DB info에 설정된 Default URL이 없다면 무조건 무사통과 $default_url = trim($this->db_info->default_url); if (!$default_url) { return true; } if (substr($default_url, -1) != '/') { $default_url .= '/'; } // SSO 검증을 요청 받는 사이트 if ($default_url == Context::getRequestUri()) { if (Context::get('default_url')) { $url = base64_decode(Context::get('default_url')); $url_info = parse_url($url); $url_info['query'] .= ($url_info['query'] ? '&' : '') . 'SSOID=' . session_id(); $redirect_url = sprintf('%s://%s%s%s?%s', $url_info['scheme'], $url_info['host'], $url_info['port'] ? ':' . $url_info['port'] : '', $url_info['path'], $url_info['query']); header("location:" . $redirect_url); return false; } // SSO 검증을 요청하는 사이트 } else { // SSO 결과를 받는 경우 session_name() 세팅 if (Context::get('SSOID')) { $session_name = Context::get('SSOID'); setcookie(session_name(), $session_name); $url = preg_replace('/([\\?\\&])$/', '', str_replace('SSOID=' . $session_name, '', Context::getRequestUrl())); header("location:" . $url); return false; // SSO 결과를 요청 } else { if ($_COOKIE['sso'] != md5(Context::getRequestUri()) && !Context::get('SSOID')) { setcookie('sso', md5(Context::getRequestUri()), 0, '/'); $url = sprintf("%s?default_url=%s", $default_url, base64_encode(Context::getRequestUrl())); header("location:" . $url); return false; } } } return true; }
<?php if (!defined("__ZBXE__")) { exit; } /** * @file counter.addon.php * @author zero (zero@nzeo.com) * @brief 카운터 애드온 **/ // called_position가 before_display_content 일 경우 실행 if (Context::isInstalled() && $called_position == 'before_module_init' && Context::get('module') != 'admin') { $oCounterController =& getController('counter'); $oCounterController->procCounterExecute(); }
/** * Single Sign On (SSO) * * @return bool True : Module handling is necessary in the control path of current request , False : Otherwise */ function checkSSO() { // pass if it's not GET request or XE is not yet installed if ($this->db_info->use_sso != 'Y' || isCrawler()) { return true; } $checkActList = array('rss' => 1, 'atom' => 1); if (Context::getRequestMethod() != 'GET' || !Context::isInstalled() || isset($checkActList[Context::get('act')])) { return true; } // pass if default URL is not set $default_url = trim($this->db_info->default_url); if (!$default_url) { return true; } if (substr($default_url, -1) != '/') { $default_url .= '/'; } // for sites recieving SSO valdiation if ($default_url == Context::getRequestUri()) { if (Context::get('default_url')) { $url = base64_decode(Context::get('default_url')); $url_info = parse_url($url); $url_info['query'] .= ($url_info['query'] ? '&' : '') . 'SSOID=' . session_id(); $redirect_url = sprintf('%s://%s%s%s?%s', $url_info['scheme'], $url_info['host'], $url_info['port'] ? ':' . $url_info['port'] : '', $url_info['path'], $url_info['query']); header('location:' . $redirect_url); return false; } // for sites requesting SSO validation } else { // result handling : set session_name() if (Context::get('SSOID')) { $session_name = Context::get('SSOID'); setcookie(session_name(), $session_name); $url = preg_replace('/([\\?\\&])$/', '', str_replace('SSOID=' . $session_name, '', Context::getRequestUrl())); header('location:' . $url); return false; // send SSO request } else { if ($_COOKIE['sso'] != md5(Context::getRequestUri()) && !Context::get('SSOID')) { setcookie('sso', md5(Context::getRequestUri()), 0, '/'); $url = sprintf("%s?default_url=%s", $default_url, base64_encode(Context::getRequestUrl())); header('location:' . $url); return false; } } } return true; }
/** * returns instance of certain db type * @param string $db_type type of db * @return DB return DB object instance */ public static function getInstance($db_type = NULL) { if (!$db_type) { $db_type = config('db.master.type'); if (config('db.master.engine') === 'innodb') { $db_type .= '_innodb'; } } if (!$db_type && Context::isInstalled()) { return new Object(-1, 'msg_db_not_setted'); } if (!isset($GLOBALS['__DB__'])) { $GLOBALS['__DB__'] = array(); } if (!isset($GLOBALS['__DB__'][$db_type])) { $class_name = 'DB' . ucfirst($db_type); $class_file = RX_BASEDIR . "classes/db/{$class_name}.class.php"; if (!file_exists($class_file)) { return new Object(-1, 'msg_db_not_setted'); } // get a singletone instance of the database driver class require_once $class_file; $GLOBALS['__DB__'][$db_type] = new $class_name(); $GLOBALS['__DB__'][$db_type]->db_type = $db_type; } return $GLOBALS['__DB__'][$db_type]; }
/** * @brief trigger_name, called_position을 주고 trigger 호출 **/ function triggerCall($trigger_name, $called_position, &$obj) { // 설치가 안되어 있다면 trigger call을 하지 않고 바로 return if (!Context::isInstalled()) { return new Object(); } $oModuleModel =& getModel('module'); $triggers = $oModuleModel->getTriggers($trigger_name, $called_position); if (!$triggers || !count($triggers)) { return new Object(); } foreach ($triggers as $item) { $module = $item->module; $type = $item->type; $called_method = $item->called_method; $oModule = null; $oModule =& getModule($module, $type); if (!$oModule || !method_exists($oModule, $called_method)) { continue; } $output = $oModule->{$called_method}($obj); if (is_object($output) && method_exists($output, 'toBool') && !$output->toBool()) { return $output; } unset($oModule); } return new Object(); }
// still no act means error if (!$this->act) { $this->error = 'msg_module_is_not_exists'; return; } // get type, kind $type = $xml_info->action->{$this->act}->type; $kind = strpos(strtolower($this->act), 'admin') !== false ? 'admin' : ''; if (!$kind && $this->module == 'admin') { $kind = 'admin'; } if ($this->module_info->use_mobile != "Y") { Mobile::setMobile(false); } // if(type == view, and case for using mobilephone) if ($type == "view" && Mobile::isFromMobilePhone() && Context::isInstalled()) { $orig_type = "view"; $type = "mobile"; } // // ad-hoc 끝!(ModuleHandler procModule()) // // 텍스타일뷰일 때만 실행... if (!($this->module == 'textyle' && ($type == 'view' || $type == 'mobile'))) { return; } // 예약 발행해야할 문서를 구한다. $now = date('YmdHis'); $oTextyleModel =& getModel('textyle'); $args->module_srl = $this->module_info->module_srl; $args->less_publish_date = $now;