From 6bb0f71bebfcdecb45d45a8298fb05ae474a0cd2 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Sat, 18 Feb 2017 17:14:02 +0900 Subject: [PATCH 01/55] Add 'domains' table to module module --- modules/module/schemas/domains.xml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 modules/module/schemas/domains.xml diff --git a/modules/module/schemas/domains.xml b/modules/module/schemas/domains.xml new file mode 100644 index 000000000..296173d81 --- /dev/null +++ b/modules/module/schemas/domains.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + +
\ No newline at end of file From a69bac6e2b8839466d352841df30907321e26112 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Mon, 20 Feb 2017 18:14:15 +0900 Subject: [PATCH 02/55] Implement migration of site info from 'sites' table and multidomain module (if installed) --- modules/module/module.class.php | 209 ++++++++++++++---------- modules/module/queries/getDomains.xml | 14 ++ modules/module/queries/getSites.xml | 11 ++ modules/module/queries/insertDomain.xml | 20 +++ 4 files changed, 171 insertions(+), 83 deletions(-) create mode 100644 modules/module/queries/getDomains.xml create mode 100644 modules/module/queries/getSites.xml create mode 100644 modules/module/queries/insertDomain.xml diff --git a/modules/module/module.class.php b/modules/module/module.class.php index 59425c718..07f6e1340 100644 --- a/modules/module/module.class.php +++ b/modules/module/module.class.php @@ -17,32 +17,34 @@ class module extends ModuleObject $oDB = &DB::getInstance(); $oDB->addIndex("modules","idx_site_mid", array("site_srl","mid"), true); - $oDB->addIndex('sites','unique_domain',array('domain'),true); + + // Insert new domain + $output = executeQuery('module.getDomains'); + if(!$output->data || !$output->data->index_module_srl) + { + $current_url = Rhymix\Framework\Url::getCurrentUrl(); + $domain = new stdClass(); + $domain->domain_srl = 0; + $domain->domain = Rhymix\Framework\URL::decodeIdna(parse_url($current_url, PHP_URL_HOST)); + $domain->index_module_srl = 0; + $domain->index_document_srl = 0; + $domain->http_port = null; + $domain->https_port = null; + $domain->security = config('url.ssl') ?: 'none'; + $domain->description = ''; + $domain->settings = json_encode(array('language' => null, 'timezone' => null)); + $output = executeQuery('module.insertDomain', $domain); + if (!$output->toBool()) + { + return $output; + } + } + // Create a directory to use in the module module FileHandler::makeDir('./files/cache/module_info'); FileHandler::makeDir('./files/cache/triggers'); FileHandler::makeDir('./files/ruleset'); - // Insert site information into the sites table - $args = new stdClass; - $args->site_srl = 0; - $output = $oDB->executeQuery('module.getSite', $args); - if(!$output->data || !$output->data->index_module_srl) - { - $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 = 0; - $site_args->domain = $domain; - $site_args->default_language = config('locale.default_lang'); - - $output = executeQuery('module.insertSite', $site_args); - if(!$output->toBool()) return $output; - } - return new Object(); } @@ -58,23 +60,13 @@ class module extends ModuleObject if(!$oDB->isIndexExists('modules',"idx_site_mid")) return true; // Move permissions/skin information of all modules to the table, grants. if($oDB->isColumnExists('modules', 'grants')) return true; - // Move permissions/skin information of all modules to the table, grants. - if(!$oDB->isColumnExists('sites', 'default_language')) return true; // Delete extra_vars* column for($i=1;$i<=20;$i++) { if($oDB->isColumnExists("documents","extra_vars".$i)) return true; } - // Insert site information to the table, sites - $args = new stdClass(); - $args->site_srl = 0; - $output = $oDB->executeQuery('module.getSite', $args); - if(!$output->data) return true; - - // If domain index is defined on the table, sites - if($oDB->isIndexExists('sites', 'idx_domain')) return true; - if(!$oDB->isIndexExists('sites','unique_domain')) return true; + // Check indexes if(!$oDB->isColumnExists("modules", "use_mobile")) return true; if(!$oDB->isColumnExists("modules", "mlayout_srl")) return true; if(!$oDB->isColumnExists("modules", "mcontent")) return true; @@ -99,7 +91,16 @@ class module extends ModuleObject } } - // XE 1.7 + // Check domains + if (!$oDB->isTableExists('domains')) + { + return true; + } + $output = $oDB->executeQuery('module.getDomains', new stdClass); + if (!$output->data) + { + return true; + } // check fix mskin if(!$oDB->isColumnExists("modules", "is_mskin_fix")) return true; @@ -303,11 +304,7 @@ class module extends ModuleObject $oDB->dropColumn('modules','skin_vars'); $oDB->dropColumn('modules','extra_vars'); } - // Rights of all modules/skins transferring the information into a table Update grants - if(!$oDB->isColumnExists('sites', 'default_language')) - { - $oDB->addColumn('sites','default_language','varchar',255,0,false); - } + // extra_vars * Remove Column for($i=1;$i<=20;$i++) { @@ -315,35 +312,16 @@ class module extends ModuleObject $oDB->dropColumn('documents','extra_vars'.$i); } - // Enter the main site information sites on the table - $args = new stdClass; - $args->site_srl = 0; - $output = $oDB->executeQuery('module.getSite', $args); - if(!$output->data) + // Migrate domains + if (!$oDB->isTableExists('domains')) { - // Basic mid, language Wanted - $mid_output = $oDB->executeQuery('module.getDefaultMidInfo', $args); - $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 = config('locale.default_lang'); - - $output = executeQuery('module.insertSite', $site_args); - if(!$output->toBool()) return $output; + $oDB->createTableByXmlFile($this->module_path . 'schemas/domains.xml'); } - - if($oDB->isIndexExists('sites','idx_domain')) + + $output = executeQuery('module.getDomains'); + if (!$output->data) { - $oDB->dropIndex('sites','idx_domain'); - } - if(!$oDB->isIndexExists('sites','unique_domain')) - { - $this->updateForUniqueSiteDomain(); - $oDB->addIndex('sites','unique_domain',array('domain'),true); + $this->migrateDomains(); } if(!$oDB->isColumnExists("modules", "use_mobile")) @@ -414,30 +392,95 @@ class module extends ModuleObject return new Object(0, 'success_updated'); } - function updateForUniqueSiteDomain() + /** + * @brief Migrate old sites and multidomain info to new 'domains' table + */ + function migrateDomains() { - $output = executeQueryArray("module.getNonuniqueDomains"); - if(!$output->data) return; - foreach($output->data as $data) + // Initialize domains data. + $domains = array(); + + // Check XE sites. + $output = executeQueryArray('module.getSites'); + if ($output->data) { - if($data->count == 1) continue; - $domain = $data->domain; - $args = new stdClass; - $args->domain = $domain; - $output2 = executeQueryArray("module.getSiteByDomain", $args); - $bFirst = true; - foreach($output2->data as $site) + foreach ($output->data as $site_info) { - if($bFirst) + $site_domain = $site_info->domain; + if (!preg_match('@^https?://@', $site_domain)) { - $bFirst = false; - continue; + $site_domain = 'http://' . $site_domain; } - $domain .= "_"; - $args = new stdClass; - $args->domain = $domain; - $args->site_srl = $site->site_srl; - $output3 = executeQuery("module.updateSite", $args); + + $domain = new stdClass(); + $domain->domain_srl = $site_info->site_srl; + $domain->domain = Rhymix\Framework\URL::decodeIdna(strtolower(parse_url($site_domain, PHP_URL_HOST))); + $domain->index_module_srl = $site_info->index_module_srl; + $domain->index_document_srl = 0; + $domain->http_port = config('url.http_port') ?: null; + $domain->https_port = config('url.https_port') ?: null; + $domain->security = config('url.ssl') ?: 'none'; + $domain->description = ''; + $domain->settings = json_encode(array('language' => $site_info->default_language, 'timezone' => null)); + $domain->regdate = $site_info->regdate; + $domains[$domain->domain] = $domain; + } + } + else + { + $output = executeQuery('module.getDefaultMidInfo', $args); + $default_hostinfo = parse_url(Context::getDefaultUrl()); + + $domain = new stdClass(); + $domain->domain_srl = 0; + $domain->domain = Rhymix\Framework\URL::decodeIdna(strtolower($default_hostinfo['host'])); + $domain->index_module_srl = $output->data->module_srl; + $domain->index_document_srl = 0; + $domain->http_port = isset($default_hostinfo['port']) ? intval($default_hostinfo['port']) : null; + $domain->https_port = null; + $domain->security = config('url.ssl') ?: 'none'; + $domain->description = ''; + $domain->settings = json_encode(array('language' => null, 'timezone' => null)); + $domains[$domain->domain] = $domain; + } + + // Check multidomain module. + if (getModel('multidomain')) + { + $output = executeQueryArray('multidomain.getMultidomainList', (object)array('order_type' => 'asc', 'list_count' => 100000000)); + if ($output->data) + { + foreach ($output->data as $site_info) + { + $site_domain = $site_info->domain; + if (!preg_match('@^https?://@', $site_domain)) + { + $site_domain = 'http://' . $site_domain; + } + + $domain = new stdClass(); + $domain->domain_srl = $site_info->multidomain_srl; + $domain->domain = Rhymix\Framework\URL::decodeIdna(strtolower(parse_url($site_domain, PHP_URL_HOST))); + $domain->index_module_srl = intval($site_info->module_srl); + $domain->index_document_srl = intval($site_info->document_srl); + $domain->http_port = config('url.http_port') ?: null; + $domain->https_port = config('url.https_port') ?: null; + $domain->security = config('url.ssl') ?: 'none'; + $domain->description = ''; + $domain->settings = json_encode(array('language' => null, 'timezone' => null)); + $domain->regdate = $site_info->regdate; + $domains[$domain->domain] = $domain; + } + } + } + + // Insert into DB. + foreach ($domains as $domain) + { + $output = executeQuery('module.insertDomain', $domain); + if (!$output->toBool()) + { + return $output; } } } diff --git a/modules/module/queries/getDomains.xml b/modules/module/queries/getDomains.xml new file mode 100644 index 000000000..9e883152c --- /dev/null +++ b/modules/module/queries/getDomains.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/modules/module/queries/getSites.xml b/modules/module/queries/getSites.xml new file mode 100644 index 000000000..788cb1e9e --- /dev/null +++ b/modules/module/queries/getSites.xml @@ -0,0 +1,11 @@ + + +
+ + + + + + + + diff --git a/modules/module/queries/insertDomain.xml b/modules/module/queries/insertDomain.xml new file mode 100644 index 000000000..f90f2ea55 --- /dev/null +++ b/modules/module/queries/insertDomain.xml @@ -0,0 +1,20 @@ + + +
+ + + + + + + + + + + + + + + + + \ No newline at end of file From 726220d3eb226d0cfced42ac32a3b31878ea4b9f Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Mon, 20 Feb 2017 20:43:30 +0900 Subject: [PATCH 03/55] Load site_module_info from 'domains' table instead of 'sites' table --- classes/context/Context.class.php | 28 ++--- modules/module/module.class.php | 14 ++- modules/module/module.model.php | 139 +++++++---------------- modules/module/queries/getDomainInfo.xml | 25 ++++ 4 files changed, 85 insertions(+), 121 deletions(-) create mode 100644 modules/module/queries/getDomainInfo.xml diff --git a/classes/context/Context.class.php b/classes/context/Context.class.php index 3af362869..388ec8048 100644 --- a/classes/context/Context.class.php +++ b/classes/context/Context.class.php @@ -262,14 +262,10 @@ class Context { $oModuleModel = getModel('module'); $site_module_info = $oModuleModel->getDefaultMid() ?: 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); + self::set('_http_port', self::$_instance->db_info->http_port = $site_module_info->http_port ?: null); + self::set('_https_port', self::$_instance->db_info->https_port = $site_module_info->https_port ?: null); + self::set('_use_ssl', self::$_instance->db_info->use_ssl = $site_module_info->security ?: 'none'); if($site_module_info->site_srl && isSiteID($site_module_info->domain)) { self::set('vid', $site_module_info->domain, TRUE); @@ -312,9 +308,9 @@ class Context if(!$this->lang_type || !isset($enabled_langs[$this->lang_type])) { - if($site_module_info->default_language) + if($site_module_info->settings->language) { - $this->lang_type = $this->db_info->lang_type = $site_module_info->default_language; + $this->lang_type = $this->db_info->lang_type = $site_module_info->settings->language; } else { @@ -470,9 +466,6 @@ class Context // Copy to old format for backward compatibility. self::$_instance->db_info = self::convertDBInfo($config); self::$_instance->allow_rewrite = self::$_instance->db_info->use_rewrite === 'Y'; - self::set('_http_port', self::$_instance->db_info->http_port ?: null); - self::set('_https_port', self::$_instance->db_info->https_port ?: null); - self::set('_use_ssl', self::$_instance->db_info->use_ssl); $GLOBALS['_time_zone'] = self::$_instance->db_info->time_zone; } @@ -1568,19 +1561,14 @@ class Context // if $domain is set, compare current URL. If they are same, remove the domain, otherwise link to the domain. if($domain) { - $domain_info = parse_url($domain); if(is_null($current_info)) { - $current_info = parse_url((RX_SSL ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . RX_BASEURL); + $current_info = parse_url((RX_SSL ? 'https' : 'http') . '://' . Rhymix\Framework\URL::decodeIdna($_SERVER['HTTP_HOST']) . RX_BASEURL); } - if($domain_info['host'] . $domain_info['path'] == $current_info['host'] . $current_info['path']) + if($domain === $current_info['host']) { unset($domain); } - else - { - $domain = rtrim(preg_replace('/^(http|https):\/\//i', '', trim($domain)), '/') . '/'; - } } $get_vars = array(); @@ -1794,7 +1782,7 @@ class Context if($domain) { - $target_url = rtrim(trim($domain), '/') . '/'; + $target_url = rtrim(trim($domain), '/') . RX_BASEURL; } else { diff --git a/modules/module/module.class.php b/modules/module/module.class.php index 07f6e1340..e274d3fca 100644 --- a/modules/module/module.class.php +++ b/modules/module/module.class.php @@ -79,6 +79,7 @@ class module extends ModuleObject if(!is_dir('./files/ruleset')) return true; + $args = new stdClass; $args->skin = '.'; $output = executeQueryArray('module.getModuleSkinDotList', $args); if($output->data && count($output->data) > 0) @@ -313,12 +314,7 @@ class module extends ModuleObject } // Migrate domains - if (!$oDB->isTableExists('domains')) - { - $oDB->createTableByXmlFile($this->module_path . 'schemas/domains.xml'); - } - - $output = executeQuery('module.getDomains'); + $output = @executeQuery('module.getDomains'); if (!$output->data) { $this->migrateDomains(); @@ -397,6 +393,12 @@ class module extends ModuleObject */ function migrateDomains() { + // Create the domains table. + if (!$oDB->isTableExists('domains')) + { + $oDB->createTableByXmlFile($this->module_path . 'schemas/domains.xml'); + } + // Initialize domains data. $domains = array(); diff --git a/modules/module/module.model.php b/modules/module/module.model.php index 50eb777bb..42665aea8 100644 --- a/modules/module/module.model.php +++ b/modules/module/module.model.php @@ -51,16 +51,21 @@ class moduleModel extends module function getSiteInfo($site_srl, $columnList = array()) { $args = new stdClass(); - $args->site_srl = $site_srl; - $output = executeQuery('module.getSiteInfo', $args, $columnList); + $args->domain_srl = $site_srl; + $output = executeQuery('module.getDomainInfo', $args, $columnList); return $output->data; } function getSiteInfoByDomain($domain, $columnList = array()) { + if (strpos($domain, '/') !== false) + { + $domain = parse_url($domain, PHP_URL_HOST); + } + $args = new stdClass(); $args->domain = $domain; - $output = executeQuery('module.getSiteInfoByDomain', $args, $columnList); + $output = executeQuery('module.getDomainInfo', $args, $columnList); return $output->data; } @@ -82,108 +87,52 @@ class moduleModel extends module */ 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']) + // Get current domain. + $domain = strtolower(preg_replace('/:\d+$/', '', $_SERVER['HTTP_HOST'])); + if (strpos($domain, 'xn--') !== false) { - $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); + $domain = Rhymix\Framework\URL::decodeIdna($domain); } - - if($domain === '') + + // Find the domain information. + $domain_info = Rhymix\Framework\Cache::get('site_and_module:domain_info:' . $domain); + if (!$domain_info) { - if(!$vid) $vid = $mid; - if($vid) + $output = executeQuery('module.getDomainInfo', (object)array('domain' => $domain)); + if ($output->data) { - $domain = $vid; + $domain_info = $output->data; } - } - - // If domain is set, look for subsite - if($domain !== '') - { - $site_info = Rhymix\Framework\Cache::get('site_and_module:site_info:' . md5($domain)); - if($site_info === null) + else { - $args = new stdClass(); - $args->domain = $domain; - $output = executeQuery('module.getSiteInfoByDomain', $args); - $site_info = $output->data; - Rhymix\Framework\Cache::set('site_and_module:site_info:' . md5($domain), $site_info, 0, true); - } - - 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 = Rhymix\Framework\Cache::get('site_and_module:default_site'); - if($site_info === null) - { - $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) + $output = executeQuery('module.getDomainInfo', (object)array('domain_srl' => 0)); + 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); - $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 = config('locale.default_lang'); - - 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); + $domain_info = $output->data; + } + else + { + $this->migrateDomains(); + return $this->getDefaultMid(); } - $site_info = $output->data; - Rhymix\Framework\Cache::set('site_and_module:default_site', $site_info, 0, true); } + + $domain_info->site_srl = $domain_info->domain_srl; + $domain_info->settings = $domain_info->settings ? json_decode($domain_info->settings) : new stdClass; + $domain_info->default_language = $domain_info->settings->language ?: config('locale.default_lang'); + + Rhymix\Framework\Cache::set('site_and_module:domain_info:' . $domain, $domain_info, 0, true); + } + + // Fill in module extra vars and return. + if ($domain_info->module_srl) + { + return $this->addModuleExtraVars($domain_info); + } + else + { + return $domain_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); } /** diff --git a/modules/module/queries/getDomainInfo.xml b/modules/module/queries/getDomainInfo.xml new file mode 100644 index 000000000..b22cbf59b --- /dev/null +++ b/modules/module/queries/getDomainInfo.xml @@ -0,0 +1,25 @@ + + +
+
+ + + + + + + + + + + + + + + + + + + + + From c82c2f307a91512b2059d04150468c8682d9dcf8 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Mon, 20 Feb 2017 21:22:38 +0900 Subject: [PATCH 04/55] Various changes to URL handling routines --- classes/context/Context.class.php | 101 +++++++++---------------- classes/module/ModuleHandler.class.php | 20 ----- modules/module/module.controller.php | 13 +--- modules/module/module.model.php | 8 +- 4 files changed, 44 insertions(+), 98 deletions(-) diff --git a/classes/context/Context.class.php b/classes/context/Context.class.php index 388ec8048..10938f7e1 100644 --- a/classes/context/Context.class.php +++ b/classes/context/Context.class.php @@ -238,7 +238,6 @@ class Context // Set global variables for backward compatibility. $GLOBALS['__Context__'] = $this; - $this->_COOKIE = $_COOKIE; // Set information about the current request. $this->setRequestMethod(); @@ -263,6 +262,7 @@ class Context $oModuleModel = getModel('module'); $site_module_info = $oModuleModel->getDefaultMid() ?: new stdClass; self::set('site_module_info', $site_module_info); + self::set('_default_url', self::$_instance->db_info->default_url = self::getDefaultUrl($site_module_info)); self::set('_http_port', self::$_instance->db_info->http_port = $site_module_info->http_port ?: null); self::set('_https_port', self::$_instance->db_info->https_port = $site_module_info->https_port ?: null); self::set('_use_ssl', self::$_instance->db_info->use_ssl = $site_module_info->security ?: 'none'); @@ -338,6 +338,7 @@ class Context // start session $relax_key_checks = ($this->act === 'procFileUpload' && preg_match('/shockwave\s?flash/i', $_SERVER['HTTP_USER_AGENT'])); Rhymix\Framework\Session::start(false, $relax_key_checks); + $this->_COOKIE = $_COOKIE; // start output buffer ob_start(); @@ -517,14 +518,6 @@ class Context $db_info->ftp_info->ftp_pasv = $config['ftp']['pasv'] ? 'Y' : 'N'; $db_info->ftp_info->ftp_root_path = $config['ftp']['path']; $db_info->ftp_info->sftp = $config['ftp']['sftp'] ? 'Y' : 'N'; - $db_info->default_url = $config['url']['default']; - if (!$db_info->default_url) - { - $db_info->default_url = (RX_SSL ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . RX_BASEURL; - } - $db_info->http_port = $config['url']['http_port']; - $db_info->https_port = $config['url']['https_port']; - $db_info->use_ssl = $config['url']['ssl']; $db_info->lang_type = $config['locale']['default_lang']; $db_info->time_zone = $config['locale']['internal_timezone']; $db_info->time_zone = sprintf('%s%02d%02d', $db_info->time_zone >= 0 ? '+' : '-', abs($db_info->time_zone) / 3600, (abs($db_info->time_zone) % 3600 / 60)); @@ -596,11 +589,26 @@ class Context /** * Return default URL * + * @param object $site_module_info (optional) * @return string Default URL */ - public static function getDefaultUrl() + public static function getDefaultUrl($site_module_info = null) { - return self::$_instance->db_info->default_url; + if ($site_module_info === null && ($default_url = self::get('_default_url'))) + { + return $default_url; + } + + if ($site_module_info === null) + { + $site_module_info === self::get('site_module_info'); + } + + $prefix = $site_module_info->security === 'always' ? 'https://' : 'http://'; + $hostname = $site_module_info->domain; + $port = $site_module_info->security === 'always' ? $site_module_info->https_port : $site_module_info->http_port; + $result = $prefix . $hostname . ($port ? sprintf(':%d', $port) : '') . RX_BASEURL; + return $result; } /** @@ -1539,6 +1547,10 @@ class Context } // If $domain is set, handle it (if $domain is vid type, remove $domain and handle with $vid) + if (strpos($domain, '/') !== false) + { + $domain = Rhymix\Framework\URL::getDomainFromURL($domain); + } if($domain && isSiteID($domain)) { $vid = $domain; @@ -1743,7 +1755,7 @@ class Context */ public static function getRequestUri($ssl_mode = FOLLOW_REQUEST_SSL, $domain = null) { - static $url = array(); + static $domain_infos = array(); // Check HTTP Request if(!isset($_SERVER['SERVER_PROTOCOL'])) @@ -1756,20 +1768,6 @@ class Context $ssl_mode = ENFORCE_SSL; } - if($domain) - { - $domain_key = md5($domain); - } - else - { - $domain_key = 'default'; - } - - if(isset($url[$ssl_mode][$domain_key])) - { - return $url[$ssl_mode][$domain_key]; - } - switch($ssl_mode) { case FOLLOW_REQUEST_SSL: $use_ssl = RX_SSL; @@ -1780,50 +1778,21 @@ class Context break; } - if($domain) + $site_module_info = self::get('site_module_info'); + if ($domain !== null && $domain !== $site_module_info->domain) { - $target_url = rtrim(trim($domain), '/') . RX_BASEURL; - } - else - { - $target_url = $_SERVER['HTTP_HOST'] . RX_BASEURL; - } - - $url_info = parse_url('http://' . $target_url); - - if($use_ssl != RX_SSL) - { - unset($url_info['port']); - } - - if($use_ssl) - { - $port = self::get('_https_port'); - if($port && $port != 443) + if (!isset($domain_infos[$domain])) { - $url_info['port'] = $port; - } - elseif($url_info['port'] == 443) - { - unset($url_info['port']); + $domain_infos[$domain] = getModel('module')->getSiteInfoByDomain($domain); } + $site_module_info = $domain_infos[$domain] ?: $site_module_info; } - else - { - $port = self::get('_http_port'); - if($port && $port != 80) - { - $url_info['port'] = $port; - } - elseif($url_info['port'] == 80) - { - unset($url_info['port']); - } - } - - $url[$ssl_mode][$domain_key] = sprintf('%s://%s%s%s', $use_ssl ? 'https' : $url_info['scheme'], $url_info['host'], $url_info['port'] && $url_info['port'] != 80 ? ':' . $url_info['port'] : '', $url_info['path']); - - return $url[$ssl_mode][$domain_key]; + + $prefix = ($use_ssl && $site_module_info->security !== 'none') ? 'https://' : 'http://'; + $hostname = $site_module_info->domain; + $port = ($use_ssl && $site_module_info->security !== 'none') ? $site_module_info->https_port : $site_module_info->http_port; + $result = $prefix . $hostname . ($port ? sprintf(':%d', $port) : '') . RX_BASEURL; + return $result; } /** diff --git a/classes/module/ModuleHandler.class.php b/classes/module/ModuleHandler.class.php index 983892843..683eef647 100644 --- a/classes/module/ModuleHandler.class.php +++ b/classes/module/ModuleHandler.class.php @@ -251,26 +251,6 @@ class ModuleHandler extends Handler $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 && !Rhymix\Framework\UA::isRobot()) - { - // 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 - { - $redirect_url = getNotEncodedSiteUrl(Context::getDefaultUrl(), 'mid', Context::get('mid'), 'document_srl', Context::get('document_srl'), 'module_srl', Context::get('module_srl'), 'entry', Context::get('entry')); - } - - Context::setCacheControl(0); - header("Location: $redirect_url", true, 301); - return false; - } - // redirect, if site start module if(Context::getRequestMethod() === 'GET' && isset($_GET['mid']) && $_GET['mid'] === $site_module_info->mid && count($_GET) === 1) { diff --git a/modules/module/module.controller.php b/modules/module/module.controller.php index f5568f294..6c7298d24 100644 --- a/modules/module/module.controller.php +++ b/modules/module/module.controller.php @@ -1087,18 +1087,11 @@ class moduleController extends module if(is_null($lang)) { - $site_module_info = Context::get('site_module_info'); - if(!$site_module_info) - { - $oModuleModel = getModel('module'); - $site_module_info = $oModuleModel->getDefaultMid(); - Context::set('site_module_info', $site_module_info); - } - $cache_file = sprintf('%sfiles/cache/lang_defined/%d.%s.php', _XE_PATH_, $site_module_info->site_srl, Context::getLangType()); + $cache_file = sprintf('%sfiles/cache/lang_defined/%d.%s.php', _XE_PATH_, 0, Context::getLangType()); if(!file_exists($cache_file)) { $oModuleAdminController = getAdminController('module'); - $oModuleAdminController->makeCacheDefinedLangCode($site_module_info->site_srl); + $oModuleAdminController->makeCacheDefinedLangCode(0); } if(file_exists($cache_file)) @@ -1108,7 +1101,7 @@ class moduleController extends module if($cacheFileMtime < $moduleAdminControllerMtime) { $oModuleAdminController = getAdminController('module'); - $oModuleAdminController->makeCacheDefinedLangCode($site_module_info->site_srl); + $oModuleAdminController->makeCacheDefinedLangCode(0); } require_once($cache_file); diff --git a/modules/module/module.model.php b/modules/module/module.model.php index 42665aea8..b58817b6c 100644 --- a/modules/module/module.model.php +++ b/modules/module/module.model.php @@ -60,7 +60,11 @@ class moduleModel extends module { if (strpos($domain, '/') !== false) { - $domain = parse_url($domain, PHP_URL_HOST); + $domain = Rhymix\Framework\URL::getDomainFromURL($domain); + if ($domain === false) + { + return null; + } } $args = new stdClass(); @@ -117,7 +121,7 @@ class moduleModel extends module } } - $domain_info->site_srl = $domain_info->domain_srl; + $domain_info->site_srl = 0; $domain_info->settings = $domain_info->settings ? json_decode($domain_info->settings) : new stdClass; $domain_info->default_language = $domain_info->settings->language ?: config('locale.default_lang'); From aae4d884c1b1bfc26fe9eb22c714c86edc2600fe Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Mon, 20 Feb 2017 21:23:31 +0900 Subject: [PATCH 05/55] Add homepage (CafeXE) module to blacklist --- common/defaults/blacklist.php | 1 + 1 file changed, 1 insertion(+) diff --git a/common/defaults/blacklist.php b/common/defaults/blacklist.php index b3add3eaf..e49e81ce2 100644 --- a/common/defaults/blacklist.php +++ b/common/defaults/blacklist.php @@ -10,6 +10,7 @@ return array( 'auto_login' => true, 'errorlogger' => true, 'fix_mysql_utf8' => true, + 'homepage' => true, 'member_communication' => true, 'seo' => true, 'session_shield' => true, From 4e4ef2f7627c62359f5af33b71f0d010b265bf85 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Mon, 20 Feb 2017 21:51:16 +0900 Subject: [PATCH 06/55] Fix missing DB object in module::migrateDomains() --- modules/module/module.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/module/module.class.php b/modules/module/module.class.php index e274d3fca..214b04e37 100644 --- a/modules/module/module.class.php +++ b/modules/module/module.class.php @@ -394,6 +394,7 @@ class module extends ModuleObject function migrateDomains() { // Create the domains table. + $oDB = DB::getInstance(); if (!$oDB->isTableExists('domains')) { $oDB->createTableByXmlFile($this->module_path . 'schemas/domains.xml'); From fdf568bbb2ee0e427ba7dd44e0abf5b48d29e564 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Mon, 20 Feb 2017 21:53:00 +0900 Subject: [PATCH 07/55] Update URL::isInternalURL() --- common/framework/url.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/framework/url.php b/common/framework/url.php index f41c5dc09..05775cee5 100644 --- a/common/framework/url.php +++ b/common/framework/url.php @@ -98,7 +98,7 @@ class URL return true; } - if ($domain === self::getDomainFromURL(\Context::getDefaultUrl())) + if (getModel('module')->getSiteInfoByDomain($domain)) { return true; } From 5757fec7a6122dff559bc93f25cffcf56b0e008e Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Mon, 20 Feb 2017 22:06:44 +0900 Subject: [PATCH 08/55] Use current URL to fill initial domain info --- modules/module/module.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/module/module.class.php b/modules/module/module.class.php index 214b04e37..0ad97869a 100644 --- a/modules/module/module.class.php +++ b/modules/module/module.class.php @@ -432,12 +432,12 @@ class module extends ModuleObject else { $output = executeQuery('module.getDefaultMidInfo', $args); - $default_hostinfo = parse_url(Context::getDefaultUrl()); + $default_hostinfo = parse_url(Rhymix\Framework\URL::getCurrentURL()); $domain = new stdClass(); $domain->domain_srl = 0; $domain->domain = Rhymix\Framework\URL::decodeIdna(strtolower($default_hostinfo['host'])); - $domain->index_module_srl = $output->data->module_srl; + $domain->index_module_srl = $output->data ? $output->data->module_srl : 0; $domain->index_document_srl = 0; $domain->http_port = isset($default_hostinfo['port']) ? intval($default_hostinfo['port']) : null; $domain->https_port = null; From 19cfef17d105823e01f72fa2e7bdb68207e01983 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Mon, 20 Feb 2017 22:13:18 +0900 Subject: [PATCH 09/55] Fix install script to update domain, not site --- modules/install/script/ko.install.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/modules/install/script/ko.install.php b/modules/install/script/ko.install.php index d0ea28061..f591ed9a0 100644 --- a/modules/install/script/ko.install.php +++ b/modules/install/script/ko.install.php @@ -293,11 +293,10 @@ $output = $oModuleController->updateModule($module_info); if(!$output->toBool()) return $output; // insertFirstModule -$site_args = new stdClass(); -$site_args->site_srl = 0; -$site_args->index_module_srl = $module_srl; -$oModuleController->updateSite($site_args); - +$domain_args = new stdClass(); +$domain_args->domain_srl = 0; +$domain_args->index_module_srl = $module_srl; +executeQuery('module.updateDomain', $domain_args); // XEIcon page $moduleInfo = $oModuleModel->getModuleInfoByMenuItemSrl($sitemap['GNB']['list'][2]['menu_srl']); From beb2bf346e27263978aea4a7b778a7cb1de6ae01 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Mon, 20 Feb 2017 22:30:41 +0900 Subject: [PATCH 10/55] Add updateDomain query --- modules/module/queries/updateDomain.xml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 modules/module/queries/updateDomain.xml diff --git a/modules/module/queries/updateDomain.xml b/modules/module/queries/updateDomain.xml new file mode 100644 index 000000000..94f64a84a --- /dev/null +++ b/modules/module/queries/updateDomain.xml @@ -0,0 +1,22 @@ + + +
+ + + + + + + + + + + + + + + + + + + \ No newline at end of file From 5dba5f201537d26e5adea9ccd08a6ef9a0c88720 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Mon, 20 Feb 2017 22:43:24 +0900 Subject: [PATCH 11/55] Make some site-related changes to general config screen --- modules/admin/admin.admin.controller.php | 9 ++++----- modules/admin/admin.admin.view.php | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/modules/admin/admin.admin.controller.php b/modules/admin/admin.admin.controller.php index 6183e5913..01cbfd337 100644 --- a/modules/admin/admin.admin.controller.php +++ b/modules/admin/admin.admin.controller.php @@ -516,11 +516,10 @@ class adminAdminController extends admin $oModuleController->updateModuleConfig('module', $args); // Index module - $site_args = new stdClass(); - $site_args->site_srl = 0; - $site_args->index_module_srl = $vars->index_module_srl; - $site_args->default_language = $vars->default_lang; - $oModuleController->updateSite($site_args); + $domain_args = new stdClass(); + $domain_args->domain_srl = 0; + $domain_args->index_module_srl = $vars->index_module_srl; + executeQuery('module.updateDomain', $domain_args); // Default and enabled languages $enabled_lang = $vars->enabled_lang; diff --git a/modules/admin/admin.admin.view.php b/modules/admin/admin.admin.view.php index da728a2ae..9f924676d 100644 --- a/modules/admin/admin.admin.view.php +++ b/modules/admin/admin.admin.view.php @@ -421,7 +421,7 @@ class adminAdminView extends admin Context::set('all_html_footer', escape($config->htmlFooter)); // Index module - $columnList = array('modules.mid', 'modules.browser_title', 'sites.index_module_srl'); + $columnList = array('modules.mid', 'modules.browser_title', 'index_module_srl'); $start_module = $oModuleModel->getSiteInfo(0, $columnList); Context::set('start_module', $start_module); From 5b182ab4b33543a06d6a7a68abc9c695c7540696 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Mon, 20 Feb 2017 22:45:32 +0900 Subject: [PATCH 12/55] Simplify getDomainInfo query --- modules/module/queries/getDomainInfo.xml | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/modules/module/queries/getDomainInfo.xml b/modules/module/queries/getDomainInfo.xml index b22cbf59b..f159558b6 100644 --- a/modules/module/queries/getDomainInfo.xml +++ b/modules/module/queries/getDomainInfo.xml @@ -4,17 +4,7 @@
- - - - - - - - - - - + From bad9fe5d98e181ca4fe639fab1f140ccdd4277df Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Mon, 20 Feb 2017 22:46:28 +0900 Subject: [PATCH 13/55] Add deleteDomain query --- modules/module/queries/deleteDomain.xml | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 modules/module/queries/deleteDomain.xml diff --git a/modules/module/queries/deleteDomain.xml b/modules/module/queries/deleteDomain.xml new file mode 100644 index 000000000..85b47b290 --- /dev/null +++ b/modules/module/queries/deleteDomain.xml @@ -0,0 +1,8 @@ + + +
+ + + + + \ No newline at end of file From 254e6910d03a1850e638b60d5477222462c6911b Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Mon, 20 Feb 2017 22:49:32 +0900 Subject: [PATCH 14/55] Fill in missing fields in getSiteInfo() and getSiteInfoByDomain() --- modules/module/module.model.php | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/modules/module/module.model.php b/modules/module/module.model.php index b58817b6c..e6de9a1fa 100644 --- a/modules/module/module.model.php +++ b/modules/module/module.model.php @@ -53,7 +53,18 @@ class moduleModel extends module $args = new stdClass(); $args->domain_srl = $site_srl; $output = executeQuery('module.getDomainInfo', $args, $columnList); - return $output->data; + if ($output->data) + { + $domain_info = $output->data; + $domain_info->site_srl = 0; + $domain_info->settings = $domain_info->settings ? json_decode($domain_info->settings) : new stdClass; + $domain_info->default_language = $domain_info->settings->language ?: config('locale.default_lang'); + return $domain_info; + } + else + { + return $output->data; + } } function getSiteInfoByDomain($domain, $columnList = array()) @@ -70,7 +81,18 @@ class moduleModel extends module $args = new stdClass(); $args->domain = $domain; $output = executeQuery('module.getDomainInfo', $args, $columnList); - return $output->data; + if ($output->data) + { + $domain_info = $output->data; + $domain_info->site_srl = 0; + $domain_info->settings = $domain_info->settings ? json_decode($domain_info->settings) : new stdClass; + $domain_info->default_language = $domain_info->settings->language ?: config('locale.default_lang'); + return $domain_info; + } + else + { + return $output->data; + } } /** From 94c45958c45dd3bf2c0933c370739d0b5a57ad28 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Wed, 22 Feb 2017 14:31:16 +0900 Subject: [PATCH 15/55] Refactor domain info loading functions --- modules/module/module.model.php | 106 +++++++++++++++----------------- 1 file changed, 51 insertions(+), 55 deletions(-) diff --git a/modules/module/module.model.php b/modules/module/module.model.php index e6de9a1fa..b9f343020 100644 --- a/modules/module/module.model.php +++ b/modules/module/module.model.php @@ -48,26 +48,33 @@ class moduleModel extends module /** * @brief Get site information */ - function getSiteInfo($site_srl, $columnList = array()) + function getSiteInfo($domain_srl) { - $args = new stdClass(); - $args->domain_srl = $site_srl; - $output = executeQuery('module.getDomainInfo', $args, $columnList); - if ($output->data) + $domain_srl = intval($domain_srl); + $domain_info = Rhymix\Framework\Cache::get('site_and_module:domain_info:srl_' . $domain_srl); + if ($domain_info === null) { - $domain_info = $output->data; - $domain_info->site_srl = 0; - $domain_info->settings = $domain_info->settings ? json_decode($domain_info->settings) : new stdClass; - $domain_info->default_language = $domain_info->settings->language ?: config('locale.default_lang'); - return $domain_info; - } - else - { - return $output->data; + $args = new stdClass(); + $args->domain_srl = $domain_srl; + $output = executeQuery('module.getDomainInfo', $args); + if ($output->data) + { + $domain_info = $output->data; + $domain_info->site_srl = 0; + $domain_info->settings = $domain_info->settings ? json_decode($domain_info->settings) : new stdClass; + $domain_info->default_language = $domain_info->settings->language ?: config('locale.default_lang'); + } + else + { + $domain_info = false; + } + Rhymix\Framework\Cache::set('site_and_module:domain_info:srl_' . $domain_srl, $domain_info, 0, true); } + + return $domain_info; } - function getSiteInfoByDomain($domain, $columnList = array()) + function getSiteInfoByDomain($domain) { if (strpos($domain, '/') !== false) { @@ -77,22 +84,33 @@ class moduleModel extends module return null; } } + if (strpos($domain, 'xn--') !== false) + { + $domain = Rhymix\Framework\URL::decodeIdna($domain); + } - $args = new stdClass(); - $args->domain = $domain; - $output = executeQuery('module.getDomainInfo', $args, $columnList); - if ($output->data) + $domain = strtolower($domain); + $domain_info = Rhymix\Framework\Cache::get('site_and_module:domain_info:' . $domain); + if ($domain_info === null) { - $domain_info = $output->data; - $domain_info->site_srl = 0; - $domain_info->settings = $domain_info->settings ? json_decode($domain_info->settings) : new stdClass; - $domain_info->default_language = $domain_info->settings->language ?: config('locale.default_lang'); - return $domain_info; - } - else - { - return $output->data; + $args = new stdClass(); + $args->domain = $domain; + $output = executeQuery('module.getDomainInfo', $args); + if ($output->data) + { + $domain_info = $output->data; + $domain_info->site_srl = 0; + $domain_info->settings = $domain_info->settings ? json_decode($domain_info->settings) : new stdClass; + $domain_info->default_language = $domain_info->settings->language ?: config('locale.default_lang'); + } + else + { + $domain_info = false; + } + Rhymix\Framework\Cache::set('site_and_module:domain_info:' . $domain, $domain_info, 0, true); } + + return $domain_info; } /** @@ -115,39 +133,17 @@ class moduleModel extends module { // Get current domain. $domain = strtolower(preg_replace('/:\d+$/', '', $_SERVER['HTTP_HOST'])); - if (strpos($domain, 'xn--') !== false) - { - $domain = Rhymix\Framework\URL::decodeIdna($domain); - } // Find the domain information. - $domain_info = Rhymix\Framework\Cache::get('site_and_module:domain_info:' . $domain); + $domain_info = $this->getSiteInfoByDomain($domain); if (!$domain_info) { - $output = executeQuery('module.getDomainInfo', (object)array('domain' => $domain)); - if ($output->data) + $domain_info = $this->getSiteInfo(0); + if (!$domain_info) { - $domain_info = $output->data; + $this->migrateDomains(); + return $this->getDefaultMid(); } - else - { - $output = executeQuery('module.getDomainInfo', (object)array('domain_srl' => 0)); - if ($output->data) - { - $domain_info = $output->data; - } - else - { - $this->migrateDomains(); - return $this->getDefaultMid(); - } - } - - $domain_info->site_srl = 0; - $domain_info->settings = $domain_info->settings ? json_decode($domain_info->settings) : new stdClass; - $domain_info->default_language = $domain_info->settings->language ?: config('locale.default_lang'); - - Rhymix\Framework\Cache::set('site_and_module:domain_info:' . $domain, $domain_info, 0, true); } // Fill in module extra vars and return. From 37a0aa0f135831566d4bb0862076530332dce81d Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Wed, 22 Feb 2017 14:52:48 +0900 Subject: [PATCH 16/55] Implement moduleModel::getAllDomains() --- modules/module/module.class.php | 13 +++---------- modules/module/module.model.php | 18 ++++++++++++++++++ modules/module/queries/getDomains.xml | 2 +- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/modules/module/module.class.php b/modules/module/module.class.php index 0ad97869a..82193a531 100644 --- a/modules/module/module.class.php +++ b/modules/module/module.class.php @@ -19,8 +19,7 @@ class module extends ModuleObject $oDB->addIndex("modules","idx_site_mid", array("site_srl","mid"), true); // Insert new domain - $output = executeQuery('module.getDomains'); - if(!$output->data || !$output->data->index_module_srl) + if(!getModel('module')->getSiteInfo(0)) { $current_url = Rhymix\Framework\Url::getCurrentUrl(); $domain = new stdClass(); @@ -93,12 +92,7 @@ class module extends ModuleObject } // Check domains - if (!$oDB->isTableExists('domains')) - { - return true; - } - $output = $oDB->executeQuery('module.getDomains', new stdClass); - if (!$output->data) + if (!$oDB->isTableExists('domains') || !getModel('module')->getSiteInfo(0)) { return true; } @@ -314,8 +308,7 @@ class module extends ModuleObject } // Migrate domains - $output = @executeQuery('module.getDomains'); - if (!$output->data) + if (!getModel('module')->getSiteInfo(0)) { $this->migrateDomains(); } diff --git a/modules/module/module.model.php b/modules/module/module.model.php index b9f343020..fa5ffe413 100644 --- a/modules/module/module.model.php +++ b/modules/module/module.model.php @@ -44,6 +44,24 @@ class moduleModel extends module return false; } + + /** + * @brief Get all domains + * + * @return array + */ + function getAllDomains($count = 20, $page = 1) + { + $args = new stdClass; + $args->list_count = $count; + $args->page = $page; + $output = executeQueryArray('module.getDomains', $args); + foreach ($output->data as &$domain) + { + $domain->settings = $domain->settings ? json_decode($domain->settings) : new stdClass; + } + return $output->data; + } /** * @brief Get site information diff --git a/modules/module/queries/getDomains.xml b/modules/module/queries/getDomains.xml index 9e883152c..f7a56b65f 100644 --- a/modules/module/queries/getDomains.xml +++ b/modules/module/queries/getDomains.xml @@ -6,7 +6,7 @@ - + From e5126c7f98a5f7242d0db8b545d7c1860c67636a Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Wed, 22 Feb 2017 16:45:25 +0900 Subject: [PATCH 17/55] Fix domain handling in getUrl() --- classes/context/Context.class.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/classes/context/Context.class.php b/classes/context/Context.class.php index 10938f7e1..7eacaabc7 100644 --- a/classes/context/Context.class.php +++ b/classes/context/Context.class.php @@ -1547,11 +1547,15 @@ class Context } // If $domain is set, handle it (if $domain is vid type, remove $domain and handle with $vid) - if (strpos($domain, '/') !== false) + if ($domain && strpos($domain, '/') !== false) { $domain = Rhymix\Framework\URL::getDomainFromURL($domain); } - if($domain && isSiteID($domain)) + if ($domain && strpos($domain, 'xn--') !== false) + { + $domain = Rhymix\Framework\URL::decodeIdna($domain); + } + if ($domain && isSiteID($domain)) { $vid = $domain; $domain = ''; From b88bedf9fd3bd4604a86123c36ac30c77234cd90 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Wed, 22 Feb 2017 16:45:45 +0900 Subject: [PATCH 18/55] Return more data from getAllDomains() --- modules/module/module.model.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/modules/module/module.model.php b/modules/module/module.model.php index fa5ffe413..0eb96777e 100644 --- a/modules/module/module.model.php +++ b/modules/module/module.model.php @@ -47,8 +47,6 @@ class moduleModel extends module /** * @brief Get all domains - * - * @return array */ function getAllDomains($count = 20, $page = 1) { @@ -60,7 +58,7 @@ class moduleModel extends module { $domain->settings = $domain->settings ? json_decode($domain->settings) : new stdClass; } - return $output->data; + return $output; } /** From a5c2783cf537ffb4463815687e3edce324ec6d8b Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Wed, 22 Feb 2017 16:46:05 +0900 Subject: [PATCH 19/55] Implement domain management screen in admin module --- modules/admin/admin.admin.view.php | 32 ++++++++++++ modules/admin/conf/module.xml | 2 + modules/admin/lang/en.php | 21 +++++--- modules/admin/lang/ko.php | 13 +++-- modules/admin/tpl/config_domains.html | 74 +++++++++++++++++++++++++++ modules/admin/tpl/config_header.html | 1 + 6 files changed, 133 insertions(+), 10 deletions(-) create mode 100644 modules/admin/tpl/config_domains.html diff --git a/modules/admin/admin.admin.view.php b/modules/admin/admin.admin.view.php index 9f924676d..879a1af25 100644 --- a/modules/admin/admin.admin.view.php +++ b/modules/admin/admin.admin.view.php @@ -582,6 +582,38 @@ class adminAdminView extends admin $this->setTemplateFile('config_advanced'); } + /** + * Display Debug Settings page + * @return void + */ + function dispAdminConfigDomains() + { + // Get domain list. + $oModuleModel = getModel('module'); + $page = intval(Context::get('page')) ?: 1; + $domain_list = $oModuleModel->getAllDomains(20, $page); + Context::set('domain_list', $domain_list); + Context::set('page_navigation', $domain_list->page_navigation); + Context::set('page', $page); + + // Get index module info. + $module_list = array(); + $oModuleModel = getModel('module'); + foreach ($domain_list->data as $domain) + { + if ($domain->index_module_srl && !isset($module_list[$domain->index_module_srl])) + { + $module_list[$domain->index_module_srl] = $oModuleModel->getModuleInfoByModuleSrl($domain->index_module_srl); + } + } + Context::set('module_list', $module_list); + + // Get language list. + Context::set('supported_lang', Rhymix\Framework\Lang::getSupportedList()); + + $this->setTemplateFile('config_domains'); + } + /** * Display Debug Settings page * @return void diff --git a/modules/admin/conf/module.xml b/modules/admin/conf/module.xml index 7b21ba003..16709df91 100644 --- a/modules/admin/conf/module.xml +++ b/modules/admin/conf/module.xml @@ -8,6 +8,7 @@ + @@ -28,6 +29,7 @@ + diff --git a/modules/admin/lang/en.php b/modules/admin/lang/en.php index d9756bb46..64edb36ed 100644 --- a/modules/admin/lang/en.php +++ b/modules/admin/lang/en.php @@ -1,11 +1,12 @@ admin = 'Admin'; $lang->cmd_configure = 'Configure'; -$lang->subtitle_primary = 'General Settings'; -$lang->subtitle_notification = 'Notification Settings'; -$lang->subtitle_security = 'Security Settings'; -$lang->subtitle_advanced = 'Advanced Settings'; -$lang->subtitle_debug = 'Debug Settings'; +$lang->subtitle_primary = 'General'; +$lang->subtitle_notification = 'Notifications'; +$lang->subtitle_security = 'Security'; +$lang->subtitle_advanced = 'Advanced'; +$lang->subtitle_domains = 'Domains'; +$lang->subtitle_debug = 'Debug'; $lang->subtitle_seo = 'SEO Settings'; $lang->subtitle_etc = 'Other Settings'; $lang->current_state = 'Current state'; @@ -104,10 +105,16 @@ $lang->auto_select_lang = 'Auto-select Language'; $lang->about_auto_select_lang = 'Automatically select the language based on the language of each visitor\'s browser.'; $lang->about_recompile_cache = 'Delete useless or invalid cache files?'; $lang->confirm_run = 'It may take a long time. Do you want to run?'; -$lang->use_ssl = 'Use SSL'; -$lang->ssl_options['none'] = 'Never'; +$lang->use_ssl = 'Use HTTPS'; +$lang->ssl_options['none'] = 'None'; $lang->ssl_options['optional'] = 'Optional'; $lang->ssl_options['always'] = 'Always'; +$lang->cmd_http_port = 'HTTP Port'; +$lang->cmd_https_port = 'HTTPS Port'; +$lang->cmd_index_module_srl = 'Main Module'; +$lang->cmd_index_document_srl = 'Main Document'; +$lang->cmd_default_language = 'Default Language'; +$lang->cmd_new_domain = 'Add New Domain'; $lang->about_use_ssl = 'Selecting \'Optional\' is to use SSL for the specified actions such as signing up and changing information. Selecting \'Always\' is to use SSL for all services. Please be careful because you may not be avaliable to access to the site if you use SSL where its environment is not set.'; $lang->server_ports = 'Server Port'; $lang->about_server_ports = 'If your web server does not use 80 for HTTP or 443 for HTTPS port, you should specify server ports.'; diff --git a/modules/admin/lang/ko.php b/modules/admin/lang/ko.php index e407791f1..2b445b7b3 100644 --- a/modules/admin/lang/ko.php +++ b/modules/admin/lang/ko.php @@ -5,6 +5,7 @@ $lang->subtitle_primary = '기본 설정'; $lang->subtitle_notification = '알림 설정'; $lang->subtitle_security = '보안 설정'; $lang->subtitle_advanced = '고급 설정'; +$lang->subtitle_domains = '도메인 설정'; $lang->subtitle_debug = '디버그 설정'; $lang->subtitle_seo = 'SEO 설정'; $lang->subtitle_etc = '기타'; @@ -104,10 +105,16 @@ $lang->auto_select_lang = '언어 자동 선택'; $lang->about_auto_select_lang = '방문자의 브라우저 언어에 따라 자동으로 언어를 선택하는 기능입니다.'; $lang->about_recompile_cache = '쓸모 없어졌거나 잘못된 캐시파일들을 지우시겠습니까?'; $lang->confirm_run = '오랜 시간이 걸릴 수 있습니다. 실행하시겠습니까?'; -$lang->use_ssl = 'SSL 사용'; -$lang->ssl_options['none'] = '사용안함'; -$lang->ssl_options['optional'] = '선택적으로'; +$lang->use_ssl = 'HTTPS 사용'; +$lang->ssl_options['none'] = '사용 안함'; +$lang->ssl_options['optional'] = '선택적 사용'; $lang->ssl_options['always'] = '항상 사용'; +$lang->cmd_http_port = 'HTTP 포트'; +$lang->cmd_https_port = 'HTTPS 포트'; +$lang->cmd_index_module_srl = '메인 모듈'; +$lang->cmd_index_document_srl = '메인 문서'; +$lang->cmd_default_language = '기본 언어'; +$lang->cmd_new_domain = '새 도메인 추가'; $lang->about_use_ssl = '\'선택적으로\'는 회원가입, 정보수정 등의 지정된 동작(action)에서 보안접속(SSL)을 사용합니다. \'항상 사용\'은 모든 서비스에 SSL을 사용 합니다. SSL 환경이 갖춰지지 않은 상태에서 SSL을 사용할 경우 접속이 되지 않을 수 있으니 주의 바랍니다.'; $lang->server_ports = '서버 포트 지정'; $lang->about_server_ports = 'HTTP는 80, HTTPS는 443 이 아닌, 다른 포트를 사용할 경우에 포트를 지정해 주어야 합니다.'; diff --git a/modules/admin/tpl/config_domains.html b/modules/admin/tpl/config_domains.html new file mode 100644 index 000000000..ea85b6dba --- /dev/null +++ b/modules/admin/tpl/config_domains.html @@ -0,0 +1,74 @@ + +
+

{$XE_VALIDATOR_MESSAGE}

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
{$lang->domain}{$lang->cmd_http_port}{$lang->cmd_https_port}{$lang->use_ssl}{$lang->cmd_index_module_srl}{$lang->cmd_index_document_srl}{$lang->cmd_default_language}{$lang->cmd_modify} / {$lang->cmd_delete}
{$domain->domain}{$domain->http_port ?: ''}{$domain->https_port ?: ''}{$lang->ssl_options[$domain->security ?: 'none']} + + {($domain->index_module_srl && $module_list[$domain->index_module_srl]) ? $module_list[$domain->index_module_srl]->browser_title : ''} + + {$domain->index_document_srl ?: ''} + + {$domain->settings->language ? $supported_lang[$domain->settings->language]['name'] : $supported_lang[config('locale.default_lang')]['name']} + {$lang->cmd_modify} + / + {$lang->cmd_delete} +
{$lang->msg_no_result}
+ + + +
+
+ + + +
+
+ +
+
+
+
diff --git a/modules/admin/tpl/config_header.html b/modules/admin/tpl/config_header.html index 4fea11641..0a9aba5f8 100644 --- a/modules/admin/tpl/config_header.html +++ b/modules/admin/tpl/config_header.html @@ -8,6 +8,7 @@
  • {$lang->subtitle_notification}
  • {$lang->subtitle_security}
  • {$lang->subtitle_advanced}
  • +
  • {$lang->subtitle_domains}
  • {$lang->subtitle_debug}
  • {$lang->subtitle_seo}
  • {$lang->subtitle_sitelock}
  • From dcd4b8b04690aa4d6b35bbab7c47443c2c83f091 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Sat, 4 Mar 2017 17:06:12 +0900 Subject: [PATCH 20/55] Implement remainder of domain management screen --- modules/admin/admin.admin.controller.php | 139 +++++++++++++++++++++ modules/admin/admin.admin.view.php | 48 +++++++ modules/admin/conf/module.xml | 2 + modules/admin/lang/ko.php | 10 +- modules/admin/tpl/config_domains_edit.html | 79 ++++++++++++ modules/admin/tpl/config_header.html | 2 +- modules/admin/tpl/css/admin.css | 2 +- 7 files changed, 275 insertions(+), 7 deletions(-) create mode 100644 modules/admin/tpl/config_domains_edit.html diff --git a/modules/admin/admin.admin.controller.php b/modules/admin/admin.admin.controller.php index 01cbfd337..cdff0d549 100644 --- a/modules/admin/admin.admin.controller.php +++ b/modules/admin/admin.admin.controller.php @@ -987,6 +987,145 @@ class adminAdminController extends admin $this->setRedirectUrl(Context::get('success_return_url') ?: getNotEncodedUrl('', 'module', 'admin', 'act', 'dispAdminConfigSitelock')); } + /** + * Insert or update domain info + * @return void + */ + function procAdminInsertDomain() + { + $vars = Context::getRequestVars(); + $domain_srl = strval($vars->domain_srl); + $domain_info = null; + if ($domain_srl !== '') + { + $output = executeQuery('module.getDomainInfo', (object)array('domain_srl' => $domain_srl)); + if ($output->toBool() && $output->data) + { + $domain_info = $output->data; + } + } + + // Validate the domain. + if (!preg_match('@^https?://@', $vars->domain)) + { + $vars->domain = 'http://' . $vars->domain; + } + try + { + $vars->domain = Rhymix\Framework\URL::getDomainFromUrl(strtolower($vars->domain)); + } + catch (Exception $e) + { + $vars->domain = ''; + } + if (!$vars->domain) + { + return new Object(-1, 'msg_invalid_domain'); + } + $existing_domain = getModel('module')->getSiteInfoByDomain($vars->domain); + if ($existing_domain && $existing_domain->domain == $vars->domain && (!$domain_info || $existing_domain->domain_srl != $domain_info->domain_srl)) + { + return new Object(-1, 'msg_domain_already_exists'); + } + + // Validate the ports. + if ($vars->http_port == 80 || !$vars->http_port) + { + $vars->http_port = 0; + } + if ($vars->https_port == 443 || !$vars->https_port) + { + $vars->https_port = 0; + } + if ($vars->http_port !== 0 && ($vars->http_port < 1 || $vars->http_port > 65535 || $vars->http_port == 443)) + { + return new Object(-1, 'msg_invalid_http_port'); + } + if ($vars->https_port !== 0 && ($vars->https_port < 1 || $vars->https_port > 65535 || $vars->https_port == 80)) + { + return new Object(-1, 'msg_invalid_http_port'); + } + + // Validate the security setting. + $valid_security_options = array('none', 'optional', 'always'); + if (!in_array($vars->domain_security, $valid_security_options)) + { + $vars->domain_security = 'none'; + } + + // Validate the index module setting. + $module_info = getModel('module')->getModuleInfoByModuleSrl(intval($vars->index_module_srl)); + if (!$module_info || $module_info->module_srl != $vars->index_module_srl) + { + return new Object(-1, 'msg_invalid_index_module_srl'); + } + + // Validate the index document setting. + if ($vars->index_document_srl) + { + $oDocument = getModel('document')->getDocument($vars->index_document_srl); + if (!$oDocument || !$oDocument->isExists()) + { + return new Object(-1, 'msg_invalid_index_document_srl'); + } + } + else + { + $vars->index_document_srl = 0; + } + + // Validate the default language. + $enabled_lang = Rhymix\Framework\Config::get('locale.enabled_lang'); + if (!in_array($vars->default_lang, $enabled_lang)) + { + return new Object(-1, 'msg_lang_is_not_enabled'); + } + + // Insert or update the domain. + if (!$domain_info) + { + $args = new stdClass(); + $args->domain_srl = getNextSequence(); + $args->domain = $vars->domain; + $args->index_module_srl = $vars->index_module_srl; + $args->index_document_srl = $vars->index_document_srl; + $args->http_port = $vars->http_port; + $args->https_port = $vars->https_port; + $args->security = $vars->domain_security; + $args->description = ''; + $args->settings = json_encode(array('language' => $vars->default_lang, 'timezone' => null)); + $output = executeQuery('module.insertDomain', $args); + if (!$output->toBool()) + { + return $output; + } + } + else + { + $args = new stdClass(); + $args->domain_srl = $domain_info->domain_srl; + $args->domain = $vars->domain; + $args->index_module_srl = $vars->index_module_srl; + $args->index_document_srl = $vars->index_document_srl; + $args->http_port = $vars->http_port; + $args->https_port = $vars->https_port; + $args->security = $vars->domain_security; + $args->settings = json_encode(array_merge($domain_info->settings, array('language' => $vars->default_lang))); + $output = executeQuery('module.updateDomain', $args); + if (!$output->toBool()) + { + return $output; + } + + } + + // Clear cache. + Rhymix\Framework\Cache::clearGroup('site_and_module'); + + // Redirect to the domain list. + $this->setRedirectUrl(Context::get('success_return_url') ?: getNotEncodedUrl('', 'module', 'admin', 'act', 'dispAdminConfigDomains')); + } + /** * Update FTP configuration. */ diff --git a/modules/admin/admin.admin.view.php b/modules/admin/admin.admin.view.php index addf8cb4d..4b2144323 100644 --- a/modules/admin/admin.admin.view.php +++ b/modules/admin/admin.admin.view.php @@ -691,6 +691,54 @@ class adminAdminView extends admin $this->setTemplateFile('config_sitelock'); } + /** + * Display domain edit screen + * @return void + */ + function dispAdminInsertDomain() + { + // Get selected domain. + $domain_srl = strval(Context::get('domain_srl')); + $domain_info = null; + if ($domain_srl !== '') + { + $output = executeQuery('module.getDomainInfo', (object)array('domain_srl' => $domain_srl)); + if ($output->toBool() && $output->data) + { + $domain_info = $output->data; + } + } + Context::set('domain_info', $domain_info); + + // Get modules. + $module_list = getModel('module')->getMidList(); + if ($domain_info && $domain_info->index_module_srl) + { + $index_module_srl = $domain_info->index_module_srl; + } + else + { + $index_module_srl = 0; + } + Context::set('module_list', $module_list); + Context::set('index_module_srl', $index_module_srl); + + // Get language list. + Context::set('supported_lang', Rhymix\Framework\Lang::getSupportedList()); + Context::set('enabled_lang', Rhymix\Framework\Config::get('locale.enabled_lang')); + if ($domain_info && $domain_info->settings->language) + { + $domain_lang = $domain_info->settings->language; + } + else + { + $domain_lang = Rhymix\Framework\Config::get('locale.default_lang'); + } + Context::set('domain_lang', $domain_lang); + + $this->setTemplateFile('config_domains_edit'); + } + /** * Display FTP Configuration(settings) page * @return void diff --git a/modules/admin/conf/module.xml b/modules/admin/conf/module.xml index 16709df91..b24cfd36e 100644 --- a/modules/admin/conf/module.xml +++ b/modules/admin/conf/module.xml @@ -12,6 +12,7 @@ + @@ -33,6 +34,7 @@ + diff --git a/modules/admin/lang/ko.php b/modules/admin/lang/ko.php index fbcc6bffa..bd5f1650f 100644 --- a/modules/admin/lang/ko.php +++ b/modules/admin/lang/ko.php @@ -106,8 +106,8 @@ $lang->about_auto_select_lang = '방문자의 브라우저 언어에 따라 자 $lang->about_recompile_cache = '쓸모 없어졌거나 잘못된 캐시파일들을 지우시겠습니까?'; $lang->confirm_run = '오랜 시간이 걸릴 수 있습니다. 실행하시겠습니까?'; $lang->use_ssl = 'HTTPS 사용'; -$lang->ssl_options['none'] = '사용 안함'; -$lang->ssl_options['optional'] = '선택적으로 (권장하지 않음)'; +$lang->ssl_options['none'] = '사용하지 않음'; +$lang->ssl_options['optional'] = '선택적으로 사용 (권장하지 않음)'; $lang->ssl_options['always'] = '항상 사용 (권장)'; $lang->cmd_http_port = 'HTTP 포트'; $lang->cmd_https_port = 'HTTPS 포트'; @@ -115,9 +115,9 @@ $lang->cmd_index_module_srl = '메인 모듈'; $lang->cmd_index_document_srl = '메인 문서'; $lang->cmd_default_language = '기본 언어'; $lang->cmd_new_domain = '새 도메인 추가'; -$lang->about_use_ssl = '\'선택적으로\'는 회원가입, 정보수정 등의 지정된 동작(action)에서 보안접속(SSL)을 사용합니다. \'항상 사용\'은 모든 서비스에 SSL을 사용 합니다. SSL 환경이 갖춰지지 않은 상태에서 SSL을 사용할 경우 접속이 되지 않을 수 있으니 주의 바랍니다.'; -$lang->about_use_ssl = '

    \'선택적으로\'는 회원가입, 정보수정 등의 일부 동작에서만 선택적으로 보안접속(SSL)을 사용합니다.
    \'항상 사용\'은 모든 서비스에 SSL을 사용 합니다.

    SSL 환경이 갖춰지지 않은 상태에서 SSL을 사용할 경우, 접속이 되지 않을 수 있습니다. SSL 인증서가 정상적으로 설치되었는지 반드시 확인하고 설정하시기 바랍니다.

    '; -$lang->server_ports = '서버 포트 지정'; +$lang->cmd_edit_domain = '도메인 정보 수정'; +$lang->about_use_ssl = '\'선택적으로 사용\'은 회원가입, 정보수정 등의 지정된 동작(action)에서만 보안접속(HTTPS)을 사용합니다.
    \'항상 사용\'은 사이트 전체에 HTTPS를 사용합니다.
    SSL 인증서가 설치되지 않은 상태에서 HTTPS 사용을 시도하면 접속이 되지 않을 수 있으니 주의하시기 바랍니다.'; +$lang->server_ports = '포트'; $lang->about_server_ports = 'HTTP는 80, HTTPS는 443 이 아닌, 다른 포트를 사용할 경우에 포트를 지정해 주어야 합니다.'; $lang->use_db_session = '인증 세션 DB 사용'; $lang->about_db_session = '세션을 DB에 저장합니다. 현재 접속자를 파악하려면 이 기능을 켜야 합니다.
    불필요하게 사용하면 서버 성능에 악영향을 줄 수 있으니 주의하십시오.'; diff --git a/modules/admin/tpl/config_domains_edit.html b/modules/admin/tpl/config_domains_edit.html new file mode 100644 index 000000000..7a6002f0a --- /dev/null +++ b/modules/admin/tpl/config_domains_edit.html @@ -0,0 +1,79 @@ + +
    +

    {$XE_VALIDATOR_MESSAGE}

    +
    +
    +
    + + + + + +
    + +
    + +
    +
    + +
    + +
    + +
    +
    + +
    + +
    + +
    +
    + +
    + +
    + +
    {lang('admin.about_use_ssl')}
    +
    +
    + +
    + +
    + +
    +
    + +
    + +
    + +
    +
    + +
    + +
    + +
    +
    + +
    +
    + +
    +
    + +
    +
    diff --git a/modules/admin/tpl/config_header.html b/modules/admin/tpl/config_header.html index 0a9aba5f8..14bf4679f 100644 --- a/modules/admin/tpl/config_header.html +++ b/modules/admin/tpl/config_header.html @@ -8,7 +8,7 @@
  • {$lang->subtitle_notification}
  • {$lang->subtitle_security}
  • {$lang->subtitle_advanced}
  • -
  • {$lang->subtitle_domains}
  • +
  • {$lang->subtitle_domains}
  • {$lang->subtitle_debug}
  • {$lang->subtitle_seo}
  • {$lang->subtitle_sitelock}
  • diff --git a/modules/admin/tpl/css/admin.css b/modules/admin/tpl/css/admin.css index 77a34ef05..d27ecc967 100644 --- a/modules/admin/tpl/css/admin.css +++ b/modules/admin/tpl/css/admin.css @@ -434,7 +434,7 @@ margin-bottom: 10px; height: 25px; } .x input[type="number"] { - width: 50px; + width: 90px; } .x select { padding: 0; From 726a2a02096d7e593525ab283193a2412da2e27e Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Sat, 4 Mar 2017 17:31:46 +0900 Subject: [PATCH 21/55] Update module class to use getDomainFromUrl() --- modules/module/module.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/module/module.class.php b/modules/module/module.class.php index 82193a531..c09919530 100644 --- a/modules/module/module.class.php +++ b/modules/module/module.class.php @@ -24,7 +24,7 @@ class module extends ModuleObject $current_url = Rhymix\Framework\Url::getCurrentUrl(); $domain = new stdClass(); $domain->domain_srl = 0; - $domain->domain = Rhymix\Framework\URL::decodeIdna(parse_url($current_url, PHP_URL_HOST)); + $domain->domain = Rhymix\Framework\URL::getDomainFromURL($current_url); $domain->index_module_srl = 0; $domain->index_document_srl = 0; $domain->http_port = null; @@ -410,7 +410,7 @@ class module extends ModuleObject $domain = new stdClass(); $domain->domain_srl = $site_info->site_srl; - $domain->domain = Rhymix\Framework\URL::decodeIdna(strtolower(parse_url($site_domain, PHP_URL_HOST))); + $domain->domain = Rhymix\Framework\URL::getDomainFromURL(strtolower($site_domain)); $domain->index_module_srl = $site_info->index_module_srl; $domain->index_document_srl = 0; $domain->http_port = config('url.http_port') ?: null; @@ -456,7 +456,7 @@ class module extends ModuleObject $domain = new stdClass(); $domain->domain_srl = $site_info->multidomain_srl; - $domain->domain = Rhymix\Framework\URL::decodeIdna(strtolower(parse_url($site_domain, PHP_URL_HOST))); + $domain->domain = Rhymix\Framework\URL::getDomainFromURL(strtolower($site_domain)); $domain->index_module_srl = intval($site_info->module_srl); $domain->index_document_srl = intval($site_info->document_srl); $domain->http_port = config('url.http_port') ?: null; From 06ce406390c50242c039e8e5b515075b31aba8a3 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Sat, 4 Mar 2017 21:25:58 +0900 Subject: [PATCH 22/55] Remove domain, port, and SSL settings from Advanced config screen --- modules/admin/admin.admin.controller.php | 55 ++++++------------------ modules/admin/admin.admin.view.php | 13 ------ modules/admin/tpl/config_advanced.html | 22 ---------- 3 files changed, 14 insertions(+), 76 deletions(-) diff --git a/modules/admin/admin.admin.controller.php b/modules/admin/admin.admin.controller.php index cdff0d549..c8bb07912 100644 --- a/modules/admin/admin.admin.controller.php +++ b/modules/admin/admin.admin.controller.php @@ -751,46 +751,6 @@ class adminAdminController extends admin { $vars = Context::getRequestVars(); - // Default URL - $default_url = rtrim(trim($vars->default_url), '/\\') . '/'; - if (!filter_var(Rhymix\Framework\URL::encodeIdna($default_url), FILTER_VALIDATE_URL) || !preg_match('@^https?://@', $default_url)) - { - return new Object(-1, 'msg_invalid_default_url'); - } - if (parse_url($default_url, PHP_URL_PATH) !== RX_BASEURL) - { - return new Object(-1, 'msg_invalid_default_url'); - } - - // SSL and ports - if ($vars->http_port == 80) $vars->http_port = null; - if ($vars->https_port == 443) $vars->https_port = null; - $use_ssl = $vars->use_ssl ?: 'none'; - - // Check if all URL configuration is consistent - if ($use_ssl === 'always' && !preg_match('@^https://@', $default_url)) - { - return new Object(-1, 'msg_default_url_ssl_inconsistent'); - } - if ($vars->http_port && preg_match('@^http://@', $default_url) && parse_url($default_url, PHP_URL_PORT) != $vars->http_port) - { - return new Object(-1, 'msg_default_url_http_port_inconsistent'); - } - if ($vars->https_port && preg_match('@^https://@', $default_url) && parse_url($default_url, PHP_URL_PORT) != $vars->https_port) - { - return new Object(-1, 'msg_default_url_https_port_inconsistent'); - } - - // Set all URL configuration - Rhymix\Framework\Config::set('url.default', $default_url); - Rhymix\Framework\Config::set('url.http_port', $vars->http_port ?: null); - Rhymix\Framework\Config::set('url.https_port', $vars->https_port ?: null); - Rhymix\Framework\Config::set('url.ssl', $use_ssl); - getController('module')->updateSite((object)array( - 'site_srl' => 0, - 'domain' => preg_replace('@^https?://@', '', $default_url), - )); - // Object cache if ($vars->object_cache_type) { @@ -1116,7 +1076,20 @@ class adminAdminController extends admin { return $output; } - + } + + // Update system configuration to match the default domain. + if ($domain_info && $domain_srl === '0') + { + $domain_info->domain = $vars->domain; + $domain_info->http_port = $vars->http_port; + $domain_info->https_port = $vars->https_port; + $domain_info->security = $vars->domain_security; + Rhymix\Framework\Config::set('url.default', Context::getDefaultUrl($domain_info)); + Rhymix\Framework\Config::set('url.http_port', $vars->http_port ?: null); + Rhymix\Framework\Config::set('url.https_port', $vars->https_port ?: null); + Rhymix\Framework\Config::set('url.ssl', $vars->domain_security); + Rhymix\Framework\Config::save(); } // Clear cache. diff --git a/modules/admin/admin.admin.view.php b/modules/admin/admin.admin.view.php index 4b2144323..8306fc5ad 100644 --- a/modules/admin/admin.admin.view.php +++ b/modules/admin/admin.admin.view.php @@ -508,19 +508,6 @@ class adminAdminView extends admin */ function dispAdminConfigAdvanced() { - // Default URL - $default_url = Rhymix\Framework\Config::get('url.default'); - if(strpos($default_url, 'xn--') !== FALSE) - { - $default_url = Context::decodeIdna($default_url); - } - Context::set('default_url', $default_url); - - // SSL and ports - Context::set('use_ssl', Rhymix\Framework\Config::get('url.ssl') ?: 'none'); - Context::set('http_port', Rhymix\Framework\Config::get('url.http_port')); - Context::set('https_port', Rhymix\Framework\Config::get('url.https_port')); - // Object cache $object_cache_types = Rhymix\Framework\Cache::getSupportedDrivers(); $object_cache_type = Rhymix\Framework\Config::get('cache.type'); diff --git a/modules/admin/tpl/config_advanced.html b/modules/admin/tpl/config_advanced.html index 8f9586926..d488d01bb 100644 --- a/modules/admin/tpl/config_advanced.html +++ b/modules/admin/tpl/config_advanced.html @@ -7,28 +7,6 @@ -
    - -
    - -
    -
    -
    - -
    - - - -
    {lang('admin.about_use_ssl')}
    -
    -
    -
    - -
    - - -
    -
    From 107600f19c0ceece4c2f9d878fb8fce435b00121 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Sat, 4 Mar 2017 21:32:01 +0900 Subject: [PATCH 23/55] Add language codes for domain-related error messages. --- modules/admin/admin.admin.controller.php | 2 +- modules/admin/lang/en.php | 10 +++++++++- modules/admin/lang/ko.php | 7 +++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/modules/admin/admin.admin.controller.php b/modules/admin/admin.admin.controller.php index c8bb07912..dafa34d2c 100644 --- a/modules/admin/admin.admin.controller.php +++ b/modules/admin/admin.admin.controller.php @@ -1003,7 +1003,7 @@ class adminAdminController extends admin } if ($vars->https_port !== 0 && ($vars->https_port < 1 || $vars->https_port > 65535 || $vars->https_port == 80)) { - return new Object(-1, 'msg_invalid_http_port'); + return new Object(-1, 'msg_invalid_https_port'); } // Validate the security setting. diff --git a/modules/admin/lang/en.php b/modules/admin/lang/en.php index 22d3abf19..a9ec4251c 100644 --- a/modules/admin/lang/en.php +++ b/modules/admin/lang/en.php @@ -115,9 +115,17 @@ $lang->cmd_index_module_srl = 'Main Module'; $lang->cmd_index_document_srl = 'Main Document'; $lang->cmd_default_language = 'Default Language'; $lang->cmd_new_domain = 'Add New Domain'; -$lang->about_use_ssl = '

    Selecting \'Optional\' is to use SSL for the specified actions such as signing up and changing information.
    Selecting \'Always\' is to use SSL for the entire pages, generated by Rhymix.

    Please be careful! You may not be able to access to the site, before installing SSL certificate.

    '; +$lang->cmd_edit_domain = 'Edit Domain'; +$lang->about_use_ssl = 'Selecting \'Optional\' is to use SSL for the specified actions such as signing up and changing information.
    Selecting \'Always\' is to use SSL for the entire pages, generated by Rhymix.
    Please be careful! You may not be able to access to the site, before installing SSL certificate.'; $lang->server_ports = 'Server Port'; $lang->about_server_ports = 'If your web server does not use 80 for HTTP or 443 for HTTPS port, you should specify server ports.'; +$lang->msg_invalid_domain = 'Invalid domain.'; +$lang->msg_domain_already_exists = 'The domain already exists.'; +$lang->msg_invalid_http_port = 'Invalid HTTP port.'; +$lang->msg_invalid_https_port = 'Invalid HTTPS port.'; +$lang->msg_invalid_index_module_srl = 'The main module does not exist.'; +$lang->msg_invalid_index_document_srl = 'The main document number does not exist.'; +$lang->msg_lang_is_not_enabled = 'The language you selected is not enabled in this site.'; $lang->use_db_session = 'Store Session in DB'; $lang->about_db_session = 'Store PHP sessions in the database. This setting must be turned on if you want to see current users or get detailed statistics.
    Unnecessary use may decrease server performance.'; $lang->qmail_compatibility = 'Enable Qmail'; diff --git a/modules/admin/lang/ko.php b/modules/admin/lang/ko.php index bd5f1650f..ff27add03 100644 --- a/modules/admin/lang/ko.php +++ b/modules/admin/lang/ko.php @@ -119,6 +119,13 @@ $lang->cmd_edit_domain = '도메인 정보 수정'; $lang->about_use_ssl = '\'선택적으로 사용\'은 회원가입, 정보수정 등의 지정된 동작(action)에서만 보안접속(HTTPS)을 사용합니다.
    \'항상 사용\'은 사이트 전체에 HTTPS를 사용합니다.
    SSL 인증서가 설치되지 않은 상태에서 HTTPS 사용을 시도하면 접속이 되지 않을 수 있으니 주의하시기 바랍니다.'; $lang->server_ports = '포트'; $lang->about_server_ports = 'HTTP는 80, HTTPS는 443 이 아닌, 다른 포트를 사용할 경우에 포트를 지정해 주어야 합니다.'; +$lang->msg_invalid_domain = '올바르지 않은 도메인입니다.'; +$lang->msg_domain_already_exists = '이미 등록된 도메인입니다.'; +$lang->msg_invalid_http_port = '올바르지 않은 HTTP 포트입니다.'; +$lang->msg_invalid_https_port = '올바르지 않은 HTTPS 포트입니다.'; +$lang->msg_invalid_index_module_srl = '선택하신 메인 모듈이 존재하지 않습니다.'; +$lang->msg_invalid_index_document_srl = '선택하신 메인 문서 번호가 존재하지 않습니다.'; +$lang->msg_lang_is_not_enabled = '선택하신 언어가 활성화되어 있지 않습니다.'; $lang->use_db_session = '인증 세션 DB 사용'; $lang->about_db_session = '세션을 DB에 저장합니다. 현재 접속자를 파악하려면 이 기능을 켜야 합니다.
    불필요하게 사용하면 서버 성능에 악영향을 줄 수 있으니 주의하십시오.'; $lang->qmail_compatibility = '큐메일(Qmail) 사용'; From 4bde9f6c7b9e2126dcaa35a4cd7a1cdc94ac78a7 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Sat, 4 Mar 2017 21:37:23 +0900 Subject: [PATCH 24/55] Merge site admin privileges with normal admin --- modules/module/module.controller.php | 47 ---------------------------- modules/module/module.model.php | 43 ++++--------------------- 2 files changed, 6 insertions(+), 84 deletions(-) diff --git a/modules/module/module.controller.php b/modules/module/module.controller.php index 6c7298d24..279410ebd 100644 --- a/modules/module/module.controller.php +++ b/modules/module/module.controller.php @@ -784,53 +784,6 @@ class moduleController extends module return $output; } - /** - * @brief Change the site administrator - */ - function insertSiteAdmin($site_srl, $arr_admins) - { - // Remove the site administrator - $args = new stdClass; - $args->site_srl = $site_srl; - - $output = executeQuery('module.deleteSiteAdmin', $args); - - if(!$output->toBool()) return $output; - // Get user id of an administrator - if(!is_array($arr_admins) || !count($arr_admins)) return new Object(); - foreach($arr_admins as $key => $user_id) - { - if(!trim($user_id)) continue; - $admins[] = trim($user_id); - } - if(!count($admins)) return new Object(); - - $oMemberModel = getModel('member'); - $member_config = $oMemberModel->getMemberConfig(); - if($member_config->identifier == 'email_address') - { - $args->email_address = '\''.implode('\',\'',$admins).'\''; - } - else - { - $args->user_ids = '\''.implode('\',\'',$admins).'\''; - } - $output = executeQueryArray('module.getAdminSrls', $args); - if(!$output->toBool()||!$output->data) return $output; - - foreach($output->data as $key => $val) - { - unset($args); - $args = new stdClass; - $args->site_srl = $site_srl; - $args->member_srl = $val->member_srl; - $output = executeQueryArray('module.insertSiteAdmin', $args); - if(!$output->toBool()) return $output; - } - Rhymix\Framework\Cache::delete("site_and_module:site_admins:$site_srl"); - return new Object(); - } - /** * @brief Specify the admin ID to a module */ diff --git a/modules/module/module.model.php b/modules/module/module.model.php index c4ea865ba..f6a3e633e 100644 --- a/modules/module/module.model.php +++ b/modules/module/module.model.php @@ -1583,36 +1583,14 @@ class moduleModel extends module */ function isSiteAdmin($member_info, $site_srl = null) { - if (!$member_info || !$member_info->member_srl) - { - return false; - } - if ($member_info->is_admin == 'Y') + if ($member_info && $member_info->is_admin == 'Y') { return true; } - if ($site_srl === null) + else { - $site_module_info = Context::get('site_module_info'); - if(!$site_module_info) return false; - $site_srl = $site_module_info->site_srl; + return false; } - - $site_srl = $site_srl ?: 0; - $site_admins = Rhymix\Framework\Cache::get("site_and_module:site_admins:$site_srl"); - if ($site_admins === null) - { - $args = new stdClass; - $args->site_srl = $site_srl; - $output = executeQueryArray('module.isSiteAdmin', $args); - $site_admins = array(); - foreach ($output->data as $site_admin) - { - $site_admins[$site_admin->member_srl] = true; - } - Rhymix\Framework\Cache::set("site_and_module:site_admins:$site_srl", $site_admins, 0, true); - } - return isset($site_admins[$member_info->member_srl]); } /** @@ -1620,10 +1598,7 @@ class moduleModel extends module */ function getSiteAdmin($site_srl) { - $args = new stdClass; - $args->site_srl = $site_srl; - $output = executeQueryArray('module.getSiteAdmin', $args); - return $output->data; + return array(); } /** @@ -1927,19 +1902,13 @@ class moduleModel extends module if(!$module_srl) { $grant->access = true; - if($this->isSiteAdmin($member_info, $module_info->site_srl)) - { - $grant->access = $grant->manager = $grant->is_site_admin = true; - } - - $grant->is_admin = $grant->manager = ($member_info->is_admin == 'Y') ? true : false; + $grant->is_admin = $grant->manager = $grant->is_site_admin = ($member_info->is_admin == 'Y') ? true : false; } else { // If module_srl exists // Get a type of granted permission - $grant->access = $grant->manager = $grant->is_site_admin = ($member_info->is_admin=='Y'||$this->isSiteAdmin($member_info, $module_info->site_srl))?true:false; - $grant->is_admin = ($member_info->is_admin == 'Y') ? true : false; + $grant->access = $grant->is_admin = $grant->manager = $grant->is_site_admin = ($member_info->is_admin == 'Y') ? true : false; // If a just logged-in member is, check if the member is a module administrator if (!$grant->manager && $member_info->member_srl && $this->isModuleAdmin($member_info, $module_srl)) From 8cf3d7b520872a08b6d9dde5b48920ff6c0bbd6c Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Sat, 4 Mar 2017 22:05:16 +0900 Subject: [PATCH 25/55] Update SSO mechanism to use new domain system --- classes/context/Context.class.php | 7 ++-- common/framework/session.php | 60 +++++++++++++++---------------- index.php | 13 ++----- 3 files changed, 35 insertions(+), 45 deletions(-) diff --git a/classes/context/Context.class.php b/classes/context/Context.class.php index fdc3a9b59..23061b9b7 100644 --- a/classes/context/Context.class.php +++ b/classes/context/Context.class.php @@ -265,10 +265,6 @@ class Context self::set('_http_port', self::$_instance->db_info->http_port = $site_module_info->http_port ?: null); self::set('_https_port', self::$_instance->db_info->https_port = $site_module_info->https_port ?: null); self::set('_use_ssl', self::$_instance->db_info->use_ssl = $site_module_info->security ?: 'none'); - if($site_module_info->site_srl && isSiteID($site_module_info->domain)) - { - self::set('vid', $site_module_info->domain, TRUE); - } } else { @@ -336,6 +332,7 @@ class Context // start session $relax_key_checks = ($this->act === 'procFileUpload' && preg_match('/shockwave\s?flash/i', $_SERVER['HTTP_USER_AGENT'])); + Rhymix\Framework\Session::checkSSO($site_module_info); Rhymix\Framework\Session::start(false, $relax_key_checks); $this->_COOKIE = $_COOKIE; @@ -660,7 +657,7 @@ class Context */ public function checkSSO() { - return !Rhymix\Framework\Session::checkSSO(); + return true; } /** diff --git a/common/framework/session.php b/common/framework/session.php index 4379f8e56..79dc26142 100644 --- a/common/framework/session.php +++ b/common/framework/session.php @@ -270,87 +270,87 @@ class Session * This method uses more or less the same logic as XE's SSO mechanism. * It may need to be changed to a more secure mechanism later. * - * @return bool + * @param object $site_module_info + * @return void */ - public static function checkSSO() + public static function checkSSO($site_module_info) { // Abort if SSO is disabled, the visitor is a robot, or this is not a typical GET request. if ($_SERVER['REQUEST_METHOD'] !== 'GET' || !config('use_sso') || UA::isRobot() || in_array(\Context::get('act'), array('rss', 'atom'))) { - return false; - } - - // Abort of the default URL is not set. - $default_url = \Context::getDefaultUrl(); - if (!$default_url) - { - return false; + return; } // Get the current site information. - $current_url = URL::getCurrentURL(); - $current_host = parse_url($current_url, \PHP_URL_HOST); - $default_host = parse_url($default_url, \PHP_URL_HOST); + $is_default_domain = ($site_module_info->domain_srl == 0); + if (!$is_default_domain) + { + $current_domain = $site_module_info->domain; + $current_url = URL::getCurrentUrl(); + $default_domain = getModel('module')->getSiteInfo(0); + $default_url = \Context::getDefaultUrl($default_domain); + } // Step 1: if the current site is not the default site, send SSO validation request to the default site. - if($default_host !== $current_host && !\Context::get('sso_response') && $_COOKIE['sso'] !== md5($current_host)) + if(!$is_default_domain && !\Context::get('sso_response') && $_COOKIE['sso'] !== md5($current_domain)) { // Set sso cookie to prevent multiple simultaneous SSO validation requests. - setcookie('sso', md5($current_host), 0, '/'); + setcookie('sso', md5($current_domain), 0, '/'); // Redirect to the default site. $sso_request = Security::encrypt($current_url); header('Location:' . URL::modifyURL($default_url, array('sso_request' => $sso_request))); - return true; + exit; } // Step 2: receive and process SSO validation request at the default site. - if($default_host === $current_host && \Context::get('sso_request')) + if($is_default_domain && \Context::get('sso_request')) { // Get the URL of the origin site $sso_request = Security::decrypt(\Context::get('sso_request')); if (!$sso_request || !preg_match('!^https?://!', $sso_request)) { \Context::displayErrorPage('SSO Error', 'Invalid SSO Request', 400); - return true; + exit; } - // Redirect back to the origin site. + // Encrypt the session ID. + self::start(true); $sso_response = Security::encrypt(session_id()); + + // Redirect back to the origin site. header('Location: ' . URL::modifyURL($sso_request, array('sso_response' => $sso_response))); - return true; + self::close(); + exit; } // Step 3: back at the origin site, set session ID to be the same as the default site. - if($default_host !== $current_host && \Context::get('sso_response')) + if(!$is_default_domain && \Context::get('sso_response')) { // Check SSO response $sso_response = Security::decrypt(\Context::get('sso_response')); if ($sso_response === false) { \Context::displayErrorPage('SSO Error', 'Invalid SSO Response', 400); - return true; + exit; } // Check that the response was given by the default site (to prevent session fixation CSRF). if(isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], $default_url) !== 0) { \Context::displayErrorPage('SSO Error', 'Invalid SSO Response', 400); - return true; + exit; } - // Set session ID. - self::close(); + // Set the session ID. session_id($sso_response); - self::start(); + self::start(true, false); // Finally, redirect to the originally requested URL. header('Location: ' . URL::getCurrentURL(array('sso_response' => null))); - return true; + self::close(); + exit; } - - // If none of the conditions above apply, proceed normally. - return false; } /** diff --git a/index.php b/index.php index bd0e2d53b..27aaa6a15 100644 --- a/index.php +++ b/index.php @@ -47,17 +47,10 @@ $oContext = Context::getInstance(); $oContext->init(); /** - * @brief If default_url is set and it is different from the current url, attempt to redirect for SSO authentication and then process the module + * @brief Initialize and execute Module Handler **/ -if($oContext->checkSSO()) -{ - $oModuleHandler = new ModuleHandler(); - - if($oModuleHandler->init()) - { - $oModuleHandler->displayContent($oModuleHandler->procModule()); - } -} +$oModuleHandler = new ModuleHandler(); +$oModuleHandler->init() && $oModuleHandler->displayContent($oModuleHandler->procModule()); Context::close(); From f1608ad3a9f3278c65d16b3406939aec2c7dd58b Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Sat, 4 Mar 2017 22:09:07 +0900 Subject: [PATCH 26/55] Fix unit test for Session::checkSSO() --- tests/unit/framework/SessionTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/framework/SessionTest.php b/tests/unit/framework/SessionTest.php index 2f6b34f1f..e263ef4ab 100644 --- a/tests/unit/framework/SessionTest.php +++ b/tests/unit/framework/SessionTest.php @@ -134,7 +134,7 @@ class SessionTest extends \Codeception\TestCase\Test public function testCheckSSO() { - $this->assertFalse(Rhymix\Framework\Session::checkSSO()); + $this->assertNull(Rhymix\Framework\Session::checkSSO(new stdClass)); } public function testRefresh() From af7309b807f05130b4188e92f70f9ddd792cf712 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Sat, 4 Mar 2017 22:09:45 +0900 Subject: [PATCH 27/55] Consistently use new domain system for URL::isInternalUrl() and checkCSRF() --- common/framework/security.php | 8 ++++---- common/legacy.php | 19 +------------------ modules/module/module.model.php | 2 +- 3 files changed, 6 insertions(+), 23 deletions(-) diff --git a/common/framework/security.php b/common/framework/security.php index f0eb05fb3..751a8c4b0 100644 --- a/common/framework/security.php +++ b/common/framework/security.php @@ -310,10 +310,10 @@ class Security if (!$referer) { $referer = strval($_SERVER['HTTP_REFERER']); - if ($referer === '') - { - return true; - } + } + if (strval($referer) === '') + { + return true; } return URL::isInternalURL($referer); diff --git a/common/legacy.php b/common/legacy.php index a976c5a6f..f41ef8d9d 100644 --- a/common/legacy.php +++ b/common/legacy.php @@ -1051,24 +1051,7 @@ function requirePear() */ function checkCSRF() { - // Use Rhymix Security class first. - if (Rhymix\Framework\Security::checkCSRF()) - { - return true; - } - - // Check if we have a virtual site with a matching domain. - $oModuleModel = getModel('module'); - $siteModuleInfo = $oModuleModel->getDefaultMid(); - $virtualSiteInfo = $oModuleModel->getSiteInfo($siteModuleInfo->site_srl); - if (strcasecmp($virtualSiteInfo->domain, Context::get('vid')) && stristr($virtualSiteInfo->domain, $referer_host)) - { - return true; - } - else - { - return false; - } + return Rhymix\Framework\Security::checkCSRF(); } /** diff --git a/modules/module/module.model.php b/modules/module/module.model.php index f6a3e633e..2c0863e22 100644 --- a/modules/module/module.model.php +++ b/modules/module/module.model.php @@ -97,7 +97,7 @@ class moduleModel extends module $domain = Rhymix\Framework\URL::getDomainFromURL($domain); if ($domain === false) { - return null; + return false; } } if (strpos($domain, 'xn--') !== false) From 5bd5044126f727d4c7d2212b44839e4dcf3729cc Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Sat, 4 Mar 2017 22:15:46 +0900 Subject: [PATCH 28/55] Improve referer checks in Session::checkSSO() --- common/framework/session.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/common/framework/session.php b/common/framework/session.php index 79dc26142..5a6d206f1 100644 --- a/common/framework/session.php +++ b/common/framework/session.php @@ -313,6 +313,11 @@ class Session \Context::displayErrorPage('SSO Error', 'Invalid SSO Request', 400); exit; } + if (!URL::isInternalUrl($sso_request) || !Security::checkCSRF()) + { + \Context::displayErrorPage('SSO Error', 'Invalid SSO Request', 400); + exit; + } // Encrypt the session ID. self::start(true); @@ -336,7 +341,7 @@ class Session } // Check that the response was given by the default site (to prevent session fixation CSRF). - if(isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], $default_url) !== 0) + if(isset($_SERVER['HTTP_REFERER']) && strpos(URL::decodeIdna($_SERVER['HTTP_REFERER']), $default_url) !== 0) { \Context::displayErrorPage('SSO Error', 'Invalid SSO Response', 400); exit; From 190e9f039eb4917482bb5859edc27e2c24b071ce Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Sat, 11 Mar 2017 22:48:53 +0900 Subject: [PATCH 29/55] Implement title, subtitle, and other information for domains --- modules/admin/admin.admin.controller.php | 37 ++++++++-- modules/admin/admin.admin.model.php | 33 +++++---- modules/admin/admin.admin.view.php | 24 ++++++- modules/admin/lang/en.php | 4 +- modules/admin/lang/ko.php | 4 +- modules/admin/tpl/config_domains_edit.html | 81 ++++++++++++++++++++-- 6 files changed, 153 insertions(+), 30 deletions(-) diff --git a/modules/admin/admin.admin.controller.php b/modules/admin/admin.admin.controller.php index dafa34d2c..66181f39e 100644 --- a/modules/admin/admin.admin.controller.php +++ b/modules/admin/admin.admin.controller.php @@ -958,13 +958,21 @@ class adminAdminController extends admin $domain_info = null; if ($domain_srl !== '') { - $output = executeQuery('module.getDomainInfo', (object)array('domain_srl' => $domain_srl)); - if ($output->toBool() && $output->data) + $domain_info = getModel('module')->getSiteInfo($domain_srl); + if ($domain_info->domain_srl != $domain_srl) { - $domain_info = $output->data; + $domain_info = null; } } + // Validate the title and subtitle. + $vars->title = utf8_trim($vars->title); + $vars->subtitle = utf8_trim($vars->subtitle); + if ($vars->title === '') + { + return new Object(-1, 'msg_site_title_is_empty'); + } + // Validate the domain. if (!preg_match('@^https?://@', $vars->domain)) { @@ -1041,6 +1049,25 @@ class adminAdminController extends admin return new Object(-1, 'msg_lang_is_not_enabled'); } + // Validate the default time zone. + $timezone_list = Rhymix\Framework\DateTime::getTimezoneList(); + if (!isset($timezone_list[$vars->default_timezone])) + { + return new Object(-1, 'msg_invalid_timezone'); + } + + // Clean up the footer script. + $vars->html_footer = utf8_trim($vars->html_footer); + + // Merge all settings into an array. + $settings = array( + 'title' => $vars->title, + 'subtitle' => $vars->subtitle, + 'language' => $vars->default_lang, + 'timezone' => $vars->default_timezone, + 'html_footer' => $vars->html_footer, + ); + // Insert or update the domain. if (!$domain_info) { @@ -1053,7 +1080,7 @@ class adminAdminController extends admin $args->https_port = $vars->https_port; $args->security = $vars->domain_security; $args->description = ''; - $args->settings = json_encode(array('language' => $vars->default_lang, 'timezone' => null)); + $args->settings = json_encode($settings); $output = executeQuery('module.insertDomain', $args); if (!$output->toBool()) { @@ -1070,7 +1097,7 @@ class adminAdminController extends admin $args->http_port = $vars->http_port; $args->https_port = $vars->https_port; $args->security = $vars->domain_security; - $args->settings = json_encode(array_merge($domain_info->settings, array('language' => $vars->default_lang))); + $args->settings = json_encode(array_merge(get_object_vars($domain_info->settings), $settings)); $output = executeQuery('module.updateDomain', $args); if (!$output->toBool()) { diff --git a/modules/admin/admin.admin.model.php b/modules/admin/admin.admin.model.php index 8d26d9711..feca54c5e 100644 --- a/modules/admin/admin.admin.model.php +++ b/modules/admin/admin.admin.model.php @@ -811,22 +811,26 @@ class adminAdminModel extends admin return $output->data->count; } - function getFaviconUrl($default = true) + function getFaviconUrl($domain_srl = 0) { - return $this->iconUrlCheck('favicon.ico', 'faviconSample.png', $default); + return $this->iconUrlCheck('favicon.ico', 'faviconSample.png', $domain_srl); } - function getMobileIconUrl($default = true) + function getMobileIconUrl($domain_srl = 0) { - return $this->iconUrlCheck('mobicon.png', 'mobiconSample.png', $default); + return $this->iconUrlCheck('mobicon.png', 'mobiconSample.png', $domain_srl); } - function getSiteDefaultImageUrl(&$width = 0, &$height = 0) + function getSiteDefaultImageUrl($domain_srl = 0, &$width = 0, &$height = 0) { - $site_info = Context::get('site_module_info'); - if ($site_info->site_srl) + $domain_srl = intval($domain_srl); + if (!$domain_srl) { - $virtual_site = $site_info->site_srl . '/'; + $domain_srl = intval(Context::get('site_module_info')->domain_srl); + } + if ($domain_srl) + { + $virtual_site = $domain_srl . '/'; } else { @@ -846,17 +850,16 @@ class adminAdminModel extends admin } } - function iconUrlCheck($iconname, $default_icon_name, $default) + function iconUrlCheck($iconname, $default_icon_name, $domain_srl) { - if ($default) + $domain_srl = intval($domain_srl); + if (!$domain_srl) { - return \RX_BASEURL . 'modules/admin/tpl/img/' . $default_icon_name; + $domain_srl = intval(Context::get('site_module_info')->domain_srl); } - - $site_info = Context::get('site_module_info'); - if ($site_info->site_srl) + if ($domain_srl) { - $virtual_site = $site_info->site_srl . '/'; + $virtual_site = $domain_srl . '/'; } else { diff --git a/modules/admin/admin.admin.view.php b/modules/admin/admin.admin.view.php index 8306fc5ad..877931fd9 100644 --- a/modules/admin/admin.admin.view.php +++ b/modules/admin/admin.admin.view.php @@ -689,10 +689,10 @@ class adminAdminView extends admin $domain_info = null; if ($domain_srl !== '') { - $output = executeQuery('module.getDomainInfo', (object)array('domain_srl' => $domain_srl)); - if ($output->toBool() && $output->data) + $domain_info = getModel('module')->getSiteInfo($domain_srl); + if ($domain_info->domain_srl != $domain_srl) { - $domain_info = $output->data; + $domain_info = null; } } Context::set('domain_info', $domain_info); @@ -723,6 +723,24 @@ class adminAdminView extends admin } Context::set('domain_lang', $domain_lang); + // Get timezone list. + Context::set('timezones', Rhymix\Framework\DateTime::getTimezoneList()); + if ($domain_info && $domain_info->settings->timezone) + { + $domain_timezone = $domain_info->settings->timezone; + } + else + { + $domain_timezone = Rhymix\Framework\Config::get('locale.default_timezone'); + } + Context::set('domain_timezone', $domain_timezone); + + // Get favicon and images. + $oAdminAdminModel = getAdminModel('admin'); + Context::set('favicon_url', $oAdminAdminModel->getFaviconUrl($domain_info->domain_srl)); + Context::set('mobicon_url', $oAdminAdminModel->getMobileIconUrl($domain_info->domain_srl)); + Context::set('default_image_url', $oAdminAdminModel->getSiteDefaultImageUrl($domain_info->domain_srl)); + $this->setTemplateFile('config_domains_edit'); } diff --git a/modules/admin/lang/en.php b/modules/admin/lang/en.php index a9ec4251c..f2b869766 100644 --- a/modules/admin/lang/en.php +++ b/modules/admin/lang/en.php @@ -119,6 +119,7 @@ $lang->cmd_edit_domain = 'Edit Domain'; $lang->about_use_ssl = 'Selecting \'Optional\' is to use SSL for the specified actions such as signing up and changing information.
    Selecting \'Always\' is to use SSL for the entire pages, generated by Rhymix.
    Please be careful! You may not be able to access to the site, before installing SSL certificate.'; $lang->server_ports = 'Server Port'; $lang->about_server_ports = 'If your web server does not use 80 for HTTP or 443 for HTTPS port, you should specify server ports.'; +$lang->msg_site_title_is_empty = 'Please enter a title for the domain.'; $lang->msg_invalid_domain = 'Invalid domain.'; $lang->msg_domain_already_exists = 'The domain already exists.'; $lang->msg_invalid_http_port = 'Invalid HTTP port.'; @@ -126,6 +127,7 @@ $lang->msg_invalid_https_port = 'Invalid HTTPS port.'; $lang->msg_invalid_index_module_srl = 'The main module does not exist.'; $lang->msg_invalid_index_document_srl = 'The main document number does not exist.'; $lang->msg_lang_is_not_enabled = 'The language you selected is not enabled in this site.'; +$lang->msg_invalid_timezone = 'The selected time zone is not usable on this server.'; $lang->use_db_session = 'Store Session in DB'; $lang->about_db_session = 'Store PHP sessions in the database. This setting must be turned on if you want to see current users or get detailed statistics.
    Unnecessary use may decrease server performance.'; $lang->qmail_compatibility = 'Enable Qmail'; @@ -235,7 +237,7 @@ $lang->about_use_mobile_view = 'Show mobile page when visitors access with mobil $lang->tablets_as_mobile = 'Treat Tablets as Mobile'; $lang->thumbnail_type = 'Select thumbnail type.'; $lang->input_footer_script = 'Footer script'; -$lang->detail_input_footer_script = 'The script is inserted into the bottom of body. It does not work at admin page.'; +$lang->detail_input_footer_script = 'Any content added here will be printed at the bottom of the page, except the admin module.'; $lang->thumbnail_crop = 'Crop'; $lang->thumbnail_ratio = 'Keep aspect ratio (may result in spaces)'; $lang->thumbnail_none = 'Do not create thumbnails'; diff --git a/modules/admin/lang/ko.php b/modules/admin/lang/ko.php index ff27add03..abf4a3ba0 100644 --- a/modules/admin/lang/ko.php +++ b/modules/admin/lang/ko.php @@ -119,6 +119,7 @@ $lang->cmd_edit_domain = '도메인 정보 수정'; $lang->about_use_ssl = '\'선택적으로 사용\'은 회원가입, 정보수정 등의 지정된 동작(action)에서만 보안접속(HTTPS)을 사용합니다.
    \'항상 사용\'은 사이트 전체에 HTTPS를 사용합니다.
    SSL 인증서가 설치되지 않은 상태에서 HTTPS 사용을 시도하면 접속이 되지 않을 수 있으니 주의하시기 바랍니다.'; $lang->server_ports = '포트'; $lang->about_server_ports = 'HTTP는 80, HTTPS는 443 이 아닌, 다른 포트를 사용할 경우에 포트를 지정해 주어야 합니다.'; +$lang->msg_site_title_is_empty = '사이트 이름을 입력해 주십시오.'; $lang->msg_invalid_domain = '올바르지 않은 도메인입니다.'; $lang->msg_domain_already_exists = '이미 등록된 도메인입니다.'; $lang->msg_invalid_http_port = '올바르지 않은 HTTP 포트입니다.'; @@ -126,6 +127,7 @@ $lang->msg_invalid_https_port = '올바르지 않은 HTTPS 포트입니다.'; $lang->msg_invalid_index_module_srl = '선택하신 메인 모듈이 존재하지 않습니다.'; $lang->msg_invalid_index_document_srl = '선택하신 메인 문서 번호가 존재하지 않습니다.'; $lang->msg_lang_is_not_enabled = '선택하신 언어가 활성화되어 있지 않습니다.'; +$lang->msg_invalid_timezone = '사용할 수 없는 표준 시간대입니다.'; $lang->use_db_session = '인증 세션 DB 사용'; $lang->about_db_session = '세션을 DB에 저장합니다. 현재 접속자를 파악하려면 이 기능을 켜야 합니다.
    불필요하게 사용하면 서버 성능에 악영향을 줄 수 있으니 주의하십시오.'; $lang->qmail_compatibility = '큐메일(Qmail) 사용'; @@ -230,7 +232,7 @@ $lang->about_use_mobile_view = '모바일 기기로 접속시 모바일 페이 $lang->tablets_as_mobile = '태블릿도 모바일 취급'; $lang->thumbnail_type = '썸네일 생성 방식'; $lang->input_footer_script = '하단(footer) 스크립트'; -$lang->detail_input_footer_script = '최하단에 코드를 삽입합니다. 관리자 페이지에서는 수행되지 않습니다.'; +$lang->detail_input_footer_script = '최하단에 코드를 삽입합니다. 관리자 화면에는 적용되지 않습니다.'; $lang->thumbnail_crop = '크기에 맞추어 잘라내기'; $lang->thumbnail_ratio = '비율 유지 (여백이 생길 수 있음)'; $lang->thumbnail_none = '썸네일 생성하지 않음'; diff --git a/modules/admin/tpl/config_domains_edit.html b/modules/admin/tpl/config_domains_edit.html index 7a6002f0a..57e9de758 100644 --- a/modules/admin/tpl/config_domains_edit.html +++ b/modules/admin/tpl/config_domains_edit.html @@ -9,6 +9,20 @@ +
    + +
    + +
    +
    + +
    + +
    + +
    +
    +
    @@ -45,11 +59,7 @@
    - +
    @@ -69,6 +79,67 @@
    +
    + +
    + +
    +
    + +
    + +
    + +
    {$lang->detail_input_footer_script}
    +
    +
    + +
    + +
    +

    + Favicon + Favicon +

    + + + {$lang->about_use_favicon} +
    +
    + +
    + +
    +

    + Mobile Home Icon + Rhymix +

    + + + {$lang->detail_use_mobile_icon} +
    +
    + +
    + +
    +

    + Default Image +

    + + + {$lang->about_site_default_image} +
    +
    +
    From 4257edf7faad397b49a7c842eccfb6b6d4f5c4a7 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Sun, 12 Mar 2017 22:55:57 +0900 Subject: [PATCH 30/55] Implement saving favicon, mobicon, and default image for domain --- common/framework/storage.php | 5 + modules/admin/admin.admin.controller.php | 103 ++++++--------------- modules/admin/tpl/config_domains_edit.html | 20 ++-- 3 files changed, 42 insertions(+), 86 deletions(-) diff --git a/common/framework/storage.php b/common/framework/storage.php index 86bcadffc..a9ff297be 100644 --- a/common/framework/storage.php +++ b/common/framework/storage.php @@ -456,6 +456,11 @@ class Storage return false; } + if (is_uploaded_file($source)) + { + @chmod($destination, 0666 & ~self::getUmask()); + } + if (function_exists('opcache_invalidate')) { if (substr($source, -4) === '.php') diff --git a/modules/admin/admin.admin.controller.php b/modules/admin/admin.admin.controller.php index 66181f39e..22f0e1e1a 100644 --- a/modules/admin/admin.admin.controller.php +++ b/modules/admin/admin.admin.controller.php @@ -542,11 +542,6 @@ class adminAdminController extends admin Rhymix\Framework\Config::set('use_mobile_view', $vars->use_mobile_view === 'Y'); } - // Favicon and mobicon - $this->_saveFavicon('favicon.ico', $vars->is_delete_favicon); - $this->_saveFavicon('mobicon.png', $vars->is_delete_mobicon); - $this->_saveDefaultImage($vars->is_delete_default_image); - // Save if (!Rhymix\Framework\Config::save()) { @@ -1105,6 +1100,20 @@ class adminAdminController extends admin } } + // Save the favicon, mobicon, and default image. + if ($vars->favicon || $vars->delete_favicon) + { + $this->_saveFavicon($args->domain_srl, $vars->favicon, 'favicon.ico', $vars->delete_favicon); + } + if ($vars->mobicon || $vars->delete_mobicon) + { + $this->_saveFavicon($args->domain_srl, $vars->mobicon, 'mobicon.png', $vars->delete_mobicon); + } + if ($vars->default_image || $vars->delete_default_image) + { + $this->_saveDefaultImage($args->domain_srl, $vars->default_image, $vars->delete_default_image); + } + // Update system configuration to match the default domain. if ($domain_info && $domain_srl === '0') { @@ -1221,69 +1230,12 @@ class adminAdminController extends admin $this->setMessage('success_deleted'); } - /** - * Upload favicon and mobicon. - */ - public function procAdminFaviconUpload() - { - if ($favicon = Context::get('favicon')) - { - $name = 'favicon'; - $tmpFileName = $this->_saveFaviconTemp($favicon, 'favicon.ico'); - } - elseif ($mobicon = Context::get('mobicon')) - { - $name = 'mobicon'; - $tmpFileName = $this->_saveFaviconTemp($mobicon, 'mobicon.png'); - } - elseif ($default_image = Context::get('default_image')) - { - $name = 'default_image'; - $tmpFileName = $this->_saveFaviconTemp($default_image, 'default_image.png'); - } - else - { - $name = $tmpFileName = ''; - Context::set('msg', lang('msg_invalid_format')); - } - - Context::set('name', $name); - Context::set('tmpFileName', $tmpFileName . '?' . time()); - $this->setTemplatePath($this->module_path . 'tpl'); - $this->setTemplateFile("favicon_upload.html"); - } - - protected function _saveFaviconTemp($icon, $iconname) - { - $site_info = Context::get('site_module_info'); - $virtual_site = ''; - if ($site_info->site_srl) - { - $virtual_site = $site_info->site_srl . '/'; - } - - $original_filename = $icon['tmp_name']; - $type = $icon['type']; - $relative_filename = 'files/attach/xeicon/'.$virtual_site.'tmp/'.$iconname; - $target_filename = \RX_BASEDIR . $relative_filename; - - if (!preg_match('/^(favicon|mobicon|default_image)\.(ico|png|jpe?g)$/', $iconname)) - { - Context::set('msg', lang('msg_invalid_format')); - return; - } - - Rhymix\Framework\Storage::copy($original_filename, $target_filename, 0666 & ~umask()); - return $relative_filename; - } - - protected function _saveFavicon($iconname, $deleteIcon = false) + protected function _saveFavicon($domain_srl, $uploaded_fileinfo, $iconname, $deleteIcon = false) { $image_filepath = 'files/attach/xeicon/'; - $site_info = Context::get('site_module_info'); - if ($site_info->site_srl) + if ($domain_srl) { - $image_filepath .= $site_info->site_srl . '/'; + $image_filepath .= intval($domain_srl) . '/'; } if ($deleteIcon) @@ -1292,21 +1244,20 @@ class adminAdminController extends admin return; } - $tmpicon_filepath = $image_filepath . 'tmp/' . $iconname; + $original_filename = $uploaded_fileinfo['tmp_name']; $icon_filepath = $image_filepath . $iconname; - if (file_exists(\RX_BASEDIR . $tmpicon_filepath)) + if (is_uploaded_file($original_filename)) { - Rhymix\Framework\Storage::move(\RX_BASEDIR . $tmpicon_filepath, \RX_BASEDIR . $icon_filepath); + Rhymix\Framework\Storage::move($original_filename, \RX_BASEDIR . $icon_filepath); } } - protected function _saveDefaultImage($deleteIcon = false) + protected function _saveDefaultImage($domain_srl, $uploaded_fileinfo, $deleteIcon = false) { $image_filepath = 'files/attach/xeicon/'; - $site_info = Context::get('site_module_info'); - if ($site_info->site_srl) + if ($domain_srl) { - $image_filepath .= $site_info->site_srl . '/'; + $image_filepath .= intval($domain_srl) . '/'; } if ($deleteIcon) @@ -1320,17 +1271,17 @@ class adminAdminController extends admin return; } - $tmpicon_filepath = \RX_BASEDIR . $image_filepath . 'tmp/default_image.png'; - if (file_exists($tmpicon_filepath)) + $original_filename = $uploaded_fileinfo['tmp_name']; + if (is_uploaded_file($original_filename)) { - list($width, $height, $type) = @getimagesize($tmpicon_filepath); + list($width, $height, $type) = @getimagesize($original_filename); switch ($type) { case 'image/gif': $target_filename = $image_filepath . 'default_image.gif'; break; case 'image/jpeg': $target_filename = $image_filepath . 'default_image.jpg'; break; case 'image/png': default: $target_filename = $image_filepath . 'default_image.png'; } - Rhymix\Framework\Storage::move($tmpicon_filepath, \RX_BASEDIR . $target_filename); + Rhymix\Framework\Storage::move($original_filename, \RX_BASEDIR . $target_filename); Rhymix\Framework\Storage::writePHPData(\RX_BASEDIR . 'files/attach/xeicon/' . $virtual_site . 'default_image.php', array( 'filename' => $target_filename, 'width' => $width, 'height' => $height, )); diff --git a/modules/admin/tpl/config_domains_edit.html b/modules/admin/tpl/config_domains_edit.html index 57e9de758..1c882208a 100644 --- a/modules/admin/tpl/config_domains_edit.html +++ b/modules/admin/tpl/config_domains_edit.html @@ -3,7 +3,7 @@

    {$XE_VALIDATOR_MESSAGE}

    -
    + @@ -103,10 +103,10 @@ Favicon Favicon

    -
    @@ -118,10 +118,10 @@ Mobile Home Icon Rhymix

    -
    @@ -132,10 +132,10 @@

    Default Image

    -
    diff --git a/modules/module/queries/insertDomain.xml b/modules/module/queries/insertDomain.xml index f90f2ea55..e42c04291 100644 --- a/modules/module/queries/insertDomain.xml +++ b/modules/module/queries/insertDomain.xml @@ -5,6 +5,7 @@ + diff --git a/modules/module/queries/updateDomain.xml b/modules/module/queries/updateDomain.xml index 94f64a84a..7861c84ba 100644 --- a/modules/module/queries/updateDomain.xml +++ b/modules/module/queries/updateDomain.xml @@ -4,6 +4,7 @@ + diff --git a/modules/module/schemas/domains.xml b/modules/module/schemas/domains.xml index 296173d81..eb488c96a 100644 --- a/modules/module/schemas/domains.xml +++ b/modules/module/schemas/domains.xml @@ -1,6 +1,7 @@ + From fc6002f2cb10f5d24acd46957cce92b2f000b976 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Sun, 12 Mar 2017 23:33:35 +0900 Subject: [PATCH 32/55] Apply site title, subtitle, and footer for each domain --- classes/context/Context.class.php | 12 ++++++------ classes/module/ModuleHandler.class.php | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/classes/context/Context.class.php b/classes/context/Context.class.php index 23061b9b7..522885688 100644 --- a/classes/context/Context.class.php +++ b/classes/context/Context.class.php @@ -774,10 +774,10 @@ class Context */ public static function getSiteTitle() { - $moduleConfig = getModel('module')->getModuleConfig('module'); - if (isset($moduleConfig->siteTitle)) + $domain_info = self::get('site_module_info'); + if ($domain_info && $domain_info->settings && $domain_info->settings->title) { - $title = trim($moduleConfig->siteTitle); + $title = trim($domain_info->settings->title); getController('module')->replaceDefinedLangCode($title); return $title; } @@ -794,10 +794,10 @@ class Context */ public static function getSiteSubtitle() { - $moduleConfig = getModel('module')->getModuleConfig('module'); - if (isset($moduleConfig->siteSubtitle)) + $domain_info = self::get('site_module_info'); + if ($domain_info && $domain_info->settings && $domain_info->settings->subtitle) { - $subtitle = trim($moduleConfig->siteSubtitle); + $subtitle = trim($domain_info->settings->subtitle); getController('module')->replaceDefinedLangCode($subtitle); return $subtitle; } diff --git a/classes/module/ModuleHandler.class.php b/classes/module/ModuleHandler.class.php index 683eef647..0c2c7cd5c 100644 --- a/classes/module/ModuleHandler.class.php +++ b/classes/module/ModuleHandler.class.php @@ -774,16 +774,16 @@ class ModuleHandler extends Handler if($type == "view" && $kind != 'admin') { - $module_config = $oModuleModel->getModuleConfig('module'); - if($module_config->htmlFooter) + $domain_info = Context::get('site_module_info'); + if ($domain_info && $domain_info->settings && $domain_info->settings->html_footer) { - Context::addHtmlFooter($module_config->htmlFooter); + Context::addHtmlFooter($domain_info->settings->html_footer); } - if($module_config->siteTitle) + if ($domain_info && $domain_info->settings && $domain_info->settings->title) { if(!Context::getBrowserTitle()) { - Context::setBrowserTitle($module_config->siteTitle); + Context::setBrowserTitle($domain_info->settings->title); } } } From d5959a91bb945e1d8c0b5e85559e4114f3c1c6c9 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Sun, 12 Mar 2017 23:40:11 +0900 Subject: [PATCH 33/55] Apply favicon, mobicon, and default image for each domain --- classes/display/HTMLDisplayHandler.php | 7 ++++--- modules/admin/admin.admin.model.php | 8 -------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/classes/display/HTMLDisplayHandler.php b/classes/display/HTMLDisplayHandler.php index aa67124a2..0e6360ace 100644 --- a/classes/display/HTMLDisplayHandler.php +++ b/classes/display/HTMLDisplayHandler.php @@ -221,9 +221,10 @@ class HTMLDisplayHandler } // set icon + $site_module_info = Context::get('site_module_info'); $oAdminModel = getAdminModel('admin'); - $favicon_url = $oAdminModel->getFaviconUrl(false); - $mobicon_url = $oAdminModel->getMobileIconUrl(false); + $favicon_url = $oAdminModel->getFaviconUrl($site_module_info->domain_srl); + $mobicon_url = $oAdminModel->getMobileIconUrl($site_module_info->domain_srl); Context::set('favicon_url', $favicon_url); Context::set('mobicon_url', $mobicon_url); @@ -500,7 +501,7 @@ class HTMLDisplayHandler Context::addOpenGraphData('og:image:width', $first_image['width']); Context::addOpenGraphData('og:image:height', $first_image['height']); } - elseif ($default_image = getAdminModel('admin')->getSiteDefaultImageUrl($width, $height)) + elseif ($default_image = getAdminModel('admin')->getSiteDefaultImageUrl($site_module_info->domain_srl, $width, $height)) { Context::addOpenGraphData('og:image', Rhymix\Framework\URL::getCurrentDomainURL($default_image)); if ($width && $height) diff --git a/modules/admin/admin.admin.model.php b/modules/admin/admin.admin.model.php index feca54c5e..10db01b46 100644 --- a/modules/admin/admin.admin.model.php +++ b/modules/admin/admin.admin.model.php @@ -824,10 +824,6 @@ class adminAdminModel extends admin function getSiteDefaultImageUrl($domain_srl = 0, &$width = 0, &$height = 0) { $domain_srl = intval($domain_srl); - if (!$domain_srl) - { - $domain_srl = intval(Context::get('site_module_info')->domain_srl); - } if ($domain_srl) { $virtual_site = $domain_srl . '/'; @@ -853,10 +849,6 @@ class adminAdminModel extends admin function iconUrlCheck($iconname, $default_icon_name, $domain_srl) { $domain_srl = intval($domain_srl); - if (!$domain_srl) - { - $domain_srl = intval(Context::get('site_module_info')->domain_srl); - } if ($domain_srl) { $virtual_site = $domain_srl . '/'; From 393a90c022da1e5f1508d282147cf64283a4c088 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Mon, 13 Mar 2017 00:00:17 +0900 Subject: [PATCH 34/55] Improve default domain handling --- modules/admin/admin.admin.controller.php | 3 ++- modules/admin/admin.admin.view.php | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/admin/admin.admin.controller.php b/modules/admin/admin.admin.controller.php index 22f0e1e1a..c21b00811 100644 --- a/modules/admin/admin.admin.controller.php +++ b/modules/admin/admin.admin.controller.php @@ -1087,6 +1087,7 @@ class adminAdminController extends admin $args = new stdClass(); $args->domain_srl = $domain_info->domain_srl; $args->domain = $vars->domain; + $args->is_default_domain = 'N'; $args->index_module_srl = $vars->index_module_srl; $args->index_document_srl = $vars->index_document_srl; $args->http_port = $vars->http_port; @@ -1115,7 +1116,7 @@ class adminAdminController extends admin } // Update system configuration to match the default domain. - if ($domain_info && $domain_srl === '0') + if ($domain_info && $domain_info->is_default_domain === 'Y') { $domain_info->domain = $vars->domain; $domain_info->http_port = $vars->http_port; diff --git a/modules/admin/admin.admin.view.php b/modules/admin/admin.admin.view.php index 877931fd9..c2a2fb65c 100644 --- a/modules/admin/admin.admin.view.php +++ b/modules/admin/admin.admin.view.php @@ -557,6 +557,7 @@ class adminAdminView extends admin // Other settings Context::set('use_rewrite', Rhymix\Framework\Config::get('use_rewrite')); Context::set('use_sso', Rhymix\Framework\Config::get('use_sso')); + Context::set('use_ssl', Rhymix\Framework\Config::get('url.ssl')); Context::set('delay_session', Rhymix\Framework\Config::get('session.delay')); Context::set('use_session_keys', Rhymix\Framework\Config::get('session.use_keys')); Context::set('use_session_ssl', Rhymix\Framework\Config::get('session.use_ssl')); @@ -705,7 +706,7 @@ class adminAdminView extends admin } else { - $index_module_srl = 0; + $index_module_srl = ''; } Context::set('module_list', $module_list); Context::set('index_module_srl', $index_module_srl); From b2157d24215ce68c7fc16f07f40e83dbf3070417 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Mon, 13 Mar 2017 00:12:10 +0900 Subject: [PATCH 35/55] Move remainder of general config into advanced config screen, and replace general config screen with domain list --- modules/admin/admin.admin.controller.php | 73 +++----- modules/admin/admin.admin.view.php | 96 ++++------- modules/admin/conf/module.xml | 2 - modules/admin/lang/en.php | 2 +- modules/admin/lang/ko.php | 3 +- modules/admin/tpl/config_advanced.html | 66 ++++++++ modules/admin/tpl/config_general.html | 206 ----------------------- modules/admin/tpl/config_header.html | 3 +- 8 files changed, 121 insertions(+), 330 deletions(-) delete mode 100644 modules/admin/tpl/config_general.html diff --git a/modules/admin/admin.admin.controller.php b/modules/admin/admin.admin.controller.php index c21b00811..3eb7974a6 100644 --- a/modules/admin/admin.admin.controller.php +++ b/modules/admin/admin.admin.controller.php @@ -500,58 +500,6 @@ class adminAdminController extends admin $this->setMessage('success_deleted'); } - /** - * Update general configuration. - */ - function procAdminUpdateConfigGeneral() - { - $oModuleController = getController('module'); - $vars = Context::getRequestVars(); - - // Site title and HTML footer - $args = new stdClass; - $args->siteTitle = $vars->site_title; - $args->siteSubtitle = $vars->site_subtitle; - $args->htmlFooter = $vars->html_footer; - $oModuleController->updateModuleConfig('module', $args); - - // Index module - $domain_args = new stdClass(); - $domain_args->domain_srl = 0; - $domain_args->index_module_srl = $vars->index_module_srl; - executeQuery('module.updateDomain', $domain_args); - - // Default and enabled languages - $enabled_lang = $vars->enabled_lang; - if (!in_array($vars->default_lang, $enabled_lang)) - { - $enabled_lang[] = $vars->default_lang; - } - Rhymix\Framework\Config::set('locale.default_lang', $vars->default_lang); - Rhymix\Framework\Config::set('locale.enabled_lang', array_values($enabled_lang)); - Rhymix\Framework\Config::set('locale.auto_select_lang', $vars->auto_select_lang === 'Y'); - - // Default time zone - Rhymix\Framework\Config::set('locale.default_timezone', $vars->default_timezone); - - // Mobile view - Rhymix\Framework\Config::set('mobile.enabled', $vars->use_mobile_view === 'Y'); - Rhymix\Framework\Config::set('mobile.tablets', $vars->tablets_as_mobile === 'Y'); - if (Rhymix\Framework\Config::get('use_mobile_view') !== null) - { - Rhymix\Framework\Config::set('use_mobile_view', $vars->use_mobile_view === 'Y'); - } - - // Save - if (!Rhymix\Framework\Config::save()) - { - return new Object(-1, 'msg_failed_to_save_config'); - } - - $this->setMessage('success_updated'); - $this->setRedirectUrl(Context::get('success_return_url') ?: getNotEncodedUrl('', 'module', 'admin', 'act', 'dispAdminConfigGeneral')); - } - /** * Update notification configuration. */ @@ -783,6 +731,25 @@ class adminAdminController extends admin $oModuleController = getController('module'); $oModuleController->insertModuleConfig('document', $document_config); + // Mobile view + Rhymix\Framework\Config::set('mobile.enabled', $vars->use_mobile_view === 'Y'); + Rhymix\Framework\Config::set('mobile.tablets', $vars->tablets_as_mobile === 'Y'); + if (Rhymix\Framework\Config::get('use_mobile_view') !== null) + { + Rhymix\Framework\Config::set('use_mobile_view', $vars->use_mobile_view === 'Y'); + } + + // Languages and time zone + $enabled_lang = $vars->enabled_lang; + if (!in_array($vars->default_lang, $enabled_lang)) + { + $enabled_lang[] = $vars->default_lang; + } + Rhymix\Framework\Config::set('locale.default_lang', $vars->default_lang); + Rhymix\Framework\Config::set('locale.enabled_lang', array_values($enabled_lang)); + Rhymix\Framework\Config::set('locale.auto_select_lang', $vars->auto_select_lang === 'Y'); + Rhymix\Framework\Config::set('locale.default_timezone', $vars->default_timezone); + // Other settings Rhymix\Framework\Config::set('use_rewrite', $vars->use_rewrite === 'Y'); Rhymix\Framework\Config::set('use_sso', $vars->use_sso === 'Y'); @@ -1133,7 +1100,7 @@ class adminAdminController extends admin Rhymix\Framework\Cache::clearGroup('site_and_module'); // Redirect to the domain list. - $this->setRedirectUrl(Context::get('success_return_url') ?: getNotEncodedUrl('', 'module', 'admin', 'act', 'dispAdminConfigDomains')); + $this->setRedirectUrl(Context::get('success_return_url') ?: getNotEncodedUrl('', 'module', 'admin', 'act', 'dispAdminConfigGeneral')); } /** diff --git a/modules/admin/admin.admin.view.php b/modules/admin/admin.admin.view.php index c2a2fb65c..6f32d2353 100644 --- a/modules/admin/admin.admin.view.php +++ b/modules/admin/admin.admin.view.php @@ -407,42 +407,30 @@ class adminAdminView extends admin */ function dispAdminConfigGeneral() { - // Default and enabled languages - Context::set('supported_lang', Rhymix\Framework\Lang::getSupportedList()); - Context::set('default_lang', Rhymix\Framework\Config::get('locale.default_lang')); - Context::set('enabled_lang', Rhymix\Framework\Config::get('locale.enabled_lang')); - Context::set('auto_select_lang', Rhymix\Framework\Config::get('locale.auto_select_lang')); - - // Site title and HTML footer + // Get domain list. $oModuleModel = getModel('module'); - $config = $oModuleModel->getModuleConfig('module'); - Context::set('var_site_title', escape($config->siteTitle)); - Context::set('var_site_subtitle', escape($config->siteSubtitle)); - Context::set('all_html_footer', escape($config->htmlFooter)); + $page = intval(Context::get('page')) ?: 1; + $domain_list = $oModuleModel->getAllDomains(20, $page); + Context::set('domain_list', $domain_list); + Context::set('page_navigation', $domain_list->page_navigation); + Context::set('page', $page); - // Index module - $columnList = array('modules.mid', 'modules.browser_title', 'index_module_srl'); - $start_module = $oModuleModel->getSiteInfo(0, $columnList); - Context::set('start_module', $start_module); + // Get index module info. + $module_list = array(); + $oModuleModel = getModel('module'); + foreach ($domain_list->data as $domain) + { + if ($domain->index_module_srl && !isset($module_list[$domain->index_module_srl])) + { + $module_list[$domain->index_module_srl] = $oModuleModel->getModuleInfoByModuleSrl($domain->index_module_srl); + } + } + Context::set('module_list', $module_list); - // Default time zone - Context::set('timezones', Rhymix\Framework\DateTime::getTimezoneList()); - Context::set('selected_timezone', Rhymix\Framework\Config::get('locale.default_timezone')); + // Get language list. + Context::set('supported_lang', Rhymix\Framework\Lang::getSupportedList()); - // Mobile view - Context::set('use_mobile_view', (config('mobile.enabled') !== null ? config('mobile.enabled') : config('use_mobile_view')) ? true : false); - Context::set('tablets_as_mobile', config('mobile.tablets') ? true : false); - - // Favicon and mobicon and site default image - $oAdminModel = getAdminModel('admin'); - $favicon_url = $oAdminModel->getFaviconUrl(false) ?: $oAdminModel->getFaviconUrl(); - $mobicon_url = $oAdminModel->getMobileIconUrl(false) ?: $oAdminModel->getMobileIconUrl(); - $site_default_image_url = $oAdminModel->getSiteDefaultImageUrl(); - Context::set('favicon_url', $favicon_url); - Context::set('mobicon_url', $mobicon_url); - Context::set('site_default_image_url', $site_default_image_url); - - $this->setTemplateFile('config_general'); + $this->setTemplateFile('config_domains'); } /** @@ -554,8 +542,20 @@ class adminAdminView extends admin $config = $oDocumentModel->getDocumentConfig(); Context::set('thumbnail_type', $config->thumbnail_type ?: 'crop'); + // Default and enabled languages + Context::set('supported_lang', Rhymix\Framework\Lang::getSupportedList()); + Context::set('default_lang', Rhymix\Framework\Config::get('locale.default_lang')); + Context::set('enabled_lang', Rhymix\Framework\Config::get('locale.enabled_lang')); + Context::set('auto_select_lang', Rhymix\Framework\Config::get('locale.auto_select_lang')); + + // Default time zone + Context::set('timezones', Rhymix\Framework\DateTime::getTimezoneList()); + Context::set('selected_timezone', Rhymix\Framework\Config::get('locale.default_timezone')); + // Other settings Context::set('use_rewrite', Rhymix\Framework\Config::get('use_rewrite')); + Context::set('use_mobile_view', (config('mobile.enabled') !== null ? config('mobile.enabled') : config('use_mobile_view')) ? true : false); + Context::set('tablets_as_mobile', config('mobile.tablets') ? true : false); Context::set('use_sso', Rhymix\Framework\Config::get('use_sso')); Context::set('use_ssl', Rhymix\Framework\Config::get('url.ssl')); Context::set('delay_session', Rhymix\Framework\Config::get('session.delay')); @@ -570,38 +570,6 @@ class adminAdminView extends admin $this->setTemplateFile('config_advanced'); } - /** - * Display Debug Settings page - * @return void - */ - function dispAdminConfigDomains() - { - // Get domain list. - $oModuleModel = getModel('module'); - $page = intval(Context::get('page')) ?: 1; - $domain_list = $oModuleModel->getAllDomains(20, $page); - Context::set('domain_list', $domain_list); - Context::set('page_navigation', $domain_list->page_navigation); - Context::set('page', $page); - - // Get index module info. - $module_list = array(); - $oModuleModel = getModel('module'); - foreach ($domain_list->data as $domain) - { - if ($domain->index_module_srl && !isset($module_list[$domain->index_module_srl])) - { - $module_list[$domain->index_module_srl] = $oModuleModel->getModuleInfoByModuleSrl($domain->index_module_srl); - } - } - Context::set('module_list', $module_list); - - // Get language list. - Context::set('supported_lang', Rhymix\Framework\Lang::getSupportedList()); - - $this->setTemplateFile('config_domains'); - } - /** * Display Debug Settings page * @return void diff --git a/modules/admin/conf/module.xml b/modules/admin/conf/module.xml index b24cfd36e..6fdf3abd8 100644 --- a/modules/admin/conf/module.xml +++ b/modules/admin/conf/module.xml @@ -8,7 +8,6 @@ - @@ -26,7 +25,6 @@ - diff --git a/modules/admin/lang/en.php b/modules/admin/lang/en.php index f2b869766..4bf93d230 100644 --- a/modules/admin/lang/en.php +++ b/modules/admin/lang/en.php @@ -1,7 +1,7 @@ admin = 'Admin'; $lang->cmd_configure = 'Configure'; -$lang->subtitle_primary = 'General'; +$lang->subtitle_site_info = 'Site'; $lang->subtitle_notification = 'Notifications'; $lang->subtitle_security = 'Security'; $lang->subtitle_advanced = 'Advanced'; diff --git a/modules/admin/lang/ko.php b/modules/admin/lang/ko.php index abf4a3ba0..16db98af4 100644 --- a/modules/admin/lang/ko.php +++ b/modules/admin/lang/ko.php @@ -1,11 +1,10 @@ admin = '관리자'; $lang->cmd_configure = '설정하기'; -$lang->subtitle_primary = '기본 설정'; +$lang->subtitle_site_info = '사이트 설정'; $lang->subtitle_notification = '알림 설정'; $lang->subtitle_security = '보안 설정'; $lang->subtitle_advanced = '고급 설정'; -$lang->subtitle_domains = '도메인 설정'; $lang->subtitle_debug = '디버그 설정'; $lang->subtitle_seo = 'SEO 설정'; $lang->subtitle_etc = '기타'; diff --git a/modules/admin/tpl/config_advanced.html b/modules/admin/tpl/config_advanced.html index d488d01bb..906c63768 100644 --- a/modules/admin/tpl/config_advanced.html +++ b/modules/admin/tpl/config_advanced.html @@ -14,6 +14,72 @@ +
    + +
    + + +
    +
    +
    + +
    + + +
    +
    +
    + +
    + + +
    +

    {$lang->about_auto_select_lang}

    +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    diff --git a/modules/admin/tpl/config_general.html b/modules/admin/tpl/config_general.html deleted file mode 100644 index c04f61ec5..000000000 --- a/modules/admin/tpl/config_general.html +++ /dev/null @@ -1,206 +0,0 @@ - -
    -

    {$XE_VALIDATOR_MESSAGE}

    -
    -
    - - - - -
    - -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - - -
    -

    {$lang->about_auto_select_lang}

    -
    -
    -
    - -
    - -
    -
    -
    - -
    - - -
    -
    -
    - -
    - - -
    -
    -
    - -
    -

    - Favicon - Favicon -

    - -
    - - -

    - - -

    - - {$lang->about_use_favicon} -
    -
    -
    - -
    -

    - Mobile Home Icon - Rhymix -

    - -
    - - -

    - - -

    - - {$lang->detail_use_mobile_icon} -
    -
    -
    - -
    -

    - Default Image -

    - -
    - - -

    - - -

    - - {$lang->about_site_default_image} -
    -
    -
    -
    - -
    -
    -
    -
    - - - - diff --git a/modules/admin/tpl/config_header.html b/modules/admin/tpl/config_header.html index 14bf4679f..ee02b455c 100644 --- a/modules/admin/tpl/config_header.html +++ b/modules/admin/tpl/config_header.html @@ -4,11 +4,10 @@

    {$lang->menu_gnb_sub['adminConfigurationGeneral']} {$lang->help}

      -
    • {$lang->subtitle_primary}
    • +
    • {$lang->subtitle_site_info}
    • {$lang->subtitle_notification}
    • {$lang->subtitle_security}
    • {$lang->subtitle_advanced}
    • -
    • {$lang->subtitle_domains}
    • {$lang->subtitle_debug}
    • {$lang->subtitle_seo}
    • {$lang->subtitle_sitelock}
    • From 2af279d6c3427226b6a2ca60db9f19b4b0b89a9a Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Mon, 13 Mar 2017 00:34:53 +0900 Subject: [PATCH 36/55] Always redirect to SSL if the current domain always uses SSL --- classes/context/Context.class.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/classes/context/Context.class.php b/classes/context/Context.class.php index 522885688..e9dac4784 100644 --- a/classes/context/Context.class.php +++ b/classes/context/Context.class.php @@ -270,6 +270,15 @@ class Context { $site_module_info = new stdClass; } + + // Redirect to SSL if the current domain always uses SSL. + if ($site_module_info->security === 'always' && !RX_SSL) + { + $ssl_url = self::getDefaultUrl($site_module_info) . RX_REQUEST_URL; + self::setCacheControl(0); + header('Location: ' . $ssl_url, true, 301); + exit; + } // Load language support. $enabled_langs = self::loadLangSelected(); From c75704c1ce0cfb9ccf7fa16164ee3b156f96e101 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Mon, 13 Mar 2017 00:40:55 +0900 Subject: [PATCH 37/55] Add action for saving generic domain configuration --- modules/admin/admin.admin.controller.php | 9 +++++++++ modules/admin/conf/module.xml | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/modules/admin/admin.admin.controller.php b/modules/admin/admin.admin.controller.php index 3eb7974a6..3764fc0fc 100644 --- a/modules/admin/admin.admin.controller.php +++ b/modules/admin/admin.admin.controller.php @@ -500,6 +500,15 @@ class adminAdminController extends admin $this->setMessage('success_deleted'); } + /** + * Update domains configuration. + */ + function procAdminUpdateDomains() + { + $vars = Context::getRequestVars(); + + } + /** * Update notification configuration. */ diff --git a/modules/admin/conf/module.xml b/modules/admin/conf/module.xml index 6fdf3abd8..3e37647ff 100644 --- a/modules/admin/conf/module.xml +++ b/modules/admin/conf/module.xml @@ -25,10 +25,10 @@ + - From e8aca55074c51330635a83c019f461234e819c75 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Mon, 13 Mar 2017 11:16:45 +0900 Subject: [PATCH 38/55] Fix incorrect update of is_default_domain --- modules/admin/admin.admin.controller.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/admin/admin.admin.controller.php b/modules/admin/admin.admin.controller.php index 3764fc0fc..b67bef555 100644 --- a/modules/admin/admin.admin.controller.php +++ b/modules/admin/admin.admin.controller.php @@ -1045,6 +1045,7 @@ class adminAdminController extends admin $args = new stdClass(); $args->domain_srl = getNextSequence(); $args->domain = $vars->domain; + $args->is_default_domain = 'N'; $args->index_module_srl = $vars->index_module_srl; $args->index_document_srl = $vars->index_document_srl; $args->http_port = $vars->http_port; @@ -1063,7 +1064,6 @@ class adminAdminController extends admin $args = new stdClass(); $args->domain_srl = $domain_info->domain_srl; $args->domain = $vars->domain; - $args->is_default_domain = 'N'; $args->index_module_srl = $vars->index_module_srl; $args->index_document_srl = $vars->index_document_srl; $args->http_port = $vars->http_port; From beee2165fb5e3f604fa4a84e6ee8ff521475f2a9 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Mon, 13 Mar 2017 11:35:37 +0900 Subject: [PATCH 39/55] Update session class to use getDefaultDomainInfo() for SSO --- common/framework/session.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/framework/session.php b/common/framework/session.php index 5a6d206f1..b3643473c 100644 --- a/common/framework/session.php +++ b/common/framework/session.php @@ -287,7 +287,7 @@ class Session { $current_domain = $site_module_info->domain; $current_url = URL::getCurrentUrl(); - $default_domain = getModel('module')->getSiteInfo(0); + $default_domain = getModel('module')->getDefaultDomainInfo(); $default_url = \Context::getDefaultUrl($default_domain); } From bb11f2d000fcc38f017c115b4d8d6e4db34303d1 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Mon, 13 Mar 2017 11:35:58 +0900 Subject: [PATCH 40/55] Blacklist multidomain module and add missing explanations --- common/defaults/blacklist.php | 1 + modules/admin/lang/en.php | 2 ++ modules/admin/lang/ko.php | 2 ++ 3 files changed, 5 insertions(+) diff --git a/common/defaults/blacklist.php b/common/defaults/blacklist.php index e49e81ce2..a234750bf 100644 --- a/common/defaults/blacklist.php +++ b/common/defaults/blacklist.php @@ -12,6 +12,7 @@ return array( 'fix_mysql_utf8' => true, 'homepage' => true, 'member_communication' => true, + 'multidomain' => true, 'seo' => true, 'session_shield' => true, 'smartphone' => true, diff --git a/modules/admin/lang/en.php b/modules/admin/lang/en.php index 4bf93d230..a3eaf686d 100644 --- a/modules/admin/lang/en.php +++ b/modules/admin/lang/en.php @@ -71,7 +71,9 @@ $lang->msg_blacklisted_reason['autolang'] = 'Similar functionality can be config $lang->msg_blacklisted_reason['auto_login'] = 'The functionality that this module used to provide is included by default in Rhymix.'; $lang->msg_blacklisted_reason['errorlogger'] = 'Similar functionality can be configured in the Debug Settings page.'; $lang->msg_blacklisted_reason['fix_mysql_utf8'] = 'The functionality that this addon used to provide is included by default in Rhymix.'; +$lang->msg_blacklisted_reason['homepage'] = 'The functionality that this module used to provide must be reimplemented using the multidomain feature of Rhymix.'; $lang->msg_blacklisted_reason['member_communication'] = 'The functionality that this addon used to provide has been moved to the member and ncenterlite modules.'; +$lang->msg_blacklisted_reason['multidomain'] = 'The functionality that this module used to provide is included by default in Rhymix.'; $lang->msg_blacklisted_reason['seo'] = 'Similar functionality can be configured in the SEO Settings page.'; $lang->msg_blacklisted_reason['session_shield'] = 'The functionality that this addon used to provide is included by default in Rhymix.'; $lang->msg_blacklisted_reason['smartphone'] = 'This module was disabled in XE long before Rhymix even existed.'; diff --git a/modules/admin/lang/ko.php b/modules/admin/lang/ko.php index 16db98af4..85d73a44f 100644 --- a/modules/admin/lang/ko.php +++ b/modules/admin/lang/ko.php @@ -70,7 +70,9 @@ $lang->msg_blacklisted_reason['autolang'] = '이 애드온에서 제공하던 $lang->msg_blacklisted_reason['auto_login'] = '이 모듈에서 제공하던 기능은 Rhymix에 포함되어 있습니다.'; $lang->msg_blacklisted_reason['errorlogger'] = '이 모듈에서 제공하던 기능은 디버그 설정 페이지에서 관리할 수 있습니다.'; $lang->msg_blacklisted_reason['fix_mysql_utf8'] = '이 애드온에서 제공하던 기능은 Rhymix에 포함되어 있습니다.'; +$lang->msg_blacklisted_reason['homepage'] = '이 모듈에서 제공하던 기능은 Rhymix에 포함된 멀티도메인 기능으로 대체하여야 합니다.'; $lang->msg_blacklisted_reason['member_communication'] = '이 애드온에서 제공하던 기능은 알림센터 모듈에서 관리할 수 있습니다.'; +$lang->msg_blacklisted_reason['multidomain'] = '이 모듈에서 제공하던 기능은 Rhymix에 포함되어 있습니다.'; $lang->msg_blacklisted_reason['seo'] = '이 모듈에서 제공하던 기능은 SEO 설정 페이지에서 관리할 수 있습니다.'; $lang->msg_blacklisted_reason['session_shield'] = '이 애드온에서 제공하던 기능은 Rhymix에 포함되어 있습니다.'; $lang->msg_blacklisted_reason['smartphone'] = '이 모듈은 XE에서도 사용되지 않고 있었습니다.'; From ce895ff640881eef9f38e658fabf8c8920e22fa9 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Mon, 13 Mar 2017 12:42:18 +0900 Subject: [PATCH 41/55] Implement index document functionality --- classes/module/ModuleHandler.class.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/classes/module/ModuleHandler.class.php b/classes/module/ModuleHandler.class.php index 0c2c7cd5c..7735b195a 100644 --- a/classes/module/ModuleHandler.class.php +++ b/classes/module/ModuleHandler.class.php @@ -251,8 +251,14 @@ class ModuleHandler extends Handler $module_info = $site_module_info; } + // Set index document + if($site_module_info->index_document_srl && !$this->module && !$this->mid && !$this->document_srl && Context::getRequestMethod() === 'GET' && !count($_GET)) + { + Context::set('document_srl', $this->document_srl = $site_module_info->index_document_srl, true); + } + // redirect, if site start module - if(Context::getRequestMethod() === 'GET' && isset($_GET['mid']) && $_GET['mid'] === $site_module_info->mid && count($_GET) === 1) + if(!$site_module_info->index_document_srl && Context::getRequestMethod() === 'GET' && isset($_GET['mid']) && $_GET['mid'] === $site_module_info->mid && count($_GET) === 1) { Context::setCacheControl(0); header('location: ' . getNotEncodedSiteUrl($site_module_info->domain), true, 301); From a984665efc77c51e19d995df253d8cfd007c053e Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Mon, 13 Mar 2017 12:51:24 +0900 Subject: [PATCH 42/55] Implement default timezone for domains --- classes/context/Context.class.php | 1 + common/framework/datetime.php | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/classes/context/Context.class.php b/classes/context/Context.class.php index e9dac4784..65269f697 100644 --- a/classes/context/Context.class.php +++ b/classes/context/Context.class.php @@ -261,6 +261,7 @@ class Context $oModuleModel = getModel('module'); $site_module_info = $oModuleModel->getDefaultMid() ?: new stdClass; self::set('site_module_info', $site_module_info); + self::set('_default_timezone', ($site_module_info->settings && $site_module_info->settings->timezone) ? $site_module_info->settings->timezone : null); self::set('_default_url', self::$_instance->db_info->default_url = self::getDefaultUrl($site_module_info)); self::set('_http_port', self::$_instance->db_info->http_port = $site_module_info->http_port ?: null); self::set('_https_port', self::$_instance->db_info->https_port = $site_module_info->https_port ?: null); diff --git a/common/framework/datetime.php b/common/framework/datetime.php index 66511d2ba..c4df3a7ea 100644 --- a/common/framework/datetime.php +++ b/common/framework/datetime.php @@ -66,6 +66,10 @@ class DateTime { return $_SESSION['RHYMIX']['timezone']; } + elseif ($default = \Context::get('_default_timezone')) + { + return $default; + } elseif ($default = Config::get('locale.default_timezone')) { return $default; From 9cea95092205abfe710e28efc2729acdd8afb3d0 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Mon, 13 Mar 2017 13:05:11 +0900 Subject: [PATCH 43/55] Implement mechanism to update the default domain --- modules/admin/admin.admin.controller.php | 30 ++++++++++++++++++---- modules/admin/lang/en.php | 1 + modules/admin/lang/ko.php | 3 ++- modules/admin/tpl/config_domains_edit.html | 4 +++ 4 files changed, 32 insertions(+), 6 deletions(-) diff --git a/modules/admin/admin.admin.controller.php b/modules/admin/admin.admin.controller.php index b67bef555..cbaa546db 100644 --- a/modules/admin/admin.admin.controller.php +++ b/modules/admin/admin.admin.controller.php @@ -1039,13 +1039,17 @@ class adminAdminController extends admin 'html_footer' => $vars->html_footer, ); + // Get the DB object and begin a transaction. + $oDB = DB::getInstance(); + $oDB->begin(); + // Insert or update the domain. if (!$domain_info) { $args = new stdClass(); - $args->domain_srl = getNextSequence(); + $args->domain_srl = $domain_srl = getNextSequence(); $args->domain = $vars->domain; - $args->is_default_domain = 'N'; + $args->is_default_domain = $vars->is_default_domain === 'Y' ? 'Y' : 'N'; $args->index_module_srl = $vars->index_module_srl; $args->index_document_srl = $vars->index_document_srl; $args->http_port = $vars->http_port; @@ -1064,6 +1068,7 @@ class adminAdminController extends admin $args = new stdClass(); $args->domain_srl = $domain_info->domain_srl; $args->domain = $vars->domain; + $args->is_default_domain = $vars->is_default_domain === 'Y' ? 'Y' : 'N'; $args->index_module_srl = $vars->index_module_srl; $args->index_document_srl = $vars->index_document_srl; $args->http_port = $vars->http_port; @@ -1077,18 +1082,30 @@ class adminAdminController extends admin } } + // If changing the default domain, set all other domains as non-default. + if ($vars->is_default_domain === 'Y') + { + $args = new stdClass(); + $args->not_domain_srl = $domain_srl; + $output = executeQuery('module.updateDefaultDomain', $args); + if (!$output->toBool()) + { + return $output; + } + } + // Save the favicon, mobicon, and default image. if ($vars->favicon || $vars->delete_favicon) { - $this->_saveFavicon($args->domain_srl, $vars->favicon, 'favicon.ico', $vars->delete_favicon); + $this->_saveFavicon($domain_srl, $vars->favicon, 'favicon.ico', $vars->delete_favicon); } if ($vars->mobicon || $vars->delete_mobicon) { - $this->_saveFavicon($args->domain_srl, $vars->mobicon, 'mobicon.png', $vars->delete_mobicon); + $this->_saveFavicon($domain_srl, $vars->mobicon, 'mobicon.png', $vars->delete_mobicon); } if ($vars->default_image || $vars->delete_default_image) { - $this->_saveDefaultImage($args->domain_srl, $vars->default_image, $vars->delete_default_image); + $this->_saveDefaultImage($domain_srl, $vars->default_image, $vars->delete_default_image); } // Update system configuration to match the default domain. @@ -1105,6 +1122,9 @@ class adminAdminController extends admin Rhymix\Framework\Config::save(); } + // Commit. + $oDB->commit(); + // Clear cache. Rhymix\Framework\Cache::clearGroup('site_and_module'); diff --git a/modules/admin/lang/en.php b/modules/admin/lang/en.php index a3eaf686d..c6a8a6ef3 100644 --- a/modules/admin/lang/en.php +++ b/modules/admin/lang/en.php @@ -118,6 +118,7 @@ $lang->cmd_index_document_srl = 'Main Document'; $lang->cmd_default_language = 'Default Language'; $lang->cmd_new_domain = 'Add New Domain'; $lang->cmd_edit_domain = 'Edit Domain'; +$lang->cmd_is_default_domain = 'Default Domain'; $lang->about_use_ssl = 'Selecting \'Optional\' is to use SSL for the specified actions such as signing up and changing information.
      Selecting \'Always\' is to use SSL for the entire pages, generated by Rhymix.
      Please be careful! You may not be able to access to the site, before installing SSL certificate.'; $lang->server_ports = 'Server Port'; $lang->about_server_ports = 'If your web server does not use 80 for HTTP or 443 for HTTPS port, you should specify server ports.'; diff --git a/modules/admin/lang/ko.php b/modules/admin/lang/ko.php index 85d73a44f..a02342c28 100644 --- a/modules/admin/lang/ko.php +++ b/modules/admin/lang/ko.php @@ -117,10 +117,11 @@ $lang->cmd_index_document_srl = '메인 문서'; $lang->cmd_default_language = '기본 언어'; $lang->cmd_new_domain = '새 도메인 추가'; $lang->cmd_edit_domain = '도메인 정보 수정'; +$lang->cmd_is_default_domain = '기본 도메인'; $lang->about_use_ssl = '\'선택적으로 사용\'은 회원가입, 정보수정 등의 지정된 동작(action)에서만 보안접속(HTTPS)을 사용합니다.
      \'항상 사용\'은 사이트 전체에 HTTPS를 사용합니다.
      SSL 인증서가 설치되지 않은 상태에서 HTTPS 사용을 시도하면 접속이 되지 않을 수 있으니 주의하시기 바랍니다.'; $lang->server_ports = '포트'; $lang->about_server_ports = 'HTTP는 80, HTTPS는 443 이 아닌, 다른 포트를 사용할 경우에 포트를 지정해 주어야 합니다.'; -$lang->msg_site_title_is_empty = '사이트 이름을 입력해 주십시오.'; +$lang->msg_site_title_is_empty = '사이트 제목을 입력해 주십시오.'; $lang->msg_invalid_domain = '올바르지 않은 도메인입니다.'; $lang->msg_domain_already_exists = '이미 등록된 도메인입니다.'; $lang->msg_invalid_http_port = '올바르지 않은 HTTP 포트입니다.'; diff --git a/modules/admin/tpl/config_domains_edit.html b/modules/admin/tpl/config_domains_edit.html index 1c882208a..889025d49 100644 --- a/modules/admin/tpl/config_domains_edit.html +++ b/modules/admin/tpl/config_domains_edit.html @@ -27,6 +27,10 @@
      +   +
    From eec75ba3726fc24066d466bd8b4a76b225049602 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Mon, 13 Mar 2017 13:18:55 +0900 Subject: [PATCH 44/55] Miscellaneous fixes --- modules/admin/admin.admin.controller.php | 4 ++++ modules/admin/lang/en.php | 1 + modules/admin/lang/ko.php | 1 + modules/admin/tpl/config_domains.html | 15 +++++++-------- modules/module/queries/updateDefaultDomain.xml | 12 ++++++++++++ 5 files changed, 25 insertions(+), 8 deletions(-) create mode 100644 modules/module/queries/updateDefaultDomain.xml diff --git a/modules/admin/admin.admin.controller.php b/modules/admin/admin.admin.controller.php index cbaa546db..6506ae67f 100644 --- a/modules/admin/admin.admin.controller.php +++ b/modules/admin/admin.admin.controller.php @@ -1007,6 +1007,10 @@ class adminAdminController extends admin { return new Object(-1, 'msg_invalid_index_document_srl'); } + if (intval($oDocument->get('module_srl')) !== intval($vars->index_module_srl)) + { + return new Object(-1, 'msg_invalid_index_document_srl_module_srl'); + } } else { diff --git a/modules/admin/lang/en.php b/modules/admin/lang/en.php index c6a8a6ef3..ae343c9fd 100644 --- a/modules/admin/lang/en.php +++ b/modules/admin/lang/en.php @@ -129,6 +129,7 @@ $lang->msg_invalid_http_port = 'Invalid HTTP port.'; $lang->msg_invalid_https_port = 'Invalid HTTPS port.'; $lang->msg_invalid_index_module_srl = 'The main module does not exist.'; $lang->msg_invalid_index_document_srl = 'The main document number does not exist.'; +$lang->msg_invalid_index_document_srl_module_srl = 'The main module does not match the main document number.'; $lang->msg_lang_is_not_enabled = 'The language you selected is not enabled in this site.'; $lang->msg_invalid_timezone = 'The selected time zone is not usable on this server.'; $lang->use_db_session = 'Store Session in DB'; diff --git a/modules/admin/lang/ko.php b/modules/admin/lang/ko.php index a02342c28..2b98c228c 100644 --- a/modules/admin/lang/ko.php +++ b/modules/admin/lang/ko.php @@ -128,6 +128,7 @@ $lang->msg_invalid_http_port = '올바르지 않은 HTTP 포트입니다.'; $lang->msg_invalid_https_port = '올바르지 않은 HTTPS 포트입니다.'; $lang->msg_invalid_index_module_srl = '선택하신 메인 모듈이 존재하지 않습니다.'; $lang->msg_invalid_index_document_srl = '선택하신 메인 문서 번호가 존재하지 않습니다.'; +$lang->msg_invalid_index_document_srl_module_srl = '선택하신 메인 모듈과 메인 문서 번호가 일치하지 않습니다.'; $lang->msg_lang_is_not_enabled = '선택하신 언어가 활성화되어 있지 않습니다.'; $lang->msg_invalid_timezone = '사용할 수 없는 표준 시간대입니다.'; $lang->use_db_session = '인증 세션 DB 사용'; diff --git a/modules/admin/tpl/config_domains.html b/modules/admin/tpl/config_domains.html index ea85b6dba..f4a792a0d 100644 --- a/modules/admin/tpl/config_domains.html +++ b/modules/admin/tpl/config_domains.html @@ -7,32 +7,31 @@
    + - - - + - - - + -
    {$lang->site_title} {$lang->domain}{$lang->cmd_http_port}{$lang->cmd_https_port} {$lang->use_ssl} {$lang->cmd_index_module_srl} {$lang->cmd_index_document_srl}{$lang->cmd_default_language} {$lang->cmd_modify} / {$lang->cmd_delete}
    + {$domain->settings->title} + {$lang->cmd_is_default_domain} + {$domain->domain}{$domain->http_port ?: ''}{$domain->https_port ?: ''}{$lang->ssl_options[$domain->security ?: 'none']}{preg_replace('/\\(.+$/', '', $lang->ssl_options[$domain->security ?: 'none'])} {($domain->index_module_srl && $module_list[$domain->index_module_srl]) ? $module_list[$domain->index_module_srl]->browser_title : ''} - + {$domain->index_document_srl ?: ''} {$domain->settings->language ? $supported_lang[$domain->settings->language]['name'] : $supported_lang[config('locale.default_lang')]['name']} {$lang->cmd_modify} / diff --git a/modules/module/queries/updateDefaultDomain.xml b/modules/module/queries/updateDefaultDomain.xml new file mode 100644 index 000000000..0b814dee1 --- /dev/null +++ b/modules/module/queries/updateDefaultDomain.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file From 51d0aa5e5e1b14a5d4617ed9306bbac49280715e Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Mon, 13 Mar 2017 13:46:49 +0900 Subject: [PATCH 45/55] Do not redirect to SSL when invoked on the CLI --- classes/context/Context.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/context/Context.class.php b/classes/context/Context.class.php index 65269f697..2fc96c340 100644 --- a/classes/context/Context.class.php +++ b/classes/context/Context.class.php @@ -273,7 +273,7 @@ class Context } // Redirect to SSL if the current domain always uses SSL. - if ($site_module_info->security === 'always' && !RX_SSL) + if ($site_module_info->security === 'always' && !RX_SSL && PHP_SAPI !== 'cli') { $ssl_url = self::getDefaultUrl($site_module_info) . RX_REQUEST_URL; self::setCacheControl(0); From 79f29b33720c3b1b10898ccbfbfb441c11fe9f96 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Mon, 13 Mar 2017 13:47:07 +0900 Subject: [PATCH 46/55] Implement multidomain settings --- common/defaults/config.php | 1 + modules/admin/admin.admin.controller.php | 18 +++++++++++++- modules/admin/admin.admin.view.php | 1 - modules/admin/lang/en.php | 8 +++++- modules/admin/lang/ko.php | 8 +++++- modules/admin/tpl/config_advanced.html | 9 ------- modules/admin/tpl/config_domains.html | 31 ++++++++++++++++++++++++ 7 files changed, 63 insertions(+), 13 deletions(-) diff --git a/common/defaults/config.php b/common/defaults/config.php index 684824a7b..8a9f620ef 100644 --- a/common/defaults/config.php +++ b/common/defaults/config.php @@ -44,6 +44,7 @@ return array( ), 'url' => array( 'default' => null, + 'unregistered_domain_action' => 'redirect_301', 'http_port' => null, 'https_port' => null, 'ssl' => 'none', diff --git a/modules/admin/admin.admin.controller.php b/modules/admin/admin.admin.controller.php index 6506ae67f..cad2d977c 100644 --- a/modules/admin/admin.admin.controller.php +++ b/modules/admin/admin.admin.controller.php @@ -507,6 +507,23 @@ class adminAdminController extends admin { $vars = Context::getRequestVars(); + // Validate the unregistered domain action. + $valid_actions = array('redirect_301', 'redirect_302', 'display', 'block'); + if (!in_array($vars->unregistered_domain_action, $valid_actions)) + { + $vars->unregistered_domain_action = 'redirect_301'; + } + + // Save system config. + Rhymix\Framework\Config::set('url.unregistered_domain_action', $vars->unregistered_domain_action); + Rhymix\Framework\Config::set('use_sso', $vars->use_sso === 'Y'); + if (!Rhymix\Framework\Config::save()) + { + return new Object(-1, 'msg_failed_to_save_config'); + } + + $this->setMessage('success_updated'); + $this->setRedirectUrl(Context::get('success_return_url') ?: getNotEncodedUrl('', 'module', 'admin', 'act', 'dispAdminConfigGeneral')); } /** @@ -761,7 +778,6 @@ class adminAdminController extends admin // Other settings Rhymix\Framework\Config::set('use_rewrite', $vars->use_rewrite === 'Y'); - Rhymix\Framework\Config::set('use_sso', $vars->use_sso === 'Y'); Rhymix\Framework\Config::set('session.delay', $vars->delay_session === 'Y'); Rhymix\Framework\Config::set('session.use_db', $vars->use_db_session === 'Y'); Rhymix\Framework\Config::set('session.use_keys', $vars->use_session_keys === 'Y'); diff --git a/modules/admin/admin.admin.view.php b/modules/admin/admin.admin.view.php index 6f32d2353..ceaebc594 100644 --- a/modules/admin/admin.admin.view.php +++ b/modules/admin/admin.admin.view.php @@ -556,7 +556,6 @@ class adminAdminView extends admin Context::set('use_rewrite', Rhymix\Framework\Config::get('use_rewrite')); Context::set('use_mobile_view', (config('mobile.enabled') !== null ? config('mobile.enabled') : config('use_mobile_view')) ? true : false); Context::set('tablets_as_mobile', config('mobile.tablets') ? true : false); - Context::set('use_sso', Rhymix\Framework\Config::get('use_sso')); Context::set('use_ssl', Rhymix\Framework\Config::get('url.ssl')); Context::set('delay_session', Rhymix\Framework\Config::get('session.delay')); Context::set('use_session_keys', Rhymix\Framework\Config::get('session.use_keys')); diff --git a/modules/admin/lang/en.php b/modules/admin/lang/en.php index ae343c9fd..86c92adca 100644 --- a/modules/admin/lang/en.php +++ b/modules/admin/lang/en.php @@ -119,6 +119,12 @@ $lang->cmd_default_language = 'Default Language'; $lang->cmd_new_domain = 'Add New Domain'; $lang->cmd_edit_domain = 'Edit Domain'; $lang->cmd_is_default_domain = 'Default Domain'; +$lang->cmd_multidomain_configuration = 'Multidomain Configuration'; +$lang->cmd_unregistered_domain_action = 'Unregistered Domains'; +$lang->cmd_unregistered_domain_redirect_301 = '301 Redirect to Default Domain (Recommended)'; +$lang->cmd_unregistered_domain_redirect_302 = '302 Redirect to Default Domain'; +$lang->cmd_unregistered_domain_display = 'Display Main Screen as Usual'; +$lang->cmd_unregistered_domain_block = '404 Not Found'; $lang->about_use_ssl = 'Selecting \'Optional\' is to use SSL for the specified actions such as signing up and changing information.
    Selecting \'Always\' is to use SSL for the entire pages, generated by Rhymix.
    Please be careful! You may not be able to access to the site, before installing SSL certificate.'; $lang->server_ports = 'Server Port'; $lang->about_server_ports = 'If your web server does not use 80 for HTTP or 443 for HTTPS port, you should specify server ports.'; @@ -258,7 +264,7 @@ $lang->detail_use_mobile_icon = 'The mobile icon should be 57x57 or 114x114, onl $lang->cmd_site_default_image = 'Default Image'; $lang->about_site_default_image = 'This image will be shown when your site is linked to in various social networks. It should be 200x200, either jpg or png format.'; $lang->use_sso = 'Use SSO?'; -$lang->about_use_sso = 'If your site uses multiple domains, logging into one domain will automatically log the user into all domains.'; +$lang->about_use_sso = 'Logging into one domain will automatically log the user into all domains.'; $lang->about_arrange_session = 'Do you want to clean up session?'; $lang->cmd_clear_session = 'Clean up session'; $lang->save = 'Save'; diff --git a/modules/admin/lang/ko.php b/modules/admin/lang/ko.php index 2b98c228c..46f020d02 100644 --- a/modules/admin/lang/ko.php +++ b/modules/admin/lang/ko.php @@ -118,6 +118,12 @@ $lang->cmd_default_language = '기본 언어'; $lang->cmd_new_domain = '새 도메인 추가'; $lang->cmd_edit_domain = '도메인 정보 수정'; $lang->cmd_is_default_domain = '기본 도메인'; +$lang->cmd_multidomain_configuration = '멀티도메인 기능 설정'; +$lang->cmd_unregistered_domain_action = '등록되지 않은 도메인 처리'; +$lang->cmd_unregistered_domain_redirect_301 = '기본 도메인으로 301 Redirect (권장)'; +$lang->cmd_unregistered_domain_redirect_302 = '기본 도메인으로 302 Redirect'; +$lang->cmd_unregistered_domain_display = '메인 화면 표시'; +$lang->cmd_unregistered_domain_block = '404 Not Found 오류 표시'; $lang->about_use_ssl = '\'선택적으로 사용\'은 회원가입, 정보수정 등의 지정된 동작(action)에서만 보안접속(HTTPS)을 사용합니다.
    \'항상 사용\'은 사이트 전체에 HTTPS를 사용합니다.
    SSL 인증서가 설치되지 않은 상태에서 HTTPS 사용을 시도하면 접속이 되지 않을 수 있으니 주의하시기 바랍니다.'; $lang->server_ports = '포트'; $lang->about_server_ports = 'HTTP는 80, HTTPS는 443 이 아닌, 다른 포트를 사용할 경우에 포트를 지정해 주어야 합니다.'; @@ -252,7 +258,7 @@ $lang->detail_use_mobile_icon = '57x57 또는 114x114 크기의 png 파일을 $lang->cmd_site_default_image = '사이트 대표 이미지'; $lang->about_site_default_image = 'SNS 등에 이 사이트가 링크되었을 때 표시되는 이미지입니다. 200x200 크기의 jpg 또는 png 파일을 권장합니다.'; $lang->use_sso = 'SSO 사용'; -$lang->about_use_sso = '여러 도메인을 사용하는 사이트에서 한 번만 로그인하면 모든 도메인에 로그인되도록 합니다.'; +$lang->about_use_sso = '한 번만 로그인하면 모든 도메인에 로그인되도록 합니다.'; $lang->about_arrange_session = '세션을 정리하시겠습니까?'; $lang->cmd_clear_session = '세션 정리'; $lang->save = '저장'; diff --git a/modules/admin/tpl/config_advanced.html b/modules/admin/tpl/config_advanced.html index 906c63768..62b5b58a3 100644 --- a/modules/admin/tpl/config_advanced.html +++ b/modules/admin/tpl/config_advanced.html @@ -116,15 +116,6 @@

    {$lang->about_use_session_ssl}

    -
    - -
    - - -
    -

    {$lang->about_use_sso}

    -
    -
    diff --git a/modules/admin/tpl/config_domains.html b/modules/admin/tpl/config_domains.html index f4a792a0d..a7b3ffb19 100644 --- a/modules/admin/tpl/config_domains.html +++ b/modules/admin/tpl/config_domains.html @@ -60,10 +60,41 @@
    +

    {$lang->cmd_multidomain_configuration}

    +
    + +
    + + + + +
    +
    +
    + +
    + + +
    +

    {$lang->about_use_sso}

    +
    +
    From 2e3e96976714c40d1f942ec52438153da462a80b Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Mon, 13 Mar 2017 14:07:18 +0900 Subject: [PATCH 47/55] Implement redirect to default domain if unregistered domain is requested --- classes/context/Context.class.php | 2 +- classes/module/ModuleHandler.class.php | 26 ++++++++++++++++++++++++++ modules/module/module.model.php | 1 + 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/classes/context/Context.class.php b/classes/context/Context.class.php index 2fc96c340..e258575d8 100644 --- a/classes/context/Context.class.php +++ b/classes/context/Context.class.php @@ -273,7 +273,7 @@ class Context } // Redirect to SSL if the current domain always uses SSL. - if ($site_module_info->security === 'always' && !RX_SSL && PHP_SAPI !== 'cli') + if ($site_module_info->security === 'always' && !RX_SSL && PHP_SAPI !== 'cli' && !$site_module_info->is_default_replaced) { $ssl_url = self::getDefaultUrl($site_module_info) . RX_REQUEST_URL; self::setCacheControl(0); diff --git a/classes/module/ModuleHandler.class.php b/classes/module/ModuleHandler.class.php index 7735b195a..998d5dfaf 100644 --- a/classes/module/ModuleHandler.class.php +++ b/classes/module/ModuleHandler.class.php @@ -126,6 +126,31 @@ class ModuleHandler extends Handler { $oModuleModel = getModel('module'); $site_module_info = Context::get('site_module_info'); + + // Check unregistered domain action. + if (!$site_module_info || !isset($site_module_info->domain_srl) || $site_module_info->is_default_replaced) + { + $site_module_info = getModel('module')->getDefaultDomainInfo(); + $domain_action = config('url.unregistered_domain_action') ?: 'redirect_301'; + switch ($domain_action) + { + case 'redirect_301': + header('Location: ' . Context::getDefaultUrl($site_module_info) . RX_REQUEST_URL, true, 301); + return false; + + case 'redirect_302': + header('Location: ' . Context::getDefaultUrl($site_module_info) . RX_REQUEST_URL, true, 302); + return false; + + case 'block': + $this->error = 'The site does not exist'; + $this->httpStatusCode = 404; + return true; + + case 'display': + // pass + } + } // if success_return_url and error_return_url is incorrect $urls = array(Context::get('success_return_url'), Context::get('error_return_url')); @@ -155,6 +180,7 @@ class ModuleHandler extends Handler } } + // Convert document alias (entry) to document_srl if(!$this->document_srl && $this->mid && $this->entry) { $oDocumentModel = getModel('document'); diff --git a/modules/module/module.model.php b/modules/module/module.model.php index 77e16ebba..06dc31590 100644 --- a/modules/module/module.model.php +++ b/modules/module/module.model.php @@ -190,6 +190,7 @@ class moduleModel extends module { $domain_info = $this->migrateDomains(); } + $domain_info->is_default_replaced = true; } // Fill in module extra vars and return. From 139bb8ac84604af12bcd0240f9ec0699b61109e3 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Mon, 13 Mar 2017 14:14:59 +0900 Subject: [PATCH 48/55] Fix installation error --- classes/module/ModuleHandler.class.php | 35 ++++++++++++++------------ 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/classes/module/ModuleHandler.class.php b/classes/module/ModuleHandler.class.php index 998d5dfaf..8d2e2be0a 100644 --- a/classes/module/ModuleHandler.class.php +++ b/classes/module/ModuleHandler.class.php @@ -131,24 +131,27 @@ class ModuleHandler extends Handler if (!$site_module_info || !isset($site_module_info->domain_srl) || $site_module_info->is_default_replaced) { $site_module_info = getModel('module')->getDefaultDomainInfo(); - $domain_action = config('url.unregistered_domain_action') ?: 'redirect_301'; - switch ($domain_action) + if ($site_module_info) { - case 'redirect_301': - header('Location: ' . Context::getDefaultUrl($site_module_info) . RX_REQUEST_URL, true, 301); - return false; + $domain_action = config('url.unregistered_domain_action') ?: 'redirect_301'; + switch ($domain_action) + { + case 'redirect_301': + header('Location: ' . Context::getDefaultUrl($site_module_info) . RX_REQUEST_URL, true, 301); + return false; + + case 'redirect_302': + header('Location: ' . Context::getDefaultUrl($site_module_info) . RX_REQUEST_URL, true, 302); + return false; - case 'redirect_302': - header('Location: ' . Context::getDefaultUrl($site_module_info) . RX_REQUEST_URL, true, 302); - return false; - - case 'block': - $this->error = 'The site does not exist'; - $this->httpStatusCode = 404; - return true; - - case 'display': - // pass + case 'block': + $this->error = 'The site does not exist'; + $this->httpStatusCode = 404; + return true; + + case 'display': + // pass + } } } From e27e0f275a463d76e7176982e5e89d00d4d6ec88 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Mon, 13 Mar 2017 14:17:51 +0900 Subject: [PATCH 49/55] Some cleanup of getUrl() routine --- classes/context/Context.class.php | 39 ++++++++++++++++--------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/classes/context/Context.class.php b/classes/context/Context.class.php index e258575d8..19909b0d7 100644 --- a/classes/context/Context.class.php +++ b/classes/context/Context.class.php @@ -1550,28 +1550,33 @@ class Context { static $site_module_info = null; static $current_info = null; - - // retrieve virtual site information - if(is_null($site_module_info)) + if ($site_module_info === null) { $site_module_info = self::get('site_module_info'); } + if ($current_info === null) + { + $current_info = Rhymix\Framework\URL::getCurrentDomainURL(RX_BASEURL); + } // If $domain is set, handle it (if $domain is vid type, remove $domain and handle with $vid) - if ($domain && strpos($domain, '/') !== false) + if ($domain) { - $domain = Rhymix\Framework\URL::getDomainFromURL($domain); + if (strpos($domain, '/') !== false) + { + $domain = Rhymix\Framework\URL::getDomainFromURL($domain); + } + if (strpos($domain, 'xn--') !== false) + { + $domain = Rhymix\Framework\URL::decodeIdna($domain); + } + if (isSiteID($domain)) + { + $vid = $domain; + $domain = ''; + } } - if ($domain && strpos($domain, 'xn--') !== false) - { - $domain = Rhymix\Framework\URL::decodeIdna($domain); - } - if ($domain && isSiteID($domain)) - { - $vid = $domain; - $domain = ''; - } - + // If $domain, $vid are not set, use current site information if(!$domain && !$vid) { @@ -1588,10 +1593,6 @@ class Context // if $domain is set, compare current URL. If they are same, remove the domain, otherwise link to the domain. if($domain) { - if(is_null($current_info)) - { - $current_info = parse_url((RX_SSL ? 'https' : 'http') . '://' . Rhymix\Framework\URL::decodeIdna($_SERVER['HTTP_HOST']) . RX_BASEURL); - } if($domain === $current_info['host']) { unset($domain); From e8bb0cf0293cb57e3d29517fa7f3819b2bcd3e7b Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Mon, 13 Mar 2017 14:21:16 +0900 Subject: [PATCH 50/55] Fix missing parse_url --- classes/context/Context.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/context/Context.class.php b/classes/context/Context.class.php index 19909b0d7..22721d691 100644 --- a/classes/context/Context.class.php +++ b/classes/context/Context.class.php @@ -1556,7 +1556,7 @@ class Context } if ($current_info === null) { - $current_info = Rhymix\Framework\URL::getCurrentDomainURL(RX_BASEURL); + $current_info = parse_url(Rhymix\Framework\URL::getCurrentDomainURL(RX_BASEURL)); } // If $domain is set, handle it (if $domain is vid type, remove $domain and handle with $vid) From 0184021e73dc44f237b410df7540c0147a37639b Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Mon, 13 Mar 2017 14:50:29 +0900 Subject: [PATCH 51/55] Remove 'vid' from URL handling and clean up the remainder --- classes/context/Context.class.php | 81 ++++++-------------------- classes/module/ModuleHandler.class.php | 9 --- 2 files changed, 19 insertions(+), 71 deletions(-) diff --git a/classes/context/Context.class.php b/classes/context/Context.class.php index 22721d691..b1e2658c3 100644 --- a/classes/context/Context.class.php +++ b/classes/context/Context.class.php @@ -1548,18 +1548,18 @@ class Context */ public static function getUrl($num_args = 0, $args_list = array(), $domain = null, $encode = TRUE, $autoEncode = FALSE) { + static $current_domain = null; static $site_module_info = null; - static $current_info = null; if ($site_module_info === null) { $site_module_info = self::get('site_module_info'); } - if ($current_info === null) + if ($current_domain === null) { - $current_info = parse_url(Rhymix\Framework\URL::getCurrentDomainURL(RX_BASEURL)); + $current_domain = parse_url(Rhymix\Framework\URL::getCurrentDomainURL(), PHP_URL_HOST); } - // If $domain is set, handle it (if $domain is vid type, remove $domain and handle with $vid) + // Find the canonical form of the domain. if ($domain) { if (strpos($domain, '/') !== false) @@ -1570,58 +1570,37 @@ class Context { $domain = Rhymix\Framework\URL::decodeIdna($domain); } - if (isSiteID($domain)) - { - $vid = $domain; - $domain = ''; - } } - - // If $domain, $vid are not set, use current site information - if(!$domain && !$vid) + else { - if($site_module_info->domain && isSiteID($site_module_info->domain)) - { - $vid = $site_module_info->domain; - } - else - { - $domain = $site_module_info->domain; - } + $domain = $site_module_info->domain; } - // if $domain is set, compare current URL. If they are same, remove the domain, otherwise link to the domain. - if($domain) + // If the domain is the same as the current domain, do not use it. + if ($domain && $domain === $current_domain) { - if($domain === $current_info['host']) - { - unset($domain); - } + $domain = null; } - $get_vars = array(); - - // If there is no GET variables or first argument is '' to reset variables - if(!self::$_instance->get_vars || $args_list[0] == '') + // Get URL parameters. If the first argument is '', reset existing parameters. + if (!self::$_instance->get_vars || strval($args_list[0]) === '') { - // rearrange args_list - if(is_array($args_list) && $args_list[0] == '') + $get_vars = array(); + if(is_array($args_list) && strval($args_list[0]) === '') { array_shift($args_list); } } else { - // Otherwise, make GET variables into array $get_vars = get_object_vars(self::$_instance->get_vars); } - + // arrange args_list for($i = 0, $c = count($args_list); $i < $c; $i += 2) { $key = $args_list[$i]; $val = trim($args_list[$i + 1]); - // If value is not set, remove the key if(!isset($val) || !strlen($val)) { @@ -1631,18 +1610,11 @@ class Context // set new variables $get_vars[$key] = $val; } - + // remove vid, rnd unset($get_vars['rnd']); - if($vid) - { - $get_vars['vid'] = $vid; - } - else - { - unset($get_vars['vid']); - } - + unset($get_vars['vid']); + // for compatibility to lower versions $act = $get_vars['act']; $act_alias = array( @@ -1655,7 +1627,7 @@ class Context { $get_vars['act'] = $act_alias[$act]; } - + // organize URL $query = ''; if(count($get_vars) > 0) @@ -1665,47 +1637,32 @@ class Context { $var_keys = array_keys($get_vars); sort($var_keys); - $target = join('.', $var_keys); - $act = $get_vars['act']; - $vid = $get_vars['vid']; $mid = $get_vars['mid']; $key = $get_vars['key']; $srl = $get_vars['document_srl']; - $tmpArray = array('rss' => 1, 'atom' => 1, 'api' => 1); $is_feed = isset($tmpArray[$act]); - $target_map = array( - 'vid' => $vid, 'mid' => $mid, - 'mid.vid' => "$vid/$mid", 'category.mid' => "$mid/category/" . $get_vars['category'], 'entry.mid' => "$mid/entry/" . $get_vars['entry'], - 'entry.mid.vid' => "$vid/$mid/entry/" . $get_vars['entry'], 'document_srl' => $srl, 'document_srl.mid' => "$mid/$srl", - 'document_srl.vid' => "$vid/$srl", - 'document_srl.mid.vid' => "$vid/$mid/$srl", 'act' => ($is_feed && $act !== 'api') ? $act : '', 'act.mid' => $is_feed ? "$mid/$act" : '', - 'act.mid.vid' => $is_feed ? "$vid/$mid/$act" : '', 'act.document_srl.key' => ($act == 'trackback') ? "$srl/$key/$act" : '', 'act.document_srl.key.mid' => ($act == 'trackback') ? "$mid/$srl/$key/$act" : '', - 'act.document_srl.key.vid' => ($act == 'trackback') ? "$vid/$srl/$key/$act" : '', - 'act.document_srl.key.mid.vid' => ($act == 'trackback') ? "$vid/$mid/$srl/$key/$act" : '' ); - $query = $target_map[$target]; } - if(!$query && count($get_vars) > 0) { $query = 'index.php?' . http_build_query($get_vars); } } - + // If using SSL always $_use_ssl = self::get('_use_ssl'); if($_use_ssl == 'always') diff --git a/classes/module/ModuleHandler.class.php b/classes/module/ModuleHandler.class.php index 8d2e2be0a..e0eec9d44 100644 --- a/classes/module/ModuleHandler.class.php +++ b/classes/module/ModuleHandler.class.php @@ -260,15 +260,6 @@ class ModuleHandler extends Handler //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) - { - Context::setCacheControl(0); - $site_info = $oModuleModel->getSiteInfo($site_module_info->module_site_srl); - header('location: ' . getNotEncodedSiteUrl($site_info->domain, 'mid', $site_module_info->mid), true, 301); - 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) { From 1feb506b3ce4d149ccff8cfca92e0bc95c1c7324 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Mon, 13 Mar 2017 14:54:50 +0900 Subject: [PATCH 52/55] Remove vid from URL rewrite list --- .htaccess | 13 ------------- .../manual/server_config/rhymix-nginx-subdir.conf | 12 +----------- common/manual/server_config/rhymix-nginx.conf | 12 +----------- 3 files changed, 2 insertions(+), 35 deletions(-) diff --git a/.htaccess b/.htaccess index 10da8e3b2..fe203659a 100644 --- a/.htaccess +++ b/.htaccess @@ -17,13 +17,10 @@ RewriteRule ^(.+)\.min\.(css|js)$ ./$1.$2 [L] # rss, blogAPI RewriteRule ^(rss|atom)$ ./index.php?module=rss&act=$1 [L] RewriteRule ^([a-zA-Z0-9_]+)/(rss|atom|api)$ ./index.php?mid=$1&act=$2 [L] -RewriteRule ^([a-zA-Z0-9_]+)/([a-zA-Z0-9_]+)/(rss|atom|api)$ ./index.php?vid=$1&mid=$2&act=$3 [L] # trackback RewriteRule ^([0-9]+)/(.+)/trackback$ ./index.php?document_srl=$1&key=$2&act=trackback [L] RewriteRule ^([a-zA-Z0-9_]+)/([0-9]+)/(.+)/trackback$ ./index.php?mid=$1&document_srl=$2&key=$3&act=trackback [L] -RewriteRule ^([a-zA-Z0-9_]+)/([0-9]+)/(.+)/trackback$ ./index.php?vid=$1&document_srl=$2&key=$3&act=trackback [L] -RewriteRule ^([a-zA-Z0-9_]+)/([a-zA-Z0-9_]+)/([0-9]+)/(.+)/trackback$ ./index.php?vid=$1&mid=$2&document_srl=$3&key=$4&act=trackback [L] # document category RewriteRule ^([a-zA-Z0-9_]+)/category/([0-9]+)$ ./index.php?mid=$1&category=$2 [L,QSA] @@ -39,15 +36,5 @@ RewriteRule ^([a-zA-Z0-9_]+)/?$ ./index.php?mid=$1 [L,QSA] # mid + document link RewriteRule ^([a-zA-Z0-9_]+)/([0-9]+)$ ./index.php?mid=$1&document_srl=$2 [L,QSA] -# vid + mid link -RewriteCond %{SCRIPT_FILENAME} !-d -RewriteRule ^([a-zA-Z0-9_]+)/([a-zA-Z0-9_]+)/?$ ./index.php?vid=$1&mid=$2 [L,QSA] - -# vid + mid + document link -RewriteRule ^([a-zA-Z0-9_]+)/([a-zA-Z0-9_]+)/([0-9]+)$ ./index.php?vid=$1&mid=$2&document_srl=$3 [L,QSA] - # mid + entry title RewriteRule ^([a-zA-Z0-9_]+)/entry/(.+)$ ./index.php?mid=$1&entry=$2 [L,QSA] - -# vid + mid + entry title -RewriteRule ^([a-zA-Z0-9_]+)/([a-zA-Z0-9_]+)/entry/(.+)$ ./index.php?vid=$1&mid=$2&entry=$3 [L,QSA] diff --git a/common/manual/server_config/rhymix-nginx-subdir.conf b/common/manual/server_config/rhymix-nginx-subdir.conf index 3559ccb9c..3524fa495 100644 --- a/common/manual/server_config/rhymix-nginx-subdir.conf +++ b/common/manual/server_config/rhymix-nginx-subdir.conf @@ -31,11 +31,10 @@ location ~ ^/rhymix/(.+)\.min\.(css|js)$ { # rss, blogAPI rewrite ^/rhymix/(rss|atom)$ /rhymix/index.php?module=rss&act=$1 last; rewrite ^/rhymix/([a-zA-Z0-9_]+)/(rss|atom|api)$ /rhymix/index.php?mid=$1&act=$2 last; -rewrite ^/rhymix/([a-zA-Z0-9_]+)/([a-zA-Z0-9_]+)/(rss|atom|api)$ /rhymix/index.php?vid=$1&mid=$2&act=$3 last; # trackback rewrite ^/rhymix/([0-9]+)/(.+)/trackback$ /rhymix/index.php?document_srl=$1&key=$2&act=trackback last; -rewrite ^/rhymix/([a-zA-Z0-9_]+)/([0-9]+)/(.+)/trackback$ /rhymix/index.php?vid=$1&document_srl=$2&key=$3&act=trackback last; +rewrite ^/rhymix/([a-zA-Z0-9_]+)/([0-9]+)/(.+)/trackback$ /rhymix/index.php?mid=$1&document_srl=$2&key=$3&act=trackback last; # administrator page rewrite ^/rhymix/admin/?$ /rhymix/index.php?module=admin last; @@ -52,14 +51,5 @@ rewrite ^/rhymix/([a-zA-Z0-9_]+)/?$ /rhymix/index.php?mid=$1 last; # mid + document link rewrite ^/rhymix/([a-zA-Z0-9_]+)/([0-9]+)$ /rhymix/index.php?mid=$1&document_srl=$2 last; -# vid + mid link -rewrite ^/rhymix/([a-zA-Z0-9_]+)/([a-zA-Z0-9_]+)/?$ /rhymix/index.php?vid=$1&mid=$2 last; - -# vid + mid + document link -rewrite ^/rhymix/([a-zA-Z0-9_]+)/([a-zA-Z0-9_]+)/([0-9]+)$ /rhymix/index.php?vid=$1&mid=$2&document_srl=$3 last; - # mid + entry title rewrite ^/rhymix/([a-zA-Z0-9_]+)/entry/(.+)$ /rhymix/index.php?mid=$1&entry=$2 last; - -# vid + mid + entry title -rewrite ^/rhymix/([a-zA-Z0-9_]+)/([a-zA-Z0-9_]+)/entry/(.+)$ /rhymix/index.php?vid=$1&mid=$2&entry=$3 last; diff --git a/common/manual/server_config/rhymix-nginx.conf b/common/manual/server_config/rhymix-nginx.conf index 5ea8ab1e0..6edcf6922 100644 --- a/common/manual/server_config/rhymix-nginx.conf +++ b/common/manual/server_config/rhymix-nginx.conf @@ -31,11 +31,10 @@ location ~ ^/(.+)\.min\.(css|js)$ { # rss, blogAPI rewrite ^/(rss|atom)$ /index.php?module=rss&act=$1 last; rewrite ^/([a-zA-Z0-9_]+)/(rss|atom|api)$ /index.php?mid=$1&act=$2 last; -rewrite ^/([a-zA-Z0-9_]+)/([a-zA-Z0-9_]+)/(rss|atom|api)$ /index.php?vid=$1&mid=$2&act=$3 last; # trackback rewrite ^/([0-9]+)/(.+)/trackback$ /index.php?document_srl=$1&key=$2&act=trackback last; -rewrite ^/([a-zA-Z0-9_]+)/([0-9]+)/(.+)/trackback$ /index.php?vid=$1&document_srl=$2&key=$3&act=trackback last; +rewrite ^/([a-zA-Z0-9_]+)/([0-9]+)/(.+)/trackback$ /index.php?mid=$1&document_srl=$2&key=$3&act=trackback last; # administrator page rewrite ^/admin/?$ /index.php?module=admin last; @@ -52,14 +51,5 @@ rewrite ^/([a-zA-Z0-9_]+)/?$ /index.php?mid=$1 last; # mid + document link rewrite ^/([a-zA-Z0-9_]+)/([0-9]+)$ /index.php?mid=$1&document_srl=$2 last; -# vid + mid link -rewrite ^/([a-zA-Z0-9_]+)/([a-zA-Z0-9_]+)/?$ /index.php?vid=$1&mid=$2 last; - -# vid + mid + document link -rewrite ^/([a-zA-Z0-9_]+)/([a-zA-Z0-9_]+)/([0-9]+)$ /index.php?vid=$1&mid=$2&document_srl=$3 last; - # mid + entry title rewrite ^/([a-zA-Z0-9_]+)/entry/(.+)$ /index.php?mid=$1&entry=$2 last; - -# vid + mid + entry title -rewrite ^/([a-zA-Z0-9_]+)/([a-zA-Z0-9_]+)/entry/(.+)$ /index.php?vid=$1&mid=$2&entry=$3 last; From e7c5d884e85957a91724cb7561533bd5417a59df Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Mon, 13 Mar 2017 15:24:38 +0900 Subject: [PATCH 53/55] Implement domain deletion --- modules/admin/admin.admin.controller.php | 35 ++++++++++++++++++++++++ modules/admin/admin.admin.view.php | 4 +-- modules/admin/conf/module.xml | 1 + modules/admin/lang/en.php | 1 + modules/admin/lang/ko.php | 3 ++ modules/admin/tpl/config_domains.html | 22 ++++++++++++++- 6 files changed, 62 insertions(+), 4 deletions(-) diff --git a/modules/admin/admin.admin.controller.php b/modules/admin/admin.admin.controller.php index cad2d977c..6b7970ed8 100644 --- a/modules/admin/admin.admin.controller.php +++ b/modules/admin/admin.admin.controller.php @@ -1152,6 +1152,41 @@ class adminAdminController extends admin $this->setRedirectUrl(Context::get('success_return_url') ?: getNotEncodedUrl('', 'module', 'admin', 'act', 'dispAdminConfigGeneral')); } + /** + * Delete domain + * @return void + */ + function procAdminDeleteDomain() + { + // Get selected domain. + $domain_srl = strval(Context::get('domain_srl')); + if ($domain_srl === '') + { + return new Object(-1, 'msg_domain_not_found'); + } + $domain_info = getModel('module')->getSiteInfo($domain_srl); + if ($domain_info->domain_srl != $domain_srl) + { + return new Object(-1, 'msg_domain_not_found'); + } + if ($domain_info->is_default_domain === 'Y') + { + return new Object(-1, 'msg_cannot_delete_default_domain'); + } + + // Delete the domain. + $args = new stdClass(); + $args->domain_srl = $domain_srl; + $output = executeQuery('module.deleteDomain', $args); + if (!$output->toBool()) + { + return $output; + } + + // Clear cache. + Rhymix\Framework\Cache::clearGroup('site_and_module'); + } + /** * Update FTP configuration. */ diff --git a/modules/admin/admin.admin.view.php b/modules/admin/admin.admin.view.php index ceaebc594..629aef1ed 100644 --- a/modules/admin/admin.admin.view.php +++ b/modules/admin/admin.admin.view.php @@ -660,13 +660,12 @@ class adminAdminView extends admin $domain_info = getModel('module')->getSiteInfo($domain_srl); if ($domain_info->domain_srl != $domain_srl) { - $domain_info = null; + return new Object(-1, 'msg_domain_not_found'); } } Context::set('domain_info', $domain_info); // Get modules. - $module_list = getModel('module')->getMidList(); if ($domain_info && $domain_info->index_module_srl) { $index_module_srl = $domain_info->index_module_srl; @@ -675,7 +674,6 @@ class adminAdminView extends admin { $index_module_srl = ''; } - Context::set('module_list', $module_list); Context::set('index_module_srl', $index_module_srl); // Get language list. diff --git a/modules/admin/conf/module.xml b/modules/admin/conf/module.xml index 3e37647ff..3efb17ca9 100644 --- a/modules/admin/conf/module.xml +++ b/modules/admin/conf/module.xml @@ -33,6 +33,7 @@ + diff --git a/modules/admin/lang/en.php b/modules/admin/lang/en.php index 86c92adca..3bd52af71 100644 --- a/modules/admin/lang/en.php +++ b/modules/admin/lang/en.php @@ -125,6 +125,7 @@ $lang->cmd_unregistered_domain_redirect_301 = '301 Redirect to Default Domain (R $lang->cmd_unregistered_domain_redirect_302 = '302 Redirect to Default Domain'; $lang->cmd_unregistered_domain_display = 'Display Main Screen as Usual'; $lang->cmd_unregistered_domain_block = '404 Not Found'; +$lang->cmd_delete_domain = 'Would you like to delete this domain?'; $lang->about_use_ssl = 'Selecting \'Optional\' is to use SSL for the specified actions such as signing up and changing information.
    Selecting \'Always\' is to use SSL for the entire pages, generated by Rhymix.
    Please be careful! You may not be able to access to the site, before installing SSL certificate.'; $lang->server_ports = 'Server Port'; $lang->about_server_ports = 'If your web server does not use 80 for HTTP or 443 for HTTPS port, you should specify server ports.'; diff --git a/modules/admin/lang/ko.php b/modules/admin/lang/ko.php index 46f020d02..4d15b47d9 100644 --- a/modules/admin/lang/ko.php +++ b/modules/admin/lang/ko.php @@ -124,9 +124,12 @@ $lang->cmd_unregistered_domain_redirect_301 = '기본 도메인으로 301 Redire $lang->cmd_unregistered_domain_redirect_302 = '기본 도메인으로 302 Redirect'; $lang->cmd_unregistered_domain_display = '메인 화면 표시'; $lang->cmd_unregistered_domain_block = '404 Not Found 오류 표시'; +$lang->cmd_delete_domain = '이 도메인을 삭제하시겠습니까?'; $lang->about_use_ssl = '\'선택적으로 사용\'은 회원가입, 정보수정 등의 지정된 동작(action)에서만 보안접속(HTTPS)을 사용합니다.
    \'항상 사용\'은 사이트 전체에 HTTPS를 사용합니다.
    SSL 인증서가 설치되지 않은 상태에서 HTTPS 사용을 시도하면 접속이 되지 않을 수 있으니 주의하시기 바랍니다.'; $lang->server_ports = '포트'; $lang->about_server_ports = 'HTTP는 80, HTTPS는 443 이 아닌, 다른 포트를 사용할 경우에 포트를 지정해 주어야 합니다.'; +$lang->msg_domain_not_found = '도메인을 찾을 수 없습니다.'; +$lang->msg_cannot_delete_default_domain = '기본 도메인은 삭제할 수 없습니다.'; $lang->msg_site_title_is_empty = '사이트 제목을 입력해 주십시오.'; $lang->msg_invalid_domain = '올바르지 않은 도메인입니다.'; $lang->msg_domain_already_exists = '이미 등록된 도메인입니다.'; diff --git a/modules/admin/tpl/config_domains.html b/modules/admin/tpl/config_domains.html index a7b3ffb19..463746771 100644 --- a/modules/admin/tpl/config_domains.html +++ b/modules/admin/tpl/config_domains.html @@ -35,7 +35,12 @@
    @@ -102,3 +107,18 @@ + + From 01bb364e1085a771a57a2ddf7faf9300b8c84707 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Mon, 13 Mar 2017 15:35:48 +0900 Subject: [PATCH 54/55] Fix favicon for new domain and error message for nonexistent domain --- modules/admin/admin.admin.controller.php | 2 +- modules/admin/admin.admin.view.php | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/modules/admin/admin.admin.controller.php b/modules/admin/admin.admin.controller.php index 6b7970ed8..ac0c2b78b 100644 --- a/modules/admin/admin.admin.controller.php +++ b/modules/admin/admin.admin.controller.php @@ -948,7 +948,7 @@ class adminAdminController extends admin $domain_info = getModel('module')->getSiteInfo($domain_srl); if ($domain_info->domain_srl != $domain_srl) { - $domain_info = null; + return new Object(-1, 'msg_domain_not_found'); } } diff --git a/modules/admin/admin.admin.view.php b/modules/admin/admin.admin.view.php index 629aef1ed..1cf0ad693 100644 --- a/modules/admin/admin.admin.view.php +++ b/modules/admin/admin.admin.view.php @@ -702,10 +702,13 @@ class adminAdminView extends admin Context::set('domain_timezone', $domain_timezone); // Get favicon and images. - $oAdminAdminModel = getAdminModel('admin'); - Context::set('favicon_url', $oAdminAdminModel->getFaviconUrl($domain_info->domain_srl)); - Context::set('mobicon_url', $oAdminAdminModel->getMobileIconUrl($domain_info->domain_srl)); - Context::set('default_image_url', $oAdminAdminModel->getSiteDefaultImageUrl($domain_info->domain_srl)); + if ($domain_info) + { + $oAdminAdminModel = getAdminModel('admin'); + Context::set('favicon_url', $oAdminAdminModel->getFaviconUrl($domain_info->domain_srl)); + Context::set('mobicon_url', $oAdminAdminModel->getMobileIconUrl($domain_info->domain_srl)); + Context::set('default_image_url', $oAdminAdminModel->getSiteDefaultImageUrl($domain_info->domain_srl)); + } $this->setTemplateFile('config_domains_edit'); } From a2e326a419bf84d37b5bbdf6ee17ef859cdb7d93 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Mon, 13 Mar 2017 15:40:03 +0900 Subject: [PATCH 55/55] Always set xeVid to null --- common/tpl/common_layout.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/tpl/common_layout.html b/common/tpl/common_layout.html index e6350e4c2..05b95716e 100644 --- a/common/tpl/common_layout.html +++ b/common/tpl/common_layout.html @@ -56,7 +56,7 @@ var https_port = {Context::get("_https_port") ?: 'null'}; var enforce_ssl = {Context::get('_use_ssl') === 'always' ? 'true' : 'false'}; var ssl_actions = {json_encode(array_keys(Context::getSSLActions()))}; - var xeVid = {json_encode($vid ?: null)}; + var xeVid = null;
    {$lang->cmd_modify} / - {$lang->cmd_delete} + + {$lang->cmd_delete} + + + {$lang->cmd_delete} +