root / branches / phpBB-3_0_0 / phpBB / includes / acp / acp_users.php
History | View | Annotate | Download (84 kB)
| 1 | <?php
|
|---|---|
| 2 | /**
|
| 3 | * |
| 4 | * @package acp |
| 5 | * @version $Id: acp_users.php 11643 2011-12-25 14:15:11Z git-gate $ |
| 6 | * @copyright (c) 2005 phpBB Group |
| 7 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License |
| 8 | * |
| 9 | */ |
| 10 | |
| 11 | /**
|
| 12 | * @ignore |
| 13 | */ |
| 14 | if (!defined('IN_PHPBB')) |
| 15 | {
|
| 16 | exit;
|
| 17 | } |
| 18 | |
| 19 | /**
|
| 20 | * @package acp |
| 21 | */ |
| 22 | class acp_users |
| 23 | {
|
| 24 | var $u_action; |
| 25 | var $p_master; |
| 26 | |
| 27 | function acp_users(&$p_master) |
| 28 | {
|
| 29 | $this->p_master = &$p_master; |
| 30 | } |
| 31 | |
| 32 | function main($id, $mode) |
| 33 | {
|
| 34 | global $config, $db, $user, $auth, $template, $cache; |
| 35 | global $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix, $file_uploads; |
| 36 | |
| 37 | $user->add_lang(array('posting', 'ucp', 'acp/users')); |
| 38 | $this->tpl_name = 'acp_users'; |
| 39 | $this->page_title = 'ACP_USER_' . strtoupper($mode); |
| 40 | |
| 41 | $error = array(); |
| 42 | $username = utf8_normalize_nfc(request_var('username', '', true)); |
| 43 | $user_id = request_var('u', 0); |
| 44 | $action = request_var('action', ''); |
| 45 | |
| 46 | $submit = (isset($_POST['update']) && !isset($_POST['cancel'])) ? true : false; |
| 47 | |
| 48 | $form_name = 'acp_users'; |
| 49 | add_form_key($form_name);
|
| 50 | |
| 51 | // Whois (special case)
|
| 52 | if ($action == 'whois') |
| 53 | {
|
| 54 | include($phpbb_root_path . 'includes/functions_user.' . $phpEx); |
| 55 | |
| 56 | $this->page_title = 'WHOIS'; |
| 57 | $this->tpl_name = 'simple_body'; |
| 58 | |
| 59 | $user_ip = request_var('user_ip', ''); |
| 60 | $domain = gethostbyaddr($user_ip); |
| 61 | $ipwhois = user_ipwhois($user_ip); |
| 62 | |
| 63 | $template->assign_vars(array( |
| 64 | 'MESSAGE_TITLE' => sprintf($user->lang['IP_WHOIS_FOR'], $domain), |
| 65 | 'MESSAGE_TEXT' => nl2br($ipwhois)) |
| 66 | ); |
| 67 | |
| 68 | return;
|
| 69 | } |
| 70 | |
| 71 | // Show user selection mask
|
| 72 | if (!$username && !$user_id) |
| 73 | {
|
| 74 | $this->page_title = 'SELECT_USER'; |
| 75 | |
| 76 | $template->assign_vars(array( |
| 77 | 'U_ACTION' => $this->u_action, |
| 78 | 'ANONYMOUS_USER_ID' => ANONYMOUS, |
| 79 | |
| 80 | 'S_SELECT_USER' => true, |
| 81 | 'U_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser&form=select_user&field=username&select_single=true'), |
| 82 | )); |
| 83 | |
| 84 | return;
|
| 85 | } |
| 86 | |
| 87 | if (!$user_id) |
| 88 | {
|
| 89 | $sql = 'SELECT user_id |
| 90 | FROM ' . USERS_TABLE . " |
| 91 | WHERE username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'"; |
| 92 | $result = $db->sql_query($sql); |
| 93 | $user_id = (int) $db->sql_fetchfield('user_id'); |
| 94 | $db->sql_freeresult($result); |
| 95 | |
| 96 | if (!$user_id) |
| 97 | {
|
| 98 | trigger_error($user->lang['NO_USER'] . adm_back_link($this->u_action), E_USER_WARNING); |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | // Generate content for all modes
|
| 103 | $sql = 'SELECT u.*, s.* |
| 104 | FROM ' . USERS_TABLE . ' u |
| 105 | LEFT JOIN ' . SESSIONS_TABLE . ' s ON (s.session_user_id = u.user_id) |
| 106 | WHERE u.user_id = ' . $user_id . ' |
| 107 | ORDER BY s.session_time DESC';
|
| 108 | $result = $db->sql_query_limit($sql, 1); |
| 109 | $user_row = $db->sql_fetchrow($result); |
| 110 | $db->sql_freeresult($result); |
| 111 | |
| 112 | if (!$user_row) |
| 113 | {
|
| 114 | trigger_error($user->lang['NO_USER'] . adm_back_link($this->u_action), E_USER_WARNING); |
| 115 | } |
| 116 | |
| 117 | // Generate overall "header" for user admin
|
| 118 | $s_form_options = ''; |
| 119 | |
| 120 | // Build modes dropdown list
|
| 121 | $sql = 'SELECT module_mode, module_auth |
| 122 | FROM ' . MODULES_TABLE . " |
| 123 | WHERE module_basename = 'users' |
| 124 | AND module_enabled = 1 |
| 125 | AND module_class = 'acp' |
| 126 | ORDER BY left_id, module_mode";
|
| 127 | $result = $db->sql_query($sql); |
| 128 | |
| 129 | $dropdown_modes = array(); |
| 130 | while ($row = $db->sql_fetchrow($result)) |
| 131 | {
|
| 132 | if (!$this->p_master->module_auth($row['module_auth'])) |
| 133 | {
|
| 134 | continue;
|
| 135 | } |
| 136 | |
| 137 | $dropdown_modes[$row['module_mode']] = true; |
| 138 | } |
| 139 | $db->sql_freeresult($result); |
| 140 | |
| 141 | foreach ($dropdown_modes as $module_mode => $null) |
| 142 | {
|
| 143 | $selected = ($mode == $module_mode) ? ' selected="selected"' : ''; |
| 144 | $s_form_options .= '<option value="' . $module_mode . '"' . $selected . '>' . $user->lang['ACP_USER_' . strtoupper($module_mode)] . '</option>'; |
| 145 | } |
| 146 | |
| 147 | $template->assign_vars(array( |
| 148 | 'U_BACK' => $this->u_action, |
| 149 | 'U_MODE_SELECT' => append_sid("{$phpbb_admin_path}index.$phpEx", "i=$id&u=$user_id"), |
| 150 | 'U_ACTION' => $this->u_action . '&u=' . $user_id, |
| 151 | 'S_FORM_OPTIONS' => $s_form_options, |
| 152 | 'MANAGED_USERNAME' => $user_row['username']) |
| 153 | ); |
| 154 | |
| 155 | // Prevent normal users/admins change/view founders if they are not a founder by themselves
|
| 156 | if ($user->data['user_type'] != USER_FOUNDER && $user_row['user_type'] == USER_FOUNDER) |
| 157 | {
|
| 158 | trigger_error($user->lang['NOT_MANAGE_FOUNDER'] . adm_back_link($this->u_action), E_USER_WARNING); |
| 159 | } |
| 160 | |
| 161 | switch ($mode) |
| 162 | {
|
| 163 | case 'overview': |
| 164 | |
| 165 | include($phpbb_root_path . 'includes/functions_user.' . $phpEx); |
| 166 | |
| 167 | $user->add_lang('acp/ban'); |
| 168 | |
| 169 | $delete = request_var('delete', 0); |
| 170 | $delete_type = request_var('delete_type', ''); |
| 171 | $ip = request_var('ip', 'ip'); |
| 172 | |
| 173 | if ($submit) |
| 174 | {
|
| 175 | // You can't delete the founder
|
| 176 | if ($delete && $user_row['user_type'] != USER_FOUNDER) |
| 177 | {
|
| 178 | if (!$auth->acl_get('a_userdel')) |
| 179 | {
|
| 180 | trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); |
| 181 | } |
| 182 | |
| 183 | // Check if the user wants to remove himself or the guest user account
|
| 184 | if ($user_id == ANONYMOUS) |
| 185 | {
|
| 186 | trigger_error($user->lang['CANNOT_REMOVE_ANONYMOUS'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); |
| 187 | } |
| 188 | |
| 189 | if ($user_id == $user->data['user_id']) |
| 190 | {
|
| 191 | trigger_error($user->lang['CANNOT_REMOVE_YOURSELF'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); |
| 192 | } |
| 193 | |
| 194 | if ($delete_type) |
| 195 | {
|
| 196 | if (confirm_box(true)) |
| 197 | {
|
| 198 | user_delete($delete_type, $user_id, $user_row['username']); |
| 199 | |
| 200 | add_log('admin', 'LOG_USER_DELETED', $user_row['username']); |
| 201 | trigger_error($user->lang['USER_DELETED'] . adm_back_link($this->u_action)); |
| 202 | } |
| 203 | else
|
| 204 | {
|
| 205 | confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( |
| 206 | 'u' => $user_id, |
| 207 | 'i' => $id, |
| 208 | 'mode' => $mode, |
| 209 | 'action' => $action, |
| 210 | 'update' => true, |
| 211 | 'delete' => 1, |
| 212 | 'delete_type' => $delete_type)) |
| 213 | ); |
| 214 | } |
| 215 | } |
| 216 | else
|
| 217 | {
|
| 218 | trigger_error($user->lang['NO_MODE'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); |
| 219 | } |
| 220 | } |
| 221 | |
| 222 | // Handle quicktool actions
|
| 223 | switch ($action) |
| 224 | {
|
| 225 | case 'banuser': |
| 226 | case 'banemail': |
| 227 | case 'banip': |
| 228 | |
| 229 | if ($user_id == $user->data['user_id']) |
| 230 | {
|
| 231 | trigger_error($user->lang['CANNOT_BAN_YOURSELF'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); |
| 232 | } |
| 233 | |
| 234 | if ($user_id == ANONYMOUS) |
| 235 | {
|
| 236 | trigger_error($user->lang['CANNOT_BAN_ANONYMOUS'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); |
| 237 | } |
| 238 | |
| 239 | if ($user_row['user_type'] == USER_FOUNDER) |
| 240 | {
|
| 241 | trigger_error($user->lang['CANNOT_BAN_FOUNDER'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); |
| 242 | } |
| 243 | |
| 244 | if (!check_form_key($form_name)) |
| 245 | {
|
| 246 | trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); |
| 247 | } |
| 248 | |
| 249 | $ban = array(); |
| 250 | |
| 251 | switch ($action) |
| 252 | {
|
| 253 | case 'banuser': |
| 254 | $ban[] = $user_row['username']; |
| 255 | $reason = 'USER_ADMIN_BAN_NAME_REASON'; |
| 256 | $log = 'LOG_USER_BAN_USER'; |
| 257 | break;
|
| 258 | |
| 259 | case 'banemail': |
| 260 | $ban[] = $user_row['user_email']; |
| 261 | $reason = 'USER_ADMIN_BAN_EMAIL_REASON'; |
| 262 | $log = 'LOG_USER_BAN_EMAIL'; |
| 263 | break;
|
| 264 | |
| 265 | case 'banip': |
| 266 | $ban[] = $user_row['user_ip']; |
| 267 | |
| 268 | $sql = 'SELECT DISTINCT poster_ip |
| 269 | FROM ' . POSTS_TABLE . " |
| 270 | WHERE poster_id = $user_id"; |
| 271 | $result = $db->sql_query($sql); |
| 272 | |
| 273 | while ($row = $db->sql_fetchrow($result)) |
| 274 | {
|
| 275 | $ban[] = $row['poster_ip']; |
| 276 | } |
| 277 | $db->sql_freeresult($result); |
| 278 | |
| 279 | $reason = 'USER_ADMIN_BAN_IP_REASON'; |
| 280 | $log = 'LOG_USER_BAN_IP'; |
| 281 | break;
|
| 282 | } |
| 283 | |
| 284 | $ban_reason = utf8_normalize_nfc(request_var('ban_reason', $user->lang[$reason], true)); |
| 285 | $ban_give_reason = utf8_normalize_nfc(request_var('ban_give_reason', '', true)); |
| 286 | |
| 287 | // Log not used at the moment, we simply utilize the ban function.
|
| 288 | $result = user_ban(substr($action, 3), $ban, 0, 0, 0, $ban_reason, $ban_give_reason); |
| 289 | |
| 290 | trigger_error((($result === false) ? $user->lang['BAN_ALREADY_ENTERED'] : $user->lang['BAN_SUCCESSFUL']) . adm_back_link($this->u_action . '&u=' . $user_id)); |
| 291 | |
| 292 | break;
|
| 293 | |
| 294 | case 'reactivate': |
| 295 | |
| 296 | if ($user_id == $user->data['user_id']) |
| 297 | {
|
| 298 | trigger_error($user->lang['CANNOT_FORCE_REACT_YOURSELF'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); |
| 299 | } |
| 300 | |
| 301 | if (!check_form_key($form_name)) |
| 302 | {
|
| 303 | trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); |
| 304 | } |
| 305 | |
| 306 | if ($user_row['user_type'] == USER_FOUNDER) |
| 307 | {
|
| 308 | trigger_error($user->lang['CANNOT_FORCE_REACT_FOUNDER'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); |
| 309 | } |
| 310 | |
| 311 | if ($user_row['user_type'] == USER_IGNORE) |
| 312 | {
|
| 313 | trigger_error($user->lang['CANNOT_FORCE_REACT_BOT'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); |
| 314 | } |
| 315 | |
| 316 | if ($config['email_enable']) |
| 317 | {
|
| 318 | include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); |
| 319 | |
| 320 | $server_url = generate_board_url();
|
| 321 | |
| 322 | $user_actkey = gen_rand_string(mt_rand(6, 10)); |
| 323 | $email_template = ($user_row['user_type'] == USER_NORMAL) ? 'user_reactivate_account' : 'user_resend_inactive'; |
| 324 | |
| 325 | if ($user_row['user_type'] == USER_NORMAL) |
| 326 | {
|
| 327 | user_active_flip('deactivate', $user_id, INACTIVE_REMIND); |
| 328 | |
| 329 | $sql = 'UPDATE ' . USERS_TABLE . " |
| 330 | SET user_actkey = '" . $db->sql_escape($user_actkey) . "' |
| 331 | WHERE user_id = $user_id"; |
| 332 | $db->sql_query($sql); |
| 333 | } |
| 334 | else
|
| 335 | {
|
| 336 | // Grabbing the last confirm key - we only send a reminder
|
| 337 | $sql = 'SELECT user_actkey |
| 338 | FROM ' . USERS_TABLE . ' |
| 339 | WHERE user_id = ' . $user_id; |
| 340 | $result = $db->sql_query($sql); |
| 341 | $user_actkey = (string) $db->sql_fetchfield('user_actkey'); |
| 342 | $db->sql_freeresult($result); |
| 343 | } |
| 344 | |
| 345 | $messenger = new messenger(false); |
| 346 | |
| 347 | $messenger->template($email_template, $user_row['user_lang']); |
| 348 | |
| 349 | $messenger->to($user_row['user_email'], $user_row['username']); |
| 350 | |
| 351 | $messenger->anti_abuse_headers($config, $user); |
| 352 | |
| 353 | $messenger->assign_vars(array( |
| 354 | 'WELCOME_MSG' => htmlspecialchars_decode(sprintf($user->lang['WELCOME_SUBJECT'], $config['sitename'])), |
| 355 | 'USERNAME' => htmlspecialchars_decode($user_row['username']), |
| 356 | 'U_ACTIVATE' => "$server_url/ucp.$phpEx?mode=activate&u={$user_row['user_id']}&k=$user_actkey") |
| 357 | ); |
| 358 | |
| 359 | $messenger->send(NOTIFY_EMAIL); |
| 360 | |
| 361 | add_log('admin', 'LOG_USER_REACTIVATE', $user_row['username']); |
| 362 | add_log('user', $user_id, 'LOG_USER_REACTIVATE_USER'); |
| 363 | |
| 364 | trigger_error($user->lang['FORCE_REACTIVATION_SUCCESS'] . adm_back_link($this->u_action . '&u=' . $user_id)); |
| 365 | } |
| 366 | |
| 367 | break;
|
| 368 | |
| 369 | case 'active': |
| 370 | |
| 371 | if ($user_id == $user->data['user_id']) |
| 372 | {
|
| 373 | // It is only deactivation since the user is already activated (else he would not have reached this page)
|
| 374 | trigger_error($user->lang['CANNOT_DEACTIVATE_YOURSELF'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); |
| 375 | } |
| 376 | |
| 377 | if (!check_form_key($form_name)) |
| 378 | {
|
| 379 | trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); |
| 380 | } |
| 381 | |
| 382 | if ($user_row['user_type'] == USER_FOUNDER) |
| 383 | {
|
| 384 | trigger_error($user->lang['CANNOT_DEACTIVATE_FOUNDER'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); |
| 385 | } |
| 386 | |
| 387 | if ($user_row['user_type'] == USER_IGNORE) |
| 388 | {
|
| 389 | trigger_error($user->lang['CANNOT_DEACTIVATE_BOT'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); |
| 390 | } |
| 391 | |
| 392 | user_active_flip('flip', $user_id); |
| 393 | |
| 394 | if ($user_row['user_type'] == USER_INACTIVE) |
| 395 | {
|
| 396 | if ($config['require_activation'] == USER_ACTIVATION_ADMIN) |
| 397 | {
|
| 398 | include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); |
| 399 | |
| 400 | $messenger = new messenger(false); |
| 401 | |
| 402 | $messenger->template('admin_welcome_activated', $user_row['user_lang']); |
| 403 | |
| 404 | $messenger->to($user_row['user_email'], $user_row['username']); |
| 405 | |
| 406 | $messenger->anti_abuse_headers($config, $user); |
| 407 | |
| 408 | $messenger->assign_vars(array( |
| 409 | 'USERNAME' => htmlspecialchars_decode($user_row['username'])) |
| 410 | ); |
| 411 | |
| 412 | $messenger->send(NOTIFY_EMAIL); |
| 413 | } |
| 414 | } |
| 415 | |
| 416 | $message = ($user_row['user_type'] == USER_INACTIVE) ? 'USER_ADMIN_ACTIVATED' : 'USER_ADMIN_DEACTIVED'; |
| 417 | $log = ($user_row['user_type'] == USER_INACTIVE) ? 'LOG_USER_ACTIVE' : 'LOG_USER_INACTIVE'; |
| 418 | |
| 419 | add_log('admin', $log, $user_row['username']); |
| 420 | add_log('user', $user_id, $log . '_USER'); |
| 421 | |
| 422 | trigger_error($user->lang[$message] . adm_back_link($this->u_action . '&u=' . $user_id)); |
| 423 | |
| 424 | break;
|
| 425 | |
| 426 | case 'delsig': |
| 427 | |
| 428 | if (!check_form_key($form_name)) |
| 429 | {
|
| 430 | trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); |
| 431 | } |
| 432 | |
| 433 | $sql_ary = array( |
| 434 | 'user_sig' => '', |
| 435 | 'user_sig_bbcode_uid' => '', |
| 436 | 'user_sig_bbcode_bitfield' => '' |
| 437 | ); |
| 438 | |
| 439 | $sql = 'UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . " |
| 440 | WHERE user_id = $user_id"; |
| 441 | $db->sql_query($sql); |
| 442 | |
| 443 | add_log('admin', 'LOG_USER_DEL_SIG', $user_row['username']); |
| 444 | add_log('user', $user_id, 'LOG_USER_DEL_SIG_USER'); |
| 445 | |
| 446 | trigger_error($user->lang['USER_ADMIN_SIG_REMOVED'] . adm_back_link($this->u_action . '&u=' . $user_id)); |
| 447 | |
| 448 | break;
|
| 449 | |
| 450 | case 'delavatar': |
| 451 | |
| 452 | if (!check_form_key($form_name)) |
| 453 | {
|
| 454 | trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); |
| 455 | } |
| 456 | |
| 457 | $sql_ary = array( |
| 458 | 'user_avatar' => '', |
| 459 | 'user_avatar_type' => 0, |
| 460 | 'user_avatar_width' => 0, |
| 461 | 'user_avatar_height' => 0, |
| 462 | ); |
| 463 | |
| 464 | $sql = 'UPDATE ' . USERS_TABLE . ' |
| 465 | SET ' . $db->sql_build_array('UPDATE', $sql_ary) . " |
| 466 | WHERE user_id = $user_id"; |
| 467 | $db->sql_query($sql); |
| 468 | |
| 469 | // Delete old avatar if present
|
| 470 | if ($user_row['user_avatar'] && $user_row['user_avatar_type'] != AVATAR_GALLERY) |
| 471 | {
|
| 472 | avatar_delete('user', $user_row); |
| 473 | } |
| 474 | |
| 475 | add_log('admin', 'LOG_USER_DEL_AVATAR', $user_row['username']); |
| 476 | add_log('user', $user_id, 'LOG_USER_DEL_AVATAR_USER'); |
| 477 | |
| 478 | trigger_error($user->lang['USER_ADMIN_AVATAR_REMOVED'] . adm_back_link($this->u_action . '&u=' . $user_id)); |
| 479 | break;
|
| 480 | |
| 481 | case 'delposts': |
| 482 | |
| 483 | if (confirm_box(true)) |
| 484 | {
|
| 485 | // Delete posts, attachments, etc.
|
| 486 | delete_posts('poster_id', $user_id); |
| 487 | |
| 488 | add_log('admin', 'LOG_USER_DEL_POSTS', $user_row['username']); |
| 489 | trigger_error($user->lang['USER_POSTS_DELETED'] . adm_back_link($this->u_action . '&u=' . $user_id)); |
| 490 | } |
| 491 | else
|
| 492 | {
|
| 493 | confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( |
| 494 | 'u' => $user_id, |
| 495 | 'i' => $id, |
| 496 | 'mode' => $mode, |
| 497 | 'action' => $action, |
| 498 | 'update' => true)) |
| 499 | ); |
| 500 | } |
| 501 | |
| 502 | break;
|
| 503 | |
| 504 | case 'delattach': |
| 505 | |
| 506 | if (confirm_box(true)) |
| 507 | {
|
| 508 | delete_attachments('user', $user_id); |
| 509 | |
| 510 | add_log('admin', 'LOG_USER_DEL_ATTACH', $user_row['username']); |
| 511 | trigger_error($user->lang['USER_ATTACHMENTS_REMOVED'] . adm_back_link($this->u_action . '&u=' . $user_id)); |
| 512 | } |
| 513 | else
|
| 514 | {
|
| 515 | confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( |
| 516 | 'u' => $user_id, |
| 517 | 'i' => $id, |
| 518 | 'mode' => $mode, |
| 519 | 'action' => $action, |
| 520 | 'update' => true)) |
| 521 | ); |
| 522 | } |
| 523 | |
| 524 | break;
|
| 525 | |
| 526 | case 'deloutbox': |
| 527 | |
| 528 | if (confirm_box(true)) |
| 529 | {
|
| 530 | $msg_ids = array(); |
| 531 | $lang = 'EMPTY'; |
| 532 | |
| 533 | $sql = 'SELECT msg_id |
| 534 | FROM ' . PRIVMSGS_TO_TABLE . " |
| 535 | WHERE author_id = $user_id |
| 536 | AND folder_id = " . PRIVMSGS_OUTBOX; |
| 537 | $result = $db->sql_query($sql); |
| 538 | |
| 539 | if ($row = $db->sql_fetchrow($result)) |
| 540 | {
|
| 541 | if (!function_exists('delete_pm')) |
| 542 | {
|
| 543 | include($phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx); |
| 544 | } |
| 545 | |
| 546 | do
|
| 547 | {
|
| 548 | $msg_ids[] = (int) $row['msg_id']; |
| 549 | } |
| 550 | while ($row = $db->sql_fetchrow($result)); |
| 551 | |
| 552 | $db->sql_freeresult($result); |
| 553 | |
| 554 | delete_pm($user_id, $msg_ids, PRIVMSGS_OUTBOX); |
| 555 | |
| 556 | add_log('admin', 'LOG_USER_DEL_OUTBOX', $user_row['username']); |
| 557 | |
| 558 | $lang = 'EMPTIED'; |
| 559 | } |
| 560 | $db->sql_freeresult($result); |
| 561 | |
| 562 | trigger_error($user->lang['USER_OUTBOX_' . $lang] . adm_back_link($this->u_action . '&u=' . $user_id)); |
| 563 | } |
| 564 | else
|
| 565 | {
|
| 566 | confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( |
| 567 | 'u' => $user_id, |
| 568 | 'i' => $id, |
| 569 | 'mode' => $mode, |
| 570 | 'action' => $action, |
| 571 | 'update' => true)) |
| 572 | ); |
| 573 | } |
| 574 | break;
|
| 575 | |
| 576 | case 'moveposts': |
| 577 | |
| 578 | if (!check_form_key($form_name)) |
| 579 | {
|
| 580 | trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); |
| 581 | } |
| 582 | |
| 583 | $user->add_lang('acp/forums'); |
| 584 | |
| 585 | $new_forum_id = request_var('new_f', 0); |
| 586 | |
| 587 | if (!$new_forum_id) |
| 588 | {
|
| 589 | $this->page_title = 'USER_ADMIN_MOVE_POSTS'; |
| 590 | |
| 591 | $template->assign_vars(array( |
| 592 | 'S_SELECT_FORUM' => true, |
| 593 | 'U_ACTION' => $this->u_action . "&action=$action&u=$user_id", |
| 594 | 'U_BACK' => $this->u_action . "&u=$user_id", |
| 595 | 'S_FORUM_OPTIONS' => make_forum_select(false, false, false, true)) |
| 596 | ); |
| 597 | |
| 598 | return;
|
| 599 | } |
| 600 | |
| 601 | // Is the new forum postable to?
|
| 602 | $sql = 'SELECT forum_name, forum_type |
| 603 | FROM ' . FORUMS_TABLE . " |
| 604 | WHERE forum_id = $new_forum_id"; |
| 605 | $result = $db->sql_query($sql); |
| 606 | $forum_info = $db->sql_fetchrow($result); |
| 607 | $db->sql_freeresult($result); |
| 608 | |
| 609 | if (!$forum_info) |
| 610 | {
|
| 611 | trigger_error($user->lang['NO_FORUM'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); |
| 612 | } |
| 613 | |
| 614 | if ($forum_info['forum_type'] != FORUM_POST) |
| 615 | {
|
| 616 | trigger_error($user->lang['MOVE_POSTS_NO_POSTABLE_FORUM'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); |
| 617 | } |
| 618 | |
| 619 | // Two stage?
|
| 620 | // Move topics comprising only posts from this user
|
| 621 | $topic_id_ary = $move_topic_ary = $move_post_ary = $new_topic_id_ary = array(); |
| 622 | $forum_id_ary = array($new_forum_id); |
| 623 | |
| 624 | $sql = 'SELECT topic_id, COUNT(post_id) AS total_posts |
| 625 | FROM ' . POSTS_TABLE . " |
| 626 | WHERE poster_id = $user_id |
| 627 | AND forum_id <> $new_forum_id |
| 628 | GROUP BY topic_id";
|
| 629 | $result = $db->sql_query($sql); |
| 630 | |
| 631 | while ($row = $db->sql_fetchrow($result)) |
| 632 | {
|
| 633 | $topic_id_ary[$row['topic_id']] = $row['total_posts']; |
| 634 | } |
| 635 | $db->sql_freeresult($result); |
| 636 | |
| 637 | if (sizeof($topic_id_ary)) |
| 638 | {
|
| 639 | $sql = 'SELECT topic_id, forum_id, topic_title, topic_replies, topic_replies_real, topic_attachment |
| 640 | FROM ' . TOPICS_TABLE . ' |
| 641 | WHERE ' . $db->sql_in_set('topic_id', array_keys($topic_id_ary)); |
| 642 | $result = $db->sql_query($sql); |
| 643 | |
| 644 | while ($row = $db->sql_fetchrow($result)) |
| 645 | {
|
| 646 | if (max($row['topic_replies'], $row['topic_replies_real']) + 1 == $topic_id_ary[$row['topic_id']]) |
| 647 | {
|
| 648 | $move_topic_ary[] = $row['topic_id']; |
| 649 | } |
| 650 | else
|
| 651 | {
|
| 652 | $move_post_ary[$row['topic_id']]['title'] = $row['topic_title']; |
| 653 | $move_post_ary[$row['topic_id']]['attach'] = ($row['topic_attachment']) ? 1 : 0; |
| 654 | } |
| 655 | |
| 656 | $forum_id_ary[] = $row['forum_id']; |
| 657 | } |
| 658 | $db->sql_freeresult($result); |
| 659 | } |
| 660 | |
| 661 | // Entire topic comprises posts by this user, move these topics
|
| 662 | if (sizeof($move_topic_ary)) |
| 663 | {
|
| 664 | move_topics($move_topic_ary, $new_forum_id, false); |
| 665 | } |
| 666 | |
| 667 | if (sizeof($move_post_ary)) |
| 668 | {
|
| 669 | // Create new topic
|
| 670 | // Update post_ids, report_ids, attachment_ids
|
| 671 | foreach ($move_post_ary as $topic_id => $post_ary) |
| 672 | {
|
| 673 | // Create new topic
|
| 674 | $sql = 'INSERT INTO ' . TOPICS_TABLE . ' ' . $db->sql_build_array('INSERT', array( |
| 675 | 'topic_poster' => $user_id, |
| 676 | 'topic_time' => time(), |
| 677 | 'forum_id' => $new_forum_id, |
| 678 | 'icon_id' => 0, |
| 679 | 'topic_approved' => 1, |
| 680 | 'topic_title' => $post_ary['title'], |
| 681 | 'topic_first_poster_name' => $user_row['username'], |
| 682 | 'topic_type' => POST_NORMAL, |
| 683 | 'topic_time_limit' => 0, |
| 684 | 'topic_attachment' => $post_ary['attach']) |
| 685 | ); |
| 686 | $db->sql_query($sql); |
| 687 | |
| 688 | $new_topic_id = $db->sql_nextid(); |
| 689 | |
| 690 | // Move posts
|
| 691 | $sql = 'UPDATE ' . POSTS_TABLE . " |
| 692 | SET forum_id = $new_forum_id, topic_id = $new_topic_id |
| 693 | WHERE topic_id = $topic_id |
| 694 | AND poster_id = $user_id"; |
| 695 | $db->sql_query($sql); |
| 696 | |
| 697 | if ($post_ary['attach']) |
| 698 | {
|
| 699 | $sql = 'UPDATE ' . ATTACHMENTS_TABLE . " |
| 700 | SET topic_id = $new_topic_id |
| 701 | WHERE topic_id = $topic_id |
| 702 | AND poster_id = $user_id"; |
| 703 | $db->sql_query($sql); |
| 704 | } |
| 705 | |
| 706 | $new_topic_id_ary[] = $new_topic_id; |
| 707 | } |
| 708 | } |
| 709 | |
| 710 | $forum_id_ary = array_unique($forum_id_ary); |
| 711 | $topic_id_ary = array_unique(array_merge(array_keys($topic_id_ary), $new_topic_id_ary)); |
| 712 | |
| 713 | if (sizeof($topic_id_ary)) |
| 714 | {
|
| 715 | sync('topic_reported', 'topic_id', $topic_id_ary); |
| 716 | sync('topic', 'topic_id', $topic_id_ary); |
| 717 | } |
| 718 | |
| 719 | if (sizeof($forum_id_ary)) |
| 720 | {
|
| 721 | sync('forum', 'forum_id', $forum_id_ary, false, true); |
| 722 | } |
| 723 | |
| 724 | |
| 725 | add_log('admin', 'LOG_USER_MOVE_POSTS', $user_row['username'], $forum_info['forum_name']); |
| 726 | add_log('user', $user_id, 'LOG_USER_MOVE_POSTS_USER', $forum_info['forum_name']); |
| 727 | |
| 728 | trigger_error($user->lang['USER_POSTS_MOVED'] . adm_back_link($this->u_action . '&u=' . $user_id)); |
| 729 | |
| 730 | break;
|
| 731 | |
| 732 | case 'leave_nr': |
| 733 | |
| 734 | if (confirm_box(true)) |
| 735 | {
|
| 736 | remove_newly_registered($user_id, $user_row); |
| 737 | |
| 738 | add_log('admin', 'LOG_USER_REMOVED_NR', $user_row['username']); |
| 739 | trigger_error($user->lang['USER_LIFTED_NR'] . adm_back_link($this->u_action . '&u=' . $user_id)); |
| 740 | } |
| 741 | else
|
| 742 | {
|
| 743 | confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( |
| 744 | 'u' => $user_id, |
| 745 | 'i' => $id, |
| 746 | 'mode' => $mode, |
| 747 | 'action' => $action, |
| 748 | 'update' => true)) |
| 749 | ); |
| 750 | } |
| 751 | |
| 752 | break;
|
| 753 | } |
| 754 | |
| 755 | // Handle registration info updates
|
| 756 | $data = array( |
| 757 | 'username' => utf8_normalize_nfc(request_var('user', $user_row['username'], true)), |
| 758 | 'user_founder' => request_var('user_founder', ($user_row['user_type'] == USER_FOUNDER) ? 1 : 0), |
| 759 | 'email' => strtolower(request_var('user_email', $user_row['user_email'])), |
| 760 | 'email_confirm' => strtolower(request_var('email_confirm', '')), |
| 761 | 'new_password' => request_var('new_password', '', true), |
| 762 | 'password_confirm' => request_var('password_confirm', '', true), |
| 763 | ); |
| 764 | |
| 765 | // Validation data - we do not check the password complexity setting here
|
| 766 | $check_ary = array( |
| 767 | 'new_password' => array( |
| 768 | array('string', true, $config['min_pass_chars'], $config['max_pass_chars']), |
| 769 | array('password')), |
| 770 | 'password_confirm' => array('string', true, $config['min_pass_chars'], $config['max_pass_chars']), |
| 771 | ); |
| 772 | |
| 773 | // Check username if altered
|
| 774 | if ($data['username'] != $user_row['username']) |
| 775 | {
|
| 776 | $check_ary += array( |
| 777 | 'username' => array( |
| 778 | array('string', false, $config['min_name_chars'], $config['max_name_chars']), |
| 779 | array('username', $user_row['username']) |
| 780 | ), |
| 781 | ); |
| 782 | } |
| 783 | |
| 784 | // Check email if altered
|
| 785 | if ($data['email'] != $user_row['user_email']) |
| 786 | {
|
| 787 | $check_ary += array( |
| 788 | 'email' => array( |
| 789 | array('string', false, 6, 60), |
| 790 | array('email', $user_row['user_email']) |
| 791 | ), |
| 792 | 'email_confirm' => array('string', true, 6, 60) |
| 793 | ); |
| 794 | } |
| 795 | |
| 796 | $error = validate_data($data, $check_ary); |
| 797 | |
| 798 | if ($data['new_password'] && $data['password_confirm'] != $data['new_password']) |
| 799 | {
|
| 800 | $error[] = 'NEW_PASSWORD_ERROR'; |
| 801 | } |
| 802 | |
| 803 | if ($data['email'] != $user_row['user_email'] && $data['email_confirm'] != $data['email']) |
| 804 | {
|
| 805 | $error[] = 'NEW_EMAIL_ERROR'; |
| 806 | } |
| 807 | |
| 808 | if (!check_form_key($form_name)) |
| 809 | {
|
| 810 | $error[] = 'FORM_INVALID'; |
| 811 | } |
| 812 | |
| 813 | // Which updates do we need to do?
|
| 814 | $update_username = ($user_row['username'] != $data['username']) ? $data['username'] : false; |
| 815 | $update_password = ($data['new_password'] && !phpbb_check_hash($data['new_password'], $user_row['user_password'])) ? true : false; |
| 816 | $update_email = ($data['email'] != $user_row['user_email']) ? $data['email'] : false; |
| 817 | |
| 818 | if (!sizeof($error)) |
| 819 | {
|
| 820 | $sql_ary = array(); |
| 821 | |
| 822 | if ($user_row['user_type'] != USER_FOUNDER || $user->data['user_type'] == USER_FOUNDER) |
| 823 | {
|
| 824 | // Only allow founders updating the founder status...
|
| 825 | if ($user->data['user_type'] == USER_FOUNDER) |
| 826 | {
|
| 827 | // Setting a normal member to be a founder
|
| 828 | if ($data['user_founder'] && $user_row['user_type'] != USER_FOUNDER) |
| 829 | {
|
| 830 | // Make sure the user is not setting an Inactive or ignored user to be a founder
|
| 831 | if ($user_row['user_type'] == USER_IGNORE) |
| 832 | {
|
| 833 | trigger_error($user->lang['CANNOT_SET_FOUNDER_IGNORED'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); |
| 834 | } |
| 835 | |
| 836 | if ($user_row['user_type'] == USER_INACTIVE) |
| 837 | {
|
| 838 | trigger_error($user->lang['CANNOT_SET_FOUNDER_INACTIVE'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); |
| 839 | } |
| 840 | |
| 841 | $sql_ary['user_type'] = USER_FOUNDER; |
| 842 | } |
| 843 | else if (!$data['user_founder'] && $user_row['user_type'] == USER_FOUNDER) |
| 844 | {
|
| 845 | // Check if at least one founder is present
|
| 846 | $sql = 'SELECT user_id |
| 847 | FROM ' . USERS_TABLE . ' |
| 848 | WHERE user_type = ' . USER_FOUNDER . ' |
| 849 | AND user_id <> ' . $user_id; |
| 850 | $result = $db->sql_query_limit($sql, 1); |
| 851 | $row = $db->sql_fetchrow($result); |
| 852 | $db->sql_freeresult($result); |
| 853 | |
| 854 | if ($row) |
| 855 | {
|
| 856 | $sql_ary['user_type'] = USER_NORMAL; |
| 857 | } |
| 858 | else
|
| 859 | {
|
| 860 | trigger_error($user->lang['AT_LEAST_ONE_FOUNDER'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); |
| 861 | } |
| 862 | } |
| 863 | } |
| 864 | } |
| 865 | |
| 866 | if ($update_username !== false) |
| 867 | {
|
| 868 | $sql_ary['username'] = $update_username; |
| 869 | $sql_ary['username_clean'] = utf8_clean_string($update_username); |
| 870 | |
| 871 | add_log('user', $user_id, 'LOG_USER_UPDATE_NAME', $user_row['username'], $update_username); |
| 872 | } |
| 873 | |
| 874 | if ($update_email !== false) |
| 875 | {
|
| 876 | $sql_ary += array( |
| 877 | 'user_email' => $update_email, |
| 878 | 'user_email_hash' => phpbb_email_hash($update_email), |
| 879 | ); |
| 880 | |
| 881 | add_log('user', $user_id, 'LOG_USER_UPDATE_EMAIL', $user_row['username'], $user_row['user_email'], $update_email); |
| 882 | } |
| 883 | |
| 884 | if ($update_password) |
| 885 | {
|
| 886 | $sql_ary += array( |
| 887 | 'user_password' => phpbb_hash($data['new_password']), |
| 888 | 'user_passchg' => time(), |
| 889 | 'user_pass_convert' => 0, |
| 890 | ); |
| 891 | |
| 892 | $user->reset_login_keys($user_id); |
| 893 | add_log('user', $user_id, 'LOG_USER_NEW_PASSWORD', $user_row['username']); |
| 894 | } |
| 895 | |
| 896 | if (sizeof($sql_ary)) |
| 897 | {
|
| 898 | $sql = 'UPDATE ' . USERS_TABLE . ' |
| 899 | SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' |
| 900 | WHERE user_id = ' . $user_id; |
| 901 | $db->sql_query($sql); |
| 902 | } |
| 903 | |
| 904 | if ($update_username) |
| 905 | {
|
| 906 | user_update_name($user_row['username'], $update_username); |
| 907 | } |
| 908 | |
| 909 | // Let the users permissions being updated
|
| 910 | $auth->acl_clear_prefetch($user_id); |
| 911 | |
| 912 | add_log('admin', 'LOG_USER_USER_UPDATE', $data['username']); |
| 913 | |
| 914 | trigger_error($user->lang['USER_OVERVIEW_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_id)); |
| 915 | } |
| 916 | |
| 917 | // Replace "error" strings with their real, localised form
|
| 918 | $error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error); |
| 919 | } |
| 920 | |
| 921 | if ($user_id == $user->data['user_id']) |
| 922 | {
|
| 923 | $quick_tool_ary = array('delsig' => 'DEL_SIG', 'delavatar' => 'DEL_AVATAR', 'moveposts' => 'MOVE_POSTS', 'delposts' => 'DEL_POSTS', 'delattach' => 'DEL_ATTACH', 'deloutbox' => 'DEL_OUTBOX'); |
| 924 | if ($user_row['user_new']) |
| 925 | {
|
| 926 | $quick_tool_ary['leave_nr'] = 'LEAVE_NR'; |
| 927 | } |
| 928 | } |
| 929 | else
|
| 930 | {
|
| 931 | $quick_tool_ary = array(); |
| 932 | |
| 933 | if ($user_row['user_type'] != USER_FOUNDER) |
| 934 | {
|
| 935 | $quick_tool_ary += array('banuser' => 'BAN_USER', 'banemail' => 'BAN_EMAIL', 'banip' => 'BAN_IP'); |
| 936 | } |
| 937 | |
| 938 | if ($user_row['user_type'] != USER_FOUNDER && $user_row['user_type'] != USER_IGNORE) |
| 939 | {
|
| 940 | $quick_tool_ary += array('active' => (($user_row['user_type'] == USER_INACTIVE) ? 'ACTIVATE' : 'DEACTIVATE')); |
| 941 | } |
| 942 | |
| 943 | $quick_tool_ary += array('delsig' => 'DEL_SIG', 'delavatar' => 'DEL_AVATAR', 'moveposts' => 'MOVE_POSTS', 'delposts' => 'DEL_POSTS', 'delattach' => 'DEL_ATTACH', 'deloutbox' => 'DEL_OUTBOX'); |
| 944 | |
| 945 | if ($config['email_enable'] && ($user_row['user_type'] == USER_NORMAL || $user_row['user_type'] == USER_INACTIVE)) |
| 946 | {
|
| 947 | $quick_tool_ary['reactivate'] = 'FORCE'; |
| 948 | } |
| 949 | |
| 950 | if ($user_row['user_new']) |
| 951 | {
|
| 952 | $quick_tool_ary['leave_nr'] = 'LEAVE_NR'; |
| 953 | } |
| 954 | } |
| 955 | |
| 956 | $s_action_options = '<option class="sep" value="">' . $user->lang['SELECT_OPTION'] . '</option>'; |
| 957 | foreach ($quick_tool_ary as $value => $lang) |
| 958 | {
|
| 959 | $s_action_options .= '<option value="' . $value . '">' . $user->lang['USER_ADMIN_' . $lang] . '</option>'; |
| 960 | } |
| 961 | |
| 962 | if ($config['load_onlinetrack']) |
| 963 | {
|
| 964 | $sql = 'SELECT MAX(session_time) AS session_time, MIN(session_viewonline) AS session_viewonline |
| 965 | FROM ' . SESSIONS_TABLE . " |
| 966 | WHERE session_user_id = $user_id"; |
| 967 | $result = $db->sql_query($sql); |
| 968 | $row = $db->sql_fetchrow($result); |
| 969 | $db->sql_freeresult($result); |
| 970 | |
| 971 | $user_row['session_time'] = (isset($row['session_time'])) ? $row['session_time'] : 0; |
| 972 | $user_row['session_viewonline'] = (isset($row['session_viewonline'])) ? $row['session_viewonline'] : 0; |
| 973 | unset($row); |
| 974 | } |
| 975 | |
| 976 | $last_visit = (!empty($user_row['session_time'])) ? $user_row['session_time'] : $user_row['user_lastvisit']; |
| 977 | |
| 978 | $inactive_reason = ''; |
| 979 | if ($user_row['user_type'] == USER_INACTIVE) |
| 980 | {
|
| 981 | $inactive_reason = $user->lang['INACTIVE_REASON_UNKNOWN']; |
| 982 | |
| 983 | switch ($user_row['user_inactive_reason']) |
| 984 | {
|
| 985 | case INACTIVE_REGISTER: |
| 986 | $inactive_reason = $user->lang['INACTIVE_REASON_REGISTER']; |
| 987 | break;
|
| 988 | |
| 989 | case INACTIVE_PROFILE: |
| 990 | $inactive_reason = $user->lang['INACTIVE_REASON_PROFILE']; |
| 991 | break;
|
| 992 | |
| 993 | case INACTIVE_MANUAL: |
| 994 | $inactive_reason = $user->lang['INACTIVE_REASON_MANUAL']; |
| 995 | break;
|
| 996 | |
| 997 | case INACTIVE_REMIND: |
| 998 | $inactive_reason = $user->lang['INACTIVE_REASON_REMIND']; |
| 999 | break;
|
| 1000 | } |
| 1001 | } |
| 1002 | |
| 1003 | // Posts in Queue
|
| 1004 | $sql = 'SELECT COUNT(post_id) as posts_in_queue |
| 1005 | FROM ' . POSTS_TABLE . ' |
| 1006 | WHERE poster_id = ' . $user_id . ' |
| 1007 | AND post_approved = 0';
|
| 1008 | $result = $db->sql_query($sql); |
| 1009 | $user_row['posts_in_queue'] = (int) $db->sql_fetchfield('posts_in_queue'); |
| 1010 | $db->sql_freeresult($result); |
| 1011 | |
| 1012 | $template->assign_vars(array( |
| 1013 | 'L_NAME_CHARS_EXPLAIN' => sprintf($user->lang[$config['allow_name_chars'] . '_EXPLAIN'], $config['min_name_chars'], $config['max_name_chars']), |
| 1014 | 'L_CHANGE_PASSWORD_EXPLAIN' => sprintf($user->lang[$config['pass_complex'] . '_EXPLAIN'], $config['min_pass_chars'], $config['max_pass_chars']), |
| 1015 | 'L_POSTS_IN_QUEUE' => $user->lang('NUM_POSTS_IN_QUEUE', $user_row['posts_in_queue']), |
| 1016 | 'S_FOUNDER' => ($user->data['user_type'] == USER_FOUNDER) ? true : false, |
| 1017 | |
| 1018 | 'S_OVERVIEW' => true, |
| 1019 | 'S_USER_IP' => ($user_row['user_ip']) ? true : false, |
| 1020 | 'S_USER_FOUNDER' => ($user_row['user_type'] == USER_FOUNDER) ? true : false, |
| 1021 | 'S_ACTION_OPTIONS' => $s_action_options, |
| 1022 | 'S_OWN_ACCOUNT' => ($user_id == $user->data['user_id']) ? true : false, |
| 1023 | 'S_USER_INACTIVE' => ($user_row['user_type'] == USER_INACTIVE) ? true : false, |
| 1024 | |
| 1025 | 'U_SHOW_IP' => $this->u_action . "&u=$user_id&ip=" . (($ip == 'ip') ? 'hostname' : 'ip'), |
| 1026 | 'U_WHOIS' => $this->u_action . "&action=whois&user_ip={$user_row['user_ip']}", |
| 1027 | 'U_MCP_QUEUE' => ($auth->acl_getf_global('m_approve')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue', true, $user->session_id) : '', |
| 1028 | |
| 1029 | 'U_SWITCH_PERMISSIONS' => ($auth->acl_get('a_switchperm') && $user->data['user_id'] != $user_row['user_id']) ? append_sid("{$phpbb_root_path}ucp.$phpEx", "mode=switch_perm&u={$user_row['user_id']}&hash=" . generate_link_hash('switchperm')) : '', |
| 1030 | |
| 1031 | 'POSTS_IN_QUEUE' => $user_row['posts_in_queue'], |
| 1032 | 'USER' => $user_row['username'], |
| 1033 | 'USER_REGISTERED' => $user->format_date($user_row['user_regdate']), |
| 1034 | 'REGISTERED_IP' => ($ip == 'hostname') ? gethostbyaddr($user_row['user_ip']) : $user_row['user_ip'], |
| 1035 | 'USER_LASTACTIVE' => ($last_visit) ? $user->format_date($last_visit) : ' - ', |
| 1036 | 'USER_EMAIL' => $user_row['user_email'], |
| 1037 | 'USER_WARNINGS' => $user_row['user_warnings'], |
| 1038 | 'USER_POSTS' => $user_row['user_posts'], |
| 1039 | 'USER_INACTIVE_REASON' => $inactive_reason, |
| 1040 | )); |
| 1041 | |
| 1042 | break;
|
| 1043 | |
| 1044 | case 'feedback': |
| 1045 | |
| 1046 | $user->add_lang('mcp'); |
| 1047 | |
| 1048 | // Set up general vars
|
| 1049 | $start = request_var('start', 0); |
| 1050 | $deletemark = (isset($_POST['delmarked'])) ? true : false; |
| 1051 | $deleteall = (isset($_POST['delall'])) ? true : false; |
| 1052 | $marked = request_var('mark', array(0)); |
| 1053 | $message = utf8_normalize_nfc(request_var('message', '', true)); |
| 1054 | |
| 1055 | // Sort keys
|
| 1056 | $sort_days = request_var('st', 0); |
| 1057 | $sort_key = request_var('sk', 't'); |
| 1058 | $sort_dir = request_var('sd', 'd'); |
| 1059 | |
| 1060 | // Delete entries if requested and able
|
| 1061 | if (($deletemark || $deleteall) && $auth->acl_get('a_clearlogs')) |
| 1062 | {
|
| 1063 | if (!check_form_key($form_name)) |
| 1064 | {
|
| 1065 | trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); |
| 1066 | } |
| 1067 | |
| 1068 | $where_sql = ''; |
| 1069 | if ($deletemark && $marked) |
| 1070 | {
|
| 1071 | $sql_in = array(); |
| 1072 | foreach ($marked as $mark) |
| 1073 | {
|
| 1074 | $sql_in[] = $mark; |
| 1075 | } |
| 1076 | $where_sql = ' AND ' . $db->sql_in_set('log_id', $sql_in); |
| 1077 | unset($sql_in); |
| 1078 | } |
| 1079 | |
| 1080 | if ($where_sql || $deleteall) |
| 1081 | {
|
| 1082 | $sql = 'DELETE FROM ' . LOG_TABLE . ' |
| 1083 | WHERE log_type = ' . LOG_USERS . " |
| 1084 | AND reportee_id = $user_id |
| 1085 | $where_sql"; |
| 1086 | $db->sql_query($sql); |
| 1087 | |
| 1088 | add_log('admin', 'LOG_CLEAR_USER', $user_row['username']); |
| 1089 | } |
| 1090 | } |
| 1091 | |
| 1092 | if ($submit && $message) |
| 1093 | {
|
| 1094 | if (!check_form_key($form_name)) |
| 1095 | {
|
| 1096 | trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); |
| 1097 | } |
| 1098 | |
| 1099 | add_log('admin', 'LOG_USER_FEEDBACK', $user_row['username']); |
| 1100 | add_log('mod', 0, 0, 'LOG_USER_FEEDBACK', $user_row['username']); |
| 1101 | add_log('user', $user_id, 'LOG_USER_GENERAL', $message); |
| 1102 | |
| 1103 | trigger_error($user->lang['USER_FEEDBACK_ADDED'] . adm_back_link($this->u_action . '&u=' . $user_id)); |
| 1104 | } |
| 1105 | |
| 1106 | // Sorting
|
| 1107 | $limit_days = array(0 => $user->lang['ALL_ENTRIES'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']); |
| 1108 | $sort_by_text = array('u' => $user->lang['SORT_USERNAME'], 't' => $user->lang['SORT_DATE'], 'i' => $user->lang['SORT_IP'], 'o' => $user->lang['SORT_ACTION']); |
| 1109 | $sort_by_sql = array('u' => 'u.username_clean', 't' => 'l.log_time', 'i' => 'l.log_ip', 'o' => 'l.log_operation'); |
| 1110 | |
| 1111 | $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = ''; |
| 1112 | gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param); |
| 1113 | |
| 1114 | // Define where and sort sql for use in displaying logs
|
| 1115 | $sql_where = ($sort_days) ? (time() - ($sort_days * 86400)) : 0; |
| 1116 | $sql_sort = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC'); |
| 1117 | |
| 1118 | // Grab log data
|
| 1119 | $log_data = array(); |
| 1120 | $log_count = 0; |
| 1121 | $start = view_log('user', $log_data, $log_count, $config['topics_per_page'], $start, 0, 0, $user_id, $sql_where, $sql_sort); |
| 1122 | |
| 1123 | $template->assign_vars(array( |
| 1124 | 'S_FEEDBACK' => true, |
| 1125 | 'S_ON_PAGE' => on_page($log_count, $config['topics_per_page'], $start), |
| 1126 | 'PAGINATION' => generate_pagination($this->u_action . "&u=$user_id&$u_sort_param", $log_count, $config['topics_per_page'], $start, true), |
| 1127 | |
| 1128 | 'S_LIMIT_DAYS' => $s_limit_days, |
| 1129 | 'S_SORT_KEY' => $s_sort_key, |
| 1130 | 'S_SORT_DIR' => $s_sort_dir, |
| 1131 | 'S_CLEARLOGS' => $auth->acl_get('a_clearlogs')) |
| 1132 | ); |
| 1133 | |
| 1134 | foreach ($log_data as $row) |
| 1135 | {
|
| 1136 | $template->assign_block_vars('log', array( |
| 1137 | 'USERNAME' => $row['username_full'], |
| 1138 | 'IP' => $row['ip'], |
| 1139 | 'DATE' => $user->format_date($row['time']), |
| 1140 | 'ACTION' => nl2br($row['action']), |
| 1141 | 'ID' => $row['id']) |
| 1142 | ); |
| 1143 | } |
| 1144 | |
| 1145 | break;
|
| 1146 | |
| 1147 | case 'warnings': |
| 1148 | $user->add_lang('mcp'); |
| 1149 | |
| 1150 | // Set up general vars
|
| 1151 | $start = request_var('start', 0); |
| 1152 | $deletemark = (isset($_POST['delmarked'])) ? true : false; |
| 1153 | $deleteall = (isset($_POST['delall'])) ? true : false; |
| 1154 | $confirm = (isset($_POST['confirm'])) ? true : false; |
| 1155 | $marked = request_var('mark', array(0)); |
| 1156 | $message = utf8_normalize_nfc(request_var('message', '', true)); |
| 1157 | |
| 1158 | // Sort keys
|
| 1159 | $sort_days = request_var('st', 0); |
| 1160 | $sort_key = request_var('sk', 't'); |
| 1161 | $sort_dir = request_var('sd', 'd'); |
| 1162 | |
| 1163 | // Delete entries if requested and able
|
| 1164 | if ($deletemark || $deleteall || $confirm) |
| 1165 | {
|
| 1166 | if (confirm_box(true)) |
| 1167 | {
|
| 1168 | $where_sql = ''; |
| 1169 | $deletemark = request_var('delmarked', 0); |
| 1170 | $deleteall = request_var('delall', 0); |
| 1171 | if ($deletemark && $marked) |
| 1172 | {
|
| 1173 | $where_sql = ' AND ' . $db->sql_in_set('warning_id', array_values($marked)); |
| 1174 | } |
| 1175 | |
| 1176 | if ($where_sql || $deleteall) |
| 1177 | {
|
| 1178 | $sql = 'DELETE FROM ' . WARNINGS_TABLE . " |
| 1179 | WHERE user_id = $user_id |
| 1180 | $where_sql"; |
| 1181 | $db->sql_query($sql); |
| 1182 | |
| 1183 | if ($deleteall) |
| 1184 | {
|
| 1185 | $log_warnings = $deleted_warnings = 0; |
| 1186 | } |
| 1187 | else
|
| 1188 | {
|
| 1189 | $num_warnings = (int) $db->sql_affectedrows(); |
| 1190 | $deleted_warnings = ' user_warnings - ' . $num_warnings; |
| 1191 | $log_warnings = ($num_warnings > 2) ? 2 : $num_warnings; |
| 1192 | } |
| 1193 | |
| 1194 | $sql = 'UPDATE ' . USERS_TABLE . " |
| 1195 | SET user_warnings = $deleted_warnings |
| 1196 | WHERE user_id = $user_id"; |
| 1197 | $db->sql_query($sql); |
| 1198 | |
| 1199 | switch ($log_warnings) |
| 1200 | {
|
| 1201 | case 2: |
| 1202 | add_log('admin', 'LOG_WARNINGS_DELETED', $user_row['username'], $num_warnings); |
| 1203 | break;
|
| 1204 | case 1: |
| 1205 | add_log('admin', 'LOG_WARNING_DELETED', $user_row['username']); |
| 1206 | break;
|
| 1207 | default:
|
| 1208 | add_log('admin', 'LOG_WARNINGS_DELETED_ALL', $user_row['username']); |
| 1209 | break;
|
| 1210 | } |
| 1211 | } |
| 1212 | } |
| 1213 | else
|
| 1214 | {
|
| 1215 | $s_hidden_fields = array( |
| 1216 | 'i' => $id, |
| 1217 | 'mode' => $mode, |
| 1218 | 'u' => $user_id, |
| 1219 | 'mark' => $marked, |
| 1220 | ); |
| 1221 | if (isset($_POST['delmarked'])) |
| 1222 | {
|
| 1223 | $s_hidden_fields['delmarked'] = 1; |
| 1224 | } |
| 1225 | if (isset($_POST['delall'])) |
| 1226 | {
|
| 1227 | $s_hidden_fields['delall'] = 1; |
| 1228 | } |
| 1229 | if (isset($_POST['delall']) || (isset($_POST['delmarked']) && sizeof($marked))) |
| 1230 | {
|
| 1231 | confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields($s_hidden_fields)); |
| 1232 | } |
| 1233 | } |
| 1234 | } |
| 1235 | |
| 1236 | $sql = 'SELECT w.warning_id, w.warning_time, w.post_id, l.log_operation, l.log_data, l.user_id AS mod_user_id, m.username AS mod_username, m.user_colour AS mod_user_colour |
| 1237 | FROM ' . WARNINGS_TABLE . ' w |
| 1238 | LEFT JOIN ' . LOG_TABLE . ' l |
| 1239 | ON (w.log_id = l.log_id) |
| 1240 | LEFT JOIN ' . USERS_TABLE . ' m |
| 1241 | ON (l.user_id = m.user_id) |
| 1242 | WHERE w.user_id = ' . $user_id . ' |
| 1243 | ORDER BY w.warning_time DESC';
|
| 1244 | $result = $db->sql_query($sql); |
| 1245 | |
| 1246 | while ($row = $db->sql_fetchrow($result)) |
| 1247 | {
|
| 1248 | if (!$row['log_operation']) |
| 1249 | {
|
| 1250 | // We do not have a log-entry anymore, so there is no data available
|
| 1251 | $row['action'] = $user->lang['USER_WARNING_LOG_DELETED']; |
| 1252 | } |
| 1253 | else
|
| 1254 | {
|
| 1255 | $row['action'] = (isset($user->lang[$row['log_operation']])) ? $user->lang[$row['log_operation']] : '{' . ucfirst(str_replace('_', ' ', $row['log_operation'])) . '}'; |
| 1256 | if (!empty($row['log_data'])) |
| 1257 | {
|
| 1258 | $log_data_ary = @unserialize($row['log_data']); |
| 1259 | $log_data_ary = ($log_data_ary === false) ? array() : $log_data_ary; |
| 1260 | |
| 1261 | if (isset($user->lang[$row['log_operation']])) |
| 1262 | {
|
| 1263 | // Check if there are more occurrences of % than arguments, if there are we fill out the arguments array
|
| 1264 | // It doesn't matter if we add more arguments than placeholders
|
| 1265 | if ((substr_count($row['action'], '%') - sizeof($log_data_ary)) > 0) |
| 1266 | {
|
| 1267 | $log_data_ary = array_merge($log_data_ary, array_fill(0, substr_count($row['action'], '%') - sizeof($log_data_ary), '')); |
| 1268 | } |
| 1269 | $row['action'] = vsprintf($row['action'], $log_data_ary); |
| 1270 | $row['action'] = bbcode_nl2br(censor_text($row['action'])); |
| 1271 | } |
| 1272 | else if (!empty($log_data_ary)) |
| 1273 | {
|
| 1274 | $row['action'] .= '<br />' . implode('', $log_data_ary); |
| 1275 | } |
| 1276 | } |
| 1277 | } |
| 1278 | |
| 1279 | |
| 1280 | $template->assign_block_vars('warn', array( |
| 1281 | 'ID' => $row['warning_id'], |
| 1282 | 'USERNAME' => ($row['log_operation']) ? get_username_string('full', $row['mod_user_id'], $row['mod_username'], $row['mod_user_colour']) : '-', |
| 1283 | 'ACTION' => make_clickable($row['action']), |
| 1284 | 'DATE' => $user->format_date($row['warning_time']), |
| 1285 | )); |
| 1286 | } |
| 1287 | $db->sql_freeresult($result); |
| 1288 | |
| 1289 | $template->assign_vars(array( |
| 1290 | 'S_WARNINGS' => true, |
| 1291 | )); |
| 1292 | |
| 1293 | break;
|
| 1294 | |
| 1295 | case 'profile': |
| 1296 | |
| 1297 | include($phpbb_root_path . 'includes/functions_user.' . $phpEx); |
| 1298 | include($phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx); |
| 1299 | |
| 1300 | $cp = new custom_profile(); |
| 1301 | |
| 1302 | $cp_data = $cp_error = array(); |
| 1303 | |
| 1304 | $sql = 'SELECT lang_id |
| 1305 | FROM ' . LANG_TABLE . " |
| 1306 | WHERE lang_iso = '" . $db->sql_escape($user->data['user_lang']) . "'"; |
| 1307 | $result = $db->sql_query($sql); |
| 1308 | $row = $db->sql_fetchrow($result); |
| 1309 | $db->sql_freeresult($result); |
| 1310 | |
| 1311 | $user_row['iso_lang_id'] = $row['lang_id']; |
| 1312 | |
| 1313 | $data = array( |
| 1314 | 'icq' => request_var('icq', $user_row['user_icq']), |
| 1315 | 'aim' => request_var('aim', $user_row['user_aim']), |
| 1316 | 'msn' => request_var('msn', $user_row['user_msnm']), |
| 1317 | 'yim' => request_var('yim', $user_row['user_yim']), |
| 1318 | 'jabber' => utf8_normalize_nfc(request_var('jabber', $user_row['user_jabber'], true)), |
| 1319 | 'website' => request_var('website', $user_row['user_website']), |
| 1320 | 'location' => utf8_normalize_nfc(request_var('location', $user_row['user_from'], true)), |
| 1321 | 'occupation' => utf8_normalize_nfc(request_var('occupation', $user_row['user_occ'], true)), |
| 1322 | 'interests' => utf8_normalize_nfc(request_var('interests', $user_row['user_interests'], true)), |
| 1323 | 'bday_day' => 0, |
| 1324 | 'bday_month' => 0, |
| 1325 | 'bday_year' => 0, |
| 1326 | ); |
| 1327 | |
| 1328 | if ($user_row['user_birthday']) |
| 1329 | {
|
| 1330 | list($data['bday_day'], $data['bday_month'], $data['bday_year']) = explode('-', $user_row['user_birthday']); |
| 1331 | } |
| 1332 | |
| 1333 | $data['bday_day'] = request_var('bday_day', $data['bday_day']); |
| 1334 | $data['bday_month'] = request_var('bday_month', $data['bday_month']); |
| 1335 | $data['bday_year'] = request_var('bday_year', $data['bday_year']); |
| 1336 | $data['user_birthday'] = sprintf('%2d-%2d-%4d', $data['bday_day'], $data['bday_month'], $data['bday_year']); |
| 1337 | |
| 1338 | |
| 1339 | if ($submit) |
| 1340 | {
|
| 1341 | $error = validate_data($data, array( |
| 1342 | 'icq' => array( |
| 1343 | array('string', true, 3, 15), |
| 1344 | array('match', true, '#^[0-9]+$#i')), |
| 1345 | 'aim' => array('string', true, 3, 255), |
| 1346 | 'msn' => array('string', true, 5, 255), |
| 1347 | 'jabber' => array( |
| 1348 | array('string', true, 5, 255), |
| 1349 | array('jabber')), |
| 1350 | 'yim' => array('string', true, 5, 255), |
| 1351 | 'website' => array( |
| 1352 | array('string', true, 12, 255), |
| 1353 | array('match', true, '#^http[s]?://(.*?\.)*?[a-z0-9\-]+\.[a-z]{2,4}#i')), |
| 1354 | 'location' => array('string', true, 2, 100), |
| 1355 | 'occupation' => array('string', true, 2, 500), |
| 1356 | 'interests' => array('string', true, 2, 500), |
| 1357 | 'bday_day' => array('num', true, 1, 31), |
| 1358 | 'bday_month' => array('num', true, 1, 12), |
| 1359 | 'bday_year' => array('num', true, 1901, gmdate('Y', time())), |
| 1360 | 'user_birthday' => array('date', true), |
| 1361 | )); |
| 1362 | |
| 1363 | // validate custom profile fields
|
| 1364 | $cp->submit_cp_field('profile', $user_row['iso_lang_id'], $cp_data, $cp_error); |
| 1365 | |
| 1366 | if (sizeof($cp_error)) |
| 1367 | {
|
| 1368 | $error = array_merge($error, $cp_error); |
| 1369 | } |
| 1370 | if (!check_form_key($form_name)) |
| 1371 | {
|
| 1372 | $error[] = 'FORM_INVALID'; |
| 1373 | } |
| 1374 | |
| 1375 | if (!sizeof($error)) |
| 1376 | {
|
| 1377 | $sql_ary = array( |
| 1378 | 'user_icq' => $data['icq'], |
| 1379 | 'user_aim' => $data['aim'], |
| 1380 | 'user_msnm' => $data['msn'], |
| 1381 | 'user_yim' => $data['yim'], |
| 1382 | 'user_jabber' => $data['jabber'], |
| 1383 | 'user_website' => $data['website'], |
| 1384 | 'user_from' => $data['location'], |
| 1385 | 'user_occ' => $data['occupation'], |
| 1386 | 'user_interests'=> $data['interests'], |
| 1387 | 'user_birthday' => $data['user_birthday'], |
| 1388 | ); |
| 1389 | |
| 1390 | $sql = 'UPDATE ' . USERS_TABLE . ' |
| 1391 | SET ' . $db->sql_build_array('UPDATE', $sql_ary) . " |
| 1392 | WHERE user_id = $user_id"; |
| 1393 | $db->sql_query($sql); |
| 1394 | |
| 1395 | // Update Custom Fields
|
| 1396 | $cp->update_profile_field_data($user_id, $cp_data); |
| 1397 | |
| 1398 | trigger_error($user->lang['USER_PROFILE_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_id)); |
| 1399 | } |
| 1400 | |
| 1401 | // Replace "error" strings with their real, localised form
|
| 1402 | $error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error); |
| 1403 | } |
| 1404 | |
| 1405 | $s_birthday_day_options = '<option value="0"' . ((!$data['bday_day']) ? ' selected="selected"' : '') . '>--</option>'; |
| 1406 | for ($i = 1; $i < 32; $i++) |
| 1407 | {
|
| 1408 | $selected = ($i == $data['bday_day']) ? ' selected="selected"' : ''; |
| 1409 | $s_birthday_day_options .= "<option value=\"$i\"$selected>$i</option>"; |
| 1410 | } |
| 1411 | |
| 1412 | $s_birthday_month_options = '<option value="0"' . ((!$data['bday_month']) ? ' selected="selected"' : '') . '>--</option>'; |
| 1413 | for ($i = 1; $i < 13; $i++) |
| 1414 | {
|
| 1415 | $selected = ($i == $data['bday_month']) ? ' selected="selected"' : ''; |
| 1416 | $s_birthday_month_options .= "<option value=\"$i\"$selected>$i</option>"; |
| 1417 | } |
| 1418 | $s_birthday_year_options = ''; |
| 1419 | |
| 1420 | $now = getdate(); |
| 1421 | $s_birthday_year_options = '<option value="0"' . ((!$data['bday_year']) ? ' selected="selected"' : '') . '>--</option>'; |
| 1422 | for ($i = $now['year'] - 100; $i <= $now['year']; $i++) |
| 1423 | {
|
| 1424 | $selected = ($i == $data['bday_year']) ? ' selected="selected"' : ''; |
| 1425 | $s_birthday_year_options .= "<option value=\"$i\"$selected>$i</option>"; |
| 1426 | } |
| 1427 | unset($now); |
| 1428 | |
| 1429 | $template->assign_vars(array( |
| 1430 | 'ICQ' => $data['icq'], |
| 1431 | 'YIM' => $data['yim'], |
| 1432 | 'AIM' => $data['aim'], |
| 1433 | 'MSN' => $data['msn'], |
| 1434 | 'JABBER' => $data['jabber'], |
| 1435 | 'WEBSITE' => $data['website'], |
| 1436 | 'LOCATION' => $data['location'], |
| 1437 | 'OCCUPATION' => $data['occupation'], |
| 1438 | 'INTERESTS' => $data['interests'], |
| 1439 | |
| 1440 | 'S_BIRTHDAY_DAY_OPTIONS' => $s_birthday_day_options, |
| 1441 | 'S_BIRTHDAY_MONTH_OPTIONS' => $s_birthday_month_options, |
| 1442 | 'S_BIRTHDAY_YEAR_OPTIONS' => $s_birthday_year_options, |
| 1443 | |
| 1444 | 'S_PROFILE' => true) |
| 1445 | ); |
| 1446 | |
| 1447 | // Get additional profile fields and assign them to the template block var 'profile_fields'
|
| 1448 | $user->get_profile_fields($user_id); |
| 1449 | |
| 1450 | $cp->generate_profile_fields('profile', $user_row['iso_lang_id']); |
| 1451 | |
| 1452 | break;
|
| 1453 | |
| 1454 | case 'prefs': |
| 1455 | |
| 1456 | include($phpbb_root_path . 'includes/functions_user.' . $phpEx); |
| 1457 | |
| 1458 | $data = array( |
| 1459 | 'dateformat' => utf8_normalize_nfc(request_var('dateformat', $user_row['user_dateformat'], true)), |
| 1460 | 'lang' => basename(request_var('lang', $user_row['user_lang'])), |
| 1461 | 'tz' => request_var('tz', (float) $user_row['user_timezone']), |
| 1462 | 'style' => request_var('style', $user_row['user_style']), |
| 1463 | 'dst' => request_var('dst', $user_row['user_dst']), |
| 1464 | 'viewemail' => request_var('viewemail', $user_row['user_allow_viewemail']), |
| 1465 | 'massemail' => request_var('massemail', $user_row['user_allow_massemail']), |
| 1466 | 'hideonline' => request_var('hideonline', !$user_row['user_allow_viewonline']), |
| 1467 | 'notifymethod' => request_var('notifymethod', $user_row['user_notify_type']), |
| 1468 | 'notifypm' => request_var('notifypm', $user_row['user_notify_pm']), |
| 1469 | 'popuppm' => request_var('popuppm', $this->optionget($user_row, 'popuppm')), |
| 1470 | 'allowpm' => request_var('allowpm', $user_row['user_allow_pm']), |
| 1471 | |
| 1472 | 'topic_sk' => request_var('topic_sk', ($user_row['user_topic_sortby_type']) ? $user_row['user_topic_sortby_type'] : 't'), |
| 1473 | 'topic_sd' => request_var('topic_sd', ($user_row['user_topic_sortby_dir']) ? $user_row['user_topic_sortby_dir'] : 'd'), |
| 1474 | 'topic_st' => request_var('topic_st', ($user_row['user_topic_show_days']) ? $user_row['user_topic_show_days'] : 0), |
| 1475 | |
| 1476 | 'post_sk' => request_var('post_sk', ($user_row['user_post_sortby_type']) ? $user_row['user_post_sortby_type'] : 't'), |
| 1477 | 'post_sd' => request_var('post_sd', ($user_row['user_post_sortby_dir']) ? $user_row['user_post_sortby_dir'] : 'a'), |
| 1478 | 'post_st' => request_var('post_st', ($user_row['user_post_show_days']) ? $user_row['user_post_show_days'] : 0), |
| 1479 | |
| 1480 | 'view_images' => request_var('view_images', $this->optionget($user_row, 'viewimg')), |
| 1481 | 'view_flash' => request_var('view_flash', $this->optionget($user_row, 'viewflash')), |
| 1482 | 'view_smilies' => request_var('view_smilies', $this->optionget($user_row, 'viewsmilies')), |
| 1483 | 'view_sigs' => request_var('view_sigs', $this->optionget($user_row, 'viewsigs')), |
| 1484 | 'view_avatars' => request_var('view_avatars', $this->optionget($user_row, 'viewavatars')), |
| 1485 | 'view_wordcensor' => request_var('view_wordcensor', $this->optionget($user_row, 'viewcensors')), |
| 1486 | |
| 1487 | 'bbcode' => request_var('bbcode', $this->optionget($user_row, 'bbcode')), |
| 1488 | 'smilies' => request_var('smilies', $this->optionget($user_row, 'smilies')), |
| 1489 | 'sig' => request_var('sig', $this->optionget($user_row, 'attachsig')), |
| 1490 | 'notify' => request_var('notify', $user_row['user_notify']), |
| 1491 | ); |
| 1492 | |
| 1493 | if ($submit) |
| 1494 | {
|
| 1495 | $error = validate_data($data, array( |
| 1496 | 'dateformat' => array('string', false, 1, 30), |
| 1497 | 'lang' => array('match', false, '#^[a-z_\-]{2,}$#i'), |
| 1498 | 'tz' => array('num', false, -14, 14), |
| 1499 | |
| 1500 | 'topic_sk' => array('string', false, 1, 1), |
| 1501 | 'topic_sd' => array('string', false, 1, 1), |
| 1502 | 'post_sk' => array('string', false, 1, 1), |
| 1503 | 'post_sd' => array('string', false, 1, 1), |
| 1504 | )); |
| 1505 | |
| 1506 | if (!check_form_key($form_name)) |
| 1507 | {
|
| 1508 | $error[] = 'FORM_INVALID'; |
| 1509 | } |
| 1510 | |
| 1511 | if (!sizeof($error)) |
| 1512 | {
|
| 1513 | $this->optionset($user_row, 'popuppm', $data['popuppm']); |
| 1514 | $this->optionset($user_row, 'viewimg', $data['view_images']); |
| 1515 | $this->optionset($user_row, 'viewflash', $data['view_flash']); |
| 1516 | $this->optionset($user_row, 'viewsmilies', $data['view_smilies']); |
| 1517 | $this->optionset($user_row, 'viewsigs', $data['view_sigs']); |
| 1518 | $this->optionset($user_row, 'viewavatars', $data['view_avatars']); |
| 1519 | $this->optionset($user_row, 'viewcensors', $data['view_wordcensor']); |
| 1520 | $this->optionset($user_row, 'bbcode', $data['bbcode']); |
| 1521 | $this->optionset($user_row, 'smilies', $data['smilies']); |
| 1522 | $this->optionset($user_row, 'attachsig', $data['sig']); |
| 1523 | |
| 1524 | $sql_ary = array( |
| 1525 | 'user_options' => $user_row['user_options'], |
| 1526 | |
| 1527 | 'user_allow_pm' => $data['allowpm'], |
| 1528 | 'user_allow_viewemail' => $data['viewemail'], |
| 1529 | 'user_allow_massemail' => $data['massemail'], |
| 1530 | 'user_allow_viewonline' => !$data['hideonline'], |
| 1531 | 'user_notify_type' => $data['notifymethod'], |
| 1532 | 'user_notify_pm' => $data['notifypm'], |
| 1533 | |
| 1534 | 'user_dst' => $data['dst'], |
| 1535 | 'user_dateformat' => $data['dateformat'], |
| 1536 | 'user_lang' => $data['lang'], |
| 1537 | 'user_timezone' => $data['tz'], |
| 1538 | 'user_style' => $data['style'], |
| 1539 | |
| 1540 | 'user_topic_sortby_type' => $data['topic_sk'], |
| 1541 | 'user_post_sortby_type' => $data['post_sk'], |
| 1542 | 'user_topic_sortby_dir' => $data['topic_sd'], |
| 1543 | 'user_post_sortby_dir' => $data['post_sd'], |
| 1544 | |
| 1545 | 'user_topic_show_days' => $data['topic_st'], |
| 1546 | 'user_post_show_days' => $data['post_st'], |
| 1547 | |
| 1548 | 'user_notify' => $data['notify'], |
| 1549 | ); |
| 1550 | |
| 1551 | $sql = 'UPDATE ' . USERS_TABLE . ' |
| 1552 | SET ' . $db->sql_build_array('UPDATE', $sql_ary) . " |
| 1553 | WHERE user_id = $user_id"; |
| 1554 | $db->sql_query($sql); |
| 1555 | |
| 1556 | // Check if user has an active session
|
| 1557 | if ($user_row['session_id']) |
| 1558 | {
|
| 1559 | // We'll update the session if user_allow_viewonline has changed and the user is a bot
|
| 1560 | // Or if it's a regular user and the admin set it to hide the session
|
| 1561 | if ($user_row['user_allow_viewonline'] != $sql_ary['user_allow_viewonline'] && $user_row['user_type'] == USER_IGNORE |
| 1562 | || $user_row['user_allow_viewonline'] && !$sql_ary['user_allow_viewonline']) |
| 1563 | {
|
| 1564 | // We also need to check if the user has the permission to cloak.
|
| 1565 | $user_auth = new auth(); |
| 1566 | $user_auth->acl($user_row); |
| 1567 | |
| 1568 | $session_sql_ary = array( |
| 1569 | 'session_viewonline' => ($user_auth->acl_get('u_hideonline')) ? $sql_ary['user_allow_viewonline'] : true, |
| 1570 | ); |
| 1571 | |
| 1572 | $sql = 'UPDATE ' . SESSIONS_TABLE . ' |
| 1573 | SET ' . $db->sql_build_array('UPDATE', $session_sql_ary) . " |
| 1574 | WHERE session_user_id = $user_id"; |
| 1575 | $db->sql_query($sql); |
| 1576 | |
| 1577 | unset($user_auth); |
| 1578 | } |
| 1579 | } |
| 1580 | |
| 1581 | trigger_error($user->lang['USER_PREFS_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_id)); |
| 1582 | } |
| 1583 | |
| 1584 | // Replace "error" strings with their real, localised form
|
| 1585 | $error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error); |
| 1586 | } |
| 1587 | |
| 1588 | $dateformat_options = ''; |
| 1589 | foreach ($user->lang['dateformats'] as $format => $null) |
| 1590 | {
|
| 1591 | $dateformat_options .= '<option value="' . $format . '"' . (($format == $data['dateformat']) ? ' selected="selected"' : '') . '>'; |
| 1592 | $dateformat_options .= $user->format_date(time(), $format, false) . ((strpos($format, '|') !== false) ? $user->lang['VARIANT_DATE_SEPARATOR'] . $user->format_date(time(), $format, true) : ''); |
| 1593 | $dateformat_options .= '</option>'; |
| 1594 | } |
| 1595 | |
| 1596 | $s_custom = false; |
| 1597 | |
| 1598 | $dateformat_options .= '<option value="custom"'; |
| 1599 | if (!isset($user->lang['dateformats'][$data['dateformat']])) |
| 1600 | {
|
| 1601 | $dateformat_options .= ' selected="selected"'; |
| 1602 | $s_custom = true; |
| 1603 | } |
| 1604 | $dateformat_options .= '>' . $user->lang['CUSTOM_DATEFORMAT'] . '</option>'; |
| 1605 | |
| 1606 | $sort_dir_text = array('a' => $user->lang['ASCENDING'], 'd' => $user->lang['DESCENDING']); |
| 1607 | |
| 1608 | // Topic ordering options
|
| 1609 | $limit_topic_days = array(0 => $user->lang['ALL_TOPICS'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']); |
| 1610 | $sort_by_topic_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 'r' => $user->lang['REPLIES'], 's' => $user->lang['SUBJECT'], 'v' => $user->lang['VIEWS']); |
| 1611 | |
| 1612 | // Post ordering options
|
| 1613 | $limit_post_days = array(0 => $user->lang['ALL_POSTS'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']); |
| 1614 | $sort_by_post_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 's' => $user->lang['SUBJECT']); |
| 1615 | |
| 1616 | $_options = array('topic', 'post'); |
| 1617 | foreach ($_options as $sort_option) |
| 1618 | {
|
| 1619 | ${'s_limit_' . $sort_option . '_days'} = '<select name="' . $sort_option . '_st">';
|
| 1620 | foreach (${'limit_' . $sort_option . '_days'} as $day => $text) |
| 1621 | {
|
| 1622 | $selected = ($data[$sort_option . '_st'] == $day) ? ' selected="selected"' : ''; |
| 1623 | ${'s_limit_' . $sort_option . '_days'} .= '<option value="' . $day . '"' . $selected . '>' . $text . '</option>';
|
| 1624 | } |
| 1625 | ${'s_limit_' . $sort_option . '_days'} .= '</select>';
|
| 1626 | |
| 1627 | ${'s_sort_' . $sort_option . '_key'} = '<select name="' . $sort_option . '_sk">';
|
| 1628 | foreach (${'sort_by_' . $sort_option . '_text'} as $key => $text) |
| 1629 | {
|
| 1630 | $selected = ($data[$sort_option . '_sk'] == $key) ? ' selected="selected"' : ''; |
| 1631 | ${'s_sort_' . $sort_option . '_key'} .= '<option value="' . $key . '"' . $selected . '>' . $text . '</option>';
|
| 1632 | } |
| 1633 | ${'s_sort_' . $sort_option . '_key'} .= '</select>';
|
| 1634 | |
| 1635 | ${'s_sort_' . $sort_option . '_dir'} = '<select name="' . $sort_option . '_sd">';
|
| 1636 | foreach ($sort_dir_text as $key => $value) |
| 1637 | {
|
| 1638 | $selected = ($data[$sort_option . '_sd'] == $key) ? ' selected="selected"' : ''; |
| 1639 | ${'s_sort_' . $sort_option . '_dir'} .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>';
|
| 1640 | } |
| 1641 | ${'s_sort_' . $sort_option . '_dir'} .= '</select>';
|
| 1642 | } |
| 1643 | |
| 1644 | $template->assign_vars(array( |
| 1645 | 'S_PREFS' => true, |
| 1646 | 'S_JABBER_DISABLED' => ($config['jab_enable'] && $user_row['user_jabber'] && @extension_loaded('xml')) ? false : true, |
| 1647 | |
| 1648 | 'VIEW_EMAIL' => $data['viewemail'], |
| 1649 | 'MASS_EMAIL' => $data['massemail'], |
| 1650 | 'ALLOW_PM' => $data['allowpm'], |
| 1651 | 'HIDE_ONLINE' => $data['hideonline'], |
| 1652 | 'NOTIFY_EMAIL' => ($data['notifymethod'] == NOTIFY_EMAIL) ? true : false, |
| 1653 | 'NOTIFY_IM' => ($data['notifymethod'] == NOTIFY_IM) ? true : false, |
| 1654 | 'NOTIFY_BOTH' => ($data['notifymethod'] == NOTIFY_BOTH) ? true : false, |
| 1655 | 'NOTIFY_PM' => $data['notifypm'], |
| 1656 | 'POPUP_PM' => $data['popuppm'], |
| 1657 | 'DST' => $data['dst'], |
| 1658 | 'BBCODE' => $data['bbcode'], |
| 1659 | 'SMILIES' => $data['smilies'], |
| 1660 | 'ATTACH_SIG' => $data['sig'], |
| 1661 | 'NOTIFY' => $data['notify'], |
| 1662 | 'VIEW_IMAGES' => $data['view_images'], |
| 1663 | 'VIEW_FLASH' => $data['view_flash'], |
| 1664 | 'VIEW_SMILIES' => $data['view_smilies'], |
| 1665 | 'VIEW_SIGS' => $data['view_sigs'], |
| 1666 | 'VIEW_AVATARS' => $data['view_avatars'], |
| 1667 | 'VIEW_WORDCENSOR' => $data['view_wordcensor'], |
| 1668 | |
| 1669 | 'S_TOPIC_SORT_DAYS' => $s_limit_topic_days, |
| 1670 | 'S_TOPIC_SORT_KEY' => $s_sort_topic_key, |
| 1671 | 'S_TOPIC_SORT_DIR' => $s_sort_topic_dir, |
| 1672 | 'S_POST_SORT_DAYS' => $s_limit_post_days, |
| 1673 | 'S_POST_SORT_KEY' => $s_sort_post_key, |
| 1674 | 'S_POST_SORT_DIR' => $s_sort_post_dir, |
| 1675 | |
| 1676 | 'DATE_FORMAT' => $data['dateformat'], |
| 1677 | 'S_DATEFORMAT_OPTIONS' => $dateformat_options, |
| 1678 | 'S_CUSTOM_DATEFORMAT' => $s_custom, |
| 1679 | 'DEFAULT_DATEFORMAT' => $config['default_dateformat'], |
| 1680 | 'A_DEFAULT_DATEFORMAT' => addslashes($config['default_dateformat']), |
| 1681 | |
| 1682 | 'S_LANG_OPTIONS' => language_select($data['lang']), |
| 1683 | 'S_STYLE_OPTIONS' => style_select($data['style']), |
| 1684 | 'S_TZ_OPTIONS' => tz_select($data['tz'], true), |
| 1685 | ) |
| 1686 | ); |
| 1687 | |
| 1688 | break;
|
| 1689 | |
| 1690 | case 'avatar': |
| 1691 | |
| 1692 | include($phpbb_root_path . 'includes/functions_display.' . $phpEx); |
| 1693 | include($phpbb_root_path . 'includes/functions_user.' . $phpEx); |
| 1694 | |
| 1695 | $can_upload = (file_exists($phpbb_root_path . $config['avatar_path']) && phpbb_is_writable($phpbb_root_path . $config['avatar_path']) && $file_uploads) ? true : false; |
| 1696 | |
| 1697 | if ($submit) |
| 1698 | {
|
| 1699 | |
| 1700 | if (!check_form_key($form_name)) |
| 1701 | {
|
| 1702 | trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); |
| 1703 | } |
| 1704 | |
| 1705 | if (avatar_process_user($error, $user_row, $can_upload)) |
| 1706 | {
|
| 1707 | trigger_error($user->lang['USER_AVATAR_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_row['user_id'])); |
| 1708 | } |
| 1709 | |
| 1710 | // Replace "error" strings with their real, localised form
|
| 1711 | $error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error); |
| 1712 | } |
| 1713 | |
| 1714 | if (!$config['allow_avatar'] && $user_row['user_avatar_type']) |
| 1715 | {
|
| 1716 | $error[] = $user->lang['USER_AVATAR_NOT_ALLOWED']; |
| 1717 | } |
| 1718 | else if ((($user_row['user_avatar_type'] == AVATAR_UPLOAD) && !$config['allow_avatar_upload']) || |
| 1719 | (($user_row['user_avatar_type'] == AVATAR_REMOTE) && !$config['allow_avatar_remote']) || |
| 1720 | (($user_row['user_avatar_type'] == AVATAR_GALLERY) && !$config['allow_avatar_local'])) |
| 1721 | {
|
| 1722 | $error[] = $user->lang['USER_AVATAR_TYPE_NOT_ALLOWED']; |
| 1723 | } |
| 1724 | |
| 1725 | // Generate users avatar
|
| 1726 | $avatar_img = ($user_row['user_avatar']) ? get_user_avatar($user_row['user_avatar'], $user_row['user_avatar_type'], $user_row['user_avatar_width'], $user_row['user_avatar_height'], 'USER_AVATAR', true) : '<img src="' . $phpbb_admin_path . 'images/no_avatar.gif" alt="" />'; |
| 1727 | |
| 1728 | $display_gallery = (isset($_POST['display_gallery'])) ? true : false; |
| 1729 | $avatar_select = basename(request_var('avatar_select', '')); |
| 1730 | $category = basename(request_var('category', '')); |
| 1731 | |
| 1732 | if ($config['allow_avatar_local'] && $display_gallery) |
| 1733 | {
|
| 1734 | avatar_gallery($category, $avatar_select, 4); |
| 1735 | } |
| 1736 | |
| 1737 | $template->assign_vars(array( |
| 1738 | 'S_AVATAR' => true, |
| 1739 | 'S_CAN_UPLOAD' => $can_upload, |
| 1740 | 'S_UPLOAD_FILE' => ($config['allow_avatar'] && $can_upload && $config['allow_avatar_upload']) ? true : false, |
| 1741 | 'S_REMOTE_UPLOAD' => ($config['allow_avatar'] && $can_upload && $config['allow_avatar_remote_upload']) ? true : false, |
| 1742 | 'S_ALLOW_REMOTE' => ($config['allow_avatar'] && $config['allow_avatar_remote']) ? true : false, |
| 1743 | 'S_DISPLAY_GALLERY' => ($config['allow_avatar'] && $config['allow_avatar_local'] && !$display_gallery) ? true : false, |
| 1744 | 'S_IN_GALLERY' => ($config['allow_avatar'] && $config['allow_avatar_local'] && $display_gallery) ? true : false, |
| 1745 | |
| 1746 | 'AVATAR_IMAGE' => $avatar_img, |
| 1747 | 'AVATAR_MAX_FILESIZE' => $config['avatar_filesize'], |
| 1748 | 'USER_AVATAR_WIDTH' => $user_row['user_avatar_width'], |
| 1749 | 'USER_AVATAR_HEIGHT' => $user_row['user_avatar_height'], |
| 1750 | |
| 1751 | 'L_AVATAR_EXPLAIN' => sprintf($user->lang['AVATAR_EXPLAIN'], $config['avatar_max_width'], $config['avatar_max_height'], round($config['avatar_filesize'] / 1024))) |
| 1752 | ); |
| 1753 | |
| 1754 | break;
|
| 1755 | |
| 1756 | case 'rank': |
| 1757 | |
| 1758 | if ($submit) |
| 1759 | {
|
| 1760 | if (!check_form_key($form_name)) |
| 1761 | {
|
| 1762 | trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); |
| 1763 | } |
| 1764 | |
| 1765 | $rank_id = request_var('user_rank', 0); |
| 1766 | |
| 1767 | $sql = 'UPDATE ' . USERS_TABLE . " |
| 1768 | SET user_rank = $rank_id |
| 1769 | WHERE user_id = $user_id"; |
| 1770 | $db->sql_query($sql); |
| 1771 | |
| 1772 | trigger_error($user->lang['USER_RANK_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_id)); |
| 1773 | } |
| 1774 | |
| 1775 | $sql = 'SELECT * |
| 1776 | FROM ' . RANKS_TABLE . ' |
| 1777 | WHERE rank_special = 1 |
| 1778 | ORDER BY rank_title';
|
| 1779 | $result = $db->sql_query($sql); |
| 1780 | |
| 1781 | $s_rank_options = '<option value="0"' . ((!$user_row['user_rank']) ? ' selected="selected"' : '') . '>' . $user->lang['NO_SPECIAL_RANK'] . '</option>'; |
| 1782 | |
| 1783 | while ($row = $db->sql_fetchrow($result)) |
| 1784 | {
|
| 1785 | $selected = ($user_row['user_rank'] && $row['rank_id'] == $user_row['user_rank']) ? ' selected="selected"' : ''; |
| 1786 | $s_rank_options .= '<option value="' . $row['rank_id'] . '"' . $selected . '>' . $row['rank_title'] . '</option>'; |
| 1787 | } |
| 1788 | $db->sql_freeresult($result); |
| 1789 | |
| 1790 | $template->assign_vars(array( |
| 1791 | 'S_RANK' => true, |
| 1792 | 'S_RANK_OPTIONS' => $s_rank_options) |
| 1793 | ); |
| 1794 | |
| 1795 | break;
|
| 1796 | |
| 1797 | case 'sig': |
| 1798 | |
| 1799 | include_once($phpbb_root_path . 'includes/functions_posting.' . $phpEx); |
| 1800 | include_once($phpbb_root_path . 'includes/functions_display.' . $phpEx); |
| 1801 | |
| 1802 | $enable_bbcode = ($config['allow_sig_bbcode']) ? (bool) $this->optionget($user_row, 'sig_bbcode') : false; |
| 1803 | $enable_smilies = ($config['allow_sig_smilies']) ? (bool) $this->optionget($user_row, 'sig_smilies') : false; |
| 1804 | $enable_urls = ($config['allow_sig_links']) ? (bool) $this->optionget($user_row, 'sig_links') : false; |
| 1805 | $signature = utf8_normalize_nfc(request_var('signature', (string) $user_row['user_sig'], true)); |
| 1806 | |
| 1807 | $preview = (isset($_POST['preview'])) ? true : false; |
| 1808 | |
| 1809 | if ($submit || $preview) |
| 1810 | {
|
| 1811 | include_once($phpbb_root_path . 'includes/message_parser.' . $phpEx); |
| 1812 | |
| 1813 | $enable_bbcode = ($config['allow_sig_bbcode']) ? ((request_var('disable_bbcode', false)) ? false : true) : false; |
| 1814 | $enable_smilies = ($config['allow_sig_smilies']) ? ((request_var('disable_smilies', false)) ? false : true) : false; |
| 1815 | $enable_urls = ($config['allow_sig_links']) ? ((request_var('disable_magic_url', false)) ? false : true) : false; |
| 1816 | |
| 1817 | $message_parser = new parse_message($signature); |
| 1818 | |
| 1819 | // Allowing Quote BBCode
|
| 1820 | $message_parser->parse($enable_bbcode, $enable_urls, $enable_smilies, $config['allow_sig_img'], $config['allow_sig_flash'], true, $config['allow_sig_links'], true, 'sig'); |
| 1821 | |
| 1822 | if (sizeof($message_parser->warn_msg)) |
| 1823 | {
|
| 1824 | $error[] = implode('<br />', $message_parser->warn_msg); |
| 1825 | } |
| 1826 | |
| 1827 | if (!check_form_key($form_name)) |
| 1828 | {
|
| 1829 | $error = 'FORM_INVALID'; |
| 1830 | } |
| 1831 | |
| 1832 | if (!sizeof($error) && $submit) |
| 1833 | {
|
| 1834 | $this->optionset($user_row, 'sig_bbcode', $enable_bbcode); |
| 1835 | $this->optionset($user_row, 'sig_smilies', $enable_smilies); |
| 1836 | $this->optionset($user_row, 'sig_links', $enable_urls); |
| 1837 | |
| 1838 | $sql_ary = array( |
| 1839 | 'user_sig' => (string) $message_parser->message, |
| 1840 | 'user_options' => $user_row['user_options'], |
| 1841 | 'user_sig_bbcode_uid' => (string) $message_parser->bbcode_uid, |
| 1842 | 'user_sig_bbcode_bitfield' => (string) $message_parser->bbcode_bitfield |
| 1843 | ); |
| 1844 | |
| 1845 | $sql = 'UPDATE ' . USERS_TABLE . ' |
| 1846 | SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' |
| 1847 | WHERE user_id = ' . $user_id; |
| 1848 | $db->sql_query($sql); |
| 1849 | |
| 1850 | trigger_error($user->lang['USER_SIG_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_id)); |
| 1851 | } |
| 1852 | |
| 1853 | // Replace "error" strings with their real, localised form
|
| 1854 | $error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error); |
| 1855 | } |
| 1856 | |
| 1857 | $signature_preview = ''; |
| 1858 | |
| 1859 | if ($preview) |
| 1860 | {
|
| 1861 | // Now parse it for displaying
|
| 1862 | $signature_preview = $message_parser->format_display($enable_bbcode, $enable_urls, $enable_smilies, false); |
| 1863 | unset($message_parser); |
| 1864 | } |
| 1865 | |
| 1866 | decode_message($signature, $user_row['user_sig_bbcode_uid']); |
| 1867 | |
| 1868 | $template->assign_vars(array( |
| 1869 | 'S_SIGNATURE' => true, |
| 1870 | |
| 1871 | 'SIGNATURE' => $signature, |
| 1872 | 'SIGNATURE_PREVIEW' => $signature_preview, |
| 1873 | |
| 1874 | 'S_BBCODE_CHECKED' => (!$enable_bbcode) ? ' checked="checked"' : '', |
| 1875 | 'S_SMILIES_CHECKED' => (!$enable_smilies) ? ' checked="checked"' : '', |
| 1876 | 'S_MAGIC_URL_CHECKED' => (!$enable_urls) ? ' checked="checked"' : '', |
| 1877 | |
| 1878 | 'BBCODE_STATUS' => ($config['allow_sig_bbcode']) ? sprintf($user->lang['BBCODE_IS_ON'], '<a href="' . append_sid("{$phpbb_root_path}faq.$phpEx", 'mode=bbcode') . '">', '</a>') : sprintf($user->lang['BBCODE_IS_OFF'], '<a href="' . append_sid("{$phpbb_root_path}faq.$phpEx", 'mode=bbcode') . '">', '</a>'), |
| 1879 | 'SMILIES_STATUS' => ($config['allow_sig_smilies']) ? $user->lang['SMILIES_ARE_ON'] : $user->lang['SMILIES_ARE_OFF'], |
| 1880 | 'IMG_STATUS' => ($config['allow_sig_img']) ? $user->lang['IMAGES_ARE_ON'] : $user->lang['IMAGES_ARE_OFF'], |
| 1881 | 'FLASH_STATUS' => ($config['allow_sig_flash']) ? $user->lang['FLASH_IS_ON'] : $user->lang['FLASH_IS_OFF'], |
| 1882 | 'URL_STATUS' => ($config['allow_sig_links']) ? $user->lang['URL_IS_ON'] : $user->lang['URL_IS_OFF'], |
| 1883 | |
| 1884 | 'L_SIGNATURE_EXPLAIN' => sprintf($user->lang['SIGNATURE_EXPLAIN'], $config['max_sig_chars']), |
| 1885 | |
| 1886 | 'S_BBCODE_ALLOWED' => $config['allow_sig_bbcode'], |
| 1887 | 'S_SMILIES_ALLOWED' => $config['allow_sig_smilies'], |
| 1888 | 'S_BBCODE_IMG' => ($config['allow_sig_img']) ? true : false, |
| 1889 | 'S_BBCODE_FLASH' => ($config['allow_sig_flash']) ? true : false, |
| 1890 | 'S_LINKS_ALLOWED' => ($config['allow_sig_links']) ? true : false) |
| 1891 | ); |
| 1892 | |
| 1893 | // Assigning custom bbcodes
|
| 1894 | display_custom_bbcodes(); |
| 1895 | |
| 1896 | break;
|
| 1897 | |
| 1898 | case 'attach': |
| 1899 | |
| 1900 | $start = request_var('start', 0); |
| 1901 | $deletemark = (isset($_POST['delmarked'])) ? true : false; |
| 1902 | $marked = request_var('mark', array(0)); |
| 1903 | |
| 1904 | // Sort keys
|
| 1905 | $sort_key = request_var('sk', 'a'); |
| 1906 | $sort_dir = request_var('sd', 'd'); |
| 1907 | |
| 1908 | if ($deletemark && sizeof($marked)) |
| 1909 | {
|
| 1910 | $sql = 'SELECT attach_id |
| 1911 | FROM ' . ATTACHMENTS_TABLE . ' |
| 1912 | WHERE poster_id = ' . $user_id . ' |
| 1913 | AND is_orphan = 0 |
| 1914 | AND ' . $db->sql_in_set('attach_id', $marked); |
| 1915 | $result = $db->sql_query($sql); |
| 1916 | |
| 1917 | $marked = array(); |
| 1918 | while ($row = $db->sql_fetchrow($result)) |
| 1919 | {
|
| 1920 | $marked[] = $row['attach_id']; |
| 1921 | } |
| 1922 | $db->sql_freeresult($result); |
| 1923 | } |
| 1924 | |
| 1925 | if ($deletemark && sizeof($marked)) |
| 1926 | {
|
| 1927 | if (confirm_box(true)) |
| 1928 | {
|
| 1929 | $sql = 'SELECT real_filename |
| 1930 | FROM ' . ATTACHMENTS_TABLE . ' |
| 1931 | WHERE ' . $db->sql_in_set('attach_id', $marked); |
| 1932 | $result = $db->sql_query($sql); |
| 1933 | |
| 1934 | $log_attachments = array(); |
| 1935 | while ($row = $db->sql_fetchrow($result)) |
| 1936 | {
|
| 1937 | $log_attachments[] = $row['real_filename']; |
| 1938 | } |
| 1939 | $db->sql_freeresult($result); |
| 1940 | |
| 1941 | delete_attachments('attach', $marked); |
| 1942 | |
| 1943 | $message = (sizeof($log_attachments) == 1) ? $user->lang['ATTACHMENT_DELETED'] : $user->lang['ATTACHMENTS_DELETED']; |
| 1944 | |
| 1945 | add_log('admin', 'LOG_ATTACHMENTS_DELETED', implode(', ', $log_attachments)); |
| 1946 | trigger_error($message . adm_back_link($this->u_action . '&u=' . $user_id)); |
| 1947 | } |
| 1948 | else
|
| 1949 | {
|
| 1950 | confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( |
| 1951 | 'u' => $user_id, |
| 1952 | 'i' => $id, |
| 1953 | 'mode' => $mode, |
| 1954 | 'action' => $action, |
| 1955 | 'delmarked' => true, |
| 1956 | 'mark' => $marked)) |
| 1957 | ); |
| 1958 | } |
| 1959 | } |
| 1960 | |
| 1961 | $sk_text = array('a' => $user->lang['SORT_FILENAME'], 'c' => $user->lang['SORT_EXTENSION'], 'd' => $user->lang['SORT_SIZE'], 'e' => $user->lang['SORT_DOWNLOADS'], 'f' => $user->lang['SORT_POST_TIME'], 'g' => $user->lang['SORT_TOPIC_TITLE']); |
| 1962 | $sk_sql = array('a' => 'a.real_filename', 'c' => 'a.extension', 'd' => 'a.filesize', 'e' => 'a.download_count', 'f' => 'a.filetime', 'g' => 't.topic_title'); |
| 1963 | |
| 1964 | $sd_text = array('a' => $user->lang['ASCENDING'], 'd' => $user->lang['DESCENDING']); |
| 1965 | |
| 1966 | $s_sort_key = ''; |
| 1967 | foreach ($sk_text as $key => $value) |
| 1968 | {
|
| 1969 | $selected = ($sort_key == $key) ? ' selected="selected"' : ''; |
| 1970 | $s_sort_key .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>'; |
| 1971 | } |
| 1972 | |
| 1973 | $s_sort_dir = ''; |
| 1974 | foreach ($sd_text as $key => $value) |
| 1975 | {
|
| 1976 | $selected = ($sort_dir == $key) ? ' selected="selected"' : ''; |
| 1977 | $s_sort_dir .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>'; |
| 1978 | } |
| 1979 | |
| 1980 | if (!isset($sk_sql[$sort_key])) |
| 1981 | {
|
| 1982 | $sort_key = 'a'; |
| 1983 | } |
| 1984 | |
| 1985 | $order_by = $sk_sql[$sort_key] . ' ' . (($sort_dir == 'a') ? 'ASC' : 'DESC'); |
| 1986 | |
| 1987 | $sql = 'SELECT COUNT(attach_id) as num_attachments |
| 1988 | FROM ' . ATTACHMENTS_TABLE . " |
| 1989 | WHERE poster_id = $user_id |
| 1990 | AND is_orphan = 0";
|
| 1991 | $result = $db->sql_query_limit($sql, 1); |
| 1992 | $num_attachments = (int) $db->sql_fetchfield('num_attachments'); |
| 1993 | $db->sql_freeresult($result); |
| 1994 | |
| 1995 | $sql = 'SELECT a.*, t.topic_title, p.message_subject as message_title |
| 1996 | FROM ' . ATTACHMENTS_TABLE . ' a |
| 1997 | LEFT JOIN ' . TOPICS_TABLE . ' t ON (a.topic_id = t.topic_id |
| 1998 | AND a.in_message = 0) |
| 1999 | LEFT JOIN ' . PRIVMSGS_TABLE . ' p ON (a.post_msg_id = p.msg_id |
| 2000 | AND a.in_message = 1) |
| 2001 | WHERE a.poster_id = ' . $user_id . " |
| 2002 | AND a.is_orphan = 0 |
| 2003 | ORDER BY $order_by"; |
| 2004 | $result = $db->sql_query_limit($sql, $config['posts_per_page'], $start); |
| 2005 | |
| 2006 | while ($row = $db->sql_fetchrow($result)) |
| 2007 | {
|
| 2008 | if ($row['in_message']) |
| 2009 | {
|
| 2010 | $view_topic = append_sid("{$phpbb_root_path}ucp.$phpEx", "i=pm&p={$row['post_msg_id']}"); |
| 2011 | } |
| 2012 | else
|
| 2013 | {
|
| 2014 | $view_topic = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "t={$row['topic_id']}&p={$row['post_msg_id']}") . '#p' . $row['post_msg_id']; |
| 2015 | } |
| 2016 | |
| 2017 | $template->assign_block_vars('attach', array( |
| 2018 | 'REAL_FILENAME' => $row['real_filename'], |
| 2019 | 'COMMENT' => nl2br($row['attach_comment']), |
| 2020 | 'EXTENSION' => $row['extension'], |
| 2021 | 'SIZE' => get_formatted_filesize($row['filesize']), |
| 2022 | 'DOWNLOAD_COUNT' => $row['download_count'], |
| 2023 | 'POST_TIME' => $user->format_date($row['filetime']), |
| 2024 | 'TOPIC_TITLE' => ($row['in_message']) ? $row['message_title'] : $row['topic_title'], |
| 2025 | |
| 2026 | 'ATTACH_ID' => $row['attach_id'], |
| 2027 | 'POST_ID' => $row['post_msg_id'], |
| 2028 | 'TOPIC_ID' => $row['topic_id'], |
| 2029 | |
| 2030 | 'S_IN_MESSAGE' => $row['in_message'], |
| 2031 | |
| 2032 | 'U_DOWNLOAD' => append_sid("{$phpbb_root_path}download/file.$phpEx", 'mode=view&id=' . $row['attach_id']), |
| 2033 | 'U_VIEW_TOPIC' => $view_topic) |
| 2034 | ); |
| 2035 | } |
| 2036 | $db->sql_freeresult($result); |
| 2037 | |
| 2038 | $template->assign_vars(array( |
| 2039 | 'S_ATTACHMENTS' => true, |
| 2040 | 'S_ON_PAGE' => on_page($num_attachments, $config['topics_per_page'], $start), |
| 2041 | 'S_SORT_KEY' => $s_sort_key, |
| 2042 | 'S_SORT_DIR' => $s_sort_dir, |
| 2043 | |
| 2044 | 'PAGINATION' => generate_pagination($this->u_action . "&u=$user_id&sk=$sort_key&sd=$sort_dir", $num_attachments, $config['topics_per_page'], $start, true)) |
| 2045 | ); |
| 2046 | |
| 2047 | break;
|
| 2048 | |
| 2049 | case 'groups': |
| 2050 | |
| 2051 | include($phpbb_root_path . 'includes/functions_user.' . $phpEx); |
| 2052 | |
| 2053 | $user->add_lang(array('groups', 'acp/groups')); |
| 2054 | $group_id = request_var('g', 0); |
| 2055 | |
| 2056 | if ($group_id) |
| 2057 | {
|
| 2058 | // Check the founder only entry for this group to make sure everything is well
|
| 2059 | $sql = 'SELECT group_founder_manage |
| 2060 | FROM ' . GROUPS_TABLE . ' |
| 2061 | WHERE group_id = ' . $group_id; |
| 2062 | $result = $db->sql_query($sql); |
| 2063 | $founder_manage = (int) $db->sql_fetchfield('group_founder_manage'); |
| 2064 | $db->sql_freeresult($result); |
| 2065 | |
| 2066 | if ($user->data['user_type'] != USER_FOUNDER && $founder_manage) |
| 2067 | {
|
| 2068 | trigger_error($user->lang['NOT_ALLOWED_MANAGE_GROUP'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); |
| 2069 | } |
| 2070 | } |
| 2071 | else
|
| 2072 | {
|
| 2073 | $founder_manage = 0; |
| 2074 | } |
| 2075 | |
| 2076 | switch ($action) |
| 2077 | {
|
| 2078 | case 'demote': |
| 2079 | case 'promote': |
| 2080 | case 'default': |
| 2081 | if (!$group_id) |
| 2082 | {
|
| 2083 | trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); |
| 2084 | } |
| 2085 | group_user_attributes($action, $group_id, $user_id); |
| 2086 | |
| 2087 | if ($action == 'default') |
| 2088 | {
|
| 2089 | $user_row['group_id'] = $group_id; |
| 2090 | } |
| 2091 | break;
|
| 2092 | |
| 2093 | case 'delete': |
| 2094 | |
| 2095 | if (confirm_box(true)) |
| 2096 | {
|
| 2097 | if (!$group_id) |
| 2098 | {
|
| 2099 | trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); |
| 2100 | } |
| 2101 | |
| 2102 | if ($error = group_user_del($group_id, $user_id)) |
| 2103 | {
|
| 2104 | trigger_error($user->lang[$error] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); |
| 2105 | } |
| 2106 | |
| 2107 | $error = array(); |
| 2108 | |
| 2109 | // The delete action was successful - therefore update the user row...
|
| 2110 | $sql = 'SELECT u.*, s.* |
| 2111 | FROM ' . USERS_TABLE . ' u |
| 2112 | LEFT JOIN ' . SESSIONS_TABLE . ' s ON (s.session_user_id = u.user_id) |
| 2113 | WHERE u.user_id = ' . $user_id . ' |
| 2114 | ORDER BY s.session_time DESC';
|
| 2115 | $result = $db->sql_query_limit($sql, 1); |
| 2116 | $user_row = $db->sql_fetchrow($result); |
| 2117 | $db->sql_freeresult($result); |
| 2118 | } |
| 2119 | else
|
| 2120 | {
|
| 2121 | confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( |
| 2122 | 'u' => $user_id, |
| 2123 | 'i' => $id, |
| 2124 | 'mode' => $mode, |
| 2125 | 'action' => $action, |
| 2126 | 'g' => $group_id)) |
| 2127 | ); |
| 2128 | } |
| 2129 | |
| 2130 | break;
|
| 2131 | |
| 2132 | case 'approve': |
| 2133 | |
| 2134 | if (confirm_box(true)) |
| 2135 | {
|
| 2136 | if (!$group_id) |
| 2137 | {
|
| 2138 | trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); |
| 2139 | } |
| 2140 | group_user_attributes($action, $group_id, $user_id); |
| 2141 | } |
| 2142 | else
|
| 2143 | {
|
| 2144 | confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( |
| 2145 | 'u' => $user_id, |
| 2146 | 'i' => $id, |
| 2147 | 'mode' => $mode, |
| 2148 | 'action' => $action, |
| 2149 | 'g' => $group_id)) |
| 2150 | ); |
| 2151 | } |
| 2152 | |
| 2153 | break;
|
| 2154 | } |
| 2155 | |
| 2156 | // Add user to group?
|
| 2157 | if ($submit) |
| 2158 | {
|
| 2159 | |
| 2160 | if (!check_form_key($form_name)) |
| 2161 | {
|
| 2162 | trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); |
| 2163 | } |
| 2164 | |
| 2165 | if (!$group_id) |
| 2166 | {
|
| 2167 | trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); |
| 2168 | } |
| 2169 | |
| 2170 | // Add user/s to group
|
| 2171 | if ($error = group_user_add($group_id, $user_id)) |
| 2172 | {
|
| 2173 | trigger_error($user->lang[$error] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); |
| 2174 | } |
| 2175 | |
| 2176 | $error = array(); |
| 2177 | } |
| 2178 | |
| 2179 | |
| 2180 | $sql = 'SELECT ug.*, g.* |
| 2181 | FROM ' . GROUPS_TABLE . ' g, ' . USER_GROUP_TABLE . " ug |
| 2182 | WHERE ug.user_id = $user_id |
| 2183 | AND g.group_id = ug.group_id |
| 2184 | ORDER BY g.group_type DESC, ug.user_pending ASC, g.group_name";
|
| 2185 | $result = $db->sql_query($sql); |
| 2186 | |
| 2187 | $i = 0; |
| 2188 | $group_data = $id_ary = array(); |
| 2189 | while ($row = $db->sql_fetchrow($result)) |
| 2190 | {
|
| 2191 | $type = ($row['group_type'] == GROUP_SPECIAL) ? 'special' : (($row['user_pending']) ? 'pending' : 'normal'); |
| 2192 | |
| 2193 | $group_data[$type][$i]['group_id'] = $row['group_id']; |
| 2194 | $group_data[$type][$i]['group_name'] = $row['group_name']; |
| 2195 | $group_data[$type][$i]['group_leader'] = ($row['group_leader']) ? 1 : 0; |
| 2196 | |
| 2197 | $id_ary[] = $row['group_id']; |
| 2198 | |
| 2199 | $i++;
|
| 2200 | } |
| 2201 | $db->sql_freeresult($result); |
| 2202 | |
| 2203 | // Select box for other groups
|
| 2204 | $sql = 'SELECT group_id, group_name, group_type, group_founder_manage |
| 2205 | FROM ' . GROUPS_TABLE . ' |
| 2206 | ' . ((sizeof($id_ary)) ? 'WHERE ' . $db->sql_in_set('group_id', $id_ary, true) : '') . ' |
| 2207 | ORDER BY group_type DESC, group_name ASC';
|
| 2208 | $result = $db->sql_query($sql); |
| 2209 | |
| 2210 | $s_group_options = ''; |
| 2211 | while ($row = $db->sql_fetchrow($result)) |
| 2212 | {
|
| 2213 | if (!$config['coppa_enable'] && $row['group_name'] == 'REGISTERED_COPPA') |
| 2214 | {
|
| 2215 | continue;
|
| 2216 | } |
| 2217 | |
| 2218 | // Do not display those groups not allowed to be managed
|
| 2219 | if ($user->data['user_type'] != USER_FOUNDER && $row['group_founder_manage']) |
| 2220 | {
|
| 2221 | continue;
|
| 2222 | } |
| 2223 | |
| 2224 | $s_group_options .= '<option' . (($row['group_type'] == GROUP_SPECIAL) ? ' class="sep"' : '') . ' value="' . $row['group_id'] . '">' . (($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name']) . '</option>'; |
| 2225 | } |
| 2226 | $db->sql_freeresult($result); |
| 2227 | |
| 2228 | $current_type = ''; |
| 2229 | foreach ($group_data as $group_type => $data_ary) |
| 2230 | {
|
| 2231 | if ($current_type != $group_type) |
| 2232 | {
|
| 2233 | $template->assign_block_vars('group', array( |
| 2234 | 'S_NEW_GROUP_TYPE' => true, |
| 2235 | 'GROUP_TYPE' => $user->lang['USER_GROUP_' . strtoupper($group_type)]) |
| 2236 | ); |
| 2237 | } |
| 2238 | |
| 2239 | foreach ($data_ary as $data) |
| 2240 | {
|
| 2241 | $template->assign_block_vars('group', array( |
| 2242 | 'U_EDIT_GROUP' => append_sid("{$phpbb_admin_path}index.$phpEx", "i=groups&mode=manage&action=edit&u=$user_id&g={$data['group_id']}&back_link=acp_users_groups"), |
| 2243 | 'U_DEFAULT' => $this->u_action . "&action=default&u=$user_id&g=" . $data['group_id'], |
| 2244 | 'U_DEMOTE_PROMOTE' => $this->u_action . '&action=' . (($data['group_leader']) ? 'demote' : 'promote') . "&u=$user_id&g=" . $data['group_id'], |
| 2245 | 'U_DELETE' => $this->u_action . "&action=delete&u=$user_id&g=" . $data['group_id'], |
| 2246 | 'U_APPROVE' => ($group_type == 'pending') ? $this->u_action . "&action=approve&u=$user_id&g=" . $data['group_id'] : '', |
| 2247 | |
| 2248 | 'GROUP_NAME' => ($group_type == 'special') ? $user->lang['G_' . $data['group_name']] : $data['group_name'], |
| 2249 | 'L_DEMOTE_PROMOTE' => ($data['group_leader']) ? $user->lang['GROUP_DEMOTE'] : $user->lang['GROUP_PROMOTE'], |
| 2250 | |
| 2251 | 'S_IS_MEMBER' => ($group_type != 'pending') ? true : false, |
| 2252 | 'S_NO_DEFAULT' => ($user_row['group_id'] != $data['group_id']) ? true : false, |
| 2253 | 'S_SPECIAL_GROUP' => ($group_type == 'special') ? true : false, |
| 2254 | ) |
| 2255 | ); |
| 2256 | } |
| 2257 | } |
| 2258 | |
| 2259 | $template->assign_vars(array( |
| 2260 | 'S_GROUPS' => true, |
| 2261 | 'S_GROUP_OPTIONS' => $s_group_options) |
| 2262 | ); |
| 2263 | |
| 2264 | break;
|
| 2265 | |
| 2266 | case 'perm': |
| 2267 | |
| 2268 | include_once($phpbb_root_path . 'includes/acp/auth.' . $phpEx); |
| 2269 | |
| 2270 | $auth_admin = new auth_admin(); |
| 2271 | |
| 2272 | $user->add_lang('acp/permissions'); |
| 2273 | add_permission_language(); |
| 2274 | |
| 2275 | $forum_id = request_var('f', 0); |
| 2276 | |
| 2277 | // Global Permissions
|
| 2278 | if (!$forum_id) |
| 2279 | {
|
| 2280 | // Select auth options
|
| 2281 | $sql = 'SELECT auth_option, is_local, is_global |
| 2282 | FROM ' . ACL_OPTIONS_TABLE . ' |
| 2283 | WHERE auth_option ' . $db->sql_like_expression($db->any_char . '_') . ' |
| 2284 | AND is_global = 1 |
| 2285 | ORDER BY auth_option';
|
| 2286 | $result = $db->sql_query($sql); |
| 2287 | |
| 2288 | $hold_ary = array(); |
| 2289 | |
| 2290 | while ($row = $db->sql_fetchrow($result)) |
| 2291 | {
|
| 2292 | $hold_ary = $auth_admin->get_mask('view', $user_id, false, false, $row['auth_option'], 'global', ACL_NEVER); |
| 2293 | $auth_admin->display_mask('view', $row['auth_option'], $hold_ary, 'user', false, false); |
| 2294 | } |
| 2295 | $db->sql_freeresult($result); |
| 2296 | |
| 2297 | unset($hold_ary); |
| 2298 | } |
| 2299 | else
|
| 2300 | {
|
| 2301 | $sql = 'SELECT auth_option, is_local, is_global |
| 2302 | FROM ' . ACL_OPTIONS_TABLE . " |
| 2303 | WHERE auth_option " . $db->sql_like_expression($db->any_char . '_') . " |
| 2304 | AND is_local = 1 |
| 2305 | ORDER BY is_global DESC, auth_option";
|
| 2306 | $result = $db->sql_query($sql); |
| 2307 | |
| 2308 | while ($row = $db->sql_fetchrow($result)) |
| 2309 | {
|
| 2310 | $hold_ary = $auth_admin->get_mask('view', $user_id, false, $forum_id, $row['auth_option'], 'local', ACL_NEVER); |
| 2311 | $auth_admin->display_mask('view', $row['auth_option'], $hold_ary, 'user', true, false); |
| 2312 | } |
| 2313 | $db->sql_freeresult($result); |
| 2314 | } |
| 2315 | |
| 2316 | $s_forum_options = '<option value="0"' . ((!$forum_id) ? ' selected="selected"' : '') . '>' . $user->lang['VIEW_GLOBAL_PERMS'] . '</option>'; |
| 2317 | $s_forum_options .= make_forum_select($forum_id, false, true, false, false, false); |
| 2318 | |
| 2319 | $template->assign_vars(array( |
| 2320 | 'S_PERMISSIONS' => true, |
| 2321 | |
| 2322 | 'S_GLOBAL' => (!$forum_id) ? true : false, |
| 2323 | 'S_FORUM_OPTIONS' => $s_forum_options, |
| 2324 | |
| 2325 | 'U_ACTION' => $this->u_action . '&u=' . $user_id, |
| 2326 | 'U_USER_PERMISSIONS' => append_sid("{$phpbb_admin_path}index.$phpEx" ,'i=permissions&mode=setting_user_global&user_id[]=' . $user_id), |
| 2327 | 'U_USER_FORUM_PERMISSIONS' => append_sid("{$phpbb_admin_path}index.$phpEx", 'i=permissions&mode=setting_user_local&user_id[]=' . $user_id)) |
| 2328 | ); |
| 2329 | |
| 2330 | break;
|
| 2331 | |
| 2332 | } |
| 2333 | |
| 2334 | // Assign general variables
|
| 2335 | $template->assign_vars(array( |
| 2336 | 'S_ERROR' => (sizeof($error)) ? true : false, |
| 2337 | 'ERROR_MSG' => (sizeof($error)) ? implode('<br />', $error) : '') |
| 2338 | ); |
| 2339 | } |
| 2340 | |
| 2341 | /**
|
| 2342 | * Set option bit field for user options in a user row array. |
| 2343 | * |
| 2344 | * Optionset replacement for this module based on $user->optionset. |
| 2345 | * |
| 2346 | * @param array $user_row Row from the users table. |
| 2347 | * @param int $key Option key, as defined in $user->keyoptions property. |
| 2348 | * @param bool $value True to set the option, false to clear the option. |
| 2349 | * @param int $data Current bit field value, or false to use $user_row['user_options'] |
| 2350 | * @return int|bool If $data is false, the bit field is modified and |
| 2351 | * written back to $user_row['user_options'], and |
| 2352 | * return value is true if the bit field changed and |
| 2353 | * false otherwise. If $data is not false, the new |
| 2354 | * bitfield value is returned. |
| 2355 | */ |
| 2356 | function optionset(&$user_row, $key, $value, $data = false) |
| 2357 | {
|
| 2358 | global $user; |
| 2359 | |
| 2360 | $var = ($data !== false) ? $data : $user_row['user_options']; |
| 2361 | |
| 2362 | $new_var = phpbb_optionset($user->keyoptions[$key], $value, $var); |
| 2363 | |
| 2364 | if ($data === false) |
| 2365 | {
|
| 2366 | if ($new_var != $var) |
| 2367 | {
|
| 2368 | $user_row['user_options'] = $new_var; |
| 2369 | return true; |
| 2370 | } |
| 2371 | else
|
| 2372 | {
|
| 2373 | return false; |
| 2374 | } |
| 2375 | } |
| 2376 | else
|
| 2377 | {
|
| 2378 | return $new_var; |
| 2379 | } |
| 2380 | } |
| 2381 | |
| 2382 | /**
|
| 2383 | * Get option bit field from user options in a user row array. |
| 2384 | * |
| 2385 | * Optionget replacement for this module based on $user->optionget. |
| 2386 | * |
| 2387 | * @param array $user_row Row from the users table. |
| 2388 | * @param int $key option key, as defined in $user->keyoptions property. |
| 2389 | * @param int $data bit field value to use, or false to use $user_row['user_options'] |
| 2390 | * @return bool true if the option is set in the bit field, false otherwise |
| 2391 | */ |
| 2392 | function optionget(&$user_row, $key, $data = false) |
| 2393 | {
|
| 2394 | global $user; |
| 2395 | |
| 2396 | $var = ($data !== false) ? $data : $user_row['user_options']; |
| 2397 | return phpbb_optionget($user->keyoptions[$key], $var); |
| 2398 | } |
| 2399 | } |
| 2400 | |
| 2401 | ?> |

