root / trunk / phpBB / ucp.php
History | View | Annotate | Download (9.3 KB)
| 1 | 4950 | psotfx | <?php
|
|---|---|---|---|
| 2 | 8146 | acydburn | /**
|
| 3 | 5114 | acydburn | * |
| 4 | 5114 | acydburn | * @package ucp |
| 5 | 5114 | acydburn | * @version $Id$ |
| 6 | 8146 | acydburn | * @copyright (c) 2005 phpBB Group |
| 7 | 8146 | acydburn | * @license http://opensource.org/licenses/gpl-license.php GNU Public License |
| 8 | 5114 | acydburn | * |
| 9 | 5114 | acydburn | */ |
| 10 | 3075 | thefinn | |
| 11 | 5114 | acydburn | /**
|
| 12 | 5883 | acydburn | * @ignore |
| 13 | 5114 | acydburn | */ |
| 14 | 3075 | thefinn | define('IN_PHPBB', true); |
| 15 | 7954 | acydburn | $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './'; |
| 16 | 4473 | psotfx | $phpEx = substr(strrchr(__FILE__, '.'), 1); |
| 17 | 6015 | acydburn | require($phpbb_root_path . 'common.' . $phpEx); |
| 18 | 6015 | acydburn | require($phpbb_root_path . 'includes/functions_user.' . $phpEx); |
| 19 | 6015 | acydburn | require($phpbb_root_path . 'includes/functions_module.' . $phpEx); |
| 20 | 4906 | acydburn | |
| 21 | 4950 | psotfx | // Basic parameter data
|
| 22 | 5254 | acydburn | $id = request_var('i', ''); |
| 23 | 4950 | psotfx | $mode = request_var('mode', ''); |
| 24 | 4950 | psotfx | |
| 25 | 6892 | davidmj | if ($mode == 'login' || $mode == 'logout' || $mode == 'confirm') |
| 26 | 4906 | acydburn | {
|
| 27 | 4906 | acydburn | define('IN_LOGIN', true); |
| 28 | 4906 | acydburn | } |
| 29 | 3075 | thefinn | |
| 30 | 4950 | psotfx | // Start session management
|
| 31 | 5254 | acydburn | $user->session_begin(); |
| 32 | 4950 | psotfx | $auth->acl($user->data); |
| 33 | 4950 | psotfx | $user->setup('ucp');
|
| 34 | 4950 | psotfx | |
| 35 | 6104 | acydburn | // Setting a variable to let the style designer know where he is...
|
| 36 | 6104 | acydburn | $template->assign_var('S_IN_UCP', true); |
| 37 | 6104 | acydburn | |
| 38 | 5254 | acydburn | $module = new p_master();
|
| 39 | 8915 | acydburn | $default = false;
|
| 40 | 4950 | psotfx | |
| 41 | 4020 | psotfx | // Basic "global" modes
|
| 42 | 4003 | psotfx | switch ($mode)
|
| 43 | 4003 | psotfx | {
|
| 44 | 4003 | psotfx | case 'activate': |
| 45 | 5254 | acydburn | $module->load('ucp', 'activate'); |
| 46 | 5254 | acydburn | $module->display($user->lang['UCP_ACTIVATE']);
|
| 47 | 5790 | acydburn | |
| 48 | 6015 | acydburn | redirect(append_sid("{$phpbb_root_path}index.$phpEx"));
|
| 49 | 5254 | acydburn | break;
|
| 50 | 5254 | acydburn | |
| 51 | 5114 | acydburn | case 'resend_act': |
| 52 | 5254 | acydburn | $module->load('ucp', 'resend'); |
| 53 | 5254 | acydburn | $module->display($user->lang['UCP_RESEND']);
|
| 54 | 5254 | acydburn | break;
|
| 55 | 5114 | acydburn | |
| 56 | 4583 | psotfx | case 'sendpassword': |
| 57 | 5254 | acydburn | $module->load('ucp', 'remind'); |
| 58 | 5254 | acydburn | $module->display($user->lang['UCP_REMIND']);
|
| 59 | 5254 | acydburn | break;
|
| 60 | 4020 | psotfx | |
| 61 | 4003 | psotfx | case 'register': |
| 62 | 5117 | acydburn | if ($user->data['is_registered'] || isset($_REQUEST['not_agreed'])) |
| 63 | 4003 | psotfx | {
|
| 64 | 6015 | acydburn | redirect(append_sid("{$phpbb_root_path}index.$phpEx"));
|
| 65 | 4003 | psotfx | } |
| 66 | 3650 | psotfx | |
| 67 | 5254 | acydburn | $module->load('ucp', 'register'); |
| 68 | 5378 | subblue | $module->display($user->lang['REGISTER']);
|
| 69 | 5254 | acydburn | break;
|
| 70 | 3650 | psotfx | |
| 71 | 4020 | psotfx | case 'confirm': |
| 72 | 5254 | acydburn | $module->load('ucp', 'confirm'); |
| 73 | 5254 | acydburn | break;
|
| 74 | 5254 | acydburn | |
| 75 | 4003 | psotfx | case 'login': |
| 76 | 5117 | acydburn | if ($user->data['is_registered']) |
| 77 | 4003 | psotfx | {
|
| 78 | 6015 | acydburn | redirect(append_sid("{$phpbb_root_path}index.$phpEx"));
|
| 79 | 4003 | psotfx | } |
| 80 | 3650 | psotfx | |
| 81 | 6832 | naderman | login_box(request_var('redirect', "index.$phpEx")); |
| 82 | 5494 | acydburn | break;
|
| 83 | 4003 | psotfx | |
| 84 | 4003 | psotfx | case 'logout': |
| 85 | 7966 | acydburn | if ($user->data['user_id'] != ANONYMOUS && isset($_GET['sid']) && !is_array($_GET['sid']) && $_GET['sid'] === $user->session_id) |
| 86 | 7593 | acydburn | {
|
| 87 | 7593 | acydburn | $user->session_kill(); |
| 88 | 7593 | acydburn | $user->session_begin(); |
| 89 | 7593 | acydburn | $message = $user->lang['LOGOUT_REDIRECT'];
|
| 90 | 7593 | acydburn | } |
| 91 | 7593 | acydburn | else
|
| 92 | 7593 | acydburn | {
|
| 93 | 7593 | acydburn | $message = ($user->data['user_id'] == ANONYMOUS) ? $user->lang['LOGOUT_REDIRECT'] : $user->lang['LOGOUT_FAILED']; |
| 94 | 7593 | acydburn | } |
| 95 | 7593 | acydburn | meta_refresh(3, append_sid("{$phpbb_root_path}index.$phpEx")); |
| 96 | 8655 | acydburn | |
| 97 | 7593 | acydburn | $message = $message . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid("{$phpbb_root_path}index.$phpEx") . '">', '</a> '); |
| 98 | 7593 | acydburn | trigger_error($message); |
| 99 | 7593 | acydburn | |
| 100 | 5494 | acydburn | break;
|
| 101 | 4904 | acydburn | |
| 102 | 5650 | acydburn | case 'terms': |
| 103 | 5650 | acydburn | case 'privacy': |
| 104 | 5650 | acydburn | |
| 105 | 5650 | acydburn | $message = ($mode == 'terms') ? 'TERMS_OF_USE_CONTENT' : 'PRIVACY_POLICY'; |
| 106 | 5650 | acydburn | $title = ($mode == 'terms') ? 'TERMS_USE' : 'PRIVACY'; |
| 107 | 5650 | acydburn | |
| 108 | 5650 | acydburn | if (empty($user->lang[$message])) |
| 109 | 5650 | acydburn | {
|
| 110 | 5650 | acydburn | if ($user->data['is_registered']) |
| 111 | 5650 | acydburn | {
|
| 112 | 6015 | acydburn | redirect(append_sid("{$phpbb_root_path}index.$phpEx"));
|
| 113 | 5650 | acydburn | } |
| 114 | 6015 | acydburn | |
| 115 | 5881 | acydburn | login_box(); |
| 116 | 5650 | acydburn | } |
| 117 | 5650 | acydburn | |
| 118 | 5650 | acydburn | $template->set_filenames(array(
|
| 119 | 5650 | acydburn | 'body' => 'ucp_agreement.html') |
| 120 | 5650 | acydburn | ); |
| 121 | 5650 | acydburn | |
| 122 | 6054 | acydburn | // Disable online list
|
| 123 | 6054 | acydburn | page_header($user->lang[$title], false);
|
| 124 | 5650 | acydburn | |
| 125 | 5650 | acydburn | $template->assign_vars(array(
|
| 126 | 5650 | acydburn | 'S_AGREEMENT' => true, |
| 127 | 5650 | acydburn | 'AGREEMENT_TITLE' => $user->lang[$title],
|
| 128 | 5662 | acydburn | 'AGREEMENT_TEXT' => sprintf($user->lang[$message], $config['sitename'], generate_board_url()), |
| 129 | 6015 | acydburn | 'U_BACK' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login'), |
| 130 | 9668 | acydburn | 'L_BACK' => $user->lang['BACK_TO_LOGIN'], |
| 131 | 9668 | acydburn | )); |
| 132 | 6015 | acydburn | |
| 133 | 5650 | acydburn | page_footer(); |
| 134 | 5650 | acydburn | |
| 135 | 5494 | acydburn | break;
|
| 136 | 5114 | acydburn | |
| 137 | 4904 | acydburn | case 'delete_cookies': |
| 138 | 8655 | acydburn | |
| 139 | 4904 | acydburn | // Delete Cookies with dynamic names (do NOT delete poll cookies)
|
| 140 | 4912 | acydburn | if (confirm_box(true)) |
| 141 | 4904 | acydburn | {
|
| 142 | 4912 | acydburn | $set_time = time() - 31536000;
|
| 143 | 6015 | acydburn | |
| 144 | 4912 | acydburn | foreach ($_COOKIE as $cookie_name => $cookie_data) |
| 145 | 4904 | acydburn | {
|
| 146 | 10090 | acydburn | // Only delete board cookies, no other ones...
|
| 147 | 10090 | acydburn | if (strpos($cookie_name, $config['cookie_name'] . '_') !== 0) |
| 148 | 10090 | acydburn | {
|
| 149 | 10090 | acydburn | continue;
|
| 150 | 10090 | acydburn | } |
| 151 | 10090 | acydburn | |
| 152 | 4912 | acydburn | $cookie_name = str_replace($config['cookie_name'] . '_', '', $cookie_name); |
| 153 | 6851 | acydburn | |
| 154 | 6851 | acydburn | // Polls are stored as {cookie_name}_poll_{topic_id}, cookie_name_ got removed, therefore checking for poll_
|
| 155 | 6851 | acydburn | if (strpos($cookie_name, 'poll_') !== 0) |
| 156 | 4912 | acydburn | {
|
| 157 | 4912 | acydburn | $user->set_cookie($cookie_name, '', $set_time);
|
| 158 | 4912 | acydburn | } |
| 159 | 4904 | acydburn | } |
| 160 | 6015 | acydburn | |
| 161 | 4912 | acydburn | $user->set_cookie('track', '', $set_time); |
| 162 | 5183 | psotfx | $user->set_cookie('u', '', $set_time); |
| 163 | 5183 | psotfx | $user->set_cookie('k', '', $set_time); |
| 164 | 4912 | acydburn | $user->set_cookie('sid', '', $set_time); |
| 165 | 4904 | acydburn | |
| 166 | 4912 | acydburn | // We destroy the session here, the user will be logged out nevertheless
|
| 167 | 5199 | acydburn | $user->session_kill(); |
| 168 | 5429 | subblue | $user->session_begin(); |
| 169 | 4904 | acydburn | |
| 170 | 6015 | acydburn | meta_refresh(3, append_sid("{$phpbb_root_path}index.$phpEx")); |
| 171 | 4904 | acydburn | |
| 172 | 6015 | acydburn | $message = $user->lang['COOKIES_DELETED'] . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid("{$phpbb_root_path}index.$phpEx") . '">', '</a>'); |
| 173 | 4912 | acydburn | trigger_error($message); |
| 174 | 4912 | acydburn | } |
| 175 | 4912 | acydburn | else
|
| 176 | 4912 | acydburn | {
|
| 177 | 4912 | acydburn | confirm_box(false, 'DELETE_COOKIES', ''); |
| 178 | 4912 | acydburn | } |
| 179 | 5595 | acydburn | |
| 180 | 6015 | acydburn | redirect(append_sid("{$phpbb_root_path}index.$phpEx"));
|
| 181 | 6015 | acydburn | |
| 182 | 5494 | acydburn | break;
|
| 183 | 5790 | acydburn | |
| 184 | 5790 | acydburn | case 'switch_perm': |
| 185 | 5790 | acydburn | |
| 186 | 5790 | acydburn | $user_id = request_var('u', 0); |
| 187 | 5790 | acydburn | |
| 188 | 5790 | acydburn | $sql = 'SELECT *
|
| 189 | 5790 | acydburn | FROM ' . USERS_TABLE . ' |
| 190 | 5790 | acydburn | WHERE user_id = ' . (int) $user_id;
|
| 191 | 5790 | acydburn | $result = $db->sql_query($sql); |
| 192 | 5790 | acydburn | $user_row = $db->sql_fetchrow($result); |
| 193 | 5790 | acydburn | $db->sql_freeresult($result); |
| 194 | 5790 | acydburn | |
| 195 | 9915 | Kellanved | if (!$auth->acl_get('a_switchperm') || !$user_row || $user_id == $user->data['user_id'] || !check_link_hash(request_var('hash', ''), 'switchperm')) |
| 196 | 5790 | acydburn | {
|
| 197 | 6015 | acydburn | redirect(append_sid("{$phpbb_root_path}index.$phpEx"));
|
| 198 | 5790 | acydburn | } |
| 199 | 5790 | acydburn | |
| 200 | 5790 | acydburn | include($phpbb_root_path . 'includes/acp/auth.' . $phpEx); |
| 201 | 5790 | acydburn | |
| 202 | 5790 | acydburn | $auth_admin = new auth_admin();
|
| 203 | 5790 | acydburn | if (!$auth_admin->ghost_permissions($user_id, $user->data['user_id'])) |
| 204 | 5790 | acydburn | {
|
| 205 | 6015 | acydburn | redirect(append_sid("{$phpbb_root_path}index.$phpEx"));
|
| 206 | 5790 | acydburn | } |
| 207 | 5790 | acydburn | |
| 208 | 6015 | acydburn | add_log('admin', 'LOG_ACL_TRANSFER_PERMISSIONS', $user_row['username']); |
| 209 | 5790 | acydburn | |
| 210 | 6915 | acydburn | $message = sprintf($user->lang['PERMISSIONS_TRANSFERRED'], $user_row['username']) . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid("{$phpbb_root_path}index.$phpEx") . '">', '</a>'); |
| 211 | 5790 | acydburn | trigger_error($message); |
| 212 | 5790 | acydburn | |
| 213 | 5790 | acydburn | break;
|
| 214 | 5790 | acydburn | |
| 215 | 5790 | acydburn | case 'restore_perm': |
| 216 | 5790 | acydburn | |
| 217 | 5790 | acydburn | if (!$user->data['user_perm_from'] || !$auth->acl_get('a_switchperm')) |
| 218 | 5790 | acydburn | {
|
| 219 | 6015 | acydburn | redirect(append_sid("{$phpbb_root_path}index.$phpEx"));
|
| 220 | 5790 | acydburn | } |
| 221 | 5790 | acydburn | |
| 222 | 5790 | acydburn | $auth->acl_cache($user->data); |
| 223 | 5790 | acydburn | |
| 224 | 5790 | acydburn | $sql = 'SELECT username
|
| 225 | 5790 | acydburn | FROM ' . USERS_TABLE . ' |
| 226 | 5790 | acydburn | WHERE user_id = ' . $user->data['user_perm_from']; |
| 227 | 5790 | acydburn | $result = $db->sql_query($sql); |
| 228 | 5790 | acydburn | $username = $db->sql_fetchfield('username');
|
| 229 | 5790 | acydburn | $db->sql_freeresult($result); |
| 230 | 5790 | acydburn | |
| 231 | 5790 | acydburn | add_log('admin', 'LOG_ACL_RESTORE_PERMISSIONS', $username); |
| 232 | 5790 | acydburn | |
| 233 | 6015 | acydburn | $message = $user->lang['PERMISSIONS_RESTORED'] . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid("{$phpbb_root_path}index.$phpEx") . '">', '</a>'); |
| 234 | 5790 | acydburn | trigger_error($message); |
| 235 | 5790 | acydburn | |
| 236 | 5790 | acydburn | break;
|
| 237 | 8915 | acydburn | |
| 238 | 8915 | acydburn | default:
|
| 239 | 8915 | acydburn | $default = true;
|
| 240 | 8915 | acydburn | break;
|
| 241 | 3431 | thefinn | } |
| 242 | 3075 | thefinn | |
| 243 | 8915 | acydburn | // We use this approach because it does not impose large code changes
|
| 244 | 8915 | acydburn | if (!$default)
|
| 245 | 8915 | acydburn | {
|
| 246 | 8915 | acydburn | return true; |
| 247 | 8915 | acydburn | } |
| 248 | 8915 | acydburn | |
| 249 | 4003 | psotfx | // Only registered users can go beyond this point
|
| 250 | 5117 | acydburn | if (!$user->data['is_registered']) |
| 251 | 4003 | psotfx | {
|
| 252 | 5117 | acydburn | if ($user->data['is_bot']) |
| 253 | 4903 | acydburn | {
|
| 254 | 6015 | acydburn | redirect(append_sid("{$phpbb_root_path}index.$phpEx"));
|
| 255 | 4903 | acydburn | } |
| 256 | 4950 | psotfx | |
| 257 | 4970 | psotfx | login_box('', $user->lang['LOGIN_EXPLAIN_UCP']); |
| 258 | 4003 | psotfx | } |
| 259 | 3650 | psotfx | |
| 260 | 7229 | davidmj | // Instantiate module system and generate list of available modules
|
| 261 | 7229 | davidmj | $module->list_modules('ucp');
|
| 262 | 3650 | psotfx | |
| 263 | 7229 | davidmj | // Check if the zebra module is set
|
| 264 | 7232 | acydburn | if ($module->is_active('zebra', 'friends')) |
| 265 | 7229 | davidmj | {
|
| 266 | 7229 | davidmj | // Output listing of friends online
|
| 267 | 7229 | davidmj | $update_time = $config['load_online_time'] * 60; |
| 268 | 5885 | davidmj | |
| 269 | 7229 | davidmj | $sql = $db->sql_build_query('SELECT_DISTINCT', array( |
| 270 | 7829 | kellanved | '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', |
| 271 | 5885 | davidmj | |
| 272 | 7229 | davidmj | 'FROM' => array( |
| 273 | 7229 | davidmj | USERS_TABLE => 'u',
|
| 274 | 7229 | davidmj | ZEBRA_TABLE => 'z'
|
| 275 | 7229 | davidmj | ), |
| 276 | 5885 | davidmj | |
| 277 | 7229 | davidmj | 'LEFT_JOIN' => array( |
| 278 | 7229 | davidmj | array(
|
| 279 | 7229 | davidmj | 'FROM' => array(SESSIONS_TABLE => 's'), |
| 280 | 7229 | davidmj | 'ON' => 's.session_user_id = z.zebra_id' |
| 281 | 7229 | davidmj | ) |
| 282 | 7229 | davidmj | ), |
| 283 | 5885 | davidmj | |
| 284 | 7229 | davidmj | 'WHERE' => 'z.user_id = ' . $user->data['user_id'] . ' |
| 285 | 7229 | davidmj | AND z.friend = 1 |
| 286 | 7229 | davidmj | AND u.user_id = z.zebra_id',
|
| 287 | 5957 | acydburn | |
| 288 | 7828 | kellanved | 'GROUP_BY' => 'z.zebra_id, u.user_id, u.username_clean, u.user_colour, u.username', |
| 289 | 5885 | davidmj | |
| 290 | 7229 | davidmj | 'ORDER_BY' => 'u.username_clean ASC', |
| 291 | 7229 | davidmj | )); |
| 292 | 3431 | thefinn | |
| 293 | 7229 | davidmj | $result = $db->sql_query($sql); |
| 294 | 3996 | psotfx | |
| 295 | 7229 | davidmj | while ($row = $db->sql_fetchrow($result))
|
| 296 | 7229 | davidmj | {
|
| 297 | 7828 | kellanved | $which = (time() - $update_time < $row['online_time'] && ($row['viewonline'] || $auth->acl_get('u_viewonline'))) ? 'online' : 'offline'; |
| 298 | 4950 | psotfx | |
| 299 | 7229 | davidmj | $template->assign_block_vars("friends_{$which}", array( |
| 300 | 7229 | davidmj | 'USER_ID' => $row['user_id'], |
| 301 | 7229 | davidmj | |
| 302 | 7229 | davidmj | 'U_PROFILE' => get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour']), |
| 303 | 7229 | davidmj | 'USER_COLOUR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']), |
| 304 | 7229 | davidmj | 'USERNAME' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']), |
| 305 | 7229 | davidmj | 'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'])) |
| 306 | 7229 | davidmj | ); |
| 307 | 7229 | davidmj | } |
| 308 | 7229 | davidmj | $db->sql_freeresult($result); |
| 309 | 3591 | thefinn | } |
| 310 | 3591 | thefinn | |
| 311 | 7426 | acydburn | // Do not display subscribed topics/forums if not allowed
|
| 312 | 7426 | acydburn | if (!$config['allow_topic_notify'] && !$config['allow_forum_notify']) |
| 313 | 7426 | acydburn | {
|
| 314 | 7426 | acydburn | $module->set_display('main', 'subscribed', false); |
| 315 | 7426 | acydburn | } |
| 316 | 7426 | acydburn | |
| 317 | 5254 | acydburn | // Select the active module
|
| 318 | 5254 | acydburn | $module->set_active($id, $mode); |
| 319 | 5254 | acydburn | |
| 320 | 4522 | psotfx | // Load and execute the relevant module
|
| 321 | 5254 | acydburn | $module->load_active(); |
| 322 | 4522 | psotfx | |
| 323 | 5254 | acydburn | // Assign data to the template engine for the list of modules
|
| 324 | 6015 | acydburn | $module->assign_tpl_vars(append_sid("{$phpbb_root_path}ucp.$phpEx"));
|
| 325 | 5254 | acydburn | |
| 326 | 6054 | acydburn | // Generate the page, do not display/query online list
|
| 327 | 6054 | acydburn | $module->display($module->get_page_title(), false);
|
| 328 | 5254 | acydburn | |
| 329 | 5767 | acydburn | /**
|
| 330 | 5767 | acydburn | * Function for assigning a template var if the zebra module got included |
| 331 | 5767 | acydburn | */ |
| 332 | 5767 | acydburn | function _module_zebra($mode, &$module_row)
|
| 333 | 5767 | acydburn | {
|
| 334 | 5767 | acydburn | global $template;
|
| 335 | 5767 | acydburn | |
| 336 | 5767 | acydburn | $template->assign_var('S_ZEBRA_ENABLED', true); |
| 337 | 7232 | acydburn | |
| 338 | 7232 | acydburn | if ($mode == 'friends') |
| 339 | 7232 | acydburn | {
|
| 340 | 7232 | acydburn | $template->assign_var('S_ZEBRA_FRIENDS_ENABLED', true); |
| 341 | 7232 | acydburn | } |
| 342 | 7232 | acydburn | |
| 343 | 7232 | acydburn | if ($mode == 'foes') |
| 344 | 7232 | acydburn | {
|
| 345 | 7232 | acydburn | $template->assign_var('S_ZEBRA_FOES_ENABLED', true); |
| 346 | 7232 | acydburn | } |
| 347 | 5767 | acydburn | } |
| 348 | 5767 | acydburn | |
| 349 | 3075 | thefinn | ?> |