public function check($file) { // TODO: 기능개선후 enable return TRUE; // disable if (!$file || !FileHandler::exists($file)) { return TRUE; } return self::_check($file); }
/** * excute the member method specified by $act variable * @return boolean true : success false : fail * */ function proc() { // pass if stop_proc is true if ($this->stop_proc) { debugPrint($this->message, 'ERROR'); return FALSE; } // trigger call $triggerOutput = ModuleHandler::triggerCall('moduleObject.proc', 'before', $this); if (!$triggerOutput->toBool()) { $this->setError($triggerOutput->getError()); $this->setMessage($triggerOutput->getMessage()); return FALSE; } // execute an addon(call called_position as before_module_proc) $called_position = 'before_module_proc'; $oAddonController = getController('addon'); $addon_file = $oAddonController->getCacheFilePath(Mobile::isFromMobilePhone() ? "mobile" : "pc"); if (FileHandler::exists($addon_file)) { include $addon_file; } if (isset($this->xml_info->action->{$this->act}) && method_exists($this, $this->act)) { // Check permissions if ($this->module_srl && !$this->grant->access) { $this->stop("msg_not_permitted_act"); return FALSE; } // integrate skin information of the module(change to sync skin info with the target module only by seperating its table) $is_default_skin = !Mobile::isFromMobilePhone() && $this->module_info->is_skin_fix == 'N' || Mobile::isFromMobilePhone() && $this->module_info->is_mskin_fix == 'N'; $usedSkinModule = !($this->module == 'page' && ($this->module_info->page_type == 'OUTSIDE' || $this->module_info->page_type == 'WIDGET')); if ($usedSkinModule && $is_default_skin && $this->module != 'admin' && strpos($this->act, 'Admin') === false && $this->module == $this->module_info->module) { $dir = Mobile::isFromMobilePhone() ? 'm.skins' : 'skins'; $valueName = Mobile::isFromMobilePhone() ? 'mskin' : 'skin'; $oModuleModel = getModel('module'); $skinType = Mobile::isFromMobilePhone() ? 'M' : 'P'; $skinName = $oModuleModel->getModuleDefaultSkin($this->module, $skinType); if ($this->module == 'page') { $this->module_info->{$valueName} = $skinName; } else { $isTemplatPath = strpos($this->getTemplatePath(), '/tpl/') !== FALSE; if (!$isTemplatPath) { $this->setTemplatePath(sprintf('%s%s/%s/', $this->module_path, $dir, $skinName)); } } } $oModuleModel = getModel('module'); $oModuleModel->syncSkinInfoToModuleInfo($this->module_info); Context::set('module_info', $this->module_info); // Run $output = $this->{$this->act}(); } else { return FALSE; } // trigger call $triggerOutput = ModuleHandler::triggerCall('moduleObject.proc', 'after', $this); if (!$triggerOutput->toBool()) { $this->setError($triggerOutput->getError()); $this->setMessage($triggerOutput->getMessage()); return FALSE; } // execute an addon(call called_position as after_module_proc) $called_position = 'after_module_proc'; $oAddonController = getController('addon'); $addon_file = $oAddonController->getCacheFilePath(Mobile::isFromMobilePhone() ? "mobile" : "pc"); if (FileHandler::exists($addon_file)) { include $addon_file; } if (is_a($output, 'Object') || is_subclass_of($output, 'Object')) { $this->setError($output->getError()); $this->setMessage($output->getMessage()); if (!$output->toBool()) { return FALSE; } } // execute api methos of the module if view action is and result is XMLRPC or JSON 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; }
/** * Preview a layout * @return void|Object (void : success, Object : fail) */ function dispLayoutPreview() { // admin check // this act is admin view but in normal view because do not load admin css/js files $logged_info = Context::get('logged_info'); if ($logged_info->is_admin != 'Y') { return $this->stop('msg_invalid_request'); } $layout_srl = Context::get('layout_srl'); $code = Context::get('code'); $code_css = Context::get('code_css'); if (!$layout_srl || !$code) { return new Object(-1, 'msg_invalid_request'); } // Get the layout information $oLayoutModel = getModel('layout'); $layout_info = $oLayoutModel->getLayout($layout_srl); if (!$layout_info) { return new Object(-1, 'msg_invalid_request'); } // Separately handle the layout if its type is faceoff if ($layout_info && $layout_info->type == 'faceoff') { $oLayoutModel->doActivateFaceOff($layout_info); } // Apply CSS directly Context::addHtmlHeader("<style type=\"text/css\" charset=\"UTF-8\">" . $code_css . "</style>"); // Set names and values of extra_vars to $layout_info if ($layout_info->extra_var_count) { foreach ($layout_info->extra_var as $var_id => $val) { $layout_info->{$var_id} = $val->value; } } // menu in layout information becomes an argument for Context:: set if ($layout_info->menu_count) { foreach ($layout_info->menu as $menu_id => $menu) { $menu->php_file = FileHandler::getRealPath($menu->php_file); if (FileHandler::exists($menu->php_file)) { include $menu->php_file; } Context::set($menu_id, $menu); } } Context::set('layout_info', $layout_info); Context::set('content', Context::getLang('layout_preview_content')); // Temporary save the codes $edited_layout_file = _XE_PATH_ . 'files/cache/layout/tmp.tpl'; FileHandler::writeFile($edited_layout_file, $code); // Compile $oTemplate =& TemplateHandler::getInstance(); $layout_path = $layout_info->path; $layout_file = 'layout'; $layout_tpl = $oTemplate->compile($layout_path, $layout_file, $edited_layout_file); Context::set('layout', 'none'); // Convert widgets and others $oContext =& Context::getInstance(); Context::set('layout_tpl', $layout_tpl); // Delete Temporary Files FileHandler::removeFile($edited_layout_file); $this->setTemplateFile('layout_preview'); }
/** * Migrate data after completing xml file extraction * @return void */ function procImporterAdminImport() { // Variable setting $type = Context::get('type'); $total = Context::get('total'); $cur = Context::get('cur'); $key = Context::get('key'); $user_id = Context::get('user_id'); $target_module = Context::get('target_module'); $guestbook_target_module = Context::get('guestbook_target_module'); $this->unit_count = Context::get('unit_count'); // Check if an index file exists $index_file = './files/cache/importer/' . $key . '/index'; if (!file_exists($index_file)) { return new Object(-1, 'msg_invalid_xml_file'); } switch ($type) { case 'ttxml': if (!$target_module) { return new Object(-1, 'msg_invalid_request'); } $oModuleModel = getModel('module'); $columnList = array('module_srl', 'module'); $target_module_info = $oModuleModel->getModuleInfoByModuleSrl($target_module, $columnList); $ttimporter = FileHandler::exists(_XE_PATH_ . 'modules/importer/ttimport.class.php'); if ($ttimporter) { require_once $ttimporter; } $oTT = new ttimport(); $cur = $oTT->importModule($key, $cur, $index_file, $this->unit_count, $target_module, $guestbook_target_module, $user_id, $target_module_info->module); break; case 'message': $cur = $this->importMessage($key, $cur, $index_file); break; case 'member': $cur = $this->importMember($key, $cur, $index_file); break; case 'module': // Check if the target module exists if (!$target_module) { return new Object(-1, 'msg_invalid_request'); } $cur = $this->importModule($key, $cur, $index_file, $target_module); break; } // Notify that all data completely extracted $this->add('type', $type); $this->add('total', $total); $this->add('cur', $cur); $this->add('key', $key); $this->add('target_module', $target_module); // When completing, success message appears and remove the cache files if ($total <= $cur) { $this->setMessage(sprintf(Context::getLang('msg_import_finished'), $cur, $total)); FileHandler::removeDir('./files/cache/importer/' . $key); } else { $this->setMessage(sprintf(Context::getLang('msg_importing'), $total, $cur)); } }
px;"></div> <?php if ($__Context->allow_fileupload) { ?> <?php $__tpl = TemplateHandler::getInstance(); echo $__tpl->compile('modules/editor/skins/ckeditor', 'file_upload.html'); } ?> <script> (function($){ "use strict"; // editor $(function(){ <?php if (!FileHandler::exists('common/js/plugins/ckeditor/ckeditor/config.js')) { ?> CKEDITOR.config.customConfig = '';<?php } ?> var settings = { ckeconfig: { height: '<?php echo $__Context->editor_height; ?> ', skin: '<?php echo $__Context->colorset; ?> ', contentsCss: '<?php
function procProfilerAdminDeleteLogFile() { $slowlog_files = array(_XE_PATH_ . 'files/_slowlog_addon.php', _XE_PATH_ . 'files/_slowlog_trigger.php', _XE_PATH_ . 'files/_slowlog_widget.php', _XE_PATH_ . 'files/_slowlog_query.php'); foreach ($slowlog_files as $file) { $slowlog_file = FileHandler::exists($file); if ($slowlog_file === false) { continue; } FileHandler::removeFile($file); } $this->setMessage('msg_profiler_slowlog_file_arranged'); $this->setRedirectUrl(Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispProfilerAdminConfig')); }
function _getMyNotifyList($member_srl = null, $page = 1, $readed = 'N') { if (!$member_srl) { $logged_info = Context::get('logged_info'); if (!$logged_info) { return array(); } $member_srl = $logged_info->member_srl; } $flag_path = \RX_BASEDIR . 'files/cache/ncenterlite/new_notify/' . getNumberingPath($member_srl) . $member_srl . '.php'; if (FileHandler::exists($flag_path) && $page <= 1) { $output = (require_once $flag_path); if (is_object($output)) { $output->flag_exists = true; return $output; } } $args = new stdClass(); $args->member_srl = $member_srl; $args->page = $page ? $page : 1; if ($readed) { $args->readed = $readed; } $output = executeQueryArray('ncenterlite.getNotifyList', $args); $output->flag_exists = false; if (!$output->data) { $output->data = array(); } return $output; }
/** * Initialization, it sets DB information, request arguments and so on. * * @see This function should be called only once * @return void */ public function init() { // fix missing HTTP_RAW_POST_DATA in PHP 5.6 and above if (!isset($GLOBALS['HTTP_RAW_POST_DATA']) && version_compare(PHP_VERSION, '5.6.0', '>=') === TRUE) { $GLOBALS['HTTP_RAW_POST_DATA'] = file_get_contents("php://input"); // If content is not XML or JSON, unset if (!preg_match('/^[\\<\\{\\[]/', $GLOBALS['HTTP_RAW_POST_DATA'])) { unset($GLOBALS['HTTP_RAW_POST_DATA']); } } // set context variables in $GLOBALS (backward compatibility) $GLOBALS['__Context__'] = $this; $GLOBALS['lang'] =& $this->lang; $this->_COOKIE = $_COOKIE; // 20140429 editor/image_link $this->_checkGlobalVars(); $this->setRequestMethod(''); $this->_setXmlRpcArgument(); $this->_setJSONRequestArgument(); $this->_setRequestArgument(); $this->_setUploadedArgument(); $this->loadDBInfo(); if ($this->db_info->use_sitelock == 'Y') { if (is_array($this->db_info->sitelock_whitelist)) { $whitelist = $this->db_info->sitelock_whitelist; } if (!IpFilter::filter($whitelist)) { $title = $this->db_info->sitelock_title ? $this->db_info->sitelock_title : 'Maintenance in progress...'; $message = $this->db_info->sitelock_message; define('_XE_SITELOCK_', TRUE); define('_XE_SITELOCK_TITLE_', $title); define('_XE_SITELOCK_MESSAGE_', $message); header("HTTP/1.1 403 Forbidden"); if (FileHandler::exists(_XE_PATH_ . 'common/tpl/sitelock.user.html')) { include _XE_PATH_ . 'common/tpl/sitelock.user.html'; } else { include _XE_PATH_ . 'common/tpl/sitelock.html'; } exit; } } // If XE is installed, get virtual site information if (self::isInstalled()) { $oModuleModel = getModel('module'); $site_module_info = $oModuleModel->getDefaultMid(); if (!isset($site_module_info)) { $site_module_info = new stdClass(); } // if site_srl of site_module_info is 0 (default site), compare the domain to default_url of db_config if ($site_module_info->site_srl == 0 && $site_module_info->domain != $this->db_info->default_url) { $site_module_info->domain = $this->db_info->default_url; } self::set('site_module_info', $site_module_info); if ($site_module_info->site_srl && isSiteID($site_module_info->domain)) { self::set('vid', $site_module_info->domain, TRUE); } if (!isset($this->db_info)) { $this->db_info = new stdClass(); } $this->db_info->lang_type = $site_module_info->default_language; if (!$this->db_info->lang_type) { $this->db_info->lang_type = 'ko'; } if (!$this->db_info->use_db_session) { $this->db_info->use_db_session = 'N'; } } // Load Language File $lang_supported = self::loadLangSelected(); // Retrieve language type set in user's cookie if ($this->lang_type = self::get('l')) { if ($_COOKIE['lang_type'] != $this->lang_type) { setcookie('lang_type', $this->lang_type, $_SERVER['REQUEST_TIME'] + 3600 * 24 * 1000, '/'); } } elseif ($_COOKIE['lang_type']) { $this->lang_type = $_COOKIE['lang_type']; } // If it's not exists, follow default language type set in db_info if (!$this->lang_type) { $this->lang_type = $this->db_info->lang_type; } // if still lang_type has not been set or has not-supported type , set as Korean. if (!$this->lang_type) { $this->lang_type = 'ko'; } if (is_array($lang_supported) && !isset($lang_supported[$this->lang_type])) { $this->lang_type = 'ko'; } self::set('lang_supported', $lang_supported); self::setLangType($this->lang_type); // Load languages $this->lang = Rhymix\Framework\Lang::getInstance($this->lang_type); $this->lang->loadDirectory(RX_BASEDIR . 'common/lang', 'common'); $this->lang->loadDirectory(RX_BASEDIR . 'modules/module/lang', 'module'); // set session handler if (self::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')); } // start session if it was previously started $session_name = session_name(); $session_id = NULL; if ($session_id = $_POST[$session_name]) { session_id($session_id); } else { $session_id = $_COOKIE[$session_name]; } if ($session_id !== NULL || $this->db_info->delay_session != 'Y') { $this->setCacheControl(0, false); session_start(); } else { ob_start(); $this->setCacheControl(-1, true); register_shutdown_function(array($this, 'checkSessionStatus')); $_SESSION = array(); } // set authentication information in Context and session if (self::isInstalled()) { $oModuleModel = getModel('module'); $oModuleModel->loadModuleExtends(); $oMemberModel = getModel('member'); $oMemberController = getController('member'); if ($oMemberController && $oMemberModel) { // if signed in, validate it. if ($oMemberModel->isLogged()) { $oMemberController->setSessionInfo(); } elseif ($_COOKIE['xeak']) { $oMemberController->doAutologin(); } self::set('is_logged', $oMemberModel->isLogged()); if ($oMemberModel->isLogged()) { self::set('logged_info', $oMemberModel->getLoggedInfo()); } } } // check if using rewrite module $this->allow_rewrite = $this->db_info->use_rewrite == 'Y' ? TRUE : FALSE; // set locations for javascript use $url = array(); $current_url = self::getRequestUri(); if ($_SERVER['REQUEST_METHOD'] == 'GET') { if ($this->get_vars) { $url = array(); foreach ($this->get_vars as $key => $val) { if (is_array($val) && count($val) > 0) { foreach ($val as $k => $v) { $url[] = $key . '[' . $k . ']=' . urlencode($v); } } elseif ($val) { $url[] = $key . '=' . urlencode($val); } } $current_url = self::getRequestUri(); if ($url) { $current_url .= '?' . join('&', $url); } } else { $current_url = self::getUrl(); } } else { $current_url = self::getRequestUri(); } self::set('current_url', $current_url); self::set('request_uri', self::getRequestUri()); if (strpos($current_url, 'xn--') !== FALSE) { self::set('current_url', self::decodeIdna($current_url)); } if (strpos(self::getRequestUri(), 'xn--') !== FALSE) { self::set('request_uri', self::decodeIdna(self::getRequestUri())); } }
/** * Fetch a stored variable from the cache * * @param string $key The $key used to store the value. * @param int $modified_time Not used * @return false|mixed Return false on failure. Return the string associated with the $key on success. */ function get($key, $modified_time = 0) { if (!($cache_file = FileHandler::exists($this->getCacheFileName($key)))) { return false; } if ($modified_time > 0 && filemtime($cache_file) < $modified_timed) { FileHandler::removeFile($cache_file); return false; } $content = (include $cache_file); return unserialize(stripslashes($content)); }
/** * Initialization, it sets DB information, request arguments and so on. * * @see This function should be called only once * @return void */ function init() { if (!isset($GLOBALS['HTTP_RAW_POST_DATA']) && version_compare(PHP_VERSION, '5.6.0', '>=') === true) { if (simplexml_load_string(file_get_contents("php://input")) !== false) { $GLOBALS['HTTP_RAW_POST_DATA'] = file_get_contents("php://input"); } if (strpos($_SERVER['CONTENT_TYPE'], 'json') || strpos($_SERVER['HTTP_CONTENT_TYPE'], 'json')) { $GLOBALS['HTTP_RAW_POST_DATA'] = file_get_contents("php://input"); } } // set context variables in $GLOBALS (to use in display handler) $this->context =& $GLOBALS['__Context__']; $this->context->lang =& $GLOBALS['lang']; $this->context->_COOKIE = $_COOKIE; // 20140429 editor/image_link $this->_checkGlobalVars(); $this->setRequestMethod(''); $this->_setXmlRpcArgument(); $this->_setJSONRequestArgument(); $this->_setRequestArgument(); $this->_setUploadedArgument(); $this->loadDBInfo(); if ($this->db_info->use_sitelock == 'Y') { if (is_array($this->db_info->sitelock_whitelist)) { $whitelist = $this->db_info->sitelock_whitelist; } if (!IpFilter::filter($whitelist)) { $title = $this->db_info->sitelock_title ? $this->db_info->sitelock_title : 'Maintenance in progress...'; $message = $this->db_info->sitelock_message; define('_XE_SITELOCK_', TRUE); define('_XE_SITELOCK_TITLE_', $title); define('_XE_SITELOCK_MESSAGE_', $message); header("HTTP/1.1 403 Forbidden"); if (FileHandler::exists(_XE_PATH_ . 'common/tpl/sitelock.user.html')) { include _XE_PATH_ . 'common/tpl/sitelock.user.html'; } else { include _XE_PATH_ . 'common/tpl/sitelock.html'; } exit; } } // If XE is installed, get virtual site information if (self::isInstalled()) { $oModuleModel = getModel('module'); $site_module_info = $oModuleModel->getDefaultMid(); if (!isset($site_module_info)) { $site_module_info = new stdClass(); } // if site_srl of site_module_info is 0 (default site), compare the domain to default_url of db_config if ($site_module_info->site_srl == 0 && $site_module_info->domain != $this->db_info->default_url) { $site_module_info->domain = $this->db_info->default_url; } $this->set('site_module_info', $site_module_info); if ($site_module_info->site_srl && isSiteID($site_module_info->domain)) { $this->set('vid', $site_module_info->domain, TRUE); } if (!isset($this->db_info)) { $this->db_info = new stdClass(); } $this->db_info->lang_type = $site_module_info->default_language; if (!$this->db_info->lang_type) { $this->db_info->lang_type = 'en'; } if (!$this->db_info->use_db_session) { $this->db_info->use_db_session = 'N'; } } // Load Language File $lang_supported = $this->loadLangSelected(); // Retrieve language type set in user's cookie if ($this->lang_type = $this->get('l')) { if ($_COOKIE['lang_type'] != $this->lang_type) { setcookie('lang_type', $this->lang_type, $_SERVER['REQUEST_TIME'] + 3600 * 24 * 1000, '/'); } } elseif ($_COOKIE['lang_type']) { $this->lang_type = $_COOKIE['lang_type']; } // If it's not exists, follow default language type set in db_info if (!$this->lang_type) { $this->lang_type = $this->db_info->lang_type; } // if still lang_type has not been set or has not-supported type , set as English. if (!$this->lang_type) { $this->lang_type = 'en'; } if (is_array($lang_supported) && !isset($lang_supported[$this->lang_type])) { $this->lang_type = 'en'; } $this->set('lang_supported', $lang_supported); $this->setLangType($this->lang_type); // load module module's language file according to language setting $this->loadLang(_XE_PATH_ . 'modules/module/lang'); // set session handler if (self::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')); } if ($sess = $_POST[session_name()]) { session_id($sess); } session_start(); // set authentication information in Context and session if (self::isInstalled()) { $oModuleModel = getModel('module'); $oModuleModel->loadModuleExtends(); $oMemberModel = getModel('member'); $oMemberController = getController('member'); if ($oMemberController && $oMemberModel) { // if signed in, validate it. if ($oMemberModel->isLogged()) { $oMemberController->setSessionInfo(); } elseif ($_COOKIE['xeak']) { $oMemberController->doAutologin(); } $this->set('is_logged', $oMemberModel->isLogged()); $this->set('logged_info', $oMemberModel->getLoggedInfo()); } } // load common language file $this->lang =& $GLOBALS['lang']; $this->loadLang(_XE_PATH_ . 'common/lang/'); // check if using rewrite module $this->allow_rewrite = $this->db_info->use_rewrite == 'Y' ? TRUE : FALSE; // set locations for javascript use $url = array(); $current_url = self::getRequestUri(); if ($_SERVER['REQUEST_METHOD'] == 'GET') { if ($this->get_vars) { $url = array(); foreach ($this->get_vars as $key => $val) { if (is_array($val) && count($val) > 0) { foreach ($val as $k => $v) { $url[] = $key . '[' . $k . ']=' . urlencode($v); } } elseif ($val) { $url[] = $key . '=' . urlencode($val); } } $current_url = self::getRequestUri(); if ($url) { $current_url .= '?' . join('&', $url); } } else { $current_url = $this->getUrl(); } } else { $current_url = self::getRequestUri(); } $this->set('current_url', $current_url); $this->set('request_uri', self::getRequestUri()); if (strpos($current_url, 'xn--') !== FALSE) { $this->set('current_url', self::decodeIdna($current_url)); } if (strpos(self::getRequestUri(), 'xn--') !== FALSE) { $this->set('request_uri', self::decodeIdna(self::getRequestUri())); } }
public function getSiteDefaultLayout($viewType = 'P', $siteSrl = 0) { $target = $viewType == 'M' ? 'mlayout_srl' : 'layout_srl'; $designInfoFile = sprintf(_XE_PATH_ . 'files/site_design/design_%s.php', $siteSrl); if (FileHandler::exists($designInfoFile)) { include $designInfoFile; } if (!$designInfo || !$designInfo->{$target}) { return 0; } $oModel = getModel('layout'); $layout_info = $oModel->getLayout($designInfo->{$target}); if (!$layout_info) { return 0; } return $designInfo->{$target}; }
/** * Enforce site lock. */ private static function enforceSiteLock() { // Allow if the current user is logged in as administrator, or trying to log in. $logged_info = self::get('logged_info'); if ($logged_info && $logged_info->is_admin === 'Y') { return; } elseif (in_array(self::get('act'), array('procMemberLogin', 'dispMemberLogout'))) { return; } // Allow if the current user is in the list of allowed IPs. if (Rhymix\Framework\Filters\IpFilter::inRanges(RX_CLIENT_IP, config('lock.allow'))) { return; } // Set headers and constants for backward compatibility. header('HTTP/1.1 503 Service Unavailable'); define('_XE_SITELOCK_', TRUE); define('_XE_SITELOCK_TITLE_', config('lock.title') ?: self::getLang('admin.sitelock_in_use')); define('_XE_SITELOCK_MESSAGE_', config('lock.message')); unset($_SESSION['XE_VALIDATOR_RETURN_URL']); // Load the sitelock template. if (FileHandler::exists(RX_BASEDIR . 'common/tpl/sitelock.user.html')) { include RX_BASEDIR . 'common/tpl/sitelock.user.html'; } else { self::displayErrorPage(_XE_SITELOCK_TITLE_, _XE_SITELOCK_MESSAGE_, 503); } exit; }
/** * Execute update * * @return Object */ function moduleUpdate() { $oDB = DB::getInstance(); $oModuleModel = getModel('module'); $oModuleController = getController('module'); if (!FileHandler::exists('./modules/autoinstall/schemas/autoinstall_installed_packages.xml') && $oDB->isTableExists("autoinstall_installed_packages")) { $oDB->dropTable("autoinstall_installed_packages"); } if (!FileHandler::exists('./modules/autoinstall/schemas/autoinstall_remote_categories.xml') && $oDB->isTableExists("autoinstall_remote_categories")) { $oDB->dropTable("autoinstall_remote_categories"); } // 2011.08.08 add column 'list_order' in 'ai_remote_categories if (!$oDB->isColumnExists('ai_remote_categories', 'list_order')) { $oDB->addColumn('ai_remote_categories', 'list_order', 'number', 11, NULL, TRUE); $oDB->addIndex('ai_remote_categories', 'idx_list_order', array('list_order')); } // 2011. 08. 08 set _XE_DOWNLOAD_SERVER_ at module config $config = $oModuleModel->getModuleConfig('autoinstall'); if (!isset($config->downloadServer)) { $config->downloadServer = _XE_DOWNLOAD_SERVER_; $oModuleController->insertModuleConfig('autoinstall', $config); } // 2012.11.12 add column 'have_instance' in autoinstall_packages if (!$oDB->isColumnExists('autoinstall_packages', 'have_instance')) { $oDB->addColumn('autoinstall_packages', 'have_instance', 'char', '1', 'N', TRUE); } return new Object(0, 'success_updated'); }
/** * @brief Install with received information */ function procInstall() { // Check if it is already installed if (Context::isInstalled()) { return new Object(-1, 'msg_already_installed'); } // Assign a temporary administrator when installing $logged_info = new stdClass(); $logged_info->is_admin = 'Y'; Context::set('logged_info', $logged_info); // check install config if (Context::get('install_config')) { $db_info = $this->_makeDbInfoByInstallConfig(); } else { if (FileHandler::exists($this->db_tmp_config_file)) { include $this->db_tmp_config_file; } if (FileHandler::exists($this->etc_tmp_config_file)) { include $this->etc_tmp_config_file; } } // Set DB type and information Context::setDBInfo($db_info); // Create DB Instance $oDB =& DB::getInstance(); // Check if available to connect to the DB if (!$oDB->isConnected()) { return $oDB->getError(); } // Install all the modules try { $oDB->begin(); $this->installDownloadedModule(); $oDB->commit(); } catch (Exception $e) { $oDB->rollback(); return new Object(-1, $e->getMessage()); } // Create a config file if (!$this->makeConfigFile()) { return new Object(-1, 'msg_install_failed'); } // load script $scripts = FileHandler::readDir(_XE_PATH_ . 'modules/install/script', '/(\\.php)$/'); if (count($scripts) > 0) { sort($scripts); foreach ($scripts as $script) { $script_path = FileHandler::getRealPath('./modules/install/script/'); $output = (include $script_path . $script); } } // save selected lang info $oInstallAdminController = getAdminController('install'); $oInstallAdminController->saveLangSelected(array(Context::getLangType())); // Display a message that installation is completed $this->setMessage('msg_install_completed'); unset($_SESSION['use_rewrite']); if (!in_array(Context::getRequestMethod(), array('XMLRPC', 'JSON'))) { $returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl(''); header('location:' . $returnUrl); return new Object(); } }
/** * Return theme info * @param string $theme_name * @param array $layout_list * @return object */ function getThemeInfo($theme_name, $layout_list = NULL) { if ($GLOBALS['__ThemeInfo__'][$theme_name]) { return $GLOBALS['__ThemeInfo__'][$theme_name]; } $info_file = _XE_PATH_ . 'themes/' . $theme_name . '/conf/info.xml'; if (!file_exists($info_file)) { return; } $oXmlParser = new XmlParser(); $_xml_obj = $oXmlParser->loadXmlFile($info_file); if (!$_xml_obj->theme) { return; } $xml_obj = $_xml_obj->theme; // 스킨이름 $theme_info = new stdClass(); $theme_info->name = $theme_name; $theme_info->title = $xml_obj->title->body; $thumbnail = './themes/' . $theme_name . '/thumbnail.png'; $theme_info->thumbnail = FileHandler::exists($thumbnail) ? $thumbnail : NULL; $theme_info->version = $xml_obj->version->body; $date_obj = new stdClass(); sscanf($xml_obj->date->body, '%d-%d-%d', $date_obj->y, $date_obj->m, $date_obj->d); $theme_info->date = sprintf('%04d%02d%02d', $date_obj->y, $date_obj->m, $date_obj->d); $theme_info->description = $xml_obj->description->body; $theme_info->path = './themes/' . $theme_name . '/'; if (!is_array($xml_obj->publisher)) { $publisher_list = array(); $publisher_list[] = $xml_obj->publisher; } else { $publisher_list = $xml_obj->publisher; } $theme_info->publisher = array(); foreach ($publisher_list as $publisher) { $publisher_obj = new stdClass(); $publisher_obj->name = $publisher->name->body; $publisher_obj->email_address = $publisher->attrs->email_address; $publisher_obj->homepage = $publisher->attrs->link; $theme_info->publisher[] = $publisher_obj; } $layout = $xml_obj->layout; $layout_path = $layout->directory->attrs->path; $layout_parse = explode('/', $layout_path); $layout_info = new stdClass(); switch ($layout_parse[1]) { case 'themes': $layout_info->name = $theme_name . '|@|' . $layout_parse[count($layout_parse) - 1]; break; case 'layouts': $layout_info->name = $layout_parse[count($layout_parse) - 1]; break; } $layout_info->title = $layout_parse[count($layout_parse) - 1]; $layout_info->path = $layout_path; $site_info = Context::get('site_module_info'); // check layout instance $is_new_layout = TRUE; $oLayoutModel = getModel('layout'); $layout_info_list = array(); $layout_list = $oLayoutModel->getLayoutList($site_info->site_srl); if ($layout_list) { foreach ($layout_list as $val) { if ($val->layout == $layout_info->name) { $is_new_layout = FALSE; $layout_info->layout_srl = $val->layout_srl; break; } } } if ($is_new_layout) { $site_module_info = Context::get('site_module_info'); $args = new stdClass(); $args->site_srl = (int) $site_module_info->site_srl; $args->layout_srl = getNextSequence(); $args->layout = $layout_info->name; $args->title = $layout_info->title; $args->layout_type = "P"; // Insert into the DB $oLayoutAdminController = getAdminController('layout'); $output = $oLayoutAdminController->insertLayout($args); $layout_info->layout_srl = $args->layout_srl; } $theme_info->layout_info = $layout_info; $skin_infos = $xml_obj->skininfos; if (is_array($skin_infos->skininfo)) { $skin_list = $skin_infos->skininfo; } else { $skin_list = array($skin_infos->skininfo); } $oModuleModel = getModel('module'); $skins = array(); foreach ($skin_list as $val) { $skin_info = new stdClass(); unset($skin_parse); $skin_parse = explode('/', $val->directory->attrs->path); switch ($skin_parse[1]) { case 'themes': $is_theme = TRUE; $module_name = $skin_parse[count($skin_parse) - 1]; $skin_info->name = $theme_name . '|@|' . $module_name; break; case 'modules': $is_theme = FALSE; $module_name = $skin_parse[2]; $skin_info->name = $skin_parse[count($skin_parse) - 1]; break; } $skin_info->path = $val->directory->attrs->path; $skin_info->is_theme = $is_theme; $skins[$module_name] = $skin_info; if ($is_theme) { if (!$GLOBALS['__ThemeModuleSkin__'][$module_name]) { $GLOBALS['__ThemeModuleSkin__'][$module_name] = array(); $GLOBALS['__ThemeModuleSkin__'][$module_name]['skins'] = array(); $moduleInfo = $oModuleModel->getModuleInfoXml($module_name); $GLOBALS['__ThemeModuleSkin__'][$module_name]['title'] = $moduleInfo->title; } $GLOBALS['__ThemeModuleSkin__'][$module_name]['skins'][$skin_info->name] = $oModuleModel->loadSkinInfo($skin_info->path, '', ''); } } $theme_info->skin_infos = $skins; $GLOBALS['__ThemeInfo__'][$theme_name] = $theme_info; return $theme_info; }
/** * Produce HTML compliant content given a module object.\n * @param ModuleObject $oModule the module object * @return string compiled template string */ function toDoc(&$oModule) { $oTemplate = TemplateHandler::getInstance(); // compile module tpl // deprecated themes skin $template_path = $oModule->getTemplatePath(); if (!is_dir($template_path)) { if ($oModule->module_info->module == $oModule->module) { $skin = $oModule->origin_module_info->skin; } else { $skin = $oModule->module_config->skin; } if (Context::get('module') != 'admin' && strpos(Context::get('act'), 'Admin') === false) { if ($skin && is_string($skin)) { $theme_skin = explode('|@|', $skin); $template_path = $oModule->getTemplatePath(); if (count($theme_skin) == 2) { $theme_path = sprintf('./themes/%s', $theme_skin[0]); // FIXME $theme_path $theme_path $theme_path ?? if (substr($theme_path, 0, strlen($theme_path)) != $theme_path) { $template_path = sprintf('%s/modules/%s/', $theme_path, $theme_skin[1]); } } } else { $template_path = $oModule->getTemplatePath(); } } else { $template_path = $oModule->getTemplatePath(); } } $tpl_file = $oModule->getTemplateFile(); $output = $oTemplate->compile($template_path, $tpl_file); // add .x div for adminitration pages if (Context::getResponseMethod() == 'HTML') { if (Context::get('module') != 'admin' && strpos(Context::get('act'), 'Admin') > 0 && Context::get('act') != 'dispPageAdminContentModify' && Context::get('act') != 'dispPageAdminMobileContentModify') { $output = '<div class="x">' . $output . '</div>'; } if (Context::get('layout') != 'none') { if (__DEBUG__ == 3) { $start = getMicroTime(); } Context::set('content', $output, false); $layout_path = $oModule->getLayoutPath(); $layout_file = $oModule->getLayoutFile(); $edited_layout_file = $oModule->getEditedLayoutFile(); // get the layout information currently requested $oLayoutModel = getModel('layout'); $layout_info = Context::get('layout_info'); $layout_srl = $layout_info->layout_srl; // compile if connected to the layout if ($layout_srl > 0) { // handle separately if the layout is faceoff if ($layout_info && $layout_info->type == 'faceoff') { $oLayoutModel->doActivateFaceOff($layout_info); Context::set('layout_info', $layout_info); } // search if the changes CSS exists in the admin layout edit window $edited_layout_css = $oLayoutModel->getUserLayoutCss($layout_srl); if (FileHandler::exists($edited_layout_css)) { Context::loadFile(array($edited_layout_css, 'all', '', 100)); } } if (!$layout_path) { $layout_path = './common/tpl'; } if (!$layout_file) { $layout_file = 'default_layout'; } $output = $oTemplate->compile($layout_path, $layout_file, $edited_layout_file); // if popup_layout, remove admin bar. $realLayoutPath = FileHandler::getRealPath($layout_path); if (substr_compare($realLayoutPath, '/', -1) !== 0) { $realLayoutPath .= '/'; } $pathInfo = pathinfo($layout_file); $onlyLayoutFile = $pathInfo['filename']; if ($realLayoutPath === _XE_PATH_ . 'common/tpl/' && $onlyLayoutFile === 'popup_layout') { Context::set('admin_bar', 'false'); } // DISABLE ADMIN BAR Context::set('admin_bar', 'false'); if (__DEBUG__ == 3) { $GLOBALS['__layout_compile_elapsed__'] = getMicroTime() - $start; } if (stripos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE && (Context::get('_use_ssl') == 'optional' || Context::get('_use_ssl') == 'always')) { Context::addHtmlFooter('<iframe id="xeTmpIframe" name="xeTmpIframe" style="width:1px;height:1px;position:absolute;top:-2px;left:-2px;"></iframe>'); } } } return $output; }
/** * display contents from executed module * @param ModuleObject $oModule module instance * @return void * */ function displayContent($oModule = NULL) { // If the module is not set or not an object, set error if (!$oModule || !is_object($oModule)) { $this->error = 'msg_module_is_not_exists'; $this->httpStatusCode = '404'; } // If connection to DB has a problem even though it's not install module, set error if ($this->module != 'install' && isset($GLOBALS['__DB__']) && $GLOBALS['__DB__'][Context::getDBType()]->isConnected() == FALSE) { $this->error = 'msg_dbconnect_failed'; } // Call trigger after moduleHandler proc $output = ModuleHandler::triggerCall('moduleHandler.proc', 'after', $oModule); if (!$output->toBool()) { $this->error = $output->getMessage(); } // Use message view object, if HTML call $methodList = array('XMLRPC' => 1, 'JSON' => 1, 'JS_CALLBACK' => 1); if (!isset($methodList[Context::getRequestMethod()])) { if ($_SESSION['XE_VALIDATOR_RETURN_URL']) { $display_handler = new DisplayHandler(); $display_handler->_debugOutput(); header('location:' . $_SESSION['XE_VALIDATOR_RETURN_URL']); return; } // If error occurred, handle it if ($this->error) { // display content with message module instance $type = Mobile::isFromMobilePhone() ? 'mobile' : 'view'; $oMessageObject = ModuleHandler::getModuleInstance('message', $type); $oMessageObject->setError(-1); $oMessageObject->setMessage($this->error); $oMessageObject->dispMessage(); if ($oMessageObject->getHttpStatusCode() && $oMessageObject->getHttpStatusCode() != '200') { $this->_setHttpStatusMessage($oMessageObject->getHttpStatusCode()); $oMessageObject->setTemplateFile('http_status_code'); } // If module was called normally, change the templates of the module into ones of the message view module if ($oModule) { $oModule->setTemplatePath($oMessageObject->getTemplatePath()); $oModule->setTemplateFile($oMessageObject->getTemplateFile()); // Otherwise, set message instance as the target module } else { $oModule = $oMessageObject; } $this->_clearErrorSession(); } // Check if layout_srl exists for the module if (Mobile::isFromMobilePhone()) { $layout_srl = $oModule->module_info->mlayout_srl; } else { $layout_srl = $oModule->module_info->layout_srl; } // if layout_srl is rollback by module, set default layout if ($layout_srl == -1) { $viewType = Mobile::isFromMobilePhone() ? 'M' : 'P'; $oLayoutAdminModel = getAdminModel('layout'); $layout_srl = $oLayoutAdminModel->getSiteDefaultLayout($viewType, $oModule->module_info->site_srl); } if ($layout_srl && !$oModule->getLayoutFile()) { // If layout_srl exists, get information of the layout, and set the location of layout_path/ layout_file $oLayoutModel = getModel('layout'); $layout_info = $oLayoutModel->getLayout($layout_srl); if ($layout_info) { // Input extra_vars into $layout_info if ($layout_info->extra_var_count) { foreach ($layout_info->extra_var as $var_id => $val) { if ($val->type == 'image') { if (strncmp('./files/attach/images/', $val->value, 22) === 0) { $val->value = Context::getRequestUri() . substr($val->value, 2); } } $layout_info->{$var_id} = $val->value; } } // Set menus into context if ($layout_info->menu_count) { foreach ($layout_info->menu as $menu_id => $menu) { // set default menu set(included home menu) if (!$menu->menu_srl || $menu->menu_srl == -1) { $oMenuAdminController = getAdminController('menu'); $homeMenuCacheFile = $oMenuAdminController->getHomeMenuCacheFile(); if (FileHandler::exists($homeMenuCacheFile)) { include $homeMenuCacheFile; } if (!$menu->menu_srl) { $menu->xml_file = str_replace('.xml.php', $homeMenuSrl . '.xml.php', $menu->xml_file); $menu->php_file = str_replace('.php', $homeMenuSrl . '.php', $menu->php_file); $layout_info->menu->{$menu_id}->menu_srl = $homeMenuSrl; } else { $menu->xml_file = str_replace($menu->menu_srl, $homeMenuSrl, $menu->xml_file); $menu->php_file = str_replace($menu->menu_srl, $homeMenuSrl, $menu->php_file); } } $php_file = FileHandler::exists($menu->php_file); if ($php_file) { include $php_file; } Context::set($menu_id, $menu); } } // Set layout information into context Context::set('layout_info', $layout_info); $oModule->setLayoutPath($layout_info->path); $oModule->setLayoutFile('layout'); // If layout was modified, use the modified version $edited_layout = $oLayoutModel->getUserLayoutHtml($layout_info->layout_srl); if (file_exists($edited_layout)) { $oModule->setEditedLayoutFile($edited_layout); } } } $isLayoutDrop = Context::get('isLayoutDrop'); if ($isLayoutDrop) { $kind = stripos($this->act, 'admin') !== FALSE ? 'admin' : ''; if ($kind == 'admin') { $oModule->setLayoutFile('popup_layout'); } else { $oModule->setLayoutPath('common/tpl'); $oModule->setLayoutFile('default_layout'); } } } // Display contents $oDisplayHandler = new DisplayHandler(); $oDisplayHandler->printContent($oModule); }
/** * user layout html * @param int $layout_srl * @return string */ function getUserLayoutHtml($layout_srl) { $src = $this->getUserLayoutPath($layout_srl) . 'layout.html'; if ($this->useUserLayoutTemp == 'temp') { $temp = $this->getUserLayoutTempHtml($layout_srl); if (FileHandler::exists($temp) === FALSE) { FileHandler::copyFile($src, $temp); } return $temp; } return $src; }
/** * Enforce site lock. */ private static function enforceSiteLock() { // Allow if the current user is logged in as administrator, or trying to log in. $logged_info = self::get('logged_info'); if ($logged_info && $logged_info->is_admin === 'Y') { return; } elseif (in_array(self::get('act'), array('procMemberLogin', 'dispMemberLogout'))) { return; } // Allow if the current user is in the list of allowed IPs. $allowed_list = config('lock.allow'); foreach ($allowed_list as $allowed_ip) { if (Rhymix\Framework\IpFilter::inRange(RX_CLIENT_IP, $allowed_ip)) { return; } } // Set headers and constants for backward compatibility. header('HTTP/1.1 503 Service Unavailable'); define('_XE_SITELOCK_', TRUE); define('_XE_SITELOCK_TITLE_', config('lock.title') ?: self::getLang('admin.sitelock_in_use')); define('_XE_SITELOCK_MESSAGE_', config('lock.message')); unset($_SESSION['XE_VALIDATOR_RETURN_URL']); // Load the sitelock template. if (FileHandler::exists(RX_BASEDIR . 'common/tpl/sitelock.user.html')) { include RX_BASEDIR . 'common/tpl/sitelock.user.html'; } else { self::setBrowserTitle(self::getSiteTitle()); $oMessageObject = getView('message'); $oMessageObject->setHttpStatusCode(503); $oMessageObject->setError(-1); $oMessageObject->setMessage(_XE_SITELOCK_TITLE_); $oMessageObject->dispMessage(); $oModuleHandler = new ModuleHandler(); $oModuleHandler->displayContent($oMessageObject); } exit; }