mirror of
https://github.com/e107inc/e107.git
synced 2025-08-08 07:36:32 +02:00
Fixes #4826 - redirect dynamic content on static domain.
This commit is contained in:
@@ -10,10 +10,19 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (!defined('e107_INIT')) { exit; }
|
if (!defined('e107_INIT')) { exit; }
|
||||||
if(!defined('USER_AREA')) { define('USER_AREA',TRUE); }
|
if(!defined('USER_AREA')) { define('USER_AREA',TRUE); }
|
||||||
if(!defined('ADMIN_AREA')) { define('ADMIN_AREA', false); }
|
if(!defined('ADMIN_AREA')) { define('ADMIN_AREA', false); }
|
||||||
|
|
||||||
|
if($redirect = e107::getRedirect()->redirectStaticDomain())
|
||||||
|
{
|
||||||
|
e107::redirect($redirect);
|
||||||
|
}
|
||||||
|
|
||||||
e107::getDebug()->logTime('(Header Top)');
|
e107::getDebug()->logTime('(Header Top)');
|
||||||
|
|
||||||
e_theme::initThemeLayout(); // set THEME_LAYOUT
|
e_theme::initThemeLayout(); // set THEME_LAYOUT
|
||||||
|
@@ -43,6 +43,17 @@ class redirection
|
|||||||
*/
|
*/
|
||||||
protected $query_exceptions = array();
|
protected $query_exceptions = array();
|
||||||
|
|
||||||
|
|
||||||
|
public $staticDomains;
|
||||||
|
|
||||||
|
public $domain;
|
||||||
|
|
||||||
|
public $subdomain;
|
||||||
|
|
||||||
|
public $self;
|
||||||
|
|
||||||
|
public $siteurl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manage Member-Only Mode.
|
* 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->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->page_exceptions = array('e_ajax.php', 'e_js.php', 'e_jslib.php', 'sitedown.php',e_LOGIN, 'secimg.php');
|
||||||
$this->query_exceptions = array('logout');
|
$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.
|
// 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);
|
$this->redirect(SITEURL.'sitedown.php', TRUE, 307);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -440,4 +452,27 @@ class redirection
|
|||||||
|
|
||||||
exit();
|
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;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -665,7 +665,7 @@ class news_front
|
|||||||
$options['query'] = ['page'=> $page];
|
$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);
|
e107::title($this->caption);
|
||||||
}
|
}
|
||||||
|
106
e107_tests/tests/unit/redirectionTest.php
Normal file
106
e107_tests/tests/unit/redirectionTest.php
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
class redirectionTest extends \Codeception\Test\Unit
|
||||||
|
{
|
||||||
|
|
||||||
|
/** @var redirection */
|
||||||
|
protected $rd;
|
||||||
|
|
||||||
|
protected function _before()
|
||||||
|
{
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$this->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);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Reference in New Issue
Block a user