diff --git a/e107_core/templates/header_default.php b/e107_core/templates/header_default.php index 3955664ff..07dd6b26d 100644 --- a/e107_core/templates/header_default.php +++ b/e107_core/templates/header_default.php @@ -10,10 +10,19 @@ * */ + + + + if (!defined('e107_INIT')) { exit; } if(!defined('USER_AREA')) { define('USER_AREA',TRUE); } if(!defined('ADMIN_AREA')) { define('ADMIN_AREA', false); } +if($redirect = e107::getRedirect()->redirectStaticDomain()) +{ + e107::redirect($redirect); +} + e107::getDebug()->logTime('(Header Top)'); e_theme::initThemeLayout(); // set THEME_LAYOUT diff --git a/e107_handlers/redirection_class.php b/e107_handlers/redirection_class.php index 2ef0adbde..065b6c17a 100644 --- a/e107_handlers/redirection_class.php +++ b/e107_handlers/redirection_class.php @@ -42,7 +42,18 @@ class redirection * @var array */ protected $query_exceptions = array(); - + + + public $staticDomains; + + public $domain; + + public $subdomain; + + public $self; + + public $siteurl; + /** * Manage Member-Only Mode. * @@ -53,6 +64,10 @@ class redirection $this->self_exceptions = array(e_SIGNUP, SITEURL.'fpw.php', e_LOGIN, SITEURL.'membersonly.php'); $this->page_exceptions = array('e_ajax.php', 'e_js.php', 'e_jslib.php', 'sitedown.php',e_LOGIN, 'secimg.php'); $this->query_exceptions = array('logout'); + $this->staticDomains = defset('e_HTTP_STATIC'); + $this->domain = defset('e_DOMAIN'); + $this->subdomain = defset('e_SUBDOMAIN'); + $this->self = $this->getSelf(true); // Remove from self_exceptions: SITEURL, SITEURL.'index.php', // allows a custom frontpage to be viewed while logged out and membersonly active. } @@ -242,10 +257,7 @@ class redirection $this->redirect(SITEURL.'sitedown.php', TRUE, 307); } } - else - { - return; - } + } @@ -440,4 +452,27 @@ class redirection exit(); } + + + /** + * If a static subdomain is detected, returns the equivalent non-static domain. + * @return string|false + */ + public function redirectStaticDomain() + { + if(empty($this->staticDomains)) + { + return false; + } + + if(strpos($this->subdomain, 'static') !== false) + { + return str_replace($this->subdomain.'.'.$this->domain.'/', $this->domain.'/', $this->self); + } + + return false; + + } + + } diff --git a/e107_plugins/news/news.php b/e107_plugins/news/news.php index 8ba0fb64b..1d9bfd348 100644 --- a/e107_plugins/news/news.php +++ b/e107_plugins/news/news.php @@ -665,7 +665,7 @@ class news_front $options['query'] = ['page'=> $page]; } - if(!deftrue('e_FRONTPAGE')) // Use site title when on frontpage. + if(!deftrue('e_FRONTPAGE') && !empty($this->caption)) // Use site title when on frontpage. { e107::title($this->caption); } diff --git a/e107_tests/tests/unit/redirectionTest.php b/e107_tests/tests/unit/redirectionTest.php new file mode 100644 index 000000000..742d4c6fc --- /dev/null +++ b/e107_tests/tests/unit/redirectionTest.php @@ -0,0 +1,106 @@ +rd = $this->make('redirection'); + } + + catch(Exception $e) + { + $this->fail($e->getMessage()); + } + + } + +/* public function testRedirect() + { + + } + + public function testGetPreviousUrl() + { + + } + + public function testGo() + { + + } + + public function testCheckMaintenance() + { + + } + + public function testSetPreviousUrl() + { + + } + + public function testRedirectPrevious() + { + + } + + public function testGetSelfExceptions() + { + + } + + public function testGetCookie() + { + + } + + public function testCheckMembersOnly() + { + + } + + public function testSetCookie() + { + + } + + public function testClearCookie() + { + + } + + public function testGetSelf() + { + + }*/ + + public function testRedirectStaticDomain() + { + $result = $this->rd->redirectStaticDomain(); + $this->assertEmpty($result); + + $this->rd->domain = 'e107.org'; + $this->rd->subdomain = 'static1'; + $this->rd->staticDomains = ['https://static1.e107.org', 'https://static2.e107.org']; + + $this->rd->self = 'https://static1.e107.org/blogs'; + $this->rd->siteurl = 'https://e107.org/'; + + $result = $this->rd->redirectStaticDomain(); + + $this->assertSame("https://e107.org/blogs", $result); + + } + + + + + }