1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-05 22:27:34 +02:00

work on sitedown

+ some tweaks
+ some doc
This commit is contained in:
marj
2009-10-28 20:16:12 +00:00
parent fb80da0b91
commit d4f929ab17

View File

@@ -11,21 +11,40 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/e107_handlers/redirection_class.php,v $ | $Source: /cvs_backup/e107_0.8/e107_handlers/redirection_class.php,v $
| $Revision: 1.4 $ | $Revision: 1.5 $
| $Date: 2009-10-28 16:57:51 $ | $Date: 2009-10-28 20:16:12 $
| $Author: marj_nl_fr $ | $Author: marj_nl_fr $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
/**
* Redirection class
*
* @package e107
* @category e107_handlers
* @version 1.0
* @author Cameron
* @copyright Copyright (C) 2009, e107 Inc.
*/
class redirection class redirection
{ {
/**
* List of pages to not check agaist e_SELF
*
* @var array
*/
protected $self_exceptions = array();
var $self_exceptions = array(); /**
* List of pages to not check agaist e_PAGE
var $page_exceptions = array(); *
* @var array
*/
protected $page_exceptions = array();
/** /**
* Manage Member-Only Mode. * Manage Member-Only Mode.
*
* @return void * @return void
*/ */
function __construct() function __construct()
@@ -36,29 +55,28 @@ class redirection
/** /**
* Perform re-direction when Maintenance Mode is active. * Perform re-direction when Maintenance Mode is active.
*
* @return void * @return void
*/ */
public function checkMaintenance() public function checkMaintenance()
{ {
// prevent looping.
if(strpos(e_SELF, 'sitedown.php') !== FALSE) // prevent looping. if(strpos(e_SELF, 'admin.php') !== FALSE || strpos(e_SELF, 'sitedown.php') !== FALSE)
{ {
return; return;
} }
if(e107::getPref('maintainance_flag')) if(e107::getPref('maintainance_flag'))
{ {
if(e107::getPref('main_admin_only')==1 && ADMIN==TRUE && !getperms('0')) if(!ADMIN
|| (e_UC_MAINADMIN == e107::getPref('maintainance_flag')
&& !getperms('0')
)
)
{ {
$this->redirect(SITEURL.'sitedown.php?logout'); // 307 Temporary Redirect
$this->redirect(SITEURL.'sitedown.php', TRUE, 307);
} }
if((strpos(e_SELF, 'admin.php') !== FALSE) || (ADMIN == TRUE))
{
return;
}
$this->redirect(SITEURL.'sitedown.php');
} }
else else
{ {
@@ -68,10 +86,10 @@ class redirection
/** /**
* check if user is logged in. * Check if user is logged in.
*
* @return void * @return void
*/ */
public function checkMembersOnly() public function checkMembersOnly()
{ {
@@ -114,11 +132,12 @@ class redirection
$this->redirect(e_HTTP.'membersonly.php'); $this->redirect(e_HTTP.'membersonly.php');
} }
/** /**
* Store the current URL so that it can retrieved after login. * Store the current URL so that it can retrieved after login.
*
* @return void * @return void
*/ */
private function saveMembersOnlyUrl() private function saveMembersOnlyUrl()
{ {
// remember the url for after-login. // remember the url for after-login.
@@ -130,9 +149,9 @@ class redirection
/** /**
* Restore the previously saved URL, and redirect the User to it after login. * Restore the previously saved URL, and redirect the User to it after login.
*
* @return void * @return void
*/ */
private function restoreMembersOnlyUrl() private function restoreMembersOnlyUrl()
{ {
if (USER && ($_SESSION[e_COOKIE.'_afterlogin'] || $_COOKIE[e_COOKIE.'_afterlogin'])) if (USER && ($_SESSION[e_COOKIE.'_afterlogin'] || $_COOKIE[e_COOKIE.'_afterlogin']))
@@ -143,10 +162,28 @@ class redirection
} }
} }
function redirect($url)
/**
* Redirect to the given URI
*
* @param string $url
* @param boolean $replace - default TRUE
* @param integer|null $http_response_code - default NULL
* @return void
*/
public function redirect($url, $replace = TRUE, $http_response_code = NULL)
{ {
header('Location: '.$url); if(NULL == $http_response_code)
header("Content-Length: 0"); // Safari endless loop fix. {
header('Location: '.$url, $replace);
}
else
{
header('Location: '.$url, $replace, $http_response_code);
}
// Safari endless loop fix.
header('Content-Length: 0');
exit(); exit();
} }
} }