git-svn-id: file:///svn/phpbb/trunk@8587 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Henry Sudhof 2008-06-03 16:33:02 +00:00
parent 59e6bc27f1
commit 65fb840b76
7 changed files with 129 additions and 16 deletions

View file

@ -28,10 +28,14 @@ $user->setup('acp/common');
// End session management // End session management
// Have they authenticated (again) as an admin for this session? // Have they authenticated (again) as an admin for this session?
if (!isset($user->data['session_admin']) || !$user->data['session_admin']) if ($user->data['user_id'] != ANONYMOUS && (!isset($user->data['session_admin']) || !$user->data['session_admin']))
{ {
login_box('', $user->lang['LOGIN_ADMIN_CONFIRM'], $user->lang['LOGIN_ADMIN_SUCCESS'], true, false); login_box('', $user->lang['LOGIN_ADMIN_CONFIRM'], $user->lang['LOGIN_ADMIN_SUCCESS'], true, false);
} }
else if ($user->data['user_id'] == ANONYMOUS)
{
login_box('');
}
// Is user any type of admin? No, then stop here, each script needs to // Is user any type of admin? No, then stop here, each script needs to
// check specific permissions but this is a catchall // check specific permissions but this is a catchall
@ -108,7 +112,7 @@ function adm_page_header($page_title)
$template->assign_vars(array( $template->assign_vars(array(
'PAGE_TITLE' => $page_title, 'PAGE_TITLE' => $page_title,
'USERNAME' => $user->data['username'], 'USERNAME' => ($user->data['user_id'] != ANONYMOUS) ? $user->data['username'] : '',
'SID' => $SID, 'SID' => $SID,
'_SID' => $_SID, '_SID' => $_SID,
@ -116,9 +120,13 @@ function adm_page_header($page_title)
'ROOT_PATH' => PHPBB_ADMIN_PATH, 'ROOT_PATH' => PHPBB_ADMIN_PATH,
'U_LOGOUT' => append_sid('ucp', 'mode=logout'), 'U_LOGOUT' => append_sid('ucp', 'mode=logout'),
'U_ADM_LOGOUT' => append_sid(PHPBB_ADMIN_PATH . 'index.' . PHP_EXT, 'action=admlogout'),
'U_ADM_INDEX' => append_sid(PHPBB_ADMIN_PATH . 'index.' . PHP_EXT), 'U_ADM_INDEX' => append_sid(PHPBB_ADMIN_PATH . 'index.' . PHP_EXT),
'U_INDEX' => append_sid('index'), 'U_INDEX' => append_sid('index'),
'S_USER_ADMIN' => $user->data['session_admin'],
'S_USER_LOGGED_IN' => ($user->data['user_id'] != ANONYMOUS && !$user->data['is_bot']),
'T_IMAGES_PATH' => PHPBB_ROOT_PATH . 'images/', 'T_IMAGES_PATH' => PHPBB_ROOT_PATH . 'images/',
'T_SMILIES_PATH' => PHPBB_ROOT_PATH . $config['smilies_path'] . '/', 'T_SMILIES_PATH' => PHPBB_ROOT_PATH . $config['smilies_path'] . '/',
'T_AVATAR_PATH' => PHPBB_ROOT_PATH . $config['avatar_path'] . '/', 'T_AVATAR_PATH' => PHPBB_ROOT_PATH . $config['avatar_path'] . '/',

46
phpBB/adm/style/acp_login.html Executable file
View file

@ -0,0 +1,46 @@
<!-- INCLUDE overall_header.html -->
<h1>{PAGE_TITLE}</h1>
<p><!-- IF LOGIN_EXPLAIN -->{LOGIN_EXPLAIN}<!-- ELSE -->{L_LOGIN}<!-- ENDIF --></p>
<!-- IF LOGIN_ERROR -->
<div class="errorbox">
<h3>{L_WARNING}</h3>
<p>{LOGIN_ERROR}</p>
</div>
<!-- ENDIF -->
<form action="{S_LOGIN_ACTION}" method="post" id="login">
<fieldset>
<dl>
<dt><label for="{USERNAME_CREDENTIAL}">{L_USERNAME}:</label></dt>
<dd><input type="text" tabindex="1" name="{USERNAME_CREDENTIAL}" id="{USERNAME_CREDENTIAL}" size="25" value="{USERNAME}" class="inputbox autowidth" /></dd>
</dl>
<dl>
<dt><label for="{PASSWORD_CREDENTIAL}">{L_PASSWORD}:</label></dt>
<dd><input type="password" tabindex="2" id="{PASSWORD_CREDENTIAL}" name="{PASSWORD_CREDENTIAL}" size="25" class="inputbox autowidth" /></dd>
<!-- IF S_DISPLAY_FULL_LOGIN and (U_SEND_PASSWORD or U_RESEND_ACTIVATION) -->
<!-- IF U_SEND_PASSWORD --><dd><a href="{U_SEND_PASSWORD}">{L_FORGOT_PASS}</a></dd><!-- ENDIF -->
<!-- IF U_RESEND_ACTIVATION --><dd><a href="{U_RESEND_ACTIVATION}">{L_RESEND_ACTIVATION}</a></dd><!-- ENDIF -->
<!-- ENDIF -->
</dl>
<!-- IF S_CONFIRM_CODE -->
<dl>
<dt><label for="confirm_code">{L_CONFIRM_CODE}:</label><br /><span>{L_CONFIRM_CODE_EXPLAIN}</span></dt>
<dd><input type="hidden" name="confirm_id" value="{CONFIRM_ID}" />{CONFIRM_IMAGE}</dd>
<dd><input type="text" name="confirm_code" id="confirm_code" size="8" maxlength="8" tabindex="3" class="inputbox narrow" title="{L_CONFIRM_CODE}" /></dd>
</dl>
<!-- ENDIF -->
<p class="submit-buttons">
<!-- IF S_DISPLAY_FULL_LOGIN -->
<!-- IF S_AUTOLOGIN_ENABLED --><label for="autologin"><input type="checkbox" name="autologin" id="autologin" tabindex="4" /> {L_LOG_ME_IN}</label><!-- ENDIF -->
<label for="viewonline"><input type="checkbox" name="viewonline" id="viewonline" tabindex="5" /> {L_HIDE_ME}</label>
<!-- ENDIF -->
&nbsp;
{S_HIDDEN_FIELDS}<input type="submit" name="login" tabindex="6" value="{L_LOGIN}" class="button1" />
</p>
</fieldset>
</form>
<!-- INCLUDE overall_footer.html -->

View file

@ -181,11 +181,12 @@ function switch_menu()
<span class="corners-top"><span></span></span> <span class="corners-top"><span></span></span>
<div id="content"> <div id="content">
<!-- IF not S_USER_NOTICE --> <!-- IF not S_USER_NOTICE -->
<div id="toggle"> <div id="toggle">
<a id="toggle-handle" accesskey="m" title="{L_MENU_TOGGLE}" onclick="switch_menu(); return false;" href="#"></a></div> <a id="toggle-handle" accesskey="m" title="{L_MENU_TOGGLE}" onclick="switch_menu(); return false;" href="#"></a></div>
<!-- ENDIF --> <!-- ENDIF -->
<div id="menu"> <div id="menu">
<p>{L_LOGGED_IN_AS}<br /><strong>{USERNAME}</strong> [&nbsp;<a href="{U_LOGOUT}">{L_LOGOUT}</a>&nbsp;]</p> <p><!-- IF S_USER_LOGGED_IN --> {L_LOGGED_IN_AS}<br /><strong>{USERNAME}</strong> [&nbsp;<a href="{U_LOGOUT}">{L_LOGOUT}</a>&nbsp;]<!-- ENDIF --><!-- IF S_USER_ADMIN -->[&nbsp;<a href="{U_ADM_LOGOUT}">{L_ADM_LOGOUT}</a>&nbsp;]<!-- ENDIF --></p>
<!-- IF S_USER_ADMIN -->
<ul> <ul>
<!-- BEGIN l_block1 --> <!-- BEGIN l_block1 -->
<!-- IF l_block1.S_SELECTED --> <!-- IF l_block1.S_SELECTED -->
@ -203,6 +204,7 @@ function switch_menu()
<!-- ENDIF --> <!-- ENDIF -->
<!-- END l_block1 --> <!-- END l_block1 -->
</ul> </ul>
<!-- ENDIF -->
</div> </div>
<div id="main"> <div id="main">

View file

@ -60,6 +60,14 @@ class acp_main
if ($action) if ($action)
{ {
if ($action === 'admlogout')
{
$user->unset_admin();
$redirect_url = append_sid("{$phpbb_root_path}index.$phpEx");
meta_refresh(3, $redirect_url);
trigger_error($user->lang['ADM_LOGGED_OUT'] . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . $redirect_url . '">', '</a>'));
}
if (!confirm_box(true)) if (!confirm_box(true))
{ {
switch ($action) switch ($action)
@ -107,6 +115,7 @@ class acp_main
{ {
switch ($action) switch ($action)
{ {
case 'online': case 'online':
if (!$auth->acl_get('a_board')) if (!$auth->acl_get('a_board'))
{ {

View file

@ -2176,6 +2176,7 @@ function confirm_box($check, $title = '', $hidden = '', $html_body = 'confirm_bo
function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = false, $s_display = true) function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = false, $s_display = true)
{ {
global $db, $user, $template, $auth, $config; global $db, $user, $template, $auth, $config;
$err = ''; $err = '';
@ -2184,6 +2185,16 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa
{ {
$user->setup(); $user->setup();
} }
if (defined('ADMIN_START'))
{
// Set custom template for admin area
$template->set_custom_template(PHPBB_ADMIN_PATH . 'style', 'admin');
$template->assign_var('T_TEMPLATE_PATH', PHPBB_ADMIN_PATH . 'style');
// the acp template is never stored in the database
$user->theme['template_storedb'] = false;
}
// Print out error if user tries to authenticate as an administrator without having the privileges... // Print out error if user tries to authenticate as an administrator without having the privileges...
if ($admin && !$auth->acl_get('a_')) if ($admin && !$auth->acl_get('a_'))
@ -2351,7 +2362,7 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa
// If we are not within the admin directory we use the page dir... // If we are not within the admin directory we use the page dir...
$redirect = ''; $redirect = '';
if (!$admin) if (!$admin && !defined('ADMIN_START'))
{ {
$redirect .= ($user->page['page_dir']) ? $user->page['page_dir'] . '/' : ''; $redirect .= ($user->page['page_dir']) ? $user->page['page_dir'] . '/' : '';
} }
@ -2384,24 +2395,47 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa
'U_PRIVACY' => append_sid('ucp', 'mode=privacy'), 'U_PRIVACY' => append_sid('ucp', 'mode=privacy'),
'S_DISPLAY_FULL_LOGIN' => ($s_display) ? true : false, 'S_DISPLAY_FULL_LOGIN' => ($s_display) ? true : false,
'S_LOGIN_ACTION' => (!$admin) ? append_sid('ucp', 'mode=login') : append_sid(PHPBB_ADMIN_PATH . 'index.' . PHP_EXT, false, true, $user->session_id), 'S_LOGIN_ACTION' => (!$admin && !defined('ADMIN_START')) ? append_sid('ucp', 'mode=login') : append_sid(PHPBB_ADMIN_PATH . 'index.' . PHP_EXT, false, true, $user->session_id),
'S_HIDDEN_FIELDS' => $s_hidden_fields, 'S_HIDDEN_FIELDS' => $s_hidden_fields,
'S_ADMIN_AUTH' => $admin, 'S_ADMIN_AUTH' => $admin,
'S_ACP_LOGIN' => defined('ADMIN_START'),
'USERNAME' => ($admin) ? $user->data['username'] : '', 'USERNAME' => ($admin) ? $user->data['username'] : '',
'USERNAME_CREDENTIAL' => 'username', 'USERNAME_CREDENTIAL' => 'username',
'PASSWORD_CREDENTIAL' => ($admin) ? 'password_' . $credential : 'password', 'PASSWORD_CREDENTIAL' => ($admin) ? 'password_' . $credential : 'password',
)); ));
page_header($user->lang['LOGIN'], false); if (defined('ADMIN_START'))
{
$template->set_filenames(array( $template->set_filenames(array(
'body' => 'login_body.html') 'body' => 'acp_login.html')
); );
$template->assign_block_vars('t_block1', array(
'L_TITLE' => $user->lang['LOGIN'],
'S_SELECTED' => true,
'U_TITLE' => '',
));
adm_page_header($user->lang['LOGIN'], false);
}
else
{
$template->set_filenames(array(
'body' => 'login_body.html')
);
page_header($user->lang['LOGIN'], false);
}
make_jumpbox(append_sid('viewforum')); make_jumpbox(append_sid('viewforum'));
if (defined('ADMIN_START') && isset($user->data['session_admin']) && $user->data['session_admin'])
page_footer(); {
adm_page_footer();
}
else
{
page_footer();
}
} }
/** /**
@ -3003,7 +3037,7 @@ function msg_handler($errno, $msg_text, $errfile, $errline)
if (!defined('HEADER_INC')) if (!defined('HEADER_INC'))
{ {
if (defined('IN_ADMIN') && isset($user->data['session_admin']) && $user->data['session_admin']) if (defined('ADMIN_START') || (defined('IN_ADMIN') && isset($user->data['session_admin']) && $user->data['session_admin']))
{ {
adm_page_header($msg_title); adm_page_header($msg_title);
} }
@ -3027,7 +3061,7 @@ function msg_handler($errno, $msg_text, $errfile, $errline)
// We do not want the cron script to be called on error messages // We do not want the cron script to be called on error messages
define('IN_CRON', true); define('IN_CRON', true);
if (defined('IN_ADMIN') && isset($user->data['session_admin']) && $user->data['session_admin']) if (defined('ADMIN_START') || (defined('IN_ADMIN') && isset($user->data['session_admin']) && $user->data['session_admin']))
{ {
adm_page_footer(); adm_page_footer();
} }

View file

@ -1321,6 +1321,16 @@ class session
} }
return true; return true;
} }
function unset_admin()
{
global $db;
$sql = 'UPDATE ' . SESSIONS_TABLE . '
SET session_admin = 0
WHERE session_id = \'' . $db->sql_escape($this->session_id) . '\'';
$db->sql_query($sql);
}
} }

View file

@ -201,6 +201,9 @@ $lang = array_merge($lang, array(
'ADMIN_INDEX' => 'Admin index', 'ADMIN_INDEX' => 'Admin index',
'ADMIN_PANEL' => 'Administration Control Panel', 'ADMIN_PANEL' => 'Administration Control Panel',
'ADM_LOGOUT' => 'ACP Logout',
'ADM_LOGGED_OUT' => 'Successfully logged out from Administration Control Panel',
'BACK' => 'Back', 'BACK' => 'Back',
'COLOUR_SWATCH' => 'Web-safe colour swatch', 'COLOUR_SWATCH' => 'Web-safe colour swatch',
@ -236,6 +239,7 @@ $lang = array_merge($lang, array(
'LOOK_UP_FORUM' => 'Select a forum', 'LOOK_UP_FORUM' => 'Select a forum',
'LOOK_UP_FORUMS_EXPLAIN'=> 'You are able to select more than one forum.', 'LOOK_UP_FORUMS_EXPLAIN'=> 'You are able to select more than one forum.',
'LOGIN_REDIRECT' => 'You have been successfully logged in.',
'MANAGE' => 'Manage', 'MANAGE' => 'Manage',
'MENU_TOGGLE' => 'Hide or display the side menu', 'MENU_TOGGLE' => 'Hide or display the side menu',
'MOVE_DOWN' => 'Move down', 'MOVE_DOWN' => 'Move down',