Rejiggle "board disabled" system to allow admin/mods access, eliminate duplication and "fudges" ... hopefully I've not overlooked something fundamental ...

git-svn-id: file:///svn/phpbb/trunk@4950 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Paul S. Owen 2004-08-02 14:32:04 +00:00
parent 8b85a84d55
commit a5ac9bbb3a
4 changed files with 118 additions and 101 deletions

View file

@ -16,14 +16,12 @@ if (!defined('IN_PHPBB') || !isset($phpbb_root_path))
die('Hacking attempt');
}
define('IN_ADMIN', true);
define('NEED_SID', true);
require($phpbb_root_path . 'common.'.$phpEx);
require($phpbb_root_path . 'includes/functions_admin.'.$phpEx);
// Start session management
$user->start();
$user->setup('admin');
// Did user forget to login? Give 'em a chance to here ...
if ($user->data['user_id'] == ANONYMOUS)
@ -32,6 +30,7 @@ if ($user->data['user_id'] == ANONYMOUS)
}
$auth->acl($user->data);
$user->setup('admin');
// End session management
// Some oft used variables

View file

@ -301,11 +301,4 @@ if (file_exists('install'))
// trigger_error('REMOVE_INSTALL');
}
// Show 'Board is disabled' message
if ($config['board_disable'] && !defined('IN_ADMIN') && !defined('IN_LOGIN'))
{
$message = (!empty($config['board_disable_msg'])) ? $config['board_disable_msg'] : 'BOARD_DISABLE';
trigger_error($message);
}
?>

View file

@ -193,12 +193,6 @@ class session
WHERE u.user_id = $user_id
AND u.group_id = g.group_id
ORDER BY s.session_time DESC";
/* $sql = 'SELECT u.*, s.session_time, s.session_id
FROM (' . USERS_TABLE . ' u
LEFT JOIN ' . SESSIONS_TABLE . " s ON s.session_user_id = u.user_id)
WHERE u.user_id = $user_id
ORDER BY s.session_time DESC";*/
$result = $db->sql_query_limit($sql, 1);
$this->data = $db->sql_fetchrow($result);
@ -441,7 +435,7 @@ class session
while ($row = $db->sql_fetchrow($result));
}
if ($del_user_id != '')
if ($del_user_id)
{
// Delete expired sessions
$sql = 'DELETE FROM ' . SESSIONS_TABLE . "
@ -569,13 +563,14 @@ class user extends session
$this->theme = ($row2 = $db->sql_fetchrow($result)) ? array(
($style == $row['style_id']) ? 'primary' : 'secondary' => $row,
($style == $row2['style_id']) ? 'primary' : 'secondary' => $row2) : array('primary' => $row);
$db->sql_freeresult($result);
unset($row);
unset($row2);
// Set theme info
$theme_info = array();
$default_theme_info = array(
'pagination_sep' => ', ',
'pagination_goto_page' => true,
@ -588,6 +583,7 @@ class user extends session
{
$theme_info = array();
include($phpbb_root_path . 'styles/' . $row['theme_path'] . '/theme/theme_info.' . $phpEx);
if (sizeof($theme_info))
{
$this->theme[$style_priority] = array_merge($this->theme[$style_priority], $theme_info);
@ -608,6 +604,15 @@ class user extends session
$this->img_lang = (file_exists($phpbb_root_path . 'styles/' . $this->theme['primary']['imageset_path'] . '/imageset/' . $this->lang_name)) ? $this->lang_name : $config['default_lang'];
// Is board disabled and user not an admin or moderator?
// TODO
// New ACL enabling board access while offline?
if ($config['board_disable'] && !defined('IN_LOGIN') && !$auth->acl_gets('a_', 'm_'))
{
$message = (!empty($config['board_disable_msg'])) ? $config['board_disable_msg'] : 'BOARD_DISABLE';
trigger_error($message);
}
// Does the user need to change their password? If so, redirect to the
// ucp profile reg_details page ... of course do not redirect if we're
// already in the ucp
@ -701,9 +706,9 @@ class user extends session
}
}
function format_date($gmepoch, $format = false)
function format_date($gmepoch, $format = false, $forcedate = false)
{
static $lang_dates;
static $lang_dates, $midnight;
if (empty($lang_dates))
{
@ -715,7 +720,24 @@ class user extends session
$format = (!$format) ? $this->date_format : $format;
return strtr(@gmdate($format, $gmepoch + $this->timezone + $this->dst), $lang_dates);
if (!$midnight)
{
list($d, $m, $y) = explode(' ', gmdate('j n Y', time() + $this->timezone + $this->dst));
$midnight = gmmktime(0, 0, 0, $m, $d, $y) - $this->timezone - $this->dst;
}
if ($gmepoch > $midnight && !$forcedate)
{
return preg_replace('#\|.*?\|#', $this->lang['datetime']['TODAY'], strtr(@gmdate($format, $gmepoch + $this->timezone + $this->dst), $lang_dates));
}
else if ($gmepoch > $midnight - 86400 && !$forcedate)
{
return preg_replace('#\|.*?\|#', $this->lang['datetime']['YESTERDAY'], strtr(@gmdate($format, $gmepoch + $this->timezone + $this->dst), $lang_dates));
}
else
{
return strtr(@gmdate(str_replace('|', '', $format), $gmepoch + $this->timezone + $this->dst), $lang_dates);
}
}
function get_iso_lang_id()

View file

@ -34,13 +34,26 @@ define('IN_PHPBB', true);
$phpbb_root_path = './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
// This small snippet is required to let admins login if the board is disabled...
if ($_REQUEST['mode'] == 'login')
include($phpbb_root_path . 'common.'.$phpEx);
include($phpbb_root_path . '/includes/functions_user.'.$phpEx);
// Basic parameter data
$mode = request_var('mode', '');
$module = request_var('i', '');
if ($mode == 'login' || $mode == 'logout')
{
define('IN_LOGIN', true);
}
include($phpbb_root_path . 'common.'.$phpEx);
include($phpbb_root_path . '/includes/functions_user.'.$phpEx);
// Start session management
$user->start();
$auth->acl($user->data);
$user->setup('ucp');
$ucp = new module();
// ---------
// FUNCTIONS
@ -240,16 +253,6 @@ class module
// ---------
// Start session management
$user->start();
$auth->acl($user->data);
$user->setup('ucp');
$ucp = new module();
// Basic parameter data
$mode = request_var('mode', '');
$module = request_var('i', '');
// Basic "global" modes
switch ($mode)