|
|
ef5584 |
|
|
|
ef5584 |
/**
|
|
|
ef5584 |
*
|
|
|
ef5584 |
* @package ucp
|
|
|
ef5584 |
* @version $Id: ucp.php 8915 2008-09-23 13:30:52Z acydburn $
|
|
|
ef5584 |
* @copyright (c) 2005 phpBB Group
|
|
|
ef5584 |
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
|
|
ef5584 |
*
|
|
|
ef5584 |
*/
|
|
|
ef5584 |
|
|
|
ef5584 |
/**
|
|
|
ef5584 |
* @ignore
|
|
|
ef5584 |
*/
|
|
|
ef5584 |
define('IN_PHPBB', true);
|
|
|
ef5584 |
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
|
|
|
ef5584 |
$phpEx = substr(strrchr(__FILE__, '.'), 1);
|
|
|
ef5584 |
require($phpbb_root_path . 'common.' . $phpEx);
|
|
|
ef5584 |
require($phpbb_root_path . 'includes/functions_user.' . $phpEx);
|
|
|
ef5584 |
require($phpbb_root_path . 'includes/functions_module.' . $phpEx);
|
|
|
ef5584 |
|
|
|
ef5584 |
// Basic parameter data
|
|
|
ef5584 |
$id = request_var('i', '');
|
|
|
ef5584 |
$mode = request_var('mode', '');
|
|
|
ef5584 |
|
|
|
ef5584 |
if ($mode == 'login' || $mode == 'logout' || $mode == 'confirm')
|
|
|
ef5584 |
{
|
|
|
ef5584 |
define('IN_LOGIN', true);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
// Start session management
|
|
|
ef5584 |
$user->session_begin();
|
|
|
ef5584 |
$auth->acl($user->data);
|
|
|
ef5584 |
$user->setup('ucp');
|
|
|
ef5584 |
|
|
|
ef5584 |
// Setting a variable to let the style designer know where he is...
|
|
|
ef5584 |
$template->assign_var('S_IN_UCP', true);
|
|
|
ef5584 |
|
|
|
ef5584 |
$module = new p_master();
|
|
|
ef5584 |
$default = false;
|
|
|
ef5584 |
|
|
|
ef5584 |
// Basic "global" modes
|
|
|
ef5584 |
switch ($mode)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
case 'activate':
|
|
|
ef5584 |
$module->load('ucp', 'activate');
|
|
|
ef5584 |
$module->display($user->lang['UCP_ACTIVATE']);
|
|
|
ef5584 |
|
|
|
ef5584 |
redirect(append_sid("{$phpbb_root_path}index.$phpEx"));
|
|
|
ef5584 |
break;
|
|
|
ef5584 |
|
|
|
ef5584 |
case 'resend_act':
|
|
|
ef5584 |
$module->load('ucp', 'resend');
|
|
|
ef5584 |
$module->display($user->lang['UCP_RESEND']);
|
|
|
ef5584 |
break;
|
|
|
ef5584 |
|
|
|
ef5584 |
case 'sendpassword':
|
|
|
ef5584 |
$module->load('ucp', 'remind');
|
|
|
ef5584 |
$module->display($user->lang['UCP_REMIND']);
|
|
|
ef5584 |
break;
|
|
|
ef5584 |
|
|
|
ef5584 |
case 'register':
|
|
|
ef5584 |
if ($user->data['is_registered'] || isset($_REQUEST['not_agreed']))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
redirect(append_sid("{$phpbb_root_path}index.$phpEx"));
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$module->load('ucp', 'register');
|
|
|
ef5584 |
$module->display($user->lang['REGISTER']);
|
|
|
ef5584 |
break;
|
|
|
ef5584 |
|
|
|
ef5584 |
case 'confirm':
|
|
|
ef5584 |
$module->load('ucp', 'confirm');
|
|
|
ef5584 |
break;
|
|
|
ef5584 |
|
|
|
ef5584 |
case 'login':
|
|
|
ef5584 |
if ($user->data['is_registered'])
|
|
|
ef5584 |
{
|
|
|
ef5584 |
redirect(append_sid("{$phpbb_root_path}index.$phpEx"));
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
login_box(request_var('redirect', "index.$phpEx"));
|
|
|
ef5584 |
break;
|
|
|
ef5584 |
|
|
|
ef5584 |
case 'logout':
|
|
|
ef5584 |
if ($user->data['user_id'] != ANONYMOUS && isset($_GET['sid']) && !is_array($_GET['sid']) && $_GET['sid'] === $user->session_id)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$user->session_kill();
|
|
|
ef5584 |
$user->session_begin();
|
|
|
ef5584 |
$message = $user->lang['LOGOUT_REDIRECT'];
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$message = ($user->data['user_id'] == ANONYMOUS) ? $user->lang['LOGOUT_REDIRECT'] : $user->lang['LOGOUT_FAILED'];
|
|
|
ef5584 |
}
|
|
|
ef5584 |
meta_refresh(3, append_sid("{$phpbb_root_path}index.$phpEx"));
|
|
|
ef5584 |
|
|
|
ef5584 |
$message = $message . '
' . sprintf($user->lang['RETURN_INDEX'], '', ' ');
|
|
|
ef5584 |
trigger_error($message);
|
|
|
ef5584 |
|
|
|
ef5584 |
break;
|
|
|
ef5584 |
|
|
|
ef5584 |
case 'terms':
|
|
|
ef5584 |
case 'privacy':
|
|
|
ef5584 |
|
|
|
ef5584 |
$message = ($mode == 'terms') ? 'TERMS_OF_USE_CONTENT' : 'PRIVACY_POLICY';
|
|
|
ef5584 |
$title = ($mode == 'terms') ? 'TERMS_USE' : 'PRIVACY';
|
|
|
ef5584 |
|
|
|
ef5584 |
if (empty($user->lang[$message]))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
if ($user->data['is_registered'])
|
|
|
ef5584 |
{
|
|
|
ef5584 |
redirect(append_sid("{$phpbb_root_path}index.$phpEx"));
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
login_box();
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$template->set_filenames(array(
|
|
|
ef5584 |
'body' => 'ucp_agreement.html')
|
|
|
ef5584 |
);
|
|
|
ef5584 |
|
|
|
ef5584 |
// Disable online list
|
|
|
ef5584 |
page_header($user->lang[$title], false);
|
|
|
ef5584 |
|
|
|
ef5584 |
$template->assign_vars(array(
|
|
|
ef5584 |
'S_AGREEMENT' => true,
|
|
|
ef5584 |
'AGREEMENT_TITLE' => $user->lang[$title],
|
|
|
ef5584 |
'AGREEMENT_TEXT' => sprintf($user->lang[$message], $config['sitename'], generate_board_url()),
|
|
|
ef5584 |
'U_BACK' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login'),
|
|
|
ef5584 |
'L_BACK' => $user->lang['BACK_TO_LOGIN'])
|
|
|
ef5584 |
);
|
|
|
ef5584 |
|
|
|
ef5584 |
page_footer();
|
|
|
ef5584 |
|
|
|
ef5584 |
break;
|
|
|
ef5584 |
|
|
|
ef5584 |
case 'delete_cookies':
|
|
|
ef5584 |
|
|
|
ef5584 |
// Delete Cookies with dynamic names (do NOT delete poll cookies)
|
|
|
ef5584 |
if (confirm_box(true))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$set_time = time() - 31536000;
|
|
|
ef5584 |
|
|
|
ef5584 |
foreach ($_COOKIE as $cookie_name => $cookie_data)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$cookie_name = str_replace($config['cookie_name'] . '_', '', $cookie_name);
|
|
|
ef5584 |
|
|
|
ef5584 |
// Polls are stored as {cookie_name}_poll_{topic_id}, cookie_name_ got removed, therefore checking for poll_
|
|
|
ef5584 |
if (strpos($cookie_name, 'poll_') !== 0)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$user->set_cookie($cookie_name, '', $set_time);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$user->set_cookie('track', '', $set_time);
|
|
|
ef5584 |
$user->set_cookie('u', '', $set_time);
|
|
|
ef5584 |
$user->set_cookie('k', '', $set_time);
|
|
|
ef5584 |
$user->set_cookie('sid', '', $set_time);
|
|
|
ef5584 |
|
|
|
ef5584 |
// We destroy the session here, the user will be logged out nevertheless
|
|
|
ef5584 |
$user->session_kill();
|
|
|
ef5584 |
$user->session_begin();
|
|
|
ef5584 |
|
|
|
ef5584 |
meta_refresh(3, append_sid("{$phpbb_root_path}index.$phpEx"));
|
|
|
ef5584 |
|
|
|
ef5584 |
$message = $user->lang['COOKIES_DELETED'] . '
' . sprintf($user->lang['RETURN_INDEX'], '', '');
|
|
|
ef5584 |
trigger_error($message);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else
|
|
|
ef5584 |
{
|
|
|
ef5584 |
confirm_box(false, 'DELETE_COOKIES', '');
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
redirect(append_sid("{$phpbb_root_path}index.$phpEx"));
|
|
|
ef5584 |
|
|
|
ef5584 |
break;
|
|
|
ef5584 |
|
|
|
ef5584 |
case 'switch_perm':
|
|
|
ef5584 |
|
|
|
ef5584 |
$user_id = request_var('u', 0);
|
|
|
ef5584 |
|
|
|
ef5584 |
$sql = 'SELECT *
|
|
|
ef5584 |
FROM ' . USERS_TABLE . '
|
|
|
ef5584 |
WHERE user_id = ' . (int) $user_id;
|
|
|
ef5584 |
$result = $db->sql_query($sql);
|
|
|
ef5584 |
$user_row = $db->sql_fetchrow($result);
|
|
|
ef5584 |
$db->sql_freeresult($result);
|
|
|
ef5584 |
|
|
|
ef5584 |
if (!$auth->acl_get('a_switchperm') || !$user_row || $user_id == $user->data['user_id'])
|
|
|
ef5584 |
{
|
|
|
ef5584 |
redirect(append_sid("{$phpbb_root_path}index.$phpEx"));
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
include($phpbb_root_path . 'includes/acp/auth.' . $phpEx);
|
|
|
ef5584 |
|
|
|
ef5584 |
$auth_admin = new auth_admin();
|
|
|
ef5584 |
if (!$auth_admin->ghost_permissions($user_id, $user->data['user_id']))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
redirect(append_sid("{$phpbb_root_path}index.$phpEx"));
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
add_log('admin', 'LOG_ACL_TRANSFER_PERMISSIONS', $user_row['username']);
|
|
|
ef5584 |
|
|
|
ef5584 |
$message = sprintf($user->lang['PERMISSIONS_TRANSFERRED'], $user_row['username']) . '
' . sprintf($user->lang['RETURN_INDEX'], '', '');
|
|
|
ef5584 |
trigger_error($message);
|
|
|
ef5584 |
|
|
|
ef5584 |
break;
|
|
|
ef5584 |
|
|
|
ef5584 |
case 'restore_perm':
|
|
|
ef5584 |
|
|
|
ef5584 |
if (!$user->data['user_perm_from'] || !$auth->acl_get('a_switchperm'))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
redirect(append_sid("{$phpbb_root_path}index.$phpEx"));
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$auth->acl_cache($user->data);
|
|
|
ef5584 |
|
|
|
ef5584 |
$sql = 'UPDATE ' . USERS_TABLE . "
|
|
|
ef5584 |
SET user_perm_from = 0
|
|
|
ef5584 |
WHERE user_id = " . $user->data['user_id'];
|
|
|
ef5584 |
$db->sql_query($sql);
|
|
|
ef5584 |
|
|
|
ef5584 |
$sql = 'SELECT username
|
|
|
ef5584 |
FROM ' . USERS_TABLE . '
|
|
|
ef5584 |
WHERE user_id = ' . $user->data['user_perm_from'];
|
|
|
ef5584 |
$result = $db->sql_query($sql);
|
|
|
ef5584 |
$username = $db->sql_fetchfield('username');
|
|
|
ef5584 |
$db->sql_freeresult($result);
|
|
|
ef5584 |
|
|
|
ef5584 |
add_log('admin', 'LOG_ACL_RESTORE_PERMISSIONS', $username);
|
|
|
ef5584 |
|
|
|
ef5584 |
$message = $user->lang['PERMISSIONS_RESTORED'] . '
' . sprintf($user->lang['RETURN_INDEX'], '', '');
|
|
|
ef5584 |
trigger_error($message);
|
|
|
ef5584 |
|
|
|
ef5584 |
break;
|
|
|
ef5584 |
|
|
|
ef5584 |
default:
|
|
|
ef5584 |
$default = true;
|
|
|
ef5584 |
break;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
// We use this approach because it does not impose large code changes
|
|
|
ef5584 |
if (!$default)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
return true;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
// Only registered users can go beyond this point
|
|
|
ef5584 |
if (!$user->data['is_registered'])
|
|
|
ef5584 |
{
|
|
|
ef5584 |
if ($user->data['is_bot'])
|
|
|
ef5584 |
{
|
|
|
ef5584 |
redirect(append_sid("{$phpbb_root_path}index.$phpEx"));
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
login_box('', $user->lang['LOGIN_EXPLAIN_UCP']);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
// Instantiate module system and generate list of available modules
|
|
|
ef5584 |
$module->list_modules('ucp');
|
|
|
ef5584 |
|
|
|
ef5584 |
// Check if the zebra module is set
|
|
|
ef5584 |
if ($module->is_active('zebra', 'friends'))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
// Output listing of friends online
|
|
|
ef5584 |
$update_time = $config['load_online_time'] * 60;
|
|
|
ef5584 |
|
|
|
ef5584 |
$sql = $db->sql_build_query('SELECT_DISTINCT', array(
|
|
|
ef5584 |
'SELECT' => 'u.user_id, u.username, u.username_clean, u.user_colour, MAX(s.session_time) as online_time, MIN(s.session_viewonline) AS viewonline',
|
|
|
ef5584 |
|
|
|
ef5584 |
'FROM' => array(
|
|
|
ef5584 |
USERS_TABLE => 'u',
|
|
|
ef5584 |
ZEBRA_TABLE => 'z'
|
|
|
ef5584 |
),
|
|
|
ef5584 |
|
|
|
ef5584 |
'LEFT_JOIN' => array(
|
|
|
ef5584 |
array(
|
|
|
ef5584 |
'FROM' => array(SESSIONS_TABLE => 's'),
|
|
|
ef5584 |
'ON' => 's.session_user_id = z.zebra_id'
|
|
|
ef5584 |
)
|
|
|
ef5584 |
),
|
|
|
ef5584 |
|
|
|
ef5584 |
'WHERE' => 'z.user_id = ' . $user->data['user_id'] . '
|
|
|
ef5584 |
AND z.friend = 1
|
|
|
ef5584 |
AND u.user_id = z.zebra_id',
|
|
|
ef5584 |
|
|
|
ef5584 |
'GROUP_BY' => 'z.zebra_id, u.user_id, u.username_clean, u.user_colour, u.username',
|
|
|
ef5584 |
|
|
|
ef5584 |
'ORDER_BY' => 'u.username_clean ASC',
|
|
|
ef5584 |
));
|
|
|
ef5584 |
|
|
|
ef5584 |
$result = $db->sql_query($sql);
|
|
|
ef5584 |
|
|
|
ef5584 |
while ($row = $db->sql_fetchrow($result))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$which = (time() - $update_time < $row['online_time'] && ($row['viewonline'] || $auth->acl_get('u_viewonline'))) ? 'online' : 'offline';
|
|
|
ef5584 |
|
|
|
ef5584 |
$template->assign_block_vars("friends_{$which}", array(
|
|
|
ef5584 |
'USER_ID' => $row['user_id'],
|
|
|
ef5584 |
|
|
|
ef5584 |
'U_PROFILE' => get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour']),
|
|
|
ef5584 |
'USER_COLOUR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']),
|
|
|
ef5584 |
'USERNAME' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']),
|
|
|
ef5584 |
'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']))
|
|
|
ef5584 |
);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
$db->sql_freeresult($result);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
// Do not display subscribed topics/forums if not allowed
|
|
|
ef5584 |
if (!$config['allow_topic_notify'] && !$config['allow_forum_notify'])
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$module->set_display('main', 'subscribed', false);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
// Select the active module
|
|
|
ef5584 |
$module->set_active($id, $mode);
|
|
|
ef5584 |
|
|
|
ef5584 |
// Load and execute the relevant module
|
|
|
ef5584 |
$module->load_active();
|
|
|
ef5584 |
|
|
|
ef5584 |
// Assign data to the template engine for the list of modules
|
|
|
ef5584 |
$module->assign_tpl_vars(append_sid("{$phpbb_root_path}ucp.$phpEx"));
|
|
|
ef5584 |
|
|
|
ef5584 |
// Generate the page, do not display/query online list
|
|
|
ef5584 |
$module->display($module->get_page_title(), false);
|
|
|
ef5584 |
|
|
|
ef5584 |
/**
|
|
|
ef5584 |
* Function for assigning a template var if the zebra module got included
|
|
|
ef5584 |
*/
|
|
|
ef5584 |
function _module_zebra($mode, &$module_row)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
global $template;
|
|
|
ef5584 |
|
|
|
ef5584 |
$template->assign_var('S_ZEBRA_ENABLED', true);
|
|
|
ef5584 |
|
|
|
ef5584 |
if ($mode == 'friends')
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$template->assign_var('S_ZEBRA_FRIENDS_ENABLED', true);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
if ($mode == 'foes')
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$template->assign_var('S_ZEBRA_FOES_ENABLED', true);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
?>
|