mirror of
https://github.com/e107inc/e107.git
synced 2025-08-04 13:47:31 +02:00
review some comments
This commit is contained in:
@@ -9,8 +9,8 @@
|
|||||||
* Administration - Site Maintenance
|
* Administration - Site Maintenance
|
||||||
*
|
*
|
||||||
* $Source: /cvs_backup/e107_0.8/e107_admin/ugflag.php,v $
|
* $Source: /cvs_backup/e107_0.8/e107_admin/ugflag.php,v $
|
||||||
* $Revision: 1.6 $
|
* $Revision: 1.7 $
|
||||||
* $Date: 2009-10-28 16:57:51 $
|
* $Date: 2009-10-28 20:26:04 $
|
||||||
* $Author: marj_nl_fr $
|
* $Author: marj_nl_fr $
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@@ -94,7 +94,7 @@ $text .= "
|
|||||||
</td>
|
</td>
|
||||||
</tr>";
|
</tr>";
|
||||||
|
|
||||||
|
//TODO multilanguage pref
|
||||||
$text .= "
|
$text .= "
|
||||||
<tr>
|
<tr>
|
||||||
<td class='label'>".UGFLAN_5."
|
<td class='label'>".UGFLAN_5."
|
||||||
|
@@ -1,21 +1,21 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
+ ----------------------------------------------------------------------------+
|
+ ----------------------------------------------------------------------------+
|
||||||
| e107 website system
|
| e107 website system
|
||||||
|
|
|
|
||||||
| Copyright (C) 2001-2009 e107 Inc
|
| Copyright (C) 2001-2009 e107 Inc
|
||||||
| http://e107.org
|
| http://e107.org
|
||||||
|
|
|
|
||||||
|
|
|
|
||||||
| Released under the terms and conditions of the
|
| Released under the terms and conditions of the
|
||||||
| 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.5 $
|
| $Revision: 1.6 $
|
||||||
| $Date: 2009-10-28 20:16:12 $
|
| $Date: 2009-10-28 20:26:04 $
|
||||||
| $Author: marj_nl_fr $
|
| $Author: marj_nl_fr $
|
||||||
+----------------------------------------------------------------------------+
|
+----------------------------------------------------------------------------+
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Redirection class
|
* Redirection class
|
||||||
@@ -28,162 +28,161 @@
|
|||||||
*/
|
*/
|
||||||
class redirection
|
class redirection
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* List of pages to not check agaist e_SELF
|
* List of pages to not check against e_SELF
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $self_exceptions = array();
|
protected $self_exceptions = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of pages to not check agaist e_PAGE
|
* List of pages to not check against e_PAGE
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $page_exceptions = array();
|
protected $page_exceptions = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manage Member-Only Mode.
|
* Manage Member-Only Mode.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function __construct()
|
function __construct()
|
||||||
|
{
|
||||||
|
$this->self_exceptions = array(SITEURL.e_SIGNUP, SITEURL.'index.php', SITEURL.'fpw.php', SITEURL.e_LOGIN, SITEURL.'membersonly.php');
|
||||||
|
$this->page_exceptions = array('e_ajax.php', 'e_js.php', 'e_jslib.php', 'sitedown.php');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Perform re-direction when Maintenance Mode is active.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function checkMaintenance()
|
||||||
|
{
|
||||||
|
// prevent looping.
|
||||||
|
if(strpos(e_SELF, 'admin.php') !== FALSE || strpos(e_SELF, 'sitedown.php') !== FALSE)
|
||||||
{
|
{
|
||||||
$this->self_exceptions = array(SITEURL.e_SIGNUP, SITEURL.'index.php', SITEURL.'fpw.php', SITEURL.e_LOGIN, SITEURL.'membersonly.php');
|
return;
|
||||||
$this->page_exceptions = array('e_ajax.php', 'e_js.php', 'e_jslib.php', 'sitedown.php');
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
if(e107::getPref('maintainance_flag'))
|
||||||
* Perform re-direction when Maintenance Mode is active.
|
{
|
||||||
*
|
// if not admin
|
||||||
* @return void
|
if(!ADMIN
|
||||||
*/
|
// or if not mainadmin - ie e_UC_MAINADMIN
|
||||||
public function checkMaintenance()
|
|| (e_UC_MAINADMIN == e107::getPref('maintainance_flag') && !getperms('0')))
|
||||||
{
|
{
|
||||||
// prevent looping.
|
// 307 Temporary Redirect
|
||||||
if(strpos(e_SELF, 'admin.php') !== FALSE || strpos(e_SELF, 'sitedown.php') !== FALSE)
|
$this->redirect(SITEURL.'sitedown.php', TRUE, 307);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if user is logged in.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function checkMembersOnly()
|
||||||
|
{
|
||||||
|
|
||||||
|
if(!e107::getPref('membersonly_enabled'))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(USER && !e_AJAX_REQUEST)
|
||||||
|
{
|
||||||
|
$this->restoreMembersOnlyUrl();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(e_AJAX_REQUEST)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(strpos(e_PAGE, 'admin') !== FALSE)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(in_array(e_SELF, $this->self_exceptions))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(in_array(e_PAGE, $this->page_exceptions))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
foreach (e107::getPref('membersonly_exceptions') as $val)
|
||||||
|
{
|
||||||
|
$srch = trim($val);
|
||||||
|
if(strpos(e_SELF, $srch) !== FALSE)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->saveMembersOnlyUrl();
|
||||||
|
$this->redirect(e_HTTP.'membersonly.php');
|
||||||
|
}
|
||||||
|
|
||||||
if(e107::getPref('maintainance_flag'))
|
|
||||||
{
|
/**
|
||||||
if(!ADMIN
|
* Store the current URL so that it can retrieved after login.
|
||||||
|| (e_UC_MAINADMIN == e107::getPref('maintainance_flag')
|
*
|
||||||
&& !getperms('0')
|
* @return void
|
||||||
)
|
*/
|
||||||
)
|
private function saveMembersOnlyUrl()
|
||||||
{
|
{
|
||||||
// 307 Temporary Redirect
|
// remember the url for after-login.
|
||||||
$this->redirect(SITEURL.'sitedown.php', TRUE, 307);
|
$afterlogin = e_COOKIE.'_afterlogin';
|
||||||
}
|
$url = (e_QUERY ? e_SELF.'?'.e_QUERY : e_SELF);
|
||||||
}
|
session_set($afterlogin, $url, time() + 300);
|
||||||
else
|
}
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if user is logged in.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function checkMembersOnly()
|
|
||||||
{
|
|
||||||
|
|
||||||
if(!e107::getPref('membersonly_enabled'))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (USER && !e_AJAX_REQUEST)
|
|
||||||
{
|
|
||||||
$this->restoreMembersOnlyUrl();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (e_AJAX_REQUEST)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (strpos(e_PAGE, 'admin') !== FALSE)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (in_array(e_SELF, $this->self_exceptions))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (in_array(e_PAGE, $this->page_exceptions))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
foreach (e107::getPref('membersonly_exceptions') as $val)
|
|
||||||
{
|
|
||||||
$srch = trim($val);
|
|
||||||
if (strpos(e_SELF, $srch) !== FALSE)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->saveMembersOnlyUrl();
|
|
||||||
$this->redirect(e_HTTP.'membersonly.php');
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Store the current URL so that it can retrieved after login.
|
* Restore the previously saved URL, and redirect the User to it after login.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
private function saveMembersOnlyUrl()
|
private function restoreMembersOnlyUrl()
|
||||||
|
{
|
||||||
|
if(USER && ($_SESSION[e_COOKIE.'_afterlogin'] || $_COOKIE[e_COOKIE.'_afterlogin']))
|
||||||
{
|
{
|
||||||
// remember the url for after-login.
|
$url = ($_SESSION[e_COOKIE.'_afterlogin']) ? $_SESSION[e_COOKIE.'_afterlogin'] : $_COOKIE[e_COOKIE.'_afterlogin'];
|
||||||
$afterlogin = e_COOKIE.'_afterlogin';
|
session_set(e_COOKIE.'_afterlogin', FALSE, -1000);
|
||||||
$url = (e_QUERY ? e_SELF.'?'.e_QUERY : e_SELF);
|
$this->redirect($url);
|
||||||
session_set($afterlogin, $url, time() + 300);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Restore the previously saved URL, and redirect the User to it after login.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
private function restoreMembersOnlyUrl()
|
|
||||||
{
|
|
||||||
if (USER && ($_SESSION[e_COOKIE.'_afterlogin'] || $_COOKIE[e_COOKIE.'_afterlogin']))
|
|
||||||
{
|
|
||||||
$url = ($_SESSION[e_COOKIE.'_afterlogin']) ? $_SESSION[e_COOKIE.'_afterlogin'] : $_COOKIE[e_COOKIE.'_afterlogin'];
|
|
||||||
session_set(e_COOKIE.'_afterlogin', FALSE, -1000);
|
|
||||||
$this->redirect($url);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Redirect to the given URI
|
/**
|
||||||
*
|
* Redirect to the given URI
|
||||||
* @param string $url
|
*
|
||||||
* @param boolean $replace - default TRUE
|
* @param string $url
|
||||||
* @param integer|null $http_response_code - default NULL
|
* @param boolean $replace - default TRUE
|
||||||
* @return void
|
* @param integer|null $http_response_code - default NULL
|
||||||
*/
|
* @return void
|
||||||
public function redirect($url, $replace = TRUE, $http_response_code = NULL)
|
*/
|
||||||
|
public function redirect($url, $replace = TRUE, $http_response_code = NULL)
|
||||||
|
{
|
||||||
|
if(NULL == $http_response_code)
|
||||||
{
|
{
|
||||||
if(NULL == $http_response_code)
|
header('Location: '.$url, $replace);
|
||||||
{
|
}
|
||||||
header('Location: '.$url, $replace);
|
else
|
||||||
}
|
{
|
||||||
else
|
header('Location: '.$url, $replace, $http_response_code);
|
||||||
{
|
}
|
||||||
header('Location: '.$url, $replace, $http_response_code);
|
|
||||||
}
|
// Safari endless loop fix.
|
||||||
|
header('Content-Length: 0');
|
||||||
// Safari endless loop fix.
|
exit();
|
||||||
header('Content-Length: 0');
|
}
|
||||||
exit();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user