/** * @brief DB settings and connect/close **/ function _setDBInfo() { $db_info = Context::getDBInfo(); $this->database = $db_info->master_db["db_database"]; $this->prefix = $db_info->master_db["db_table_prefix"]; //if(!substr($this->prefix,-1)!='_') $this->prefix .= '_'; }
/** * Get current mobile mode * * @return bool */ function _isFromMobilePhone() { if ($this->ismobile !== null) { return $this->ismobile; } $db_info = Context::getDBInfo(); if ($db_info->use_mobile_view != "Y" || Context::get('full_browse') || $_COOKIE["FullBrowse"]) { return $this->ismobile = false; } $xe_web_path = Context::pathToUrl(_XE_PATH_); // default setting. if there is cookie for a device, XE do not have to check if it is mobile or not and it will enhance performace of the server. $this->ismobile = FALSE; $m = Context::get('m'); if (strlen($m) == 1) { if ($m == "1") { $this->ismobile = true; } elseif ($m == "0") { $this->ismobile = false; } } elseif (isset($_COOKIE['mobile'])) { if ($_COOKIE['user-agent'] == md5($_SERVER['HTTP_USER_AGENT'])) { if ($_COOKIE['mobile'] == 'true') { $this->ismobile = true; } else { $this->ismobile = false; } } else { $this->ismobile = FALSE; setcookie("mobile", FALSE, 0, $xe_web_path); setcookie("user-agent", FALSE, 0, $xe_web_path); if (!$this->isMobilePadCheckByAgent() && $this->isMobileCheckByAgent()) { $this->ismobile = TRUE; } } } else { if ($this->isMobilePadCheckByAgent()) { $this->ismobile = FALSE; } else { if ($this->isMobileCheckByAgent()) { $this->ismobile = TRUE; } } } if ($this->ismobile !== NULL) { if ($this->ismobile == TRUE) { if ($_COOKIE['mobile'] != 'true') { $_COOKIE['mobile'] = 'true'; setcookie("mobile", 'true', 0, $xe_web_path); } } elseif ($_COOKIE['mobile'] != 'false') { $_COOKIE['mobile'] = 'false'; setcookie("mobile", 'false', 0, $xe_web_path); } if ($_COOKIE['user-agent'] != md5($_SERVER['HTTP_USER_AGENT'])) { setcookie("user-agent", md5($_SERVER['HTTP_USER_AGENT']), 0, $xe_web_path); } } return $this->ismobile; }
/** * @brief DB정보 설정 및 connect/ close **/ function _setDBInfo() { $db_info = Context::getDBInfo(); $this->database = $db_info->db_database; $this->prefix = $db_info->db_table_prefix; if (!substr($this->prefix, -1) != '_') { $this->prefix .= '_'; } }
/** * Constructor. * * Do not use this directly. You can use getInstance() instead. * * @see CacheHandler::getInstance * @param string $target type of cache (object|template) * @param object $info info. of DB * @param boolean $always_use_file If set true, use a file cache always * @return CacheHandler */ function CacheHandler($target, $info = null, $always_use_file = false) { if (!$info) { $info = Context::getDBInfo(); } if ($info) { if ($target == 'object') { if ($info->use_object_cache == 'apc') { $type = 'apc'; } else { if (substr($info->use_object_cache, 0, 8) == 'memcache') { $type = 'memcache'; $url = $info->use_object_cache; } else { if ($info->use_object_cache == 'wincache') { $type = 'wincache'; } else { if ($info->use_object_cache == 'file') { $type = 'file'; } else { if ($always_use_file) { $type = 'file'; } } } } } } else { if ($target == 'template') { if ($info->use_template_cache == 'apc') { $type = 'apc'; } else { if (substr($info->use_template_cache, 0, 8) == 'memcache') { $type = 'memcache'; $url = $info->use_template_cache; } else { if ($info->use_template_cache == 'wincache') { $type = 'wincache'; } } } } } if ($type) { $class = 'Cache' . ucfirst($type); include_once sprintf('%sclasses/cache/%s.class.php', _XE_PATH_, $class); $this->handler = call_user_func(array($class, 'getInstance'), $url); $this->keyGroupVersions = $this->handler->get('key_group_versions', 0); if (!$this->keyGroupVersions) { $this->keyGroupVersions = array(); $this->handler->put('key_group_versions', $this->keyGroupVersions, 0); } } } }
/** * @brief DB정보 설정 및 connect/ close **/ function _setDBInfo() { $db_info = Context::getDBInfo(); $this->hostname = $db_info->db_hostname; $this->port = $db_info->db_port; $this->userid = $db_info->db_userid; $this->password = $db_info->db_password; $this->database = $db_info->db_database; $this->prefix = $db_info->db_table_prefix; if (!substr($this->prefix, -1) != '_') { $this->prefix .= '_'; } }
function dispSeoAdminSetting() { $vars = Context::getRequestVars(); if (!$vars->setting_section) { Context::set('setting_section', 'general'); } $config = $this->getConfig(); $db_info = Context::getDBInfo(); $hostname = parse_url($db_info->default_url); $hostname = $hostname['host']; Context::set('config', $config); Context::set('hostname', $hostname); }
/** * Return index hint string * @return string */ function getIndexHintString() { $result = ''; // Retrieve table prefix, to add it to index name $db_info = Context::getDBInfo(); $prefix = $db_info->master_db["db_table_prefix"]; foreach ($this->index_hints_list as $index_hint) { $index_hint_type = $index_hint->getIndexHintType(); if ($index_hint_type !== 'IGNORE') { $result .= $this->alias . '.' . '"' . $prefix . substr($index_hint->getIndexName(), 1) . ($index_hint_type == 'FORCE' ? '(+)' : '') . ', '; } } $result = substr($result, 0, -2); return $result; }
/** * @brief 업데이트 실행 **/ function moduleUpdate() { $db_info = Context::getDBInfo(); // 카운터에 site_srl추가 $oDB =& DB::getInstance(); if (!$oDB->isColumnExists('counter_log', 'site_srl')) { $oDB->addColumn('counter_log', 'site_srl', 'number', 11, 0, true); } if ($db_info->db_type == 'cubrid') { if (!$oDB->isIndexExists('counter_log', $oDB->prefix . 'counter_log_idx_site_counter_log')) { $oDB->addIndex('counter_log', $oDB->prefix . 'counter_log_idx_site_counter_log', array('site_srl', 'ipaddress'), false); } } else { if (!$oDB->isIndexExists('counter_log', 'idx_site_counter_log')) { $oDB->addIndex('counter_log', 'idx_site_counter_log', array('site_srl', 'ipaddress'), false); } } return new Object(0, 'success_updated'); }
function _getAgreement() { $agreement_file = _XE_PATH_ . 'files/authentication/agreement_' . Context::get('lang_type') . '.txt'; if (is_readable($agreement_file)) { return FileHandler::readFile($agreement_file); } $db_info = Context::getDBInfo(); $agreement_file = _XE_PATH_ . 'files/authentication/agreement_' . $db_info->lang_type . '.txt'; if (is_readable($agreement_file)) { return FileHandler::readFile($agreement_file); } $lang_selected = Context::loadLangSelected(); foreach ($lang_selected as $key => $val) { $agreement_file = _XE_PATH_ . 'files/authentication/agreement_' . $key . '.txt'; if (is_readable($agreement_file)) { return FileHandler::readFile($agreement_file); } } return null; }
function isMobileEnabled() { $db_info = Context::getDBInfo(); return $db_info->use_mobile_view === 'Y'; }
/** * DB info settings * this method is protected * @return void */ function _setDBInfo() { $db_info = Context::getDBInfo(); $this->master_db = $db_info->master_db; if ($db_info->master_db["db_hostname"] == $db_info->slave_db[0]["db_hostname"] && $db_info->master_db["db_port"] == $db_info->slave_db[0]["db_port"] && $db_info->master_db["db_userid"] == $db_info->slave_db[0]["db_userid"] && $db_info->master_db["db_password"] == $db_info->slave_db[0]["db_password"] && $db_info->master_db["db_database"] == $db_info->slave_db[0]["db_database"]) { $this->slave_db[0] =& $this->master_db; } else { $this->slave_db = $db_info->slave_db; } $this->prefix = $db_info->master_db["db_table_prefix"]; $this->use_prepared_statements = $db_info->use_prepared_statements; }
/** * check allowed target ip address when login for admin. * * @return boolean (true : allowed, false : refuse) */ function getMemberAdminIPCheck() { $db_info = Context::getDBInfo(); $admin_ip_list = $db_info->admin_ip_list; if (!$admin_ip_list) { return true; } if (!is_array($admin_ip_list)) { $admin_ip_list = explode(',', $admin_ip_list); } if (!count($admin_ip_list) || IpFilter::filter($admin_ip_list)) { return true; } else { return false; } }
/** * Sync member information with document information * @return void */ function procImporterAdminSync() { $oMemberModel = getModel('member'); $member_config = $oMemberModel->getMemberConfig(); $postFix = $member_config->identifier == 'email_address' ? 'ByEmail' : ''; // 계정이 이메일인 경우 이메일 정보로 사용자를 싱크하도록 한다. 이때 변수명은 그대로 user_id를 사용한다. /* DBMS가 CUBRID인 경우 MySQL과 동일한 방법으로는 문서 및 댓글에 대한 사용자 정보를 동기화 할 수 없으므로 예외 처리 합니다. CUBRID를 사용하지 않는 경우에만 보편적인 기존 질의문을 사용합니다. */ $db_info = Context::getDBInfo(); if ($db_info->db_type != "cubrid") { $output = executeQuery('importer.updateDocumentSync' . $postFix); $output = executeQuery('importer.updateCommentSync' . $postFix); } else { $output = executeQueryArray('importer.getDocumentMemberSrlWithUserID' . $postFix); if (is_array($output->data) && count($output->data)) { $success_count = 0; $error_count = 0; $total_count = 0; foreach ($output->data as $val) { $args->user_id = $val->user_id; $args->member_srl = $val->member_srl; $tmp = executeQuery('importer.updateDocumentSyncForCUBRID' . $postFix, $args); if ($tmp->toBool() === true) { $success_count++; } else { $error_count++; } $total_count++; } } // documents section $output = executeQueryArray('importer.getCommentMemberSrlWithUserID' . $postFix); if (is_array($output->data) && count($output->data)) { $success_count = 0; $error_count = 0; $total_count = 0; foreach ($output->data as $val) { $args->user_id = $val->user_id; $args->member_srl = $val->member_srl; $tmp = executeQuery('importer.updateCommentSyncForCUBRID' . $postFix, $args); if ($tmp->toBool() === true) { $success_count++; } else { $error_count++; } $total_count++; } } // comments section } $this->setMessage('msg_sync_completed'); }
/** * @brief optimize 대상 파일을 받아서 처리 후 optimize 된 파일이름을 return **/ function getOptimizedFiles($source_files, $type = "js") { if (!is_array($source_files) || !count($source_files)) { return; } // $source_files의 역슬래쉬 경로를 슬래쉬로 변경 (윈도우즈 대비) foreach ($source_files as $key => $file) { $source_files[$key]['file'] = str_replace("\\", "/", $file['file']); } // 관리자 설정시 설정이 되어 있지 않으면 패스 $db_info = Context::getDBInfo(); if ($db_info->use_optimizer == 'N') { return $this->_getOptimizedRemoved($source_files); } // 캐시 디렉토리가 없으면 실행하지 않음 if (!is_dir($this->cache_path)) { return $this->_getOptimizedRemoved($source_files); } $files = array(); if (!count($source_files)) { return; } foreach ($source_files as $file) { if (!$file || !$file['file']) { continue; } if (empty($file['optimized']) || preg_match('/^https?:\\/\\//i', $file['file'])) { $files[] = $file; } else { $targets[] = $file; } } if (!count($targets)) { return $this->_getOptimizedRemoved($files); } $optimized_info = $this->getOptimizedInfo($targets); $path = sprintf("%s%s", $this->cache_path, $optimized_info[0]); $filename = sprintf("%s.%s.%s.php", $optimized_info[0], $optimized_info[1], $type); $this->doOptimizedFile($path, $filename, $targets, $type); array_unshift($files, array('file' => $path . '/' . $filename, 'media' => 'all')); $files = $this->_getOptimizedRemoved($files); if (!count($files)) { return $files; } $url_info = parse_url(Context::getRequestUri()); $abpath = $url_info['path']; foreach ($files as $key => $val) { $file = $val['file']; if (substr($file, 0, 1) == '/' || strpos($file, '://') !== false) { continue; } if (substr($file, 0, 2) == './') { $file = substr($file, 2); } $file = $abpath . $file; while (strpos($file, '/../') !== false) { $file = preg_replace('/\\/([^\\/]+)\\/\\.\\.\\//', '/', $file); } $files[$key]['file'] = $file; } return $files; }
/** * Get all act list for admin menu * @return void|object */ function procMenuAdminInsertItemForAdminMenu() { $requestArgs = Context::getRequestVars(); $tmpMenuName = explode(':', $requestArgs->menu_name); $moduleName = $tmpMenuName[0]; $menuName = $tmpMenuName[1]; // variable setting $logged_info = Context::get('logged_info'); //$oMenuAdminModel = getAdminModel('menu'); $oMemberModel = getModel('member'); //$parentMenuInfo = $oMenuAdminModel->getMenuItemInfo($requestArgs->parent_srl); $groupSrlList = $oMemberModel->getMemberGroups($logged_info->member_srl); //preg_match('/\{\$lang->menu_gnb\[(.*?)\]\}/i', $parentMenuInfo->name, $m); $oModuleModel = getModel('module'); //$info = $oModuleModel->getModuleInfoXml($moduleName); $info = $oModuleModel->getModuleActionXml($moduleName); $url = getNotEncodedFullUrl('', 'module', 'admin', 'act', $info->menu->{$menuName}->index); if (empty($url)) { $url = getNotEncodedFullUrl('', 'module', 'admin', 'act', $info->admin_index_act); } if (empty($url)) { $url = getNotEncodedFullUrl('', 'module', 'admin'); } $dbInfo = Context::getDBInfo(); $args = new stdClass(); $args->menu_item_srl = !$requestArgs->menu_item_srl ? getNextSequence() : $requestArgs->menu_item_srl; $args->parent_srl = $requestArgs->parent_srl; $args->menu_srl = $requestArgs->menu_srl; $args->name = sprintf('{$lang->menu_gnb_sub[\'%s\']}', $menuName); //if now page is https... if (strpos($url, 'https') !== false) { $args->url = str_replace('https' . substr($dbInfo->default_url, 4), '', $url); } else { $args->url = str_replace($dbInfo->default_url, '', $url); } $args->open_window = 'N'; $args->expand = 'N'; $args->normal_btn = ''; $args->hover_btn = ''; $args->active_btn = ''; $args->group_srls = implode(',', array_keys($groupSrlList)); $args->listorder = -1 * $args->menu_item_srl; // Check if already exists $oMenuModel = getAdminModel('menu'); $item_info = $oMenuModel->getMenuItemInfo($args->menu_item_srl); // Update if exists if ($item_info->menu_item_srl == $args->menu_item_srl) { $output = executeQuery('menu.updateMenuItem', $args); if (!$output->toBool()) { return $output; } } else { $args->listorder = -1 * $args->menu_item_srl; $output = executeQuery('menu.insertMenuItem', $args); if (!$output->toBool()) { return $output; } } // Get information of the menu $menu_info = $oMenuModel->getMenu($args->menu_srl); $menu_title = $menu_info->title; // Update the xml file and get its location $xml_file = $this->makeXmlFile($args->menu_srl); $returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispAdminSetup'); $this->setRedirectUrl($returnUrl); }
/** * Get file information * * @param string $fileName The file name * @param string $targetIe Target IE of file * @param string $media Media of file * @param bool $forceMinify Whether this file should be minified * @return stdClass The file information */ private function getFileInfo($fileName, $targetIe = '', $media = 'all', $forceMinify = false) { static $existsInfo = array(); if (self::$minify === null) { self::$minify = Context::getDBInfo()->minify_scripts ?: 'common'; } if (isset($existsInfo[$existsKey])) { return $existsInfo[$existsKey]; } $pathInfo = pathinfo($fileName); $file = new stdClass(); $file->fileName = $pathInfo['basename']; $file->filePath = $this->_getAbsFileUrl($pathInfo['dirname']); $file->fileRealPath = FileHandler::getRealPath($pathInfo['dirname']); $file->fileExtension = strtolower($pathInfo['extension']); if (preg_match('/^(.+)\\.min$/', $pathInfo['filename'], $matches)) { $file->fileNameNoExt = $matches[1]; $file->isMinified = true; } else { $file->fileNameNoExt = $pathInfo['filename']; $file->isMinified = false; } $file->isExternalURL = preg_match('@^(https?:)?//@i', $file->filePath) ? true : false; $file->isCachedScript = !$file->isExternalURL && strpos($file->filePath, 'files/cache/') !== false; $file->keyName = $file->fileNameNoExt . '.' . $file->fileExtension; $file->cdnPath = $this->_normalizeFilePath($pathInfo['dirname']); $originalFilePath = $file->fileRealPath . '/' . $pathInfo['basename']; // Fix incorrectly minified URL if ($file->isMinified && !$file->isExternalURL && (!file_exists($originalFilePath) || is_link($originalFilePath) || filesize($originalFilePath) < 32 && trim(file_get_contents($originalFilePath)) === $file->keyName)) { if (file_exists($file->fileRealPath . '/' . $file->fileNameNoExt . '.' . $file->fileExtension)) { $file->fileName = $file->fileNameNoExt . '.' . $file->fileExtension; $file->isMinified = false; $originalFilePath = $file->fileRealPath . '/' . $file->fileNameNoExt . '.' . $file->fileExtension; } } // Decide whether to minify this file if (self::$minify === 'all') { $minify_enabled = true; } elseif (self::$minify === 'none') { $minify_enabled = false; } else { $minify_enabled = $forceMinify; } // Minify file if ($minify_enabled && !$file->isMinified && !$file->isExternalURL && !$file->isCachedScript && strpos($file->filePath, 'common/js/plugins') === false) { if (($file->fileExtension === 'css' || $file->fileExtension === 'js') && file_exists($originalFilePath)) { $minifiedFileName = $file->fileNameNoExt . '.min.' . $file->fileExtension; $minifiedFileHash = ltrim(str_replace(array('/', '\\'), '.', $pathInfo['dirname']), '.'); $minifiedFilePath = _XE_PATH_ . 'files/cache/minify/' . $minifiedFileHash . '.' . $minifiedFileName; if (!file_exists($minifiedFilePath) || filemtime($minifiedFilePath) < filemtime($originalFilePath)) { if ($file->fileExtension === 'css') { $minifier = new MatthiasMullie\Minify\CSS($originalFilePath); $content = $minifier->execute($minifiedFilePath); } else { $minifier = new MatthiasMullie\Minify\JS($originalFilePath); $content = $minifier->execute($minifiedFilePath); } FileHandler::writeFile($minifiedFilePath, $content); } $file->fileName = $minifiedFileHash . '.' . $minifiedFileName; $file->filePath = $this->_getAbsFileUrl('./files/cache/minify'); $file->fileRealPath = _XE_PATH_ . 'files/cache/minify'; $file->keyName = $minifiedFileHash . '.' . $file->fileNameNoExt . '.' . $file->fileExtension; $file->cdnPath = $this->_normalizeFilePath('./files/cache/minify'); $file->isMinified = true; } } // Process targetIe and media attributes $file->targetIe = $targetIe; if ($file->fileExtension == 'css') { $file->media = $media; if (!$file->media) { $file->media = 'all'; } $file->key = $file->filePath . $file->keyName . "\t" . $file->targetIe . "\t" . $file->media; } else { if ($file->fileExtension == 'js') { $file->key = $file->filePath . $file->keyName . "\t" . $file->targetIe; } } return $file; }
/** * @brief Save the file of user-defined language code */ function makeCacheDefinedLangCode($site_srl = 0) { $args = new stdClass(); // Get the language file of the current site if (!$site_srl) { $site_module_info = Context::get('site_module_info'); $args->site_srl = (int) $site_module_info->site_srl; } else { $args->site_srl = $site_srl; } $output = executeQueryArray('module.getLang', $args); if (!$output->toBool() || !$output->data) { return; } // Set the cache directory $cache_path = _XE_PATH_ . 'files/cache/lang_defined/'; FileHandler::makeDir($cache_path); $langMap = array(); foreach ($output->data as $val) { $langMap[$val->lang_code][$val->name] = $val->value; } $lang_supported = Context::get('lang_supported'); $dbInfo = Context::getDBInfo(); $defaultLang = $dbInfo->lang_type; if (!is_array($langMap[$defaultLang])) { $langMap[$defaultLang] = array(); } foreach ($lang_supported as $langCode => $langName) { if (!is_array($langMap[$langCode])) { $langMap[$langCode] = array(); } $langMap[$langCode] += $langMap[$defaultLang]; foreach ($lang_supported as $targetLangCode => $targetLangName) { if ($langCode == $targetLangCode || $langCode == $defaultLang) { continue; } if (!is_array($langMap[$targetLangCode])) { $langMap[$targetLangCode] = array(); } $langMap[$langCode] += $langMap[$targetLangCode]; } $buff = array("<?php if(!defined('__XE__')) exit();"); foreach ($langMap[$langCode] as $code => $value) { $buff[] = sprintf('$lang[\'%s\'] = \'%s\';', $code, addcslashes($value, "'")); } if (!@file_put_contents(sprintf('%s/%d.%s.php', $cache_path, $args->site_srl, $langCode), join(PHP_EOL, $buff), LOCK_EX)) { return; } } }
/** * Parameter arrange for send to XE collect server * @param string $type 'WORKING', 'INSTALL' * @return string */ function getEnv($type = 'WORKING') { $skip = array('ext' => array('pcre', 'json', 'hash', 'dom', 'session', 'spl', 'standard', 'date', 'ctype', 'tokenizer', 'apache2handler', 'filter', 'posix', 'reflection', 'pdo'), 'module' => array('addon', 'admin', 'autoinstall', 'comment', 'communication', 'counter', 'document', 'editor', 'file', 'importer', 'install', 'integration_search', 'layout', 'member', 'menu', 'message', 'module', 'opage', 'page', 'point', 'poll', 'rss', 'session', 'spamfilter', 'tag', 'trackback', 'trash', 'widget'), 'addon' => array('autolink', 'blogapi', 'captcha', 'counter', 'member_communication', 'member_extra_info', 'mobile', 'openid_delegation_id', 'point_level_icon', 'resize_image'), 'layout' => array('default'), 'widget' => array('content', 'language_select', 'login_info', 'mcontent'), 'widgetstyle' => array()); $info = array(); $db_info = Context::getDBInfo(); $info['type'] = $type != 'INSTALL' ? 'WORKING' : 'INSTALL'; $info['location'] = _XE_LOCATION_; $info['package'] = _XE_PACKAGE_; $info['host'] = $db_type->default_url ? $db_type->default_url : getFullUrl(); $info['app'] = $_SERVER['SERVER_SOFTWARE']; $info['xe_version'] = __XE_VERSION__; $info['php'] = phpversion(); $info['db_type'] = Context::getDBType(); $info['use_rewrite'] = $db_info->use_rewrite; $info['use_db_session'] = $db_info->use_db_session == 'Y' ? 'Y' : 'N'; $info['use_ssl'] = $db_info->use_ssl; $info['phpext'] = ''; foreach (get_loaded_extensions() as $ext) { $ext = strtolower($ext); if (in_array($ext, $skip['ext'])) { continue; } $info['phpext'] .= '|' . $ext; } $info['phpext'] = substr($info['phpext'], 1); $info['module'] = ''; $oModuleModel = getModel('module'); $module_list = $oModuleModel->getModuleList(); if ($module_list) { foreach ($module_list as $module) { if (in_array($module->module, $skip['module'])) { continue; } $info['module'] .= '|' . $module->module; } } $info['module'] = substr($info['module'], 1); $info['addon'] = ''; $oAddonAdminModel = getAdminModel('addon'); $addon_list = $oAddonAdminModel->getAddonList(); if ($addon_list) { foreach ($addon_list as $addon) { if (in_array($addon->addon, $skip['addon'])) { continue; } $info['addon'] .= '|' . $addon->addon; } } $info['addon'] = substr($info['addon'], 1); $info['layout'] = ""; $oLayoutModel = getModel('layout'); $layout_list = $oLayoutModel->getDownloadedLayoutList(); if ($layout_list) { foreach ($layout_list as $layout) { if (in_array($layout->layout, $skip['layout'])) { continue; } $info['layout'] .= '|' . $layout->layout; } } $info['layout'] = substr($info['layout'], 1); $info['widget'] = ""; $oWidgetModel = getModel('widget'); $widget_list = $oWidgetModel->getDownloadedWidgetList(); if ($widget_list) { foreach ($widget_list as $widget) { if (in_array($widget->widget, $skip['widget'])) { continue; } $info['widget'] .= '|' . $widget->widget; } } $info['widget'] = substr($info['widget'], 1); $info['widgetstyle'] = ""; $oWidgetModel = getModel('widget'); $widgetstyle_list = $oWidgetModel->getDownloadedWidgetStyleList(); if ($widgetstyle_list) { foreach ($widgetstyle_list as $widgetstyle) { if (in_array($widgetstyle->widgetStyle, $skip['widgetstyle'])) { continue; } $info['widgetstyle'] .= '|' . $widgetstyle->widgetStyle; } } $info['widgetstyle'] = substr($info['widgetstyle'], 1); $param = ''; foreach ($info as $k => $v) { if ($v) { $param .= sprintf('&%s=%s', $k, urlencode($v)); } } $param = substr($param, 1); return $param; }
/** * Execute update * @return Object */ function moduleUpdate() { $oDB =& DB::getInstance(); $oModuleModel =& getModel('module'); $oModuleController =& getController('module'); // 2007. 7. 25: Add a column(notify_message) for notification if (!$oDB->isColumnExists("documents", "notify_message")) { $oDB->addColumn('documents', "notify_message", "char", 1); } // 2007. 8. 23: create a clustered index in the document table if (!$oDB->isIndexExists("documents", "idx_module_list_order")) { $oDB->addIndex("documents", "idx_module_list_order", array("module_srl", "list_order")); } if (!$oDB->isIndexExists("documents", "idx_module_update_order")) { $oDB->addIndex("documents", "idx_module_update_order", array("module_srl", "update_order")); } if (!$oDB->isIndexExists("documents", "idx_module_readed_count")) { $oDB->addIndex("documents", "idx_module_readed_count", array("module_srl", "readed_count")); } if (!$oDB->isIndexExists("documents", "idx_module_voted_count")) { $oDB->addIndex("documents", "idx_module_voted_count", array("module_srl", "voted_count")); } // 2007. 10. 17 Add a trigger to delete all posts together when the module is deleted if (!$oModuleModel->getTrigger('module.deleteModule', 'document', 'controller', 'triggerDeleteModuleDocuments', 'after')) { $oModuleController->insertTrigger('module.deleteModule', 'document', 'controller', 'triggerDeleteModuleDocuments', 'after'); } // 2007. 10. 25 add columns(parent_srl, expand) if (!$oDB->isColumnExists("document_categories", "parent_srl")) { $oDB->addColumn('document_categories', "parent_srl", "number", 12, 0); } if (!$oDB->isColumnExists("document_categories", "expand")) { $oDB->addColumn('document_categories', "expand", "char", 1, "N"); } if (!$oDB->isColumnExists("document_categories", "group_srls")) { $oDB->addColumn('document_categories', "group_srls", "text"); } // 2007. 11. 20 create a composite index on the columns(module_srl + is_notice) if (!$oDB->isIndexExists("documents", "idx_module_notice")) { $oDB->addIndex("documents", "idx_module_notice", array("module_srl", "is_notice")); } // 2007. 12. 03: Add if the colume(extra_vars) doesn't exist if (!$oDB->isColumnExists("documents", "extra_vars")) { $oDB->addColumn('documents', 'extra_vars', 'text'); } // 2008. 02. 18 create a composite index on the columns(module_srl + document_srl) (checked by Manian)) if (!$oDB->isIndexExists("documents", "idx_module_document_srl")) { $oDB->addIndex("documents", "idx_module_document_srl", array("module_srl", "document_srl")); } // 2008. 04. 23 Add a column(blamed count) if (!$oDB->isColumnExists("documents", "blamed_count")) { $oDB->addColumn('documents', 'blamed_count', 'number', 11, 0, true); $oDB->addIndex('documents', 'idx_blamed_count', array('blamed_count')); } if (!$oDB->isIndexExists("documents", "idx_module_blamed_count")) { $oDB->addIndex('documents', 'idx_module_blamed_count', array('module_srl', 'blamed_count')); } if (!$oDB->isColumnExists("document_voted_log", "point")) { $oDB->addColumn('document_voted_log', 'point', 'number', 11, 0, true); } if (!$oDB->isColumnExists("document_categories", "color")) { $oDB->addColumn('document_categories', "color", "char", 7); } // 2009. 01. 29: Add a column(lang_code) if not exist in the document_extra_vars table if (!$oDB->isColumnExists("document_extra_vars", "lang_code")) { $oDB->addColumn('document_extra_vars', "lang_code", "varchar", 10); } // 2009. 01. 29 Added a trigger for additional setup if (!$oModuleModel->getTrigger('module.dispAdditionSetup', 'document', 'view', 'triggerDispDocumentAdditionSetup', 'before')) { $oModuleController->insertTrigger('module.dispAdditionSetup', 'document', 'view', 'triggerDispDocumentAdditionSetup', 'before'); } // 2009. 03. 09 Add a column(lang_code) to the documnets table if (!$oDB->isColumnExists("documents", "lang_code")) { $db_info = Context::getDBInfo(); $oDB->addColumn('documents', "lang_code", "varchar", 10, $db_info->lang_code); $obj->lang_code = $db_info->lang_type; executeQuery('document.updateDocumentsLangCode', $obj); } // 2009. 03. 11 Check the index in the document_extra_vars table if (!$oDB->isIndexExists("document_extra_vars", "unique_extra_vars")) { $oDB->addIndex("document_extra_vars", "unique_extra_vars", array("module_srl", "document_srl", "var_idx", "lang_code"), true); } if ($oDB->isIndexExists("document_extra_vars", "unique_module_vars")) { $oDB->dropIndex("document_extra_vars", "unique_module_vars", true); } // 2009. 03. 19: Add a column(eid) // 2009. 04. 12: Fixed the issue(#17922959) that changes another column values when adding eid column if (!$oDB->isColumnExists("document_extra_keys", "eid")) { $oDB->addColumn("document_extra_keys", "eid", "varchar", 40); $output = executeQuery('document.getGroupsExtraKeys', $obj); if ($output->toBool() && $output->data && count($output->data)) { foreach ($output->data as $extra_keys) { $args->module_srl = $extra_keys->module_srl; $args->var_idx = $extra_keys->idx; $args->new_eid = "extra_vars" . $extra_keys->idx; $output = executeQuery('document.updateDocumentExtraKeyEid', $args); } } } if (!$oDB->isColumnExists("document_extra_vars", "eid")) { $oDB->addColumn("document_extra_vars", "eid", "varchar", 40); $obj->var_idx = '-1,-2'; $output = executeQuery('document.getGroupsExtraVars', $obj); if ($output->toBool() && $output->data && count($output->data)) { foreach ($output->data as $extra_vars) { $args->module_srl = $extra_vars->module_srl; $args->var_idx = $extra_vars->idx; $args->new_eid = "extra_vars" . $extra_vars->idx; $output = executeQuery('document.updateDocumentExtraVarEid', $args); } } } // 2011. 03. 30 Cubrid index Check the index in the document_extra_vars table if (!$oDB->isIndexExists("document_extra_vars", "idx_document_list_order")) { $oDB->addIndex("document_extra_vars", "idx_document_list_order", array("document_srl", "module_srl", "var_idx"), false); } //2011. 04. 07 adding description column to document categories if (!$oDB->isColumnExists("document_categories", "description")) { $oDB->addColumn('document_categories', "description", "varchar", 200, 0); } //2011. 05. 23 adding status column to document if (!$oDB->isColumnExists('documents', 'status')) { $oDB->addColumn('documents', 'status', 'varchar', 20, 'PUBLIC'); $args->is_secret = 'Y'; $output = executeQuery('document.updateDocumentStatus', $args); } // 2011. 09. 08 drop column document is_secret if ($oDB->isColumnExists('documents', 'status') && $oDB->isColumnExists('documents', 'is_secret')) { $oDB->dropColumn('documents', 'is_secret'); } //2011. 06. 07 merge column, allow_comment and lock_comment if ($oDB->isColumnExists('documents', 'allow_comment') || $oDB->isColumnExists('documents', 'lock_comment')) { $oDB->addColumn('documents', 'comment_status', 'varchar', 20, 'ALLOW'); $columnList = array('module_srl'); $moduleSrlList = $oModuleModel->getModuleSrlList(null, $columnList); $args->commentStatus = 'DENY'; // allow_comment='Y', lock_comment='Y' $args->allowComment = 'Y'; $args->lockComment = 'Y'; $output = executeQuery('document.updateDocumentCommentStatus', $args); // allow_comment='N', lock_comment='Y' $args->allowComment = 'N'; $args->lockComment = 'Y'; $output = executeQuery('document.updateDocumentCommentStatus', $args); // allow_comment='N', lock_comment='N' $args->allowComment = 'N'; $args->lockComment = 'N'; $output = executeQuery('document.updateDocumentCommentStatus', $args); } if ($oDB->isColumnExists('documents', 'allow_comment') && $oDB->isColumnExists('documents', 'comment_status')) { $oDB->dropColumn('documents', 'allow_comment'); } if ($oDB->isColumnExists('documents', 'lock_comment') && $oDB->isColumnExists('documents', 'comment_status')) { $oDB->dropColumn('documents', 'lock_comment'); } if (!$oDB->isIndexExists("documents", "idx_module_status")) { $oDB->addIndex("documents", "idx_module_status", array("module_srl", "status")); } // 2012. 02. 27 Add a trigger to copy extra keys when the module is copied if (!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'document', 'controller', 'triggerCopyModuleExtraKeys', 'after')) { $oModuleController->insertTrigger('module.procModuleAdminCopyModule', 'document', 'controller', 'triggerCopyModuleExtraKeys', 'after'); } return new Object(0, 'success_updated'); }
function dispSocialxeLoginForm() { $config = $this->config; // 소셜 로그인을 사용하지 않으면 중지 if ($config->use_social_login != 'Y') { return $this->stop('msg_not_allow_social_login'); } // 로그인 중이면 중지 if (Context::get('logged_info')) { return $this->stop('already_logged'); } // 사용 중인 서비스 세팅 Context::set('provider_list', $this->providerManager->getProviderList()); // 기본 사이트의 도메인 $db_info = Context::getDBInfo(); $domain = str_replace(array('http://', 'https://'), '', $db_info->default_url); Context::set('domain', $domain); // 세션 파기(가끔씩 기본 사이트와 PHPSESSIONID가 일치하지 않는 문제 때문) $oMemberController =& getController('member'); $oMemberController->destroySessionInfo(); // template path 지정 $tpl_path = sprintf('%sskins/%s', $this->module_path, $config->skin); if (!is_dir($tpl_path)) { $tpl_path = sprintf('%sskins/%s', $this->module_path, 'default'); } $this->setTemplatePath($tpl_path); // 템플릿 파일 지정 $this->setTemplateFile('social_login'); }
/** * @brief 업데이트 실행 **/ function moduleUpdate() { $db_info = Context::getDBInfo(); $oModuleModel =& getModel('module'); $oModuleController =& getController('module'); $oDB =& DB::getInstance(); // 자동저장시 module_srl 을 저장 2009.6.15 if (!$oDB->isColumnExists("editor_autosave", "module_srl")) { $oDB->addColumn("editor_autosave", "module_srl", "number", 11); } // module_srl을 인덱스로 if ($db_info->db_type == 'cubrid') { if (!$oDB->isIndexExists("editor_autosave", $oDB->prefix . "editor_autosave_idx_module_srl")) { $oDB->addIndex("editor_autosave", $oDB->prefix . "editor_autosave_idx_module_srl", "module_srl"); } } else { if (!$oDB->isIndexExists("editor_autosave", "idx_module_srl")) { $oDB->addIndex("editor_autosave", "idx_module_srl", "module_srl"); } } // 2007. 10. 17 글의 입력(신규 or 수정)이 일어날때마다 자동 저장된 문서를 삭제하는 trigger 추가 if (!$oModuleModel->getTrigger('document.insertDocument', 'editor', 'controller', 'triggerDeleteSavedDoc', 'after')) { $oModuleController->insertTrigger('document.insertDocument', 'editor', 'controller', 'triggerDeleteSavedDoc', 'after'); } if (!$oModuleModel->getTrigger('document.updateDocument', 'editor', 'controller', 'triggerDeleteSavedDoc', 'after')) { $oModuleController->insertTrigger('document.updateDocument', 'editor', 'controller', 'triggerDeleteSavedDoc', 'after'); } // 2007. 10. 23 모듈의 추가 설정에서 에디터 trigger 추가 if (!$oModuleModel->getTrigger('module.dispAdditionSetup', 'editor', 'view', 'triggerDispEditorAdditionSetup', 'before')) { $oModuleController->insertTrigger('module.dispAdditionSetup', 'editor', 'view', 'triggerDispEditorAdditionSetup', 'before'); } // 2009. 04. 14 editor component 변환 코드를 trigger로 독립 if (!$oModuleModel->getTrigger('display', 'editor', 'controller', 'triggerEditorComponentCompile', 'before')) { $oModuleController->insertTrigger('display', 'editor', 'controller', 'triggerEditorComponentCompile', 'before'); } // 2009. 06. 19 사용하지 않는 트리거 제거 if ($oModuleModel->getTrigger('file.getIsPermitted', 'editor', 'controller', 'triggerSrlSetting', 'before')) { $oModuleController->deleteTrigger('file.getIsPermitted', 'editor', 'controller', 'triggerSrlSetting', 'before'); } return new Object(0, 'success_updated'); }
/** * @brief Get the defaul mid according to the domain */ function getDefaultMid() { $default_url = Context::getDefaultUrl(); if ($default_url && substr_compare($default_url, '/', -1) === 0) { $default_url = substr($default_url, 0, -1); } $request_url = Context::getRequestUri(); if ($request_url && substr_compare($request_url, '/', -1) === 0) { $request_url = substr($request_url, 0, -1); } $default_url_parse = parse_url($default_url); $request_url_parse = parse_url($request_url); $vid = Context::get('vid'); $mid = Context::get('mid'); // Set up $domain = ''; $site_info = NULL; if ($default_url && $default_url_parse['host'] != $request_url_parse['host']) { $url_info = parse_url($request_url); $hostname = $url_info['host']; $path = $url_info['path']; if (strlen($path) >= 1 && substr_compare($path, '/', -1) === 0) { $path = substr($path, 0, -1); } $domain = sprintf('%s%s%s', $hostname, $url_info['port'] && $url_info['port'] != 80 ? ':' . $url_info['port'] : '', $path); } if ($domain === '') { if (!$vid) { $vid = $mid; } if ($vid) { $domain = $vid; } } $oCacheHandler = CacheHandler::getInstance('object', null, true); // If domain is set, look for subsite if ($domain !== '') { $site_info = false; if ($oCacheHandler->isSupport()) { $object_key = 'site_info:' . md5($domain); $domain_cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key); $site_info = $oCacheHandler->get($domain_cache_key); } if ($site_info === false) { $args = new stdClass(); $args->domain = $domain; $output = executeQuery('module.getSiteInfoByDomain', $args); $site_info = $output->data; if ($oCacheHandler->isSupport()) { $oCacheHandler->put($domain_cache_key, $site_info); } } if ($site_info && $vid) { Context::set('vid', $site_info->domain, true); if (strtolower($mid) == strtolower($site_info->domain)) { Context::set('mid', $site_info->mid, true); } } if (!$site_info || !$site_info->domain) { $domain = ''; unset($site_info); } } // If no virtual website was found, get default website if ($domain === '') { $site_info = false; if ($oCacheHandler->isSupport()) { $object_key = 'default_site'; $default_site_cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key); $site_info = $oCacheHandler->get($default_site_cache_key); } if ($site_info === false) { $args = new stdClass(); $args->site_srl = 0; $output = executeQuery('module.getSiteInfo', $args); // Update the related informaion if there is no default site info if (!$output->data) { // Create a table if sites table doesn't exist $oDB =& DB::getInstance(); if (!$oDB->isTableExists('sites')) { $oDB->createTableByXmlFile(_XE_PATH_ . 'modules/module/schemas/sites.xml'); } if (!$oDB->isTableExists('sites')) { return; } // Get mid, language $mid_output = $oDB->executeQuery('module.getDefaultMidInfo', $args); $db_info = Context::getDBInfo(); $domain = Context::getDefaultUrl(); $url_info = parse_url($domain); $domain = $url_info['host'] . (!empty($url_info['port']) && $url_info['port'] != 80 ? ':' . $url_info['port'] : '') . $url_info['path']; $site_args = new stdClass(); $site_args->site_srl = 0; $site_args->index_module_srl = $mid_output->data->module_srl; $site_args->domain = $domain; $site_args->default_language = $db_info->lang_type; if ($output->data && !$output->data->index_module_srl) { $output = executeQuery('module.updateSite', $site_args); } else { $output = executeQuery('module.insertSite', $site_args); if (!$output->toBool()) { return $output; } } $output = executeQuery('module.getSiteInfo', $args); } $site_info = $output->data; if ($oCacheHandler->isSupport()) { $oCacheHandler->put($default_site_cache_key, $site_info); } } } if (!$site_info->module_srl) { return $site_info; } if (is_array($site_info) && $site_info->data[0]) { $site_info = $site_info[0]; } return $this->addModuleExtraVars($site_info); }
/** * @brief Return member information with email_address */ function getMemberInfoByEmailAddress($email_address) { if (!$email_address) { return; } $args = new stdClass(); $db_info = Context::getDBInfo(); if ($db_info->master_db['db_type'] == "cubrid") { $args->email_address = strtolower($email_address); $output = executeQuery('member.getMemberInfoByEmailAddressForCubrid', $args); } else { $args->email_address = $email_address; $output = executeQuery('member.getMemberInfoByEmailAddress', $args); } if (!$output->toBool()) { return $output; } if (!$output->data) { return; } $member_info = $this->arrangeMemberInfo($output->data); return $member_info; }
/** * @brief Textyle init tool **/ function initTool(&$oModule, $is_other_module = false) { if (!$oModule) { $oModule = $this; } $this->initCommon($is_other_module); $oTextyleModel =& getModel('textyle'); $site_module_info = Context::get('site_module_info'); $textyle = $oTextyleModel->getTextyle($site_module_info->index_module_srl); $custom_menu = $oTextyleModel->getTextyleCustomMenu(); $info = Context::getDBInfo(); if ($info->use_mobile_vie == 'Y') { $custom_menu->hidden_menu[] = strtolower('dispTextyleToolLayoutConfigMobileSkin'); } Context::set('custom_menu', $custom_menu); if ($oTextyleModel->ishiddenMenu($oModule->act) || $oModule->act == 'dispTextyleToolDashboard' && $oTextyleModel->isHiddenMenu(0)) { if ($oTextyleModel->isHiddenMenu(0)) { Context::set('act', $oModule->act = 'dispTextyleToolPostManageList', true); } else { Context::set('act', $oModule->act = 'dispTextyleToolDashboard', true); } } if ($is_other_module) { $oModule->setLayoutPath($this->module_path . 'tpl'); $oModule->setLayoutFile('_tool_layout'); } else { $template_path = sprintf("%stpl", $this->module_path); $this->setTemplatePath($template_path); $this->setTemplateFile(str_replace('dispTextyleTool', '', $this->act)); } if ($_COOKIE['tclnb']) { Context::addBodyClass('lnbClose'); } else { Context::addBodyClass('lnbToggleOpen'); } // set browser title Context::setBrowserTitle($textyle->get('browser_title') . ' - admin'); }
/** * Display Configuration(settings) page * @return void */ function dispAdminConfigGeneral() { Context::loadLang('modules/install/lang'); $db_info = Context::getDBInfo(); Context::set('selected_lang', $db_info->lang_type); if (strpos($db_info->default_url, 'xn--') !== FALSE) { $db_info->default_url = Context::decodeIdna($db_info->default_url); } Context::set('default_url', $db_info->default_url); Context::set('langs', Context::loadLangSupported()); // site lock Context::set('IP', $_SERVER['REMOTE_ADDR']); if (!$db_info->sitelock_title) { $db_info->sitelock_title = 'Maintenance in progress...'; } if (!in_array('127.0.0.1', $db_info->sitelock_whitelist)) { $db_info->sitelock_whitelist[] = '127.0.0.1'; } if (!in_array($_SERVER['REMOTE_ADDR'], $db_info->sitelock_whitelist)) { $db_info->sitelock_whitelist[] = $_SERVER['REMOTE_ADDR']; } $db_info->sitelock_whitelist = array_unique($db_info->sitelock_whitelist); Context::set('remote_addr', $_SERVER['REMOTE_ADDR']); Context::set('use_sitelock', $db_info->use_sitelock); Context::set('sitelock_title', $db_info->sitelock_title); Context::set('sitelock_message', htmlspecialchars($db_info->sitelock_message, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)); $whitelist = implode("\r\n", $db_info->sitelock_whitelist); Context::set('sitelock_whitelist', $whitelist); if ($db_info->admin_ip_list) { $admin_ip_list = implode("\r\n", $db_info->admin_ip_list); } else { $admin_ip_list = ''; } Context::set('admin_ip_list', $admin_ip_list); Context::set('lang_selected', Context::loadLangSelected()); $oAdminModel = getAdminModel('admin'); $favicon_url = $oAdminModel->getFaviconUrl(); $mobicon_url = $oAdminModel->getMobileIconUrl(); Context::set('favicon_url', $favicon_url . '?' . $_SERVER['REQUEST_TIME']); Context::set('mobicon_url', $mobicon_url . '?' . $_SERVER['REQUEST_TIME']); $oDocumentModel = getModel('document'); $config = $oDocumentModel->getDocumentConfig(); Context::set('thumbnail_type', $config->thumbnail_type); $oModuleModel = getModel('module'); $config = $oModuleModel->getModuleConfig('module'); Context::set('siteTitle', $config->siteTitle); Context::set('htmlFooter', htmlspecialchars($config->htmlFooter)); // embed filter require_once _XE_PATH_ . 'classes/security/EmbedFilter.class.php'; $oEmbedFilter = EmbedFilter::getInstance(); context::set('embed_white_object', implode(PHP_EOL, $oEmbedFilter->whiteUrlList)); context::set('embed_white_iframe', implode(PHP_EOL, $oEmbedFilter->whiteIframeUrlList)); $columnList = array('modules.mid', 'modules.browser_title', 'sites.index_module_srl'); $start_module = $oModuleModel->getSiteInfo(0, $columnList); Context::set('start_module', $start_module); Context::set('pwd', $pwd); $this->setTemplateFile('config_general'); $security = new Security(); $security->encodeHTML('news..', 'released_version', 'download_link', 'selected_lang', 'module_list..', 'module_list..author..', 'addon_list..', 'addon_list..author..', 'start_module.'); }
/** * Initialization. It finds the target module based on module, mid, document_srl, and prepares to execute an action * @return boolean true: OK, false: redirected **/ function init() { $oModuleModel =& getModel('module'); $site_module_info = Context::get('site_module_info'); if (!$this->document_srl && $this->mid && $this->entry) { $oDocumentModel =& getModel('document'); $this->document_srl = $oDocumentModel->getDocumentSrlByAlias($this->mid, $this->entry); if ($this->document_srl) { Context::set('document_srl', $this->document_srl); } } // Get module's information based on document_srl, if it's specified if ($this->document_srl && !$this->module) { $module_info = $oModuleModel->getModuleInfoByDocumentSrl($this->document_srl); // If the document does not exist, remove document_srl if (!$module_info) { unset($this->document_srl); } else { // If it exists, compare mid based on the module information // if mids are not matching, set it as the document's mid if ($this->mid != $module_info->mid) { $this->mid = $module_info->mid; Context::set('mid', $module_info->mid, true); header('location:' . getNotEncodedSiteUrl($site_info->domain, 'mid', $this->mid, 'document_srl', $this->document_srl)); return false; } } // if requested module is different from one of the document, remove the module information retrieved based on the document number if ($this->module && $module_info->module != $this->module) { unset($module_info); } } // If module_info is not set yet, and there exists mid information, get module information based on the mid if (!$module_info && $this->mid) { $module_info = $oModuleModel->getModuleInfoByMid($this->mid, $site_module_info->site_srl); //if($this->module && $module_info->module != $this->module) unset($module_info); } // redirect, if module_site_srl and site_srl are different if (!$this->module && !$module_info && $site_module_info->site_srl == 0 && $site_module_info->module_site_srl > 0) { $site_info = $oModuleModel->getSiteInfo($site_module_info->module_site_srl); header("location:" . getNotEncodedSiteUrl($site_info->domain, 'mid', $site_module_info->mid)); return false; } // If module_info is not set still, and $module does not exist, find the default module if (!$module_info && !$this->module && !$this->mid) { $module_info = $site_module_info; } if (!$module_info && !$this->module && $site_module_info->module_site_srl) { $module_info = $site_module_info; } // redirect, if site_srl of module_info is different from one of site's module_info if ($module_info && $module_info->site_srl != $site_module_info->site_srl && !isCrawler()) { // If the module is of virtual site if ($module_info->site_srl) { $site_info = $oModuleModel->getSiteInfo($module_info->site_srl); $redirect_url = getNotEncodedSiteUrl($site_info->domain, 'mid', Context::get('mid'), 'document_srl', Context::get('document_srl'), 'module_srl', Context::get('module_srl'), 'entry', Context::get('entry')); // If it's called from a virtual site, though it's not a module of the virtual site } else { $db_info = Context::getDBInfo(); if (!$db_info->default_url) { return Context::getLang('msg_default_url_is_not_defined'); } else { $redirect_url = getNotEncodedSiteUrl($db_info->default_url, 'mid', Context::get('mid'), 'document_srl', Context::get('document_srl'), 'module_srl', Context::get('module_srl'), 'entry', Context::get('entry')); } } header("location:" . $redirect_url); return false; } // If module info was set, retrieve variables from the module information if ($module_info) { $this->module = $module_info->module; $this->mid = $module_info->mid; $this->module_info = $module_info; Context::setBrowserTitle($module_info->browser_title); $part_config = $oModuleModel->getModulePartConfig('layout', $module_info->layout_srl); Context::addHtmlHeader($part_config->header_script); } // Set module and mid into module_info $this->module_info->module = $this->module; $this->module_info->mid = $this->mid; // Set site_srl add 2011 08 09 $this->module_info->site_srl = $site_module_info->site_srl; // Still no module? it's an error if (!$this->module) { $this->error = 'msg_module_is_not_exists'; $this->httpStatusCode = '404'; } // If mid exists, set mid into context if ($this->mid) { Context::set('mid', $this->mid, true); } // Call a trigger after moduleHandler init $output = ModuleHandler::triggerCall('moduleHandler.init', 'after', $this->module_info); if (!$output->toBool()) { $this->error = $output->getMessage(); return false; } // Set current module info into context Context::set('current_module_info', $this->module_info); return true; }
/** * @brief Change settings **/ function procInstallAdminSaveTimeZone() { $use_rewrite = Context::get('use_rewrite'); if ($use_rewrite != 'Y') { $use_rewrite = 'N'; } $use_sso = Context::get('use_sso'); if ($use_sso != 'Y') { $use_sso = 'N'; } $use_cdn = Context::get('use_cdn'); if ($use_cdn != 'Y') { $use_cdn = 'N'; } $time_zone = Context::get('time_zone'); $qmail_compatibility = Context::get('qmail_compatibility'); if ($qmail_compatibility != 'Y') { $qmail_compatibility = 'N'; } $use_db_session = Context::get('use_db_session'); if ($use_db_session != 'Y') { $use_db_session = 'N'; } $use_ssl = Context::get('use_ssl'); if (!$use_ssl) { $use_ssl = 'none'; } $use_html5 = Context::get('use_html5'); if (!$use_html5) { $use_html5 = 'N'; } $http_port = Context::get('http_port'); $https_port = Context::get('https_port'); $use_mobile_view = Context::get('use_mobile_view'); if ($use_mobile_view != 'Y') { $use_mobile_view = 'N'; } $admin_ip_list = Context::get('admin_ip_list'); $admin_ip_list = preg_replace("/[\r|\n|\r\n]+/", ",", $admin_ip_list); $admin_ip_list = preg_replace("/\\s+/", "", $admin_ip_list); if (preg_match('/(<\\?|<\\?php|\\?>)/xsm', $admin_ip_list)) { $admin_ip_list = ''; } $db_info = Context::getDBInfo(); $db_info->default_url = Context::get('default_url'); if ($db_info->default_url && !preg_match('/^(http|https):\\/\\//i', $db_info->default_url)) { $db_info->default_url = 'http://' . $db_info->default_url; } $db_info->time_zone = $time_zone; $db_info->qmail_compatibility = $qmail_compatibility; $db_info->use_db_session = $use_db_session; $db_info->use_rewrite = $use_rewrite; $db_info->use_sso = $use_sso; $db_info->use_ssl = $use_ssl; $db_info->use_cdn = $use_cdn; $db_info->use_html5 = $use_html5; $db_info->use_mobile_view = $use_mobile_view; $db_info->admin_ip_list = $admin_ip_list; if ($http_port) { $db_info->http_port = (int) $http_port; } else { if ($db_info->http_port) { unset($db_info->http_port); } } if ($https_port) { $db_info->https_port = (int) $https_port; } else { if ($db_info->https_port) { unset($db_info->https_port); } } unset($db_info->lang_type); Context::setDBInfo($db_info); $oInstallController =& getController('install'); $oInstallController->makeConfigFile(); $site_args->site_srl = 0; $site_args->index_module_srl = Context::get('index_module_srl'); $site_args->default_language = Context::get('change_lang_type'); $site_args->domain = $db_info->default_url; $oModuleController =& getController('module'); $oModuleController->updateSite($site_args); $this->setMessage('success_updated'); }
/** * Initialization. It finds the target module based on module, mid, document_srl, and prepares to execute an action * @return boolean true: OK, false: redirected * */ function init() { $oModuleModel = getModel('module'); $site_module_info = Context::get('site_module_info'); // if success_return_url and error_return_url is incorrect $urls = array(Context::get('success_return_url'), Context::get('error_return_url')); foreach ($urls as $url) { if (empty($url)) { continue; } $urlInfo = parse_url($url); $host = $urlInfo['host']; $dbInfo = Context::getDBInfo(); $defaultUrlInfo = parse_url($dbInfo->default_url); $defaultHost = $defaultUrlInfo['host']; if ($host && ($host != $defaultHost && $host != $site_module_info->domain)) { throw new Exception('msg_default_url_is_null'); } } if (!$this->document_srl && $this->mid && $this->entry) { $oDocumentModel = getModel('document'); $this->document_srl = $oDocumentModel->getDocumentSrlByAlias($this->mid, $this->entry); if ($this->document_srl) { Context::set('document_srl', $this->document_srl); } } // Get module's information based on document_srl, if it's specified if ($this->document_srl) { $module_info = $oModuleModel->getModuleInfoByDocumentSrl($this->document_srl); // If the document does not exist, remove document_srl if (!$module_info) { unset($this->document_srl); } else { // If it exists, compare mid based on the module information // if mids are not matching, set it as the document's mid if (!$this->mid || $this->mid != $module_info->mid) { if (Context::getRequestMethod() == 'GET') { $this->mid = $module_info->mid; header('location:' . getNotEncodedSiteUrl($site_module_info->domain, 'mid', $this->mid, 'document_srl', $this->document_srl)); return FALSE; } else { $this->mid = $module_info->mid; Context::set('mid', $this->mid); } } // if requested module is different from one of the document, remove the module information retrieved based on the document number if ($this->module && $module_info->module != $this->module) { unset($module_info); } } } // If module_info is not set yet, and there exists mid information, get module information based on the mid if (!$module_info && $this->mid) { $module_info = $oModuleModel->getModuleInfoByMid($this->mid, $site_module_info->site_srl); //if($this->module && $module_info->module != $this->module) unset($module_info); } // redirect, if module_site_srl and site_srl are different if (!$this->module && !$module_info && $site_module_info->site_srl == 0 && $site_module_info->module_site_srl > 0) { $site_info = $oModuleModel->getSiteInfo($site_module_info->module_site_srl); header("location:" . getNotEncodedSiteUrl($site_info->domain, 'mid', $site_module_info->mid)); return FALSE; } // If module_info is not set still, and $module does not exist, find the default module if (!$module_info && !$this->module && !$this->mid) { $module_info = $site_module_info; } if (!$module_info && !$this->module && $site_module_info->module_site_srl) { $module_info = $site_module_info; } // redirect, if site_srl of module_info is different from one of site's module_info if ($module_info && $module_info->site_srl != $site_module_info->site_srl && !isCrawler()) { // If the module is of virtual site if ($module_info->site_srl) { $site_info = $oModuleModel->getSiteInfo($module_info->site_srl); $redirect_url = getNotEncodedSiteUrl($site_info->domain, 'mid', Context::get('mid'), 'document_srl', Context::get('document_srl'), 'module_srl', Context::get('module_srl'), 'entry', Context::get('entry')); // If it's called from a virtual site, though it's not a module of the virtual site } else { $db_info = Context::getDBInfo(); if (!$db_info->default_url) { return Context::getLang('msg_default_url_is_not_defined'); } else { $redirect_url = getNotEncodedSiteUrl($db_info->default_url, 'mid', Context::get('mid'), 'document_srl', Context::get('document_srl'), 'module_srl', Context::get('module_srl'), 'entry', Context::get('entry')); } } header("location:" . $redirect_url); return FALSE; } // If module info was set, retrieve variables from the module information if ($module_info) { $this->module = $module_info->module; $this->mid = $module_info->mid; $this->module_info = $module_info; Context::setBrowserTitle($module_info->browser_title); $viewType = Mobile::isFromMobilePhone() ? 'M' : 'P'; $targetSrl = Mobile::isFromMobilePhone() ? 'mlayout_srl' : 'layout_srl'; // use the site default layout. if ($module_info->{$targetSrl} == -1) { $oLayoutAdminModel = getAdminModel('layout'); $layoutSrl = $oLayoutAdminModel->getSiteDefaultLayout($viewType, $module_info->site_srl); } else { $layoutSrl = $module_info->{$targetSrl}; } // reset a layout_srl in module_info. $module_info->{$targetSrl} = $layoutSrl; $part_config = $oModuleModel->getModulePartConfig('layout', $layoutSrl); Context::addHtmlHeader($part_config->header_script); } // Set module and mid into module_info if (!isset($this->module_info)) { $this->module_info = new stdClass(); } $this->module_info->module = $this->module; $this->module_info->mid = $this->mid; // Set site_srl add 2011 08 09 $this->module_info->site_srl = $site_module_info->site_srl; // Still no module? it's an error if (!$this->module) { $this->error = 'msg_module_is_not_exists'; $this->httpStatusCode = '404'; } // If mid exists, set mid into context if ($this->mid) { Context::set('mid', $this->mid, TRUE); } // Call a trigger after moduleHandler init $output = ModuleHandler::triggerCall('moduleHandler.init', 'after', $this->module_info); if (!$output->toBool()) { $this->error = $output->getMessage(); return TRUE; } // Set current module info into context Context::set('current_module_info', $this->module_info); return TRUE; }
/** * @brief module, mid, document_srl을 이용하여 모듈을 찾고 act를 실행하기 위한 준비를 함 **/ function init() { // ModuleModel 객체 생성 $oModuleModel =& getModel('module'); $site_module_info = Context::get('site_module_info'); if (!$this->document_srl && $this->mid && $this->entry) { $oDocumentModel =& getModel('document'); $this->document_srl = $oDocumentModel->getDocumentSrlByAlias($this->mid, $this->entry); if ($this->document_srl) { Context::set('document_srl', $this->document_srl); } } // 문서번호(document_srl)가 있을 경우 모듈 정보를 구해옴 if ($this->document_srl && !$this->module) { $module_info = $oModuleModel->getModuleInfoByDocumentSrl($this->document_srl); // 문서가 존재하지 않으면 문서 정보를 제거 if (!$module_info) { unset($this->document_srl); // 문서가 존재할 경우 모듈 정보를 바탕으로 virtual site 및 mid 비교 } else { // mid 값이 다르면 문서의 mid로 설정 if ($this->mid != $module_info->mid) { $this->mid = $module_info->mid; Context::set('mid', $module_info->mid, true); } } // 요청된 모듈과 문서 번호가 다르면 문서 번호에 의한 모듈 정보를 제거 if ($this->module && $module_info->module != $this->module) { unset($module_info); } } // 모듈정보를 구하지 못했고 mid 요청이 있으면 mid에 해당하는 모듈 정보를 구함 if (!$module_info && $this->mid) { $module_info = $oModuleModel->getModuleInfoByMid($this->mid, $site_module_info->site_srl); //if($this->module && $module_info->module != $this->module) unset($module_info); } // module_site_srl과 site_srl 값이 다르면 redirect 시도 if (!$this->module && !$module_info && $site_module_info->site_srl == 0 && $site_module_info->module_site_srl > 0) { $site_info = $oModuleModel->getSiteInfo($site_module_info->module_site_srl); header("location:" . getNotEncodedSiteUrl($site_info->domain, 'mid', $site_module_info->mid)); return false; } // 역시 모듈을 못 찾았고 $module이 없다면 기본 모듈을 찾아봄 if (!$module_info && !$this->module) { $module_info = $site_module_info; } if (!$module_info && !$this->module && $site_module_info->module_site_srl) { $module_info = $site_module_info; } // 모듈정보와 사이트 모듈정보가 다르면(다른 사이트이면) 페이지 리다이렉트 if ($module_info && $module_info->site_srl != $site_module_info->site_srl) { // 현재 요청된 모듈이 가상 사이트 모듈일 경우 if ($module_info->site_srl) { $site_info = $oModuleModel->getSiteInfo($module_info->site_srl); $redirect_url = getNotEncodedSiteUrl($site_info->domain, 'mid', Context::get('mid'), 'document_srl', Context::get('document_srl'), 'module_srl', Context::get('module_srl'), 'entry', Context::get('entry')); // 가상 사이트 모듈이 아닌데 가상 사이트에서 호출되었을 경우 } else { $db_info = Context::getDBInfo(); if (!$db_info->default_url) { return die("기본 URL이 정해지지 않아서 동작을 중지합니다"); } else { $redirect_url = getNotEncodedSiteUrl($db_info->default_url, 'mid', Context::get('mid'), 'document_srl', Context::get('document_srl'), 'module_srl', Context::get('module_srl'), 'entry', Context::get('entry')); } } header("location:" . $redirect_url); return false; } // 모듈 정보가 찾아졌을 경우 모듈 정보에서 기본 변수들을 구함, 모듈 정보에서 module 이름을 구해움 if ($module_info) { $this->module = $module_info->module; $this->mid = $module_info->mid; $this->module_info = $module_info; Context::setBrowserTitle($module_info->browser_title); $part_config = $oModuleModel->getModulePartConfig('layout', $module_info->layout_srl); Context::addHtmlHeader($part_config->header_script); } // 모듈정보에 module과 mid를 강제로 지정 $this->module_info->module = $this->module; $this->module_info->mid = $this->mid; // 여기까지도 모듈 정보를 찾지 못했다면 깔끔하게 시스템 오류 표시 if (!$this->module) { $this->error = 'msg_module_is_not_exists'; } // mid값이 있을 경우 mid값을 세팅 if ($this->mid) { Context::set('mid', $this->mid, true); } // 실제 동작을 하기 전에 trigger 호출 $output = ModuleHandler::triggerCall('moduleHandler.init', 'after', $this->module_info); if (!$output->toBool()) { $this->error = $output->getMessage(); return false; } // 현재 모듈의 정보를 세팅 Context::set('current_module_info', $this->module_info); return true; }
/** * check allowed target ip address when login for admin. * * @return boolean (true : allowed, false : refuse) **/ function getMemberAdminIPCheck() { $db_info = Context::getDBInfo(); $admin_ip_list = $db_info->admin_ip_list; $admin_ip_list = explode(",", $admin_ip_list); $oMemberModel =& getModel('member'); $ip = $_SERVER['REMOTE_ADDR']; $falg = false; foreach ($admin_ip_list as $admin_ip_list_key => $admin_ip_value) { if (preg_match('/^\\d{1,3}(?:.(\\d{1,3}|\\*)){3}\\s*$/', $admin_ip_value, $matches) && $ip) { $admin_ip = $matches[0]; $admin_ip = str_replace('*', '', $admin_ip); $admin_ip_patterns[] = preg_quote($admin_ip); $admin_ip_pattern = '/^(' . implode($admin_ip_patterns, '|') . ')/'; if (preg_match($admin_ip_pattern, $ip, $matches)) { return true; } $flag = true; } } if (!$flag) { return true; } return false; }