mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 22:28:51 +00:00
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:
parent
8b85a84d55
commit
a5ac9bbb3a
4 changed files with 118 additions and 101 deletions
|
@ -16,14 +16,12 @@ if (!defined('IN_PHPBB') || !isset($phpbb_root_path))
|
||||||
die('Hacking attempt');
|
die('Hacking attempt');
|
||||||
}
|
}
|
||||||
|
|
||||||
define('IN_ADMIN', true);
|
|
||||||
define('NEED_SID', true);
|
define('NEED_SID', true);
|
||||||
require($phpbb_root_path . 'common.'.$phpEx);
|
require($phpbb_root_path . 'common.'.$phpEx);
|
||||||
require($phpbb_root_path . 'includes/functions_admin.'.$phpEx);
|
require($phpbb_root_path . 'includes/functions_admin.'.$phpEx);
|
||||||
|
|
||||||
// Start session management
|
// Start session management
|
||||||
$user->start();
|
$user->start();
|
||||||
$user->setup('admin');
|
|
||||||
|
|
||||||
// Did user forget to login? Give 'em a chance to here ...
|
// Did user forget to login? Give 'em a chance to here ...
|
||||||
if ($user->data['user_id'] == ANONYMOUS)
|
if ($user->data['user_id'] == ANONYMOUS)
|
||||||
|
@ -32,6 +30,7 @@ if ($user->data['user_id'] == ANONYMOUS)
|
||||||
}
|
}
|
||||||
|
|
||||||
$auth->acl($user->data);
|
$auth->acl($user->data);
|
||||||
|
$user->setup('admin');
|
||||||
// End session management
|
// End session management
|
||||||
|
|
||||||
// Some oft used variables
|
// Some oft used variables
|
||||||
|
|
|
@ -301,11 +301,4 @@ if (file_exists('install'))
|
||||||
// trigger_error('REMOVE_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);
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -193,12 +193,6 @@ class session
|
||||||
WHERE u.user_id = $user_id
|
WHERE u.user_id = $user_id
|
||||||
AND u.group_id = g.group_id
|
AND u.group_id = g.group_id
|
||||||
ORDER BY s.session_time DESC";
|
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);
|
$result = $db->sql_query_limit($sql, 1);
|
||||||
|
|
||||||
$this->data = $db->sql_fetchrow($result);
|
$this->data = $db->sql_fetchrow($result);
|
||||||
|
@ -441,7 +435,7 @@ class session
|
||||||
while ($row = $db->sql_fetchrow($result));
|
while ($row = $db->sql_fetchrow($result));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($del_user_id != '')
|
if ($del_user_id)
|
||||||
{
|
{
|
||||||
// Delete expired sessions
|
// Delete expired sessions
|
||||||
$sql = 'DELETE FROM ' . SESSIONS_TABLE . "
|
$sql = 'DELETE FROM ' . SESSIONS_TABLE . "
|
||||||
|
@ -569,13 +563,14 @@ class user extends session
|
||||||
$this->theme = ($row2 = $db->sql_fetchrow($result)) ? array(
|
$this->theme = ($row2 = $db->sql_fetchrow($result)) ? array(
|
||||||
($style == $row['style_id']) ? 'primary' : 'secondary' => $row,
|
($style == $row['style_id']) ? 'primary' : 'secondary' => $row,
|
||||||
($style == $row2['style_id']) ? 'primary' : 'secondary' => $row2) : array('primary' => $row);
|
($style == $row2['style_id']) ? 'primary' : 'secondary' => $row2) : array('primary' => $row);
|
||||||
|
|
||||||
$db->sql_freeresult($result);
|
$db->sql_freeresult($result);
|
||||||
|
|
||||||
unset($row);
|
unset($row);
|
||||||
unset($row2);
|
unset($row2);
|
||||||
|
|
||||||
// Set theme info
|
// Set theme info
|
||||||
$theme_info = array();
|
$theme_info = array();
|
||||||
|
|
||||||
$default_theme_info = array(
|
$default_theme_info = array(
|
||||||
'pagination_sep' => ', ',
|
'pagination_sep' => ', ',
|
||||||
'pagination_goto_page' => true,
|
'pagination_goto_page' => true,
|
||||||
|
@ -588,6 +583,7 @@ class user extends session
|
||||||
{
|
{
|
||||||
$theme_info = array();
|
$theme_info = array();
|
||||||
include($phpbb_root_path . 'styles/' . $row['theme_path'] . '/theme/theme_info.' . $phpEx);
|
include($phpbb_root_path . 'styles/' . $row['theme_path'] . '/theme/theme_info.' . $phpEx);
|
||||||
|
|
||||||
if (sizeof($theme_info))
|
if (sizeof($theme_info))
|
||||||
{
|
{
|
||||||
$this->theme[$style_priority] = array_merge($this->theme[$style_priority], $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'];
|
$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
|
// 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
|
// ucp profile reg_details page ... of course do not redirect if we're
|
||||||
// already in the ucp
|
// 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))
|
if (empty($lang_dates))
|
||||||
{
|
{
|
||||||
|
@ -715,7 +720,24 @@ class user extends session
|
||||||
|
|
||||||
$format = (!$format) ? $this->date_format : $format;
|
$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()
|
function get_iso_lang_id()
|
||||||
|
|
|
@ -34,13 +34,26 @@ define('IN_PHPBB', true);
|
||||||
$phpbb_root_path = './';
|
$phpbb_root_path = './';
|
||||||
$phpEx = substr(strrchr(__FILE__, '.'), 1);
|
$phpEx = substr(strrchr(__FILE__, '.'), 1);
|
||||||
|
|
||||||
// This small snippet is required to let admins login if the board is disabled...
|
include($phpbb_root_path . 'common.'.$phpEx);
|
||||||
if ($_REQUEST['mode'] == 'login')
|
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);
|
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
|
// 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
|
// Basic "global" modes
|
||||||
switch ($mode)
|
switch ($mode)
|
||||||
|
|
Loading…
Add table
Reference in a new issue