1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/includes/acp/acp_users.php Wed Mar 07 16:41:10 2012 +0400
1.3 @@ -0,0 +1,2386 @@
1.4 +<?php
1.5 +/**
1.6 +*
1.7 +* @package acp
1.8 +* @version $Id$
1.9 +* @copyright (c) 2005 phpBB Group
1.10 +* @license http://opensource.org/licenses/gpl-license.php GNU Public License
1.11 +*
1.12 +*/
1.13 +
1.14 +/**
1.15 +* @ignore
1.16 +*/
1.17 +if (!defined('IN_PHPBB'))
1.18 +{
1.19 + exit;
1.20 +}
1.21 +
1.22 +/**
1.23 +* @package acp
1.24 +*/
1.25 +class acp_users
1.26 +{
1.27 + var $u_action;
1.28 + var $p_master;
1.29 +
1.30 + function acp_users(&$p_master)
1.31 + {
1.32 + $this->p_master = &$p_master;
1.33 + }
1.34 +
1.35 + function main($id, $mode)
1.36 + {
1.37 + global $config, $db, $user, $auth, $template, $cache;
1.38 + global $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix, $file_uploads;
1.39 +
1.40 + $user->add_lang(array('posting', 'ucp', 'acp/users'));
1.41 + $this->tpl_name = 'acp_users';
1.42 + $this->page_title = 'ACP_USER_' . strtoupper($mode);
1.43 +
1.44 + $error = array();
1.45 + $username = utf8_normalize_nfc(request_var('username', '', true));
1.46 + $user_id = request_var('u', 0);
1.47 + $action = request_var('action', '');
1.48 +
1.49 + $submit = (isset($_POST['update']) && !isset($_POST['cancel'])) ? true : false;
1.50 +
1.51 + $form_name = 'acp_users';
1.52 + add_form_key($form_name);
1.53 +
1.54 + // Whois (special case)
1.55 + if ($action == 'whois')
1.56 + {
1.57 + include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
1.58 +
1.59 + $this->page_title = 'WHOIS';
1.60 + $this->tpl_name = 'simple_body';
1.61 +
1.62 + $user_ip = request_var('user_ip', '');
1.63 + $domain = gethostbyaddr($user_ip);
1.64 + $ipwhois = user_ipwhois($user_ip);
1.65 +
1.66 + $template->assign_vars(array(
1.67 + 'MESSAGE_TITLE' => sprintf($user->lang['IP_WHOIS_FOR'], $domain),
1.68 + 'MESSAGE_TEXT' => nl2br($ipwhois))
1.69 + );
1.70 +
1.71 + return;
1.72 + }
1.73 +
1.74 + // Show user selection mask
1.75 + if (!$username && !$user_id)
1.76 + {
1.77 + $this->page_title = 'SELECT_USER';
1.78 +
1.79 + $template->assign_vars(array(
1.80 + 'U_ACTION' => $this->u_action,
1.81 + 'ANONYMOUS_USER_ID' => ANONYMOUS,
1.82 +
1.83 + 'S_SELECT_USER' => true,
1.84 + 'U_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser&form=select_user&field=username&select_single=true'),
1.85 + ));
1.86 +
1.87 + return;
1.88 + }
1.89 +
1.90 + if (!$user_id)
1.91 + {
1.92 + $sql = 'SELECT user_id
1.93 + FROM ' . USERS_TABLE . "
1.94 + WHERE username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'";
1.95 + $result = $db->sql_query($sql);
1.96 + $user_id = (int) $db->sql_fetchfield('user_id');
1.97 + $db->sql_freeresult($result);
1.98 +
1.99 + if (!$user_id)
1.100 + {
1.101 + trigger_error($user->lang['NO_USER'] . adm_back_link($this->u_action), E_USER_WARNING);
1.102 + }
1.103 + }
1.104 +
1.105 + // Generate content for all modes
1.106 + $sql = 'SELECT u.*, s.*
1.107 + FROM ' . USERS_TABLE . ' u
1.108 + LEFT JOIN ' . SESSIONS_TABLE . ' s ON (s.session_user_id = u.user_id)
1.109 + WHERE u.user_id = ' . $user_id . '
1.110 + ORDER BY s.session_time DESC';
1.111 + $result = $db->sql_query_limit($sql, 1);
1.112 + $user_row = $db->sql_fetchrow($result);
1.113 + $db->sql_freeresult($result);
1.114 +
1.115 + if (!$user_row)
1.116 + {
1.117 + trigger_error($user->lang['NO_USER'] . adm_back_link($this->u_action), E_USER_WARNING);
1.118 + }
1.119 +
1.120 + // Generate overall "header" for user admin
1.121 + $s_form_options = '';
1.122 +
1.123 + // Build modes dropdown list
1.124 + $sql = 'SELECT module_mode, module_auth
1.125 + FROM ' . MODULES_TABLE . "
1.126 + WHERE module_basename = 'users'
1.127 + AND module_enabled = 1
1.128 + AND module_class = 'acp'
1.129 + ORDER BY left_id, module_mode";
1.130 + $result = $db->sql_query($sql);
1.131 +
1.132 + $dropdown_modes = array();
1.133 + while ($row = $db->sql_fetchrow($result))
1.134 + {
1.135 + if (!$this->p_master->module_auth($row['module_auth']))
1.136 + {
1.137 + continue;
1.138 + }
1.139 +
1.140 + $dropdown_modes[$row['module_mode']] = true;
1.141 + }
1.142 + $db->sql_freeresult($result);
1.143 +
1.144 + foreach ($dropdown_modes as $module_mode => $null)
1.145 + {
1.146 + $selected = ($mode == $module_mode) ? ' selected="selected"' : '';
1.147 + $s_form_options .= '<option value="' . $module_mode . '"' . $selected . '>' . $user->lang['ACP_USER_' . strtoupper($module_mode)] . '</option>';
1.148 + }
1.149 +
1.150 + $template->assign_vars(array(
1.151 + 'U_BACK' => $this->u_action,
1.152 + 'U_MODE_SELECT' => append_sid("{$phpbb_admin_path}index.$phpEx", "i=$id&u=$user_id"),
1.153 + 'U_ACTION' => $this->u_action . '&u=' . $user_id,
1.154 + 'S_FORM_OPTIONS' => $s_form_options,
1.155 + 'MANAGED_USERNAME' => $user_row['username'])
1.156 + );
1.157 +
1.158 + // Prevent normal users/admins change/view founders if they are not a founder by themselves
1.159 + if ($user->data['user_type'] != USER_FOUNDER && $user_row['user_type'] == USER_FOUNDER)
1.160 + {
1.161 + trigger_error($user->lang['NOT_MANAGE_FOUNDER'] . adm_back_link($this->u_action), E_USER_WARNING);
1.162 + }
1.163 +
1.164 + switch ($mode)
1.165 + {
1.166 + case 'overview':
1.167 +
1.168 + include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
1.169 +
1.170 + $user->add_lang('acp/ban');
1.171 +
1.172 + $delete = request_var('delete', 0);
1.173 + $delete_type = request_var('delete_type', '');
1.174 + $ip = request_var('ip', 'ip');
1.175 +
1.176 + if ($submit)
1.177 + {
1.178 + // You can't delete the founder
1.179 + if ($delete && $user_row['user_type'] != USER_FOUNDER)
1.180 + {
1.181 + if (!$auth->acl_get('a_userdel'))
1.182 + {
1.183 + trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
1.184 + }
1.185 +
1.186 + // Check if the user wants to remove himself or the guest user account
1.187 + if ($user_id == ANONYMOUS)
1.188 + {
1.189 + trigger_error($user->lang['CANNOT_REMOVE_ANONYMOUS'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
1.190 + }
1.191 +
1.192 + if ($user_id == $user->data['user_id'])
1.193 + {
1.194 + trigger_error($user->lang['CANNOT_REMOVE_YOURSELF'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
1.195 + }
1.196 +
1.197 + if ($delete_type)
1.198 + {
1.199 + if (confirm_box(true))
1.200 + {
1.201 + user_delete($delete_type, $user_id, $user_row['username']);
1.202 +
1.203 + add_log('admin', 'LOG_USER_DELETED', $user_row['username']);
1.204 + trigger_error($user->lang['USER_DELETED'] . adm_back_link($this->u_action));
1.205 + }
1.206 + else
1.207 + {
1.208 + confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array(
1.209 + 'u' => $user_id,
1.210 + 'i' => $id,
1.211 + 'mode' => $mode,
1.212 + 'action' => $action,
1.213 + 'update' => true,
1.214 + 'delete' => 1,
1.215 + 'delete_type' => $delete_type))
1.216 + );
1.217 + }
1.218 + }
1.219 + else
1.220 + {
1.221 + trigger_error($user->lang['NO_MODE'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
1.222 + }
1.223 + }
1.224 +
1.225 + // Handle quicktool actions
1.226 + switch ($action)
1.227 + {
1.228 + case 'banuser':
1.229 + case 'banemail':
1.230 + case 'banip':
1.231 +
1.232 + if ($user_id == $user->data['user_id'])
1.233 + {
1.234 + trigger_error($user->lang['CANNOT_BAN_YOURSELF'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
1.235 + }
1.236 +
1.237 + if ($user_id == ANONYMOUS)
1.238 + {
1.239 + trigger_error($user->lang['CANNOT_BAN_ANONYMOUS'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
1.240 + }
1.241 +
1.242 + if ($user_row['user_type'] == USER_FOUNDER)
1.243 + {
1.244 + trigger_error($user->lang['CANNOT_BAN_FOUNDER'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
1.245 + }
1.246 +
1.247 + if (!check_form_key($form_name))
1.248 + {
1.249 + trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
1.250 + }
1.251 +
1.252 + $ban = array();
1.253 +
1.254 + switch ($action)
1.255 + {
1.256 + case 'banuser':
1.257 + $ban[] = $user_row['username'];
1.258 + $reason = 'USER_ADMIN_BAN_NAME_REASON';
1.259 + $log = 'LOG_USER_BAN_USER';
1.260 + break;
1.261 +
1.262 + case 'banemail':
1.263 + $ban[] = $user_row['user_email'];
1.264 + $reason = 'USER_ADMIN_BAN_EMAIL_REASON';
1.265 + $log = 'LOG_USER_BAN_EMAIL';
1.266 + break;
1.267 +
1.268 + case 'banip':
1.269 + $ban[] = $user_row['user_ip'];
1.270 +
1.271 + $sql = 'SELECT DISTINCT poster_ip
1.272 + FROM ' . POSTS_TABLE . "
1.273 + WHERE poster_id = $user_id";
1.274 + $result = $db->sql_query($sql);
1.275 +
1.276 + while ($row = $db->sql_fetchrow($result))
1.277 + {
1.278 + $ban[] = $row['poster_ip'];
1.279 + }
1.280 + $db->sql_freeresult($result);
1.281 +
1.282 + $reason = 'USER_ADMIN_BAN_IP_REASON';
1.283 + $log = 'LOG_USER_BAN_IP';
1.284 + break;
1.285 + }
1.286 +
1.287 + $ban_reason = utf8_normalize_nfc(request_var('ban_reason', $user->lang[$reason], true));
1.288 + $ban_give_reason = utf8_normalize_nfc(request_var('ban_give_reason', '', true));
1.289 +
1.290 + // Log not used at the moment, we simply utilize the ban function.
1.291 + $result = user_ban(substr($action, 3), $ban, 0, 0, 0, $ban_reason, $ban_give_reason);
1.292 +
1.293 + trigger_error((($result === false) ? $user->lang['BAN_ALREADY_ENTERED'] : $user->lang['BAN_SUCCESSFUL']) . adm_back_link($this->u_action . '&u=' . $user_id));
1.294 +
1.295 + break;
1.296 +
1.297 + case 'reactivate':
1.298 +
1.299 + if ($user_id == $user->data['user_id'])
1.300 + {
1.301 + trigger_error($user->lang['CANNOT_FORCE_REACT_YOURSELF'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
1.302 + }
1.303 +
1.304 + if (!check_form_key($form_name))
1.305 + {
1.306 + trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
1.307 + }
1.308 +
1.309 + if ($user_row['user_type'] == USER_FOUNDER)
1.310 + {
1.311 + trigger_error($user->lang['CANNOT_FORCE_REACT_FOUNDER'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
1.312 + }
1.313 +
1.314 + if ($user_row['user_type'] == USER_IGNORE)
1.315 + {
1.316 + trigger_error($user->lang['CANNOT_FORCE_REACT_BOT'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
1.317 + }
1.318 +
1.319 + if ($config['email_enable'])
1.320 + {
1.321 + include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
1.322 +
1.323 + $server_url = generate_board_url();
1.324 +
1.325 + $user_actkey = gen_rand_string(mt_rand(6, 10));
1.326 + $email_template = ($user_row['user_type'] == USER_NORMAL) ? 'user_reactivate_account' : 'user_resend_inactive';
1.327 +
1.328 + if ($user_row['user_type'] == USER_NORMAL)
1.329 + {
1.330 + user_active_flip('deactivate', $user_id, INACTIVE_REMIND);
1.331 +
1.332 + $sql = 'UPDATE ' . USERS_TABLE . "
1.333 + SET user_actkey = '" . $db->sql_escape($user_actkey) . "'
1.334 + WHERE user_id = $user_id";
1.335 + $db->sql_query($sql);
1.336 + }
1.337 + else
1.338 + {
1.339 + // Grabbing the last confirm key - we only send a reminder
1.340 + $sql = 'SELECT user_actkey
1.341 + FROM ' . USERS_TABLE . '
1.342 + WHERE user_id = ' . $user_id;
1.343 + $result = $db->sql_query($sql);
1.344 + $user_actkey = (string) $db->sql_fetchfield('user_actkey');
1.345 + $db->sql_freeresult($result);
1.346 + }
1.347 +
1.348 + $messenger = new messenger(false);
1.349 +
1.350 + $messenger->template($email_template, $user_row['user_lang']);
1.351 +
1.352 + $messenger->to($user_row['user_email'], $user_row['username']);
1.353 +
1.354 + $messenger->anti_abuse_headers($config, $user);
1.355 +
1.356 + $messenger->assign_vars(array(
1.357 + 'WELCOME_MSG' => htmlspecialchars_decode(sprintf($user->lang['WELCOME_SUBJECT'], $config['sitename'])),
1.358 + 'USERNAME' => htmlspecialchars_decode($user_row['username']),
1.359 + 'U_ACTIVATE' => "$server_url/ucp.$phpEx?mode=activate&u={$user_row['user_id']}&k=$user_actkey")
1.360 + );
1.361 +
1.362 + $messenger->send(NOTIFY_EMAIL);
1.363 +
1.364 + add_log('admin', 'LOG_USER_REACTIVATE', $user_row['username']);
1.365 + add_log('user', $user_id, 'LOG_USER_REACTIVATE_USER');
1.366 +
1.367 + trigger_error($user->lang['FORCE_REACTIVATION_SUCCESS'] . adm_back_link($this->u_action . '&u=' . $user_id));
1.368 + }
1.369 +
1.370 + break;
1.371 +
1.372 + case 'active':
1.373 +
1.374 + if ($user_id == $user->data['user_id'])
1.375 + {
1.376 + // It is only deactivation since the user is already activated (else he would not have reached this page)
1.377 + trigger_error($user->lang['CANNOT_DEACTIVATE_YOURSELF'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
1.378 + }
1.379 +
1.380 + if (!check_form_key($form_name))
1.381 + {
1.382 + trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
1.383 + }
1.384 +
1.385 + if ($user_row['user_type'] == USER_FOUNDER)
1.386 + {
1.387 + trigger_error($user->lang['CANNOT_DEACTIVATE_FOUNDER'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
1.388 + }
1.389 +
1.390 + if ($user_row['user_type'] == USER_IGNORE)
1.391 + {
1.392 + trigger_error($user->lang['CANNOT_DEACTIVATE_BOT'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
1.393 + }
1.394 +
1.395 + user_active_flip('flip', $user_id);
1.396 +
1.397 + if ($user_row['user_type'] == USER_INACTIVE)
1.398 + {
1.399 + if ($config['require_activation'] == USER_ACTIVATION_ADMIN)
1.400 + {
1.401 + include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
1.402 +
1.403 + $messenger = new messenger(false);
1.404 +
1.405 + $messenger->template('admin_welcome_activated', $user_row['user_lang']);
1.406 +
1.407 + $messenger->to($user_row['user_email'], $user_row['username']);
1.408 +
1.409 + $messenger->anti_abuse_headers($config, $user);
1.410 +
1.411 + $messenger->assign_vars(array(
1.412 + 'USERNAME' => htmlspecialchars_decode($user_row['username']))
1.413 + );
1.414 +
1.415 + $messenger->send(NOTIFY_EMAIL);
1.416 + }
1.417 + }
1.418 +
1.419 + $message = ($user_row['user_type'] == USER_INACTIVE) ? 'USER_ADMIN_ACTIVATED' : 'USER_ADMIN_DEACTIVED';
1.420 + $log = ($user_row['user_type'] == USER_INACTIVE) ? 'LOG_USER_ACTIVE' : 'LOG_USER_INACTIVE';
1.421 +
1.422 + add_log('admin', $log, $user_row['username']);
1.423 + add_log('user', $user_id, $log . '_USER');
1.424 +
1.425 + trigger_error($user->lang[$message] . adm_back_link($this->u_action . '&u=' . $user_id));
1.426 +
1.427 + break;
1.428 +
1.429 + case 'delsig':
1.430 +
1.431 + if (!check_form_key($form_name))
1.432 + {
1.433 + trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
1.434 + }
1.435 +
1.436 + $sql_ary = array(
1.437 + 'user_sig' => '',
1.438 + 'user_sig_bbcode_uid' => '',
1.439 + 'user_sig_bbcode_bitfield' => ''
1.440 + );
1.441 +
1.442 + $sql = 'UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "
1.443 + WHERE user_id = $user_id";
1.444 + $db->sql_query($sql);
1.445 +
1.446 + add_log('admin', 'LOG_USER_DEL_SIG', $user_row['username']);
1.447 + add_log('user', $user_id, 'LOG_USER_DEL_SIG_USER');
1.448 +
1.449 + trigger_error($user->lang['USER_ADMIN_SIG_REMOVED'] . adm_back_link($this->u_action . '&u=' . $user_id));
1.450 +
1.451 + break;
1.452 +
1.453 + case 'delavatar':
1.454 +
1.455 + if (!check_form_key($form_name))
1.456 + {
1.457 + trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
1.458 + }
1.459 +
1.460 + $sql_ary = array(
1.461 + 'user_avatar' => '',
1.462 + 'user_avatar_type' => 0,
1.463 + 'user_avatar_width' => 0,
1.464 + 'user_avatar_height' => 0,
1.465 + );
1.466 +
1.467 + $sql = 'UPDATE ' . USERS_TABLE . '
1.468 + SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "
1.469 + WHERE user_id = $user_id";
1.470 + $db->sql_query($sql);
1.471 +
1.472 + // Delete old avatar if present
1.473 + if ($user_row['user_avatar'] && $user_row['user_avatar_type'] != AVATAR_GALLERY)
1.474 + {
1.475 + avatar_delete('user', $user_row);
1.476 + }
1.477 +
1.478 + add_log('admin', 'LOG_USER_DEL_AVATAR', $user_row['username']);
1.479 + add_log('user', $user_id, 'LOG_USER_DEL_AVATAR_USER');
1.480 +
1.481 + trigger_error($user->lang['USER_ADMIN_AVATAR_REMOVED'] . adm_back_link($this->u_action . '&u=' . $user_id));
1.482 + break;
1.483 +
1.484 + case 'delposts':
1.485 +
1.486 + if (confirm_box(true))
1.487 + {
1.488 + // Delete posts, attachments, etc.
1.489 + delete_posts('poster_id', $user_id);
1.490 +
1.491 + add_log('admin', 'LOG_USER_DEL_POSTS', $user_row['username']);
1.492 + trigger_error($user->lang['USER_POSTS_DELETED'] . adm_back_link($this->u_action . '&u=' . $user_id));
1.493 + }
1.494 + else
1.495 + {
1.496 + confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array(
1.497 + 'u' => $user_id,
1.498 + 'i' => $id,
1.499 + 'mode' => $mode,
1.500 + 'action' => $action,
1.501 + 'update' => true))
1.502 + );
1.503 + }
1.504 +
1.505 + break;
1.506 +
1.507 + case 'delattach':
1.508 +
1.509 + if (confirm_box(true))
1.510 + {
1.511 + delete_attachments('user', $user_id);
1.512 +
1.513 + add_log('admin', 'LOG_USER_DEL_ATTACH', $user_row['username']);
1.514 + trigger_error($user->lang['USER_ATTACHMENTS_REMOVED'] . adm_back_link($this->u_action . '&u=' . $user_id));
1.515 + }
1.516 + else
1.517 + {
1.518 + confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array(
1.519 + 'u' => $user_id,
1.520 + 'i' => $id,
1.521 + 'mode' => $mode,
1.522 + 'action' => $action,
1.523 + 'update' => true))
1.524 + );
1.525 + }
1.526 +
1.527 + break;
1.528 +
1.529 + case 'deloutbox':
1.530 +
1.531 + if (confirm_box(true))
1.532 + {
1.533 + $msg_ids = array();
1.534 + $lang = 'EMPTY';
1.535 +
1.536 + $sql = 'SELECT msg_id
1.537 + FROM ' . PRIVMSGS_TO_TABLE . "
1.538 + WHERE author_id = $user_id
1.539 + AND folder_id = " . PRIVMSGS_OUTBOX;
1.540 + $result = $db->sql_query($sql);
1.541 +
1.542 + if ($row = $db->sql_fetchrow($result))
1.543 + {
1.544 + if (!function_exists('delete_pm'))
1.545 + {
1.546 + include($phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx);
1.547 + }
1.548 +
1.549 + do
1.550 + {
1.551 + $msg_ids[] = (int) $row['msg_id'];
1.552 + }
1.553 + while ($row = $db->sql_fetchrow($result));
1.554 +
1.555 + $db->sql_freeresult($result);
1.556 +
1.557 + delete_pm($user_id, $msg_ids, PRIVMSGS_OUTBOX);
1.558 +
1.559 + add_log('admin', 'LOG_USER_DEL_OUTBOX', $user_row['username']);
1.560 +
1.561 + $lang = 'EMPTIED';
1.562 + }
1.563 + $db->sql_freeresult($result);
1.564 +
1.565 + trigger_error($user->lang['USER_OUTBOX_' . $lang] . adm_back_link($this->u_action . '&u=' . $user_id));
1.566 + }
1.567 + else
1.568 + {
1.569 + confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array(
1.570 + 'u' => $user_id,
1.571 + 'i' => $id,
1.572 + 'mode' => $mode,
1.573 + 'action' => $action,
1.574 + 'update' => true))
1.575 + );
1.576 + }
1.577 + break;
1.578 +
1.579 + case 'moveposts':
1.580 +
1.581 + if (!check_form_key($form_name))
1.582 + {
1.583 + trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
1.584 + }
1.585 +
1.586 + $user->add_lang('acp/forums');
1.587 +
1.588 + $new_forum_id = request_var('new_f', 0);
1.589 +
1.590 + if (!$new_forum_id)
1.591 + {
1.592 + $this->page_title = 'USER_ADMIN_MOVE_POSTS';
1.593 +
1.594 + $template->assign_vars(array(
1.595 + 'S_SELECT_FORUM' => true,
1.596 + 'U_ACTION' => $this->u_action . "&action=$action&u=$user_id",
1.597 + 'U_BACK' => $this->u_action . "&u=$user_id",
1.598 + 'S_FORUM_OPTIONS' => make_forum_select(false, false, false, true))
1.599 + );
1.600 +
1.601 + return;
1.602 + }
1.603 +
1.604 + // Is the new forum postable to?
1.605 + $sql = 'SELECT forum_name, forum_type
1.606 + FROM ' . FORUMS_TABLE . "
1.607 + WHERE forum_id = $new_forum_id";
1.608 + $result = $db->sql_query($sql);
1.609 + $forum_info = $db->sql_fetchrow($result);
1.610 + $db->sql_freeresult($result);
1.611 +
1.612 + if (!$forum_info)
1.613 + {
1.614 + trigger_error($user->lang['NO_FORUM'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
1.615 + }
1.616 +
1.617 + if ($forum_info['forum_type'] != FORUM_POST)
1.618 + {
1.619 + trigger_error($user->lang['MOVE_POSTS_NO_POSTABLE_FORUM'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
1.620 + }
1.621 +
1.622 + // Two stage?
1.623 + // Move topics comprising only posts from this user
1.624 + $topic_id_ary = $move_topic_ary = $move_post_ary = $new_topic_id_ary = array();
1.625 + $forum_id_ary = array($new_forum_id);
1.626 +
1.627 + $sql = 'SELECT topic_id, COUNT(post_id) AS total_posts
1.628 + FROM ' . POSTS_TABLE . "
1.629 + WHERE poster_id = $user_id
1.630 + AND forum_id <> $new_forum_id
1.631 + GROUP BY topic_id";
1.632 + $result = $db->sql_query($sql);
1.633 +
1.634 + while ($row = $db->sql_fetchrow($result))
1.635 + {
1.636 + $topic_id_ary[$row['topic_id']] = $row['total_posts'];
1.637 + }
1.638 + $db->sql_freeresult($result);
1.639 +
1.640 + if (sizeof($topic_id_ary))
1.641 + {
1.642 + $sql = 'SELECT topic_id, forum_id, topic_title, topic_replies, topic_replies_real, topic_attachment
1.643 + FROM ' . TOPICS_TABLE . '
1.644 + WHERE ' . $db->sql_in_set('topic_id', array_keys($topic_id_ary));
1.645 + $result = $db->sql_query($sql);
1.646 +
1.647 + while ($row = $db->sql_fetchrow($result))
1.648 + {
1.649 + if (max($row['topic_replies'], $row['topic_replies_real']) + 1 == $topic_id_ary[$row['topic_id']])
1.650 + {
1.651 + $move_topic_ary[] = $row['topic_id'];
1.652 + }
1.653 + else
1.654 + {
1.655 + $move_post_ary[$row['topic_id']]['title'] = $row['topic_title'];
1.656 + $move_post_ary[$row['topic_id']]['attach'] = ($row['topic_attachment']) ? 1 : 0;
1.657 + }
1.658 +
1.659 + $forum_id_ary[] = $row['forum_id'];
1.660 + }
1.661 + $db->sql_freeresult($result);
1.662 + }
1.663 +
1.664 + // Entire topic comprises posts by this user, move these topics
1.665 + if (sizeof($move_topic_ary))
1.666 + {
1.667 + move_topics($move_topic_ary, $new_forum_id, false);
1.668 + }
1.669 +
1.670 + if (sizeof($move_post_ary))
1.671 + {
1.672 + // Create new topic
1.673 + // Update post_ids, report_ids, attachment_ids
1.674 + foreach ($move_post_ary as $topic_id => $post_ary)
1.675 + {
1.676 + // Create new topic
1.677 + $sql = 'INSERT INTO ' . TOPICS_TABLE . ' ' . $db->sql_build_array('INSERT', array(
1.678 + 'topic_poster' => $user_id,
1.679 + 'topic_time' => time(),
1.680 + 'forum_id' => $new_forum_id,
1.681 + 'icon_id' => 0,
1.682 + 'topic_approved' => 1,
1.683 + 'topic_title' => $post_ary['title'],
1.684 + 'topic_first_poster_name' => $user_row['username'],
1.685 + 'topic_type' => POST_NORMAL,
1.686 + 'topic_time_limit' => 0,
1.687 + 'topic_attachment' => $post_ary['attach'])
1.688 + );
1.689 + $db->sql_query($sql);
1.690 +
1.691 + $new_topic_id = $db->sql_nextid();
1.692 +
1.693 + // Move posts
1.694 + $sql = 'UPDATE ' . POSTS_TABLE . "
1.695 + SET forum_id = $new_forum_id, topic_id = $new_topic_id
1.696 + WHERE topic_id = $topic_id
1.697 + AND poster_id = $user_id";
1.698 + $db->sql_query($sql);
1.699 +
1.700 + if ($post_ary['attach'])
1.701 + {
1.702 + $sql = 'UPDATE ' . ATTACHMENTS_TABLE . "
1.703 + SET topic_id = $new_topic_id
1.704 + WHERE topic_id = $topic_id
1.705 + AND poster_id = $user_id";
1.706 + $db->sql_query($sql);
1.707 + }
1.708 +
1.709 + $new_topic_id_ary[] = $new_topic_id;
1.710 + }
1.711 + }
1.712 +
1.713 + $forum_id_ary = array_unique($forum_id_ary);
1.714 + $topic_id_ary = array_unique(array_merge(array_keys($topic_id_ary), $new_topic_id_ary));
1.715 +
1.716 + if (sizeof($topic_id_ary))
1.717 + {
1.718 + sync('topic_reported', 'topic_id', $topic_id_ary);
1.719 + sync('topic', 'topic_id', $topic_id_ary);
1.720 + }
1.721 +
1.722 + if (sizeof($forum_id_ary))
1.723 + {
1.724 + sync('forum', 'forum_id', $forum_id_ary, false, true);
1.725 + }
1.726 +
1.727 +
1.728 + add_log('admin', 'LOG_USER_MOVE_POSTS', $user_row['username'], $forum_info['forum_name']);
1.729 + add_log('user', $user_id, 'LOG_USER_MOVE_POSTS_USER', $forum_info['forum_name']);
1.730 +
1.731 + trigger_error($user->lang['USER_POSTS_MOVED'] . adm_back_link($this->u_action . '&u=' . $user_id));
1.732 +
1.733 + break;
1.734 +
1.735 + case 'leave_nr':
1.736 +
1.737 + if (confirm_box(true))
1.738 + {
1.739 + remove_newly_registered($user_id, $user_row);
1.740 +
1.741 + add_log('admin', 'LOG_USER_REMOVED_NR', $user_row['username']);
1.742 + trigger_error($user->lang['USER_LIFTED_NR'] . adm_back_link($this->u_action . '&u=' . $user_id));
1.743 + }
1.744 + else
1.745 + {
1.746 + confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array(
1.747 + 'u' => $user_id,
1.748 + 'i' => $id,
1.749 + 'mode' => $mode,
1.750 + 'action' => $action,
1.751 + 'update' => true))
1.752 + );
1.753 + }
1.754 +
1.755 + break;
1.756 + }
1.757 +
1.758 + // Handle registration info updates
1.759 + $data = array(
1.760 + 'username' => utf8_normalize_nfc(request_var('user', $user_row['username'], true)),
1.761 + 'user_founder' => request_var('user_founder', ($user_row['user_type'] == USER_FOUNDER) ? 1 : 0),
1.762 + 'email' => strtolower(request_var('user_email', $user_row['user_email'])),
1.763 + 'email_confirm' => strtolower(request_var('email_confirm', '')),
1.764 + 'new_password' => request_var('new_password', '', true),
1.765 + 'password_confirm' => request_var('password_confirm', '', true),
1.766 + );
1.767 +
1.768 + // Validation data - we do not check the password complexity setting here
1.769 + $check_ary = array(
1.770 + 'new_password' => array(
1.771 + array('string', true, $config['min_pass_chars'], $config['max_pass_chars']),
1.772 + array('password')),
1.773 + 'password_confirm' => array('string', true, $config['min_pass_chars'], $config['max_pass_chars']),
1.774 + );
1.775 +
1.776 + // Check username if altered
1.777 + if ($data['username'] != $user_row['username'])
1.778 + {
1.779 + $check_ary += array(
1.780 + 'username' => array(
1.781 + array('string', false, $config['min_name_chars'], $config['max_name_chars']),
1.782 + array('username', $user_row['username'])
1.783 + ),
1.784 + );
1.785 + }
1.786 +
1.787 + // Check email if altered
1.788 + if ($data['email'] != $user_row['user_email'])
1.789 + {
1.790 + $check_ary += array(
1.791 + 'email' => array(
1.792 + array('string', false, 6, 60),
1.793 + array('email', $user_row['user_email'])
1.794 + ),
1.795 + 'email_confirm' => array('string', true, 6, 60)
1.796 + );
1.797 + }
1.798 +
1.799 + $error = validate_data($data, $check_ary);
1.800 +
1.801 + if ($data['new_password'] && $data['password_confirm'] != $data['new_password'])
1.802 + {
1.803 + $error[] = 'NEW_PASSWORD_ERROR';
1.804 + }
1.805 +
1.806 + if ($data['email'] != $user_row['user_email'] && $data['email_confirm'] != $data['email'])
1.807 + {
1.808 + $error[] = 'NEW_EMAIL_ERROR';
1.809 + }
1.810 +
1.811 + if (!check_form_key($form_name))
1.812 + {
1.813 + $error[] = 'FORM_INVALID';
1.814 + }
1.815 +
1.816 + // Which updates do we need to do?
1.817 + $update_username = ($user_row['username'] != $data['username']) ? $data['username'] : false;
1.818 + $update_password = ($data['new_password'] && !phpbb_check_hash($data['new_password'], $user_row['user_password'])) ? true : false;
1.819 + $update_email = ($data['email'] != $user_row['user_email']) ? $data['email'] : false;
1.820 +
1.821 + if (!sizeof($error))
1.822 + {
1.823 + $sql_ary = array();
1.824 +
1.825 + if ($user_row['user_type'] != USER_FOUNDER || $user->data['user_type'] == USER_FOUNDER)
1.826 + {
1.827 + // Only allow founders updating the founder status...
1.828 + if ($user->data['user_type'] == USER_FOUNDER)
1.829 + {
1.830 + // Setting a normal member to be a founder
1.831 + if ($data['user_founder'] && $user_row['user_type'] != USER_FOUNDER)
1.832 + {
1.833 + // Make sure the user is not setting an Inactive or ignored user to be a founder
1.834 + if ($user_row['user_type'] == USER_IGNORE)
1.835 + {
1.836 + trigger_error($user->lang['CANNOT_SET_FOUNDER_IGNORED'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
1.837 + }
1.838 +
1.839 + if ($user_row['user_type'] == USER_INACTIVE)
1.840 + {
1.841 + trigger_error($user->lang['CANNOT_SET_FOUNDER_INACTIVE'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
1.842 + }
1.843 +
1.844 + $sql_ary['user_type'] = USER_FOUNDER;
1.845 + }
1.846 + else if (!$data['user_founder'] && $user_row['user_type'] == USER_FOUNDER)
1.847 + {
1.848 + // Check if at least one founder is present
1.849 + $sql = 'SELECT user_id
1.850 + FROM ' . USERS_TABLE . '
1.851 + WHERE user_type = ' . USER_FOUNDER . '
1.852 + AND user_id <> ' . $user_id;
1.853 + $result = $db->sql_query_limit($sql, 1);
1.854 + $row = $db->sql_fetchrow($result);
1.855 + $db->sql_freeresult($result);
1.856 +
1.857 + if ($row)
1.858 + {
1.859 + $sql_ary['user_type'] = USER_NORMAL;
1.860 + }
1.861 + else
1.862 + {
1.863 + trigger_error($user->lang['AT_LEAST_ONE_FOUNDER'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
1.864 + }
1.865 + }
1.866 + }
1.867 + }
1.868 +
1.869 + if ($update_username !== false)
1.870 + {
1.871 + $sql_ary['username'] = $update_username;
1.872 + $sql_ary['username_clean'] = utf8_clean_string($update_username);
1.873 +
1.874 + add_log('user', $user_id, 'LOG_USER_UPDATE_NAME', $user_row['username'], $update_username);
1.875 + }
1.876 +
1.877 + if ($update_email !== false)
1.878 + {
1.879 + $sql_ary += array(
1.880 + 'user_email' => $update_email,
1.881 + 'user_email_hash' => phpbb_email_hash($update_email),
1.882 + );
1.883 +
1.884 + add_log('user', $user_id, 'LOG_USER_UPDATE_EMAIL', $user_row['username'], $user_row['user_email'], $update_email);
1.885 + }
1.886 +
1.887 + if ($update_password)
1.888 + {
1.889 + $sql_ary += array(
1.890 + 'user_password' => phpbb_hash($data['new_password']),
1.891 + 'user_passchg' => time(),
1.892 + 'user_pass_convert' => 0,
1.893 + );
1.894 +
1.895 + $user->reset_login_keys($user_id);
1.896 + add_log('user', $user_id, 'LOG_USER_NEW_PASSWORD', $user_row['username']);
1.897 + }
1.898 +
1.899 + if (sizeof($sql_ary))
1.900 + {
1.901 + $sql = 'UPDATE ' . USERS_TABLE . '
1.902 + SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
1.903 + WHERE user_id = ' . $user_id;
1.904 + $db->sql_query($sql);
1.905 + }
1.906 +
1.907 + if ($update_username)
1.908 + {
1.909 + user_update_name($user_row['username'], $update_username);
1.910 + }
1.911 +
1.912 + // Let the users permissions being updated
1.913 + $auth->acl_clear_prefetch($user_id);
1.914 +
1.915 + add_log('admin', 'LOG_USER_USER_UPDATE', $data['username']);
1.916 +
1.917 + trigger_error($user->lang['USER_OVERVIEW_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_id));
1.918 + }
1.919 +
1.920 + // Replace "error" strings with their real, localised form
1.921 + $error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error);
1.922 + }
1.923 +
1.924 + if ($user_id == $user->data['user_id'])
1.925 + {
1.926 + $quick_tool_ary = array('delsig' => 'DEL_SIG', 'delavatar' => 'DEL_AVATAR', 'moveposts' => 'MOVE_POSTS', 'delposts' => 'DEL_POSTS', 'delattach' => 'DEL_ATTACH', 'deloutbox' => 'DEL_OUTBOX');
1.927 + if ($user_row['user_new'])
1.928 + {
1.929 + $quick_tool_ary['leave_nr'] = 'LEAVE_NR';
1.930 + }
1.931 + }
1.932 + else
1.933 + {
1.934 + $quick_tool_ary = array();
1.935 +
1.936 + if ($user_row['user_type'] != USER_FOUNDER)
1.937 + {
1.938 + $quick_tool_ary += array('banuser' => 'BAN_USER', 'banemail' => 'BAN_EMAIL', 'banip' => 'BAN_IP');
1.939 + }
1.940 +
1.941 + if ($user_row['user_type'] != USER_FOUNDER && $user_row['user_type'] != USER_IGNORE)
1.942 + {
1.943 + $quick_tool_ary += array('active' => (($user_row['user_type'] == USER_INACTIVE) ? 'ACTIVATE' : 'DEACTIVATE'));
1.944 + }
1.945 +
1.946 + $quick_tool_ary += array('delsig' => 'DEL_SIG', 'delavatar' => 'DEL_AVATAR', 'moveposts' => 'MOVE_POSTS', 'delposts' => 'DEL_POSTS', 'delattach' => 'DEL_ATTACH', 'deloutbox' => 'DEL_OUTBOX');
1.947 +
1.948 + if ($config['email_enable'] && ($user_row['user_type'] == USER_NORMAL || $user_row['user_type'] == USER_INACTIVE))
1.949 + {
1.950 + $quick_tool_ary['reactivate'] = 'FORCE';
1.951 + }
1.952 +
1.953 + if ($user_row['user_new'])
1.954 + {
1.955 + $quick_tool_ary['leave_nr'] = 'LEAVE_NR';
1.956 + }
1.957 + }
1.958 +
1.959 + $s_action_options = '<option class="sep" value="">' . $user->lang['SELECT_OPTION'] . '</option>';
1.960 + foreach ($quick_tool_ary as $value => $lang)
1.961 + {
1.962 + $s_action_options .= '<option value="' . $value . '">' . $user->lang['USER_ADMIN_' . $lang] . '</option>';
1.963 + }
1.964 +
1.965 + if ($config['load_onlinetrack'])
1.966 + {
1.967 + $sql = 'SELECT MAX(session_time) AS session_time, MIN(session_viewonline) AS session_viewonline
1.968 + FROM ' . SESSIONS_TABLE . "
1.969 + WHERE session_user_id = $user_id";
1.970 + $result = $db->sql_query($sql);
1.971 + $row = $db->sql_fetchrow($result);
1.972 + $db->sql_freeresult($result);
1.973 +
1.974 + $user_row['session_time'] = (isset($row['session_time'])) ? $row['session_time'] : 0;
1.975 + $user_row['session_viewonline'] = (isset($row['session_viewonline'])) ? $row['session_viewonline'] : 0;
1.976 + unset($row);
1.977 + }
1.978 +
1.979 + $last_visit = (!empty($user_row['session_time'])) ? $user_row['session_time'] : $user_row['user_lastvisit'];
1.980 +
1.981 + $inactive_reason = '';
1.982 + if ($user_row['user_type'] == USER_INACTIVE)
1.983 + {
1.984 + $inactive_reason = $user->lang['INACTIVE_REASON_UNKNOWN'];
1.985 +
1.986 + switch ($user_row['user_inactive_reason'])
1.987 + {
1.988 + case INACTIVE_REGISTER:
1.989 + $inactive_reason = $user->lang['INACTIVE_REASON_REGISTER'];
1.990 + break;
1.991 +
1.992 + case INACTIVE_PROFILE:
1.993 + $inactive_reason = $user->lang['INACTIVE_REASON_PROFILE'];
1.994 + break;
1.995 +
1.996 + case INACTIVE_MANUAL:
1.997 + $inactive_reason = $user->lang['INACTIVE_REASON_MANUAL'];
1.998 + break;
1.999 +
1.1000 + case INACTIVE_REMIND:
1.1001 + $inactive_reason = $user->lang['INACTIVE_REASON_REMIND'];
1.1002 + break;
1.1003 + }
1.1004 + }
1.1005 +
1.1006 + // Posts in Queue
1.1007 + $sql = 'SELECT COUNT(post_id) as posts_in_queue
1.1008 + FROM ' . POSTS_TABLE . '
1.1009 + WHERE poster_id = ' . $user_id . '
1.1010 + AND post_approved = 0';
1.1011 + $result = $db->sql_query($sql);
1.1012 + $user_row['posts_in_queue'] = (int) $db->sql_fetchfield('posts_in_queue');
1.1013 + $db->sql_freeresult($result);
1.1014 +
1.1015 + $template->assign_vars(array(
1.1016 + 'L_NAME_CHARS_EXPLAIN' => sprintf($user->lang[$config['allow_name_chars'] . '_EXPLAIN'], $config['min_name_chars'], $config['max_name_chars']),
1.1017 + 'L_CHANGE_PASSWORD_EXPLAIN' => sprintf($user->lang[$config['pass_complex'] . '_EXPLAIN'], $config['min_pass_chars'], $config['max_pass_chars']),
1.1018 + 'L_POSTS_IN_QUEUE' => $user->lang('NUM_POSTS_IN_QUEUE', $user_row['posts_in_queue']),
1.1019 + 'S_FOUNDER' => ($user->data['user_type'] == USER_FOUNDER) ? true : false,
1.1020 +
1.1021 + 'S_OVERVIEW' => true,
1.1022 + 'S_USER_IP' => ($user_row['user_ip']) ? true : false,
1.1023 + 'S_USER_FOUNDER' => ($user_row['user_type'] == USER_FOUNDER) ? true : false,
1.1024 + 'S_ACTION_OPTIONS' => $s_action_options,
1.1025 + 'S_OWN_ACCOUNT' => ($user_id == $user->data['user_id']) ? true : false,
1.1026 + 'S_USER_INACTIVE' => ($user_row['user_type'] == USER_INACTIVE) ? true : false,
1.1027 +
1.1028 + 'U_SHOW_IP' => $this->u_action . "&u=$user_id&ip=" . (($ip == 'ip') ? 'hostname' : 'ip'),
1.1029 + 'U_WHOIS' => $this->u_action . "&action=whois&user_ip={$user_row['user_ip']}",
1.1030 + 'U_MCP_QUEUE' => ($auth->acl_getf_global('m_approve')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue', true, $user->session_id) : '',
1.1031 +
1.1032 + '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')) : '',
1.1033 +
1.1034 + 'POSTS_IN_QUEUE' => $user_row['posts_in_queue'],
1.1035 + 'USER' => $user_row['username'],
1.1036 + 'USER_REGISTERED' => $user->format_date($user_row['user_regdate']),
1.1037 + 'REGISTERED_IP' => ($ip == 'hostname') ? gethostbyaddr($user_row['user_ip']) : $user_row['user_ip'],
1.1038 + 'USER_LASTACTIVE' => ($last_visit) ? $user->format_date($last_visit) : ' - ',
1.1039 + 'USER_EMAIL' => $user_row['user_email'],
1.1040 + 'USER_WARNINGS' => $user_row['user_warnings'],
1.1041 + 'USER_POSTS' => $user_row['user_posts'],
1.1042 + 'USER_INACTIVE_REASON' => $inactive_reason,
1.1043 + ));
1.1044 +
1.1045 + break;
1.1046 +
1.1047 + case 'feedback':
1.1048 +
1.1049 + $user->add_lang('mcp');
1.1050 +
1.1051 + // Set up general vars
1.1052 + $start = request_var('start', 0);
1.1053 + $deletemark = (isset($_POST['delmarked'])) ? true : false;
1.1054 + $deleteall = (isset($_POST['delall'])) ? true : false;
1.1055 + $marked = request_var('mark', array(0));
1.1056 + $message = utf8_normalize_nfc(request_var('message', '', true));
1.1057 +
1.1058 + // Sort keys
1.1059 + $sort_days = request_var('st', 0);
1.1060 + $sort_key = request_var('sk', 't');
1.1061 + $sort_dir = request_var('sd', 'd');
1.1062 +
1.1063 + // Delete entries if requested and able
1.1064 + if (($deletemark || $deleteall) && $auth->acl_get('a_clearlogs'))
1.1065 + {
1.1066 + if (!check_form_key($form_name))
1.1067 + {
1.1068 + trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
1.1069 + }
1.1070 +
1.1071 + $where_sql = '';
1.1072 + if ($deletemark && $marked)
1.1073 + {
1.1074 + $sql_in = array();
1.1075 + foreach ($marked as $mark)
1.1076 + {
1.1077 + $sql_in[] = $mark;
1.1078 + }
1.1079 + $where_sql = ' AND ' . $db->sql_in_set('log_id', $sql_in);
1.1080 + unset($sql_in);
1.1081 + }
1.1082 +
1.1083 + if ($where_sql || $deleteall)
1.1084 + {
1.1085 + $sql = 'DELETE FROM ' . LOG_TABLE . '
1.1086 + WHERE log_type = ' . LOG_USERS . "
1.1087 + AND reportee_id = $user_id
1.1088 + $where_sql";
1.1089 + $db->sql_query($sql);
1.1090 +
1.1091 + add_log('admin', 'LOG_CLEAR_USER', $user_row['username']);
1.1092 + }
1.1093 + }
1.1094 +
1.1095 + if ($submit && $message)
1.1096 + {
1.1097 + if (!check_form_key($form_name))
1.1098 + {
1.1099 + trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
1.1100 + }
1.1101 +
1.1102 + add_log('admin', 'LOG_USER_FEEDBACK', $user_row['username']);
1.1103 + add_log('mod', 0, 0, 'LOG_USER_FEEDBACK', $user_row['username']);
1.1104 + add_log('user', $user_id, 'LOG_USER_GENERAL', $message);
1.1105 +
1.1106 + trigger_error($user->lang['USER_FEEDBACK_ADDED'] . adm_back_link($this->u_action . '&u=' . $user_id));
1.1107 + }
1.1108 +
1.1109 + // Sorting
1.1110 + $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']);
1.1111 + $sort_by_text = array('u' => $user->lang['SORT_USERNAME'], 't' => $user->lang['SORT_DATE'], 'i' => $user->lang['SORT_IP'], 'o' => $user->lang['SORT_ACTION']);
1.1112 + $sort_by_sql = array('u' => 'u.username_clean', 't' => 'l.log_time', 'i' => 'l.log_ip', 'o' => 'l.log_operation');
1.1113 +
1.1114 + $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';
1.1115 + 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);
1.1116 +
1.1117 + // Define where and sort sql for use in displaying logs
1.1118 + $sql_where = ($sort_days) ? (time() - ($sort_days * 86400)) : 0;
1.1119 + $sql_sort = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC');
1.1120 +
1.1121 + // Grab log data
1.1122 + $log_data = array();
1.1123 + $log_count = 0;
1.1124 + $start = view_log('user', $log_data, $log_count, $config['topics_per_page'], $start, 0, 0, $user_id, $sql_where, $sql_sort);
1.1125 +
1.1126 + $template->assign_vars(array(
1.1127 + 'S_FEEDBACK' => true,
1.1128 + 'S_ON_PAGE' => on_page($log_count, $config['topics_per_page'], $start),
1.1129 + 'PAGINATION' => generate_pagination($this->u_action . "&u=$user_id&$u_sort_param", $log_count, $config['topics_per_page'], $start, true),
1.1130 +
1.1131 + 'S_LIMIT_DAYS' => $s_limit_days,
1.1132 + 'S_SORT_KEY' => $s_sort_key,
1.1133 + 'S_SORT_DIR' => $s_sort_dir,
1.1134 + 'S_CLEARLOGS' => $auth->acl_get('a_clearlogs'))
1.1135 + );
1.1136 +
1.1137 + foreach ($log_data as $row)
1.1138 + {
1.1139 + $template->assign_block_vars('log', array(
1.1140 + 'USERNAME' => $row['username_full'],
1.1141 + 'IP' => $row['ip'],
1.1142 + 'DATE' => $user->format_date($row['time']),
1.1143 + 'ACTION' => nl2br($row['action']),
1.1144 + 'ID' => $row['id'])
1.1145 + );
1.1146 + }
1.1147 +
1.1148 + break;
1.1149 +
1.1150 + case 'warnings':
1.1151 + $user->add_lang('mcp');
1.1152 +
1.1153 + // Set up general vars
1.1154 + $start = request_var('start', 0);
1.1155 + $deletemark = (isset($_POST['delmarked'])) ? true : false;
1.1156 + $deleteall = (isset($_POST['delall'])) ? true : false;
1.1157 + $confirm = (isset($_POST['confirm'])) ? true : false;
1.1158 + $marked = request_var('mark', array(0));
1.1159 + $message = utf8_normalize_nfc(request_var('message', '', true));
1.1160 +
1.1161 + // Sort keys
1.1162 + $sort_days = request_var('st', 0);
1.1163 + $sort_key = request_var('sk', 't');
1.1164 + $sort_dir = request_var('sd', 'd');
1.1165 +
1.1166 + // Delete entries if requested and able
1.1167 + if ($deletemark || $deleteall || $confirm)
1.1168 + {
1.1169 + if (confirm_box(true))
1.1170 + {
1.1171 + $where_sql = '';
1.1172 + $deletemark = request_var('delmarked', 0);
1.1173 + $deleteall = request_var('delall', 0);
1.1174 + if ($deletemark && $marked)
1.1175 + {
1.1176 + $where_sql = ' AND ' . $db->sql_in_set('warning_id', array_values($marked));
1.1177 + }
1.1178 +
1.1179 + if ($where_sql || $deleteall)
1.1180 + {
1.1181 + $sql = 'DELETE FROM ' . WARNINGS_TABLE . "
1.1182 + WHERE user_id = $user_id
1.1183 + $where_sql";
1.1184 + $db->sql_query($sql);
1.1185 +
1.1186 + if ($deleteall)
1.1187 + {
1.1188 + $log_warnings = $deleted_warnings = 0;
1.1189 + }
1.1190 + else
1.1191 + {
1.1192 + $num_warnings = (int) $db->sql_affectedrows();
1.1193 + $deleted_warnings = ' user_warnings - ' . $num_warnings;
1.1194 + $log_warnings = ($num_warnings > 2) ? 2 : $num_warnings;
1.1195 + }
1.1196 +
1.1197 + $sql = 'UPDATE ' . USERS_TABLE . "
1.1198 + SET user_warnings = $deleted_warnings
1.1199 + WHERE user_id = $user_id";
1.1200 + $db->sql_query($sql);
1.1201 +
1.1202 + switch ($log_warnings)
1.1203 + {
1.1204 + case 2:
1.1205 + add_log('admin', 'LOG_WARNINGS_DELETED', $user_row['username'], $num_warnings);
1.1206 + break;
1.1207 + case 1:
1.1208 + add_log('admin', 'LOG_WARNING_DELETED', $user_row['username']);
1.1209 + break;
1.1210 + default:
1.1211 + add_log('admin', 'LOG_WARNINGS_DELETED_ALL', $user_row['username']);
1.1212 + break;
1.1213 + }
1.1214 + }
1.1215 + }
1.1216 + else
1.1217 + {
1.1218 + $s_hidden_fields = array(
1.1219 + 'i' => $id,
1.1220 + 'mode' => $mode,
1.1221 + 'u' => $user_id,
1.1222 + 'mark' => $marked,
1.1223 + );
1.1224 + if (isset($_POST['delmarked']))
1.1225 + {
1.1226 + $s_hidden_fields['delmarked'] = 1;
1.1227 + }
1.1228 + if (isset($_POST['delall']))
1.1229 + {
1.1230 + $s_hidden_fields['delall'] = 1;
1.1231 + }
1.1232 + if (isset($_POST['delall']) || (isset($_POST['delmarked']) && sizeof($marked)))
1.1233 + {
1.1234 + confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields($s_hidden_fields));
1.1235 + }
1.1236 + }
1.1237 + }
1.1238 +
1.1239 + $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
1.1240 + FROM ' . WARNINGS_TABLE . ' w
1.1241 + LEFT JOIN ' . LOG_TABLE . ' l
1.1242 + ON (w.log_id = l.log_id)
1.1243 + LEFT JOIN ' . USERS_TABLE . ' m
1.1244 + ON (l.user_id = m.user_id)
1.1245 + WHERE w.user_id = ' . $user_id . '
1.1246 + ORDER BY w.warning_time DESC';
1.1247 + $result = $db->sql_query($sql);
1.1248 +
1.1249 + while ($row = $db->sql_fetchrow($result))
1.1250 + {
1.1251 + if (!$row['log_operation'])
1.1252 + {
1.1253 + // We do not have a log-entry anymore, so there is no data available
1.1254 + $row['action'] = $user->lang['USER_WARNING_LOG_DELETED'];
1.1255 + }
1.1256 + else
1.1257 + {
1.1258 + $row['action'] = (isset($user->lang[$row['log_operation']])) ? $user->lang[$row['log_operation']] : '{' . ucfirst(str_replace('_', ' ', $row['log_operation'])) . '}';
1.1259 + if (!empty($row['log_data']))
1.1260 + {
1.1261 + $log_data_ary = @unserialize($row['log_data']);
1.1262 + $log_data_ary = ($log_data_ary === false) ? array() : $log_data_ary;
1.1263 +
1.1264 + if (isset($user->lang[$row['log_operation']]))
1.1265 + {
1.1266 + // Check if there are more occurrences of % than arguments, if there are we fill out the arguments array
1.1267 + // It doesn't matter if we add more arguments than placeholders
1.1268 + if ((substr_count($row['action'], '%') - sizeof($log_data_ary)) > 0)
1.1269 + {
1.1270 + $log_data_ary = array_merge($log_data_ary, array_fill(0, substr_count($row['action'], '%') - sizeof($log_data_ary), ''));
1.1271 + }
1.1272 + $row['action'] = vsprintf($row['action'], $log_data_ary);
1.1273 + $row['action'] = bbcode_nl2br(censor_text($row['action']));
1.1274 + }
1.1275 + else if (!empty($log_data_ary))
1.1276 + {
1.1277 + $row['action'] .= '<br />' . implode('', $log_data_ary);
1.1278 + }
1.1279 + }
1.1280 + }
1.1281 +
1.1282 +
1.1283 + $template->assign_block_vars('warn', array(
1.1284 + 'ID' => $row['warning_id'],
1.1285 + 'USERNAME' => ($row['log_operation']) ? get_username_string('full', $row['mod_user_id'], $row['mod_username'], $row['mod_user_colour']) : '-',
1.1286 + 'ACTION' => make_clickable($row['action']),
1.1287 + 'DATE' => $user->format_date($row['warning_time']),
1.1288 + ));
1.1289 + }
1.1290 + $db->sql_freeresult($result);
1.1291 +
1.1292 + $template->assign_vars(array(
1.1293 + 'S_WARNINGS' => true,
1.1294 + ));
1.1295 +
1.1296 + break;
1.1297 +
1.1298 + case 'profile':
1.1299 +
1.1300 + include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
1.1301 + include($phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx);
1.1302 +
1.1303 + $cp = new custom_profile();
1.1304 +
1.1305 + $cp_data = $cp_error = array();
1.1306 +
1.1307 + $sql = 'SELECT lang_id
1.1308 + FROM ' . LANG_TABLE . "
1.1309 + WHERE lang_iso = '" . $db->sql_escape($user->data['user_lang']) . "'";
1.1310 + $result = $db->sql_query($sql);
1.1311 + $row = $db->sql_fetchrow($result);
1.1312 + $db->sql_freeresult($result);
1.1313 +
1.1314 + $user_row['iso_lang_id'] = $row['lang_id'];
1.1315 +
1.1316 + $data = array(
1.1317 + 'icq' => request_var('icq', $user_row['user_icq']),
1.1318 + 'aim' => request_var('aim', $user_row['user_aim']),
1.1319 + 'msn' => request_var('msn', $user_row['user_msnm']),
1.1320 + 'yim' => request_var('yim', $user_row['user_yim']),
1.1321 + 'jabber' => utf8_normalize_nfc(request_var('jabber', $user_row['user_jabber'], true)),
1.1322 + 'website' => request_var('website', $user_row['user_website']),
1.1323 + 'location' => utf8_normalize_nfc(request_var('location', $user_row['user_from'], true)),
1.1324 + 'occupation' => utf8_normalize_nfc(request_var('occupation', $user_row['user_occ'], true)),
1.1325 + 'interests' => utf8_normalize_nfc(request_var('interests', $user_row['user_interests'], true)),
1.1326 + 'bday_day' => 0,
1.1327 + 'bday_month' => 0,
1.1328 + 'bday_year' => 0,
1.1329 + );
1.1330 +
1.1331 + if ($user_row['user_birthday'])
1.1332 + {
1.1333 + list($data['bday_day'], $data['bday_month'], $data['bday_year']) = explode('-', $user_row['user_birthday']);
1.1334 + }
1.1335 +
1.1336 + $data['bday_day'] = request_var('bday_day', $data['bday_day']);
1.1337 + $data['bday_month'] = request_var('bday_month', $data['bday_month']);
1.1338 + $data['bday_year'] = request_var('bday_year', $data['bday_year']);
1.1339 + $data['user_birthday'] = sprintf('%2d-%2d-%4d', $data['bday_day'], $data['bday_month'], $data['bday_year']);
1.1340 +
1.1341 +
1.1342 + if ($submit)
1.1343 + {
1.1344 + $error = validate_data($data, array(
1.1345 + 'icq' => array(
1.1346 + array('string', true, 3, 15),
1.1347 + array('match', true, '#^[0-9]+$#i')),
1.1348 + 'aim' => array('string', true, 3, 255),
1.1349 + 'msn' => array('string', true, 5, 255),
1.1350 + 'jabber' => array(
1.1351 + array('string', true, 5, 255),
1.1352 + array('jabber')),
1.1353 + 'yim' => array('string', true, 5, 255),
1.1354 + 'website' => array(
1.1355 + array('string', true, 12, 255),
1.1356 + array('match', true, '#^http[s]?://(.*?\.)*?[a-z0-9\-]+\.[a-z]{2,4}#i')),
1.1357 + 'location' => array('string', true, 2, 100),
1.1358 + 'occupation' => array('string', true, 2, 500),
1.1359 + 'interests' => array('string', true, 2, 500),
1.1360 + 'bday_day' => array('num', true, 1, 31),
1.1361 + 'bday_month' => array('num', true, 1, 12),
1.1362 + 'bday_year' => array('num', true, 1901, gmdate('Y', time())),
1.1363 + 'user_birthday' => array('date', true),
1.1364 + ));
1.1365 +
1.1366 + // validate custom profile fields
1.1367 + $cp->submit_cp_field('profile', $user_row['iso_lang_id'], $cp_data, $cp_error);
1.1368 +
1.1369 + if (sizeof($cp_error))
1.1370 + {
1.1371 + $error = array_merge($error, $cp_error);
1.1372 + }
1.1373 + if (!check_form_key($form_name))
1.1374 + {
1.1375 + $error[] = 'FORM_INVALID';
1.1376 + }
1.1377 +
1.1378 + if (!sizeof($error))
1.1379 + {
1.1380 + $sql_ary = array(
1.1381 + 'user_icq' => $data['icq'],
1.1382 + 'user_aim' => $data['aim'],
1.1383 + 'user_msnm' => $data['msn'],
1.1384 + 'user_yim' => $data['yim'],
1.1385 + 'user_jabber' => $data['jabber'],
1.1386 + 'user_website' => $data['website'],
1.1387 + 'user_from' => $data['location'],
1.1388 + 'user_occ' => $data['occupation'],
1.1389 + 'user_interests'=> $data['interests'],
1.1390 + 'user_birthday' => $data['user_birthday'],
1.1391 + );
1.1392 +
1.1393 + $sql = 'UPDATE ' . USERS_TABLE . '
1.1394 + SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "
1.1395 + WHERE user_id = $user_id";
1.1396 + $db->sql_query($sql);
1.1397 +
1.1398 + // Update Custom Fields
1.1399 + $cp->update_profile_field_data($user_id, $cp_data);
1.1400 +
1.1401 + trigger_error($user->lang['USER_PROFILE_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_id));
1.1402 + }
1.1403 +
1.1404 + // Replace "error" strings with their real, localised form
1.1405 + $error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error);
1.1406 + }
1.1407 +
1.1408 + $s_birthday_day_options = '<option value="0"' . ((!$data['bday_day']) ? ' selected="selected"' : '') . '>--</option>';
1.1409 + for ($i = 1; $i < 32; $i++)
1.1410 + {
1.1411 + $selected = ($i == $data['bday_day']) ? ' selected="selected"' : '';
1.1412 + $s_birthday_day_options .= "<option value=\"$i\"$selected>$i</option>";
1.1413 + }
1.1414 +
1.1415 + $s_birthday_month_options = '<option value="0"' . ((!$data['bday_month']) ? ' selected="selected"' : '') . '>--</option>';
1.1416 + for ($i = 1; $i < 13; $i++)
1.1417 + {
1.1418 + $selected = ($i == $data['bday_month']) ? ' selected="selected"' : '';
1.1419 + $s_birthday_month_options .= "<option value=\"$i\"$selected>$i</option>";
1.1420 + }
1.1421 + $s_birthday_year_options = '';
1.1422 +
1.1423 + $now = getdate();
1.1424 + $s_birthday_year_options = '<option value="0"' . ((!$data['bday_year']) ? ' selected="selected"' : '') . '>--</option>';
1.1425 + for ($i = $now['year'] - 100; $i <= $now['year']; $i++)
1.1426 + {
1.1427 + $selected = ($i == $data['bday_year']) ? ' selected="selected"' : '';
1.1428 + $s_birthday_year_options .= "<option value=\"$i\"$selected>$i</option>";
1.1429 + }
1.1430 + unset($now);
1.1431 +
1.1432 + $template->assign_vars(array(
1.1433 + 'ICQ' => $data['icq'],
1.1434 + 'YIM' => $data['yim'],
1.1435 + 'AIM' => $data['aim'],
1.1436 + 'MSN' => $data['msn'],
1.1437 + 'JABBER' => $data['jabber'],
1.1438 + 'WEBSITE' => $data['website'],
1.1439 + 'LOCATION' => $data['location'],
1.1440 + 'OCCUPATION' => $data['occupation'],
1.1441 + 'INTERESTS' => $data['interests'],
1.1442 +
1.1443 + 'S_BIRTHDAY_DAY_OPTIONS' => $s_birthday_day_options,
1.1444 + 'S_BIRTHDAY_MONTH_OPTIONS' => $s_birthday_month_options,
1.1445 + 'S_BIRTHDAY_YEAR_OPTIONS' => $s_birthday_year_options,
1.1446 +
1.1447 + 'S_PROFILE' => true)
1.1448 + );
1.1449 +
1.1450 + // Get additional profile fields and assign them to the template block var 'profile_fields'
1.1451 + $user->get_profile_fields($user_id);
1.1452 +
1.1453 + $cp->generate_profile_fields('profile', $user_row['iso_lang_id']);
1.1454 +
1.1455 + break;
1.1456 +
1.1457 + case 'prefs':
1.1458 +
1.1459 + include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
1.1460 +
1.1461 + $data = array(
1.1462 + 'dateformat' => utf8_normalize_nfc(request_var('dateformat', $user_row['user_dateformat'], true)),
1.1463 + 'lang' => basename(request_var('lang', $user_row['user_lang'])),
1.1464 + 'tz' => request_var('tz', (float) $user_row['user_timezone']),
1.1465 + 'style' => request_var('style', $user_row['user_style']),
1.1466 + 'dst' => request_var('dst', $user_row['user_dst']),
1.1467 + 'viewemail' => request_var('viewemail', $user_row['user_allow_viewemail']),
1.1468 + 'massemail' => request_var('massemail', $user_row['user_allow_massemail']),
1.1469 + 'hideonline' => request_var('hideonline', !$user_row['user_allow_viewonline']),
1.1470 + 'notifymethod' => request_var('notifymethod', $user_row['user_notify_type']),
1.1471 + 'notifypm' => request_var('notifypm', $user_row['user_notify_pm']),
1.1472 + 'popuppm' => request_var('popuppm', $this->optionget($user_row, 'popuppm')),
1.1473 + 'allowpm' => request_var('allowpm', $user_row['user_allow_pm']),
1.1474 +
1.1475 + 'topic_sk' => request_var('topic_sk', ($user_row['user_topic_sortby_type']) ? $user_row['user_topic_sortby_type'] : 't'),
1.1476 + 'topic_sd' => request_var('topic_sd', ($user_row['user_topic_sortby_dir']) ? $user_row['user_topic_sortby_dir'] : 'd'),
1.1477 + 'topic_st' => request_var('topic_st', ($user_row['user_topic_show_days']) ? $user_row['user_topic_show_days'] : 0),
1.1478 +
1.1479 + 'post_sk' => request_var('post_sk', ($user_row['user_post_sortby_type']) ? $user_row['user_post_sortby_type'] : 't'),
1.1480 + 'post_sd' => request_var('post_sd', ($user_row['user_post_sortby_dir']) ? $user_row['user_post_sortby_dir'] : 'a'),
1.1481 + 'post_st' => request_var('post_st', ($user_row['user_post_show_days']) ? $user_row['user_post_show_days'] : 0),
1.1482 +
1.1483 + 'view_images' => request_var('view_images', $this->optionget($user_row, 'viewimg')),
1.1484 + 'view_flash' => request_var('view_flash', $this->optionget($user_row, 'viewflash')),
1.1485 + 'view_smilies' => request_var('view_smilies', $this->optionget($user_row, 'viewsmilies')),
1.1486 + 'view_sigs' => request_var('view_sigs', $this->optionget($user_row, 'viewsigs')),
1.1487 + 'view_avatars' => request_var('view_avatars', $this->optionget($user_row, 'viewavatars')),
1.1488 + 'view_wordcensor' => request_var('view_wordcensor', $this->optionget($user_row, 'viewcensors')),
1.1489 +
1.1490 + 'bbcode' => request_var('bbcode', $this->optionget($user_row, 'bbcode')),
1.1491 + 'smilies' => request_var('smilies', $this->optionget($user_row, 'smilies')),
1.1492 + 'sig' => request_var('sig', $this->optionget($user_row, 'attachsig')),
1.1493 + 'notify' => request_var('notify', $user_row['user_notify']),
1.1494 + );
1.1495 +
1.1496 + if ($submit)
1.1497 + {
1.1498 + $error = validate_data($data, array(
1.1499 + 'dateformat' => array('string', false, 1, 30),
1.1500 + 'lang' => array('match', false, '#^[a-z_\-]{2,}$#i'),
1.1501 + 'tz' => array('num', false, -14, 14),
1.1502 +
1.1503 + 'topic_sk' => array('string', false, 1, 1),
1.1504 + 'topic_sd' => array('string', false, 1, 1),
1.1505 + 'post_sk' => array('string', false, 1, 1),
1.1506 + 'post_sd' => array('string', false, 1, 1),
1.1507 + ));
1.1508 +
1.1509 + if (!check_form_key($form_name))
1.1510 + {
1.1511 + $error[] = 'FORM_INVALID';
1.1512 + }
1.1513 +
1.1514 + if (!sizeof($error))
1.1515 + {
1.1516 + $this->optionset($user_row, 'popuppm', $data['popuppm']);
1.1517 + $this->optionset($user_row, 'viewimg', $data['view_images']);
1.1518 + $this->optionset($user_row, 'viewflash', $data['view_flash']);
1.1519 + $this->optionset($user_row, 'viewsmilies', $data['view_smilies']);
1.1520 + $this->optionset($user_row, 'viewsigs', $data['view_sigs']);
1.1521 + $this->optionset($user_row, 'viewavatars', $data['view_avatars']);
1.1522 + $this->optionset($user_row, 'viewcensors', $data['view_wordcensor']);
1.1523 + $this->optionset($user_row, 'bbcode', $data['bbcode']);
1.1524 + $this->optionset($user_row, 'smilies', $data['smilies']);
1.1525 + $this->optionset($user_row, 'attachsig', $data['sig']);
1.1526 +
1.1527 + $sql_ary = array(
1.1528 + 'user_options' => $user_row['user_options'],
1.1529 +
1.1530 + 'user_allow_pm' => $data['allowpm'],
1.1531 + 'user_allow_viewemail' => $data['viewemail'],
1.1532 + 'user_allow_massemail' => $data['massemail'],
1.1533 + 'user_allow_viewonline' => !$data['hideonline'],
1.1534 + 'user_notify_type' => $data['notifymethod'],
1.1535 + 'user_notify_pm' => $data['notifypm'],
1.1536 +
1.1537 + 'user_dst' => $data['dst'],
1.1538 + 'user_dateformat' => $data['dateformat'],
1.1539 + 'user_lang' => $data['lang'],
1.1540 + 'user_timezone' => $data['tz'],
1.1541 + 'user_style' => $data['style'],
1.1542 +
1.1543 + 'user_topic_sortby_type' => $data['topic_sk'],
1.1544 + 'user_post_sortby_type' => $data['post_sk'],
1.1545 + 'user_topic_sortby_dir' => $data['topic_sd'],
1.1546 + 'user_post_sortby_dir' => $data['post_sd'],
1.1547 +
1.1548 + 'user_topic_show_days' => $data['topic_st'],
1.1549 + 'user_post_show_days' => $data['post_st'],
1.1550 +
1.1551 + 'user_notify' => $data['notify'],
1.1552 + );
1.1553 +
1.1554 + $sql = 'UPDATE ' . USERS_TABLE . '
1.1555 + SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "
1.1556 + WHERE user_id = $user_id";
1.1557 + $db->sql_query($sql);
1.1558 +
1.1559 + // Check if user has an active session
1.1560 + if ($user_row['session_id'])
1.1561 + {
1.1562 + // We'll update the session if user_allow_viewonline has changed and the user is a bot
1.1563 + // Or if it's a regular user and the admin set it to hide the session
1.1564 + if ($user_row['user_allow_viewonline'] != $sql_ary['user_allow_viewonline'] && $user_row['user_type'] == USER_IGNORE
1.1565 + || $user_row['user_allow_viewonline'] && !$sql_ary['user_allow_viewonline'])
1.1566 + {
1.1567 + // We also need to check if the user has the permission to cloak.
1.1568 + $user_auth = new auth();
1.1569 + $user_auth->acl($user_row);
1.1570 +
1.1571 + $session_sql_ary = array(
1.1572 + 'session_viewonline' => ($user_auth->acl_get('u_hideonline')) ? $sql_ary['user_allow_viewonline'] : true,
1.1573 + );
1.1574 +
1.1575 + $sql = 'UPDATE ' . SESSIONS_TABLE . '
1.1576 + SET ' . $db->sql_build_array('UPDATE', $session_sql_ary) . "
1.1577 + WHERE session_user_id = $user_id";
1.1578 + $db->sql_query($sql);
1.1579 +
1.1580 + unset($user_auth);
1.1581 + }
1.1582 + }
1.1583 +
1.1584 + trigger_error($user->lang['USER_PREFS_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_id));
1.1585 + }
1.1586 +
1.1587 + // Replace "error" strings with their real, localised form
1.1588 + $error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error);
1.1589 + }
1.1590 +
1.1591 + $dateformat_options = '';
1.1592 + foreach ($user->lang['dateformats'] as $format => $null)
1.1593 + {
1.1594 + $dateformat_options .= '<option value="' . $format . '"' . (($format == $data['dateformat']) ? ' selected="selected"' : '') . '>';
1.1595 + $dateformat_options .= $user->format_date(time(), $format, false) . ((strpos($format, '|') !== false) ? $user->lang['VARIANT_DATE_SEPARATOR'] . $user->format_date(time(), $format, true) : '');
1.1596 + $dateformat_options .= '</option>';
1.1597 + }
1.1598 +
1.1599 + $s_custom = false;
1.1600 +
1.1601 + $dateformat_options .= '<option value="custom"';
1.1602 + if (!isset($user->lang['dateformats'][$data['dateformat']]))
1.1603 + {
1.1604 + $dateformat_options .= ' selected="selected"';
1.1605 + $s_custom = true;
1.1606 + }
1.1607 + $dateformat_options .= '>' . $user->lang['CUSTOM_DATEFORMAT'] . '</option>';
1.1608 +
1.1609 + $sort_dir_text = array('a' => $user->lang['ASCENDING'], 'd' => $user->lang['DESCENDING']);
1.1610 +
1.1611 + // Topic ordering options
1.1612 + $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']);
1.1613 + $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']);
1.1614 +
1.1615 + // Post ordering options
1.1616 + $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']);
1.1617 + $sort_by_post_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 's' => $user->lang['SUBJECT']);
1.1618 +
1.1619 + $_options = array('topic', 'post');
1.1620 + foreach ($_options as $sort_option)
1.1621 + {
1.1622 + ${'s_limit_' . $sort_option . '_days'} = '<select name="' . $sort_option . '_st">';
1.1623 + foreach (${'limit_' . $sort_option . '_days'} as $day => $text)
1.1624 + {
1.1625 + $selected = ($data[$sort_option . '_st'] == $day) ? ' selected="selected"' : '';
1.1626 + ${'s_limit_' . $sort_option . '_days'} .= '<option value="' . $day . '"' . $selected . '>' . $text . '</option>';
1.1627 + }
1.1628 + ${'s_limit_' . $sort_option . '_days'} .= '</select>';
1.1629 +
1.1630 + ${'s_sort_' . $sort_option . '_key'} = '<select name="' . $sort_option . '_sk">';
1.1631 + foreach (${'sort_by_' . $sort_option . '_text'} as $key => $text)
1.1632 + {
1.1633 + $selected = ($data[$sort_option . '_sk'] == $key) ? ' selected="selected"' : '';
1.1634 + ${'s_sort_' . $sort_option . '_key'} .= '<option value="' . $key . '"' . $selected . '>' . $text . '</option>';
1.1635 + }
1.1636 + ${'s_sort_' . $sort_option . '_key'} .= '</select>';
1.1637 +
1.1638 + ${'s_sort_' . $sort_option . '_dir'} = '<select name="' . $sort_option . '_sd">';
1.1639 + foreach ($sort_dir_text as $key => $value)
1.1640 + {
1.1641 + $selected = ($data[$sort_option . '_sd'] == $key) ? ' selected="selected"' : '';
1.1642 + ${'s_sort_' . $sort_option . '_dir'} .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>';
1.1643 + }
1.1644 + ${'s_sort_' . $sort_option . '_dir'} .= '</select>';
1.1645 + }
1.1646 +
1.1647 + $template->assign_vars(array(
1.1648 + 'S_PREFS' => true,
1.1649 + 'S_JABBER_DISABLED' => ($config['jab_enable'] && $user_row['user_jabber'] && @extension_loaded('xml')) ? false : true,
1.1650 +
1.1651 + 'VIEW_EMAIL' => $data['viewemail'],
1.1652 + 'MASS_EMAIL' => $data['massemail'],
1.1653 + 'ALLOW_PM' => $data['allowpm'],
1.1654 + 'HIDE_ONLINE' => $data['hideonline'],
1.1655 + 'NOTIFY_EMAIL' => ($data['notifymethod'] == NOTIFY_EMAIL) ? true : false,
1.1656 + 'NOTIFY_IM' => ($data['notifymethod'] == NOTIFY_IM) ? true : false,
1.1657 + 'NOTIFY_BOTH' => ($data['notifymethod'] == NOTIFY_BOTH) ? true : false,
1.1658 + 'NOTIFY_PM' => $data['notifypm'],
1.1659 + 'POPUP_PM' => $data['popuppm'],
1.1660 + 'DST' => $data['dst'],
1.1661 + 'BBCODE' => $data['bbcode'],
1.1662 + 'SMILIES' => $data['smilies'],
1.1663 + 'ATTACH_SIG' => $data['sig'],
1.1664 + 'NOTIFY' => $data['notify'],
1.1665 + 'VIEW_IMAGES' => $data['view_images'],
1.1666 + 'VIEW_FLASH' => $data['view_flash'],
1.1667 + 'VIEW_SMILIES' => $data['view_smilies'],
1.1668 + 'VIEW_SIGS' => $data['view_sigs'],
1.1669 + 'VIEW_AVATARS' => $data['view_avatars'],
1.1670 + 'VIEW_WORDCENSOR' => $data['view_wordcensor'],
1.1671 +
1.1672 + 'S_TOPIC_SORT_DAYS' => $s_limit_topic_days,
1.1673 + 'S_TOPIC_SORT_KEY' => $s_sort_topic_key,
1.1674 + 'S_TOPIC_SORT_DIR' => $s_sort_topic_dir,
1.1675 + 'S_POST_SORT_DAYS' => $s_limit_post_days,
1.1676 + 'S_POST_SORT_KEY' => $s_sort_post_key,
1.1677 + 'S_POST_SORT_DIR' => $s_sort_post_dir,
1.1678 +
1.1679 + 'DATE_FORMAT' => $data['dateformat'],
1.1680 + 'S_DATEFORMAT_OPTIONS' => $dateformat_options,
1.1681 + 'S_CUSTOM_DATEFORMAT' => $s_custom,
1.1682 + 'DEFAULT_DATEFORMAT' => $config['default_dateformat'],
1.1683 + 'A_DEFAULT_DATEFORMAT' => addslashes($config['default_dateformat']),
1.1684 +
1.1685 + 'S_LANG_OPTIONS' => language_select($data['lang']),
1.1686 + 'S_STYLE_OPTIONS' => style_select($data['style']),
1.1687 + 'S_TZ_OPTIONS' => tz_select($data['tz'], true),
1.1688 + )
1.1689 + );
1.1690 +
1.1691 + break;
1.1692 +
1.1693 + case 'avatar':
1.1694 +
1.1695 + include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
1.1696 + include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
1.1697 +
1.1698 + $can_upload = (file_exists($phpbb_root_path . $config['avatar_path']) && phpbb_is_writable($phpbb_root_path . $config['avatar_path']) && $file_uploads) ? true : false;
1.1699 +
1.1700 + if ($submit)
1.1701 + {
1.1702 +
1.1703 + if (!check_form_key($form_name))
1.1704 + {
1.1705 + trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
1.1706 + }
1.1707 +
1.1708 + if (avatar_process_user($error, $user_row, $can_upload))
1.1709 + {
1.1710 + trigger_error($user->lang['USER_AVATAR_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_row['user_id']));
1.1711 + }
1.1712 +
1.1713 + // Replace "error" strings with their real, localised form
1.1714 + $error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error);
1.1715 + }
1.1716 +
1.1717 + if (!$config['allow_avatar'] && $user_row['user_avatar_type'])
1.1718 + {
1.1719 + $error[] = $user->lang['USER_AVATAR_NOT_ALLOWED'];
1.1720 + }
1.1721 + else if ((($user_row['user_avatar_type'] == AVATAR_UPLOAD) && !$config['allow_avatar_upload']) ||
1.1722 + (($user_row['user_avatar_type'] == AVATAR_REMOTE) && !$config['allow_avatar_remote']) ||
1.1723 + (($user_row['user_avatar_type'] == AVATAR_GALLERY) && !$config['allow_avatar_local']))
1.1724 + {
1.1725 + $error[] = $user->lang['USER_AVATAR_TYPE_NOT_ALLOWED'];
1.1726 + }
1.1727 +
1.1728 + // Generate users avatar
1.1729 + $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="" />';
1.1730 +
1.1731 + $display_gallery = (isset($_POST['display_gallery'])) ? true : false;
1.1732 + $avatar_select = basename(request_var('avatar_select', ''));
1.1733 + $category = basename(request_var('category', ''));
1.1734 +
1.1735 + if ($config['allow_avatar_local'] && $display_gallery)
1.1736 + {
1.1737 + avatar_gallery($category, $avatar_select, 4);
1.1738 + }
1.1739 +
1.1740 + $template->assign_vars(array(
1.1741 + 'S_AVATAR' => true,
1.1742 + 'S_CAN_UPLOAD' => $can_upload,
1.1743 + 'S_UPLOAD_FILE' => ($config['allow_avatar'] && $can_upload && $config['allow_avatar_upload']) ? true : false,
1.1744 + 'S_REMOTE_UPLOAD' => ($config['allow_avatar'] && $can_upload && $config['allow_avatar_remote_upload']) ? true : false,
1.1745 + 'S_ALLOW_REMOTE' => ($config['allow_avatar'] && $config['allow_avatar_remote']) ? true : false,
1.1746 + 'S_DISPLAY_GALLERY' => ($config['allow_avatar'] && $config['allow_avatar_local'] && !$display_gallery) ? true : false,
1.1747 + 'S_IN_GALLERY' => ($config['allow_avatar'] && $config['allow_avatar_local'] && $display_gallery) ? true : false,
1.1748 +
1.1749 + 'AVATAR_IMAGE' => $avatar_img,
1.1750 + 'AVATAR_MAX_FILESIZE' => $config['avatar_filesize'],
1.1751 + 'USER_AVATAR_WIDTH' => $user_row['user_avatar_width'],
1.1752 + 'USER_AVATAR_HEIGHT' => $user_row['user_avatar_height'],
1.1753 +
1.1754 + 'L_AVATAR_EXPLAIN' => sprintf($user->lang['AVATAR_EXPLAIN'], $config['avatar_max_width'], $config['avatar_max_height'], round($config['avatar_filesize'] / 1024)))
1.1755 + );
1.1756 +
1.1757 + break;
1.1758 +
1.1759 + case 'rank':
1.1760 +
1.1761 + if ($submit)
1.1762 + {
1.1763 + if (!check_form_key($form_name))
1.1764 + {
1.1765 + trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
1.1766 + }
1.1767 +
1.1768 + $rank_id = request_var('user_rank', 0);
1.1769 +
1.1770 + $sql = 'UPDATE ' . USERS_TABLE . "
1.1771 + SET user_rank = $rank_id
1.1772 + WHERE user_id = $user_id";
1.1773 + $db->sql_query($sql);
1.1774 +
1.1775 + trigger_error($user->lang['USER_RANK_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_id));
1.1776 + }
1.1777 +
1.1778 + $sql = 'SELECT *
1.1779 + FROM ' . RANKS_TABLE . '
1.1780 + WHERE rank_special = 1
1.1781 + ORDER BY rank_title';
1.1782 + $result = $db->sql_query($sql);
1.1783 +
1.1784 + $s_rank_options = '<option value="0"' . ((!$user_row['user_rank']) ? ' selected="selected"' : '') . '>' . $user->lang['NO_SPECIAL_RANK'] . '</option>';
1.1785 +
1.1786 + while ($row = $db->sql_fetchrow($result))
1.1787 + {
1.1788 + $selected = ($user_row['user_rank'] && $row['rank_id'] == $user_row['user_rank']) ? ' selected="selected"' : '';
1.1789 + $s_rank_options .= '<option value="' . $row['rank_id'] . '"' . $selected . '>' . $row['rank_title'] . '</option>';
1.1790 + }
1.1791 + $db->sql_freeresult($result);
1.1792 +
1.1793 + $template->assign_vars(array(
1.1794 + 'S_RANK' => true,
1.1795 + 'S_RANK_OPTIONS' => $s_rank_options)
1.1796 + );
1.1797 +
1.1798 + break;
1.1799 +
1.1800 + case 'sig':
1.1801 +
1.1802 + include_once($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
1.1803 + include_once($phpbb_root_path . 'includes/functions_display.' . $phpEx);
1.1804 +
1.1805 + $enable_bbcode = ($config['allow_sig_bbcode']) ? (bool) $this->optionget($user_row, 'sig_bbcode') : false;
1.1806 + $enable_smilies = ($config['allow_sig_smilies']) ? (bool) $this->optionget($user_row, 'sig_smilies') : false;
1.1807 + $enable_urls = ($config['allow_sig_links']) ? (bool) $this->optionget($user_row, 'sig_links') : false;
1.1808 + $signature = utf8_normalize_nfc(request_var('signature', (string) $user_row['user_sig'], true));
1.1809 +
1.1810 + $preview = (isset($_POST['preview'])) ? true : false;
1.1811 +
1.1812 + if ($submit || $preview)
1.1813 + {
1.1814 + include_once($phpbb_root_path . 'includes/message_parser.' . $phpEx);
1.1815 +
1.1816 + $enable_bbcode = ($config['allow_sig_bbcode']) ? ((request_var('disable_bbcode', false)) ? false : true) : false;
1.1817 + $enable_smilies = ($config['allow_sig_smilies']) ? ((request_var('disable_smilies', false)) ? false : true) : false;
1.1818 + $enable_urls = ($config['allow_sig_links']) ? ((request_var('disable_magic_url', false)) ? false : true) : false;
1.1819 +
1.1820 + $message_parser = new parse_message($signature);
1.1821 +
1.1822 + // Allowing Quote BBCode
1.1823 + $message_parser->parse($enable_bbcode, $enable_urls, $enable_smilies, $config['allow_sig_img'], $config['allow_sig_flash'], true, $config['allow_sig_links'], true, 'sig');
1.1824 +
1.1825 + if (sizeof($message_parser->warn_msg))
1.1826 + {
1.1827 + $error[] = implode('<br />', $message_parser->warn_msg);
1.1828 + }
1.1829 +
1.1830 + if (!check_form_key($form_name))
1.1831 + {
1.1832 + $error = 'FORM_INVALID';
1.1833 + }
1.1834 +
1.1835 + if (!sizeof($error) && $submit)
1.1836 + {
1.1837 + $this->optionset($user_row, 'sig_bbcode', $enable_bbcode);
1.1838 + $this->optionset($user_row, 'sig_smilies', $enable_smilies);
1.1839 + $this->optionset($user_row, 'sig_links', $enable_urls);
1.1840 +
1.1841 + $sql_ary = array(
1.1842 + 'user_sig' => (string) $message_parser->message,
1.1843 + 'user_options' => $user_row['user_options'],
1.1844 + 'user_sig_bbcode_uid' => (string) $message_parser->bbcode_uid,
1.1845 + 'user_sig_bbcode_bitfield' => (string) $message_parser->bbcode_bitfield
1.1846 + );
1.1847 +
1.1848 + $sql = 'UPDATE ' . USERS_TABLE . '
1.1849 + SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
1.1850 + WHERE user_id = ' . $user_id;
1.1851 + $db->sql_query($sql);
1.1852 +
1.1853 + trigger_error($user->lang['USER_SIG_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_id));
1.1854 + }
1.1855 +
1.1856 + // Replace "error" strings with their real, localised form
1.1857 + $error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error);
1.1858 + }
1.1859 +
1.1860 + $signature_preview = '';
1.1861 +
1.1862 + if ($preview)
1.1863 + {
1.1864 + // Now parse it for displaying
1.1865 + $signature_preview = $message_parser->format_display($enable_bbcode, $enable_urls, $enable_smilies, false);
1.1866 + unset($message_parser);
1.1867 + }
1.1868 +
1.1869 + decode_message($signature, $user_row['user_sig_bbcode_uid']);
1.1870 +
1.1871 + $template->assign_vars(array(
1.1872 + 'S_SIGNATURE' => true,
1.1873 +
1.1874 + 'SIGNATURE' => $signature,
1.1875 + 'SIGNATURE_PREVIEW' => $signature_preview,
1.1876 +
1.1877 + 'S_BBCODE_CHECKED' => (!$enable_bbcode) ? ' checked="checked"' : '',
1.1878 + 'S_SMILIES_CHECKED' => (!$enable_smilies) ? ' checked="checked"' : '',
1.1879 + 'S_MAGIC_URL_CHECKED' => (!$enable_urls) ? ' checked="checked"' : '',
1.1880 +
1.1881 + '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>'),
1.1882 + 'SMILIES_STATUS' => ($config['allow_sig_smilies']) ? $user->lang['SMILIES_ARE_ON'] : $user->lang['SMILIES_ARE_OFF'],
1.1883 + 'IMG_STATUS' => ($config['allow_sig_img']) ? $user->lang['IMAGES_ARE_ON'] : $user->lang['IMAGES_ARE_OFF'],
1.1884 + 'FLASH_STATUS' => ($config['allow_sig_flash']) ? $user->lang['FLASH_IS_ON'] : $user->lang['FLASH_IS_OFF'],
1.1885 + 'URL_STATUS' => ($config['allow_sig_links']) ? $user->lang['URL_IS_ON'] : $user->lang['URL_IS_OFF'],
1.1886 +
1.1887 + 'L_SIGNATURE_EXPLAIN' => sprintf($user->lang['SIGNATURE_EXPLAIN'], $config['max_sig_chars']),
1.1888 +
1.1889 + 'S_BBCODE_ALLOWED' => $config['allow_sig_bbcode'],
1.1890 + 'S_SMILIES_ALLOWED' => $config['allow_sig_smilies'],
1.1891 + 'S_BBCODE_IMG' => ($config['allow_sig_img']) ? true : false,
1.1892 + 'S_BBCODE_FLASH' => ($config['allow_sig_flash']) ? true : false,
1.1893 + 'S_LINKS_ALLOWED' => ($config['allow_sig_links']) ? true : false)
1.1894 + );
1.1895 +
1.1896 + // Assigning custom bbcodes
1.1897 + display_custom_bbcodes();
1.1898 +
1.1899 + break;
1.1900 +
1.1901 + case 'attach':
1.1902 +
1.1903 + $start = request_var('start', 0);
1.1904 + $deletemark = (isset($_POST['delmarked'])) ? true : false;
1.1905 + $marked = request_var('mark', array(0));
1.1906 +
1.1907 + // Sort keys
1.1908 + $sort_key = request_var('sk', 'a');
1.1909 + $sort_dir = request_var('sd', 'd');
1.1910 +
1.1911 + if ($deletemark && sizeof($marked))
1.1912 + {
1.1913 + $sql = 'SELECT attach_id
1.1914 + FROM ' . ATTACHMENTS_TABLE . '
1.1915 + WHERE poster_id = ' . $user_id . '
1.1916 + AND is_orphan = 0
1.1917 + AND ' . $db->sql_in_set('attach_id', $marked);
1.1918 + $result = $db->sql_query($sql);
1.1919 +
1.1920 + $marked = array();
1.1921 + while ($row = $db->sql_fetchrow($result))
1.1922 + {
1.1923 + $marked[] = $row['attach_id'];
1.1924 + }
1.1925 + $db->sql_freeresult($result);
1.1926 + }
1.1927 +
1.1928 + if ($deletemark && sizeof($marked))
1.1929 + {
1.1930 + if (confirm_box(true))
1.1931 + {
1.1932 + $sql = 'SELECT real_filename
1.1933 + FROM ' . ATTACHMENTS_TABLE . '
1.1934 + WHERE ' . $db->sql_in_set('attach_id', $marked);
1.1935 + $result = $db->sql_query($sql);
1.1936 +
1.1937 + $log_attachments = array();
1.1938 + while ($row = $db->sql_fetchrow($result))
1.1939 + {
1.1940 + $log_attachments[] = $row['real_filename'];
1.1941 + }
1.1942 + $db->sql_freeresult($result);
1.1943 +
1.1944 + delete_attachments('attach', $marked);
1.1945 +
1.1946 + $message = (sizeof($log_attachments) == 1) ? $user->lang['ATTACHMENT_DELETED'] : $user->lang['ATTACHMENTS_DELETED'];
1.1947 +
1.1948 + add_log('admin', 'LOG_ATTACHMENTS_DELETED', implode(', ', $log_attachments));
1.1949 + trigger_error($message . adm_back_link($this->u_action . '&u=' . $user_id));
1.1950 + }
1.1951 + else
1.1952 + {
1.1953 + confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array(
1.1954 + 'u' => $user_id,
1.1955 + 'i' => $id,
1.1956 + 'mode' => $mode,
1.1957 + 'action' => $action,
1.1958 + 'delmarked' => true,
1.1959 + 'mark' => $marked))
1.1960 + );
1.1961 + }
1.1962 + }
1.1963 +
1.1964 + $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']);
1.1965 + $sk_sql = array('a' => 'a.real_filename', 'c' => 'a.extension', 'd' => 'a.filesize', 'e' => 'a.download_count', 'f' => 'a.filetime', 'g' => 't.topic_title');
1.1966 +
1.1967 + $sd_text = array('a' => $user->lang['ASCENDING'], 'd' => $user->lang['DESCENDING']);
1.1968 +
1.1969 + $s_sort_key = '';
1.1970 + foreach ($sk_text as $key => $value)
1.1971 + {
1.1972 + $selected = ($sort_key == $key) ? ' selected="selected"' : '';
1.1973 + $s_sort_key .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>';
1.1974 + }
1.1975 +
1.1976 + $s_sort_dir = '';
1.1977 + foreach ($sd_text as $key => $value)
1.1978 + {
1.1979 + $selected = ($sort_dir == $key) ? ' selected="selected"' : '';
1.1980 + $s_sort_dir .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>';
1.1981 + }
1.1982 +
1.1983 + if (!isset($sk_sql[$sort_key]))
1.1984 + {
1.1985 + $sort_key = 'a';
1.1986 + }
1.1987 +
1.1988 + $order_by = $sk_sql[$sort_key] . ' ' . (($sort_dir == 'a') ? 'ASC' : 'DESC');
1.1989 +
1.1990 + $sql = 'SELECT COUNT(attach_id) as num_attachments
1.1991 + FROM ' . ATTACHMENTS_TABLE . "
1.1992 + WHERE poster_id = $user_id
1.1993 + AND is_orphan = 0";
1.1994 + $result = $db->sql_query_limit($sql, 1);
1.1995 + $num_attachments = (int) $db->sql_fetchfield('num_attachments');
1.1996 + $db->sql_freeresult($result);
1.1997 +
1.1998 + $sql = 'SELECT a.*, t.topic_title, p.message_subject as message_title
1.1999 + FROM ' . ATTACHMENTS_TABLE . ' a
1.2000 + LEFT JOIN ' . TOPICS_TABLE . ' t ON (a.topic_id = t.topic_id
1.2001 + AND a.in_message = 0)
1.2002 + LEFT JOIN ' . PRIVMSGS_TABLE . ' p ON (a.post_msg_id = p.msg_id
1.2003 + AND a.in_message = 1)
1.2004 + WHERE a.poster_id = ' . $user_id . "
1.2005 + AND a.is_orphan = 0
1.2006 + ORDER BY $order_by";
1.2007 + $result = $db->sql_query_limit($sql, $config['posts_per_page'], $start);
1.2008 +
1.2009 + while ($row = $db->sql_fetchrow($result))
1.2010 + {
1.2011 + if ($row['in_message'])
1.2012 + {
1.2013 + $view_topic = append_sid("{$phpbb_root_path}ucp.$phpEx", "i=pm&p={$row['post_msg_id']}");
1.2014 + }
1.2015 + else
1.2016 + {
1.2017 + $view_topic = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "t={$row['topic_id']}&p={$row['post_msg_id']}") . '#p' . $row['post_msg_id'];
1.2018 + }
1.2019 +
1.2020 + $template->assign_block_vars('attach', array(
1.2021 + 'REAL_FILENAME' => $row['real_filename'],
1.2022 + 'COMMENT' => nl2br($row['attach_comment']),
1.2023 + 'EXTENSION' => $row['extension'],
1.2024 + 'SIZE' => get_formatted_filesize($row['filesize']),
1.2025 + 'DOWNLOAD_COUNT' => $row['download_count'],
1.2026 + 'POST_TIME' => $user->format_date($row['filetime']),
1.2027 + 'TOPIC_TITLE' => ($row['in_message']) ? $row['message_title'] : $row['topic_title'],
1.2028 +
1.2029 + 'ATTACH_ID' => $row['attach_id'],
1.2030 + 'POST_ID' => $row['post_msg_id'],
1.2031 + 'TOPIC_ID' => $row['topic_id'],
1.2032 +
1.2033 + 'S_IN_MESSAGE' => $row['in_message'],
1.2034 +
1.2035 + 'U_DOWNLOAD' => append_sid("{$phpbb_root_path}download/file.$phpEx", 'mode=view&id=' . $row['attach_id']),
1.2036 + 'U_VIEW_TOPIC' => $view_topic)
1.2037 + );
1.2038 + }
1.2039 + $db->sql_freeresult($result);
1.2040 +
1.2041 + $template->assign_vars(array(
1.2042 + 'S_ATTACHMENTS' => true,
1.2043 + 'S_ON_PAGE' => on_page($num_attachments, $config['topics_per_page'], $start),
1.2044 + 'S_SORT_KEY' => $s_sort_key,
1.2045 + 'S_SORT_DIR' => $s_sort_dir,
1.2046 +
1.2047 + 'PAGINATION' => generate_pagination($this->u_action . "&u=$user_id&sk=$sort_key&sd=$sort_dir", $num_attachments, $config['topics_per_page'], $start, true))
1.2048 + );
1.2049 +
1.2050 + break;
1.2051 +
1.2052 + case 'groups':
1.2053 +
1.2054 + include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
1.2055 +
1.2056 + $user->add_lang(array('groups', 'acp/groups'));
1.2057 + $group_id = request_var('g', 0);
1.2058 +
1.2059 + if ($group_id)
1.2060 + {
1.2061 + // Check the founder only entry for this group to make sure everything is well
1.2062 + $sql = 'SELECT group_founder_manage
1.2063 + FROM ' . GROUPS_TABLE . '
1.2064 + WHERE group_id = ' . $group_id;
1.2065 + $result = $db->sql_query($sql);
1.2066 + $founder_manage = (int) $db->sql_fetchfield('group_founder_manage');
1.2067 + $db->sql_freeresult($result);
1.2068 +
1.2069 + if ($user->data['user_type'] != USER_FOUNDER && $founder_manage)
1.2070 + {
1.2071 + trigger_error($user->lang['NOT_ALLOWED_MANAGE_GROUP'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
1.2072 + }
1.2073 + }
1.2074 + else
1.2075 + {
1.2076 + $founder_manage = 0;
1.2077 + }
1.2078 +
1.2079 + switch ($action)
1.2080 + {
1.2081 + case 'demote':
1.2082 + case 'promote':
1.2083 + case 'default':
1.2084 + if (!$group_id)
1.2085 + {
1.2086 + trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
1.2087 + }
1.2088 + group_user_attributes($action, $group_id, $user_id);
1.2089 +
1.2090 + if ($action == 'default')
1.2091 + {
1.2092 + $user_row['group_id'] = $group_id;
1.2093 + }
1.2094 + break;
1.2095 +
1.2096 + case 'delete':
1.2097 +
1.2098 + if (confirm_box(true))
1.2099 + {
1.2100 + if (!$group_id)
1.2101 + {
1.2102 + trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
1.2103 + }
1.2104 +
1.2105 + if ($error = group_user_del($group_id, $user_id))
1.2106 + {
1.2107 + trigger_error($user->lang[$error] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
1.2108 + }
1.2109 +
1.2110 + $error = array();
1.2111 +
1.2112 + // The delete action was successful - therefore update the user row...
1.2113 + $sql = 'SELECT u.*, s.*
1.2114 + FROM ' . USERS_TABLE . ' u
1.2115 + LEFT JOIN ' . SESSIONS_TABLE . ' s ON (s.session_user_id = u.user_id)
1.2116 + WHERE u.user_id = ' . $user_id . '
1.2117 + ORDER BY s.session_time DESC';
1.2118 + $result = $db->sql_query_limit($sql, 1);
1.2119 + $user_row = $db->sql_fetchrow($result);
1.2120 + $db->sql_freeresult($result);
1.2121 + }
1.2122 + else
1.2123 + {
1.2124 + confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array(
1.2125 + 'u' => $user_id,
1.2126 + 'i' => $id,
1.2127 + 'mode' => $mode,
1.2128 + 'action' => $action,
1.2129 + 'g' => $group_id))
1.2130 + );
1.2131 + }
1.2132 +
1.2133 + break;
1.2134 +
1.2135 + case 'approve':
1.2136 +
1.2137 + if (confirm_box(true))
1.2138 + {
1.2139 + if (!$group_id)
1.2140 + {
1.2141 + trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
1.2142 + }
1.2143 + group_user_attributes($action, $group_id, $user_id);
1.2144 + }
1.2145 + else
1.2146 + {
1.2147 + confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array(
1.2148 + 'u' => $user_id,
1.2149 + 'i' => $id,
1.2150 + 'mode' => $mode,
1.2151 + 'action' => $action,
1.2152 + 'g' => $group_id))
1.2153 + );
1.2154 + }
1.2155 +
1.2156 + break;
1.2157 + }
1.2158 +
1.2159 + // Add user to group?
1.2160 + if ($submit)
1.2161 + {
1.2162 +
1.2163 + if (!check_form_key($form_name))
1.2164 + {
1.2165 + trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
1.2166 + }
1.2167 +
1.2168 + if (!$group_id)
1.2169 + {
1.2170 + trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
1.2171 + }
1.2172 +
1.2173 + // Add user/s to group
1.2174 + if ($error = group_user_add($group_id, $user_id))
1.2175 + {
1.2176 + trigger_error($user->lang[$error] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
1.2177 + }
1.2178 +
1.2179 + $error = array();
1.2180 + }
1.2181 +
1.2182 +
1.2183 + $sql = 'SELECT ug.*, g.*
1.2184 + FROM ' . GROUPS_TABLE . ' g, ' . USER_GROUP_TABLE . " ug
1.2185 + WHERE ug.user_id = $user_id
1.2186 + AND g.group_id = ug.group_id
1.2187 + ORDER BY g.group_type DESC, ug.user_pending ASC, g.group_name";
1.2188 + $result = $db->sql_query($sql);
1.2189 +
1.2190 + $i = 0;
1.2191 + $group_data = $id_ary = array();
1.2192 + while ($row = $db->sql_fetchrow($result))
1.2193 + {
1.2194 + $type = ($row['group_type'] == GROUP_SPECIAL) ? 'special' : (($row['user_pending']) ? 'pending' : 'normal');
1.2195 +
1.2196 + $group_data[$type][$i]['group_id'] = $row['group_id'];
1.2197 + $group_data[$type][$i]['group_name'] = $row['group_name'];
1.2198 + $group_data[$type][$i]['group_leader'] = ($row['group_leader']) ? 1 : 0;
1.2199 +
1.2200 + $id_ary[] = $row['group_id'];
1.2201 +
1.2202 + $i++;
1.2203 + }
1.2204 + $db->sql_freeresult($result);
1.2205 +
1.2206 + // Select box for other groups
1.2207 + $sql = 'SELECT group_id, group_name, group_type, group_founder_manage
1.2208 + FROM ' . GROUPS_TABLE . '
1.2209 + ' . ((sizeof($id_ary)) ? 'WHERE ' . $db->sql_in_set('group_id', $id_ary, true) : '') . '
1.2210 + ORDER BY group_type DESC, group_name ASC';
1.2211 + $result = $db->sql_query($sql);
1.2212 +
1.2213 + $s_group_options = '';
1.2214 + while ($row = $db->sql_fetchrow($result))
1.2215 + {
1.2216 + if (!$config['coppa_enable'] && $row['group_name'] == 'REGISTERED_COPPA')
1.2217 + {
1.2218 + continue;
1.2219 + }
1.2220 +
1.2221 + // Do not display those groups not allowed to be managed
1.2222 + if ($user->data['user_type'] != USER_FOUNDER && $row['group_founder_manage'])
1.2223 + {
1.2224 + continue;
1.2225 + }
1.2226 +
1.2227 + $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>';
1.2228 + }
1.2229 + $db->sql_freeresult($result);
1.2230 +
1.2231 + $current_type = '';
1.2232 + foreach ($group_data as $group_type => $data_ary)
1.2233 + {
1.2234 + if ($current_type != $group_type)
1.2235 + {
1.2236 + $template->assign_block_vars('group', array(
1.2237 + 'S_NEW_GROUP_TYPE' => true,
1.2238 + 'GROUP_TYPE' => $user->lang['USER_GROUP_' . strtoupper($group_type)])
1.2239 + );
1.2240 + }
1.2241 +
1.2242 + foreach ($data_ary as $data)
1.2243 + {
1.2244 + $template->assign_block_vars('group', array(
1.2245 + '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"),
1.2246 + 'U_DEFAULT' => $this->u_action . "&action=default&u=$user_id&g=" . $data['group_id'],
1.2247 + 'U_DEMOTE_PROMOTE' => $this->u_action . '&action=' . (($data['group_leader']) ? 'demote' : 'promote') . "&u=$user_id&g=" . $data['group_id'],
1.2248 + 'U_DELETE' => $this->u_action . "&action=delete&u=$user_id&g=" . $data['group_id'],
1.2249 + 'U_APPROVE' => ($group_type == 'pending') ? $this->u_action . "&action=approve&u=$user_id&g=" . $data['group_id'] : '',
1.2250 +
1.2251 + 'GROUP_NAME' => ($group_type == 'special') ? $user->lang['G_' . $data['group_name']] : $data['group_name'],
1.2252 + 'L_DEMOTE_PROMOTE' => ($data['group_leader']) ? $user->lang['GROUP_DEMOTE'] : $user->lang['GROUP_PROMOTE'],
1.2253 +
1.2254 + 'S_IS_MEMBER' => ($group_type != 'pending') ? true : false,
1.2255 + 'S_NO_DEFAULT' => ($user_row['group_id'] != $data['group_id']) ? true : false,
1.2256 + 'S_SPECIAL_GROUP' => ($group_type == 'special') ? true : false,
1.2257 + )
1.2258 + );
1.2259 + }
1.2260 + }
1.2261 +
1.2262 + $template->assign_vars(array(
1.2263 + 'S_GROUPS' => true,
1.2264 + 'S_GROUP_OPTIONS' => $s_group_options)
1.2265 + );
1.2266 +
1.2267 + break;
1.2268 +
1.2269 + case 'perm':
1.2270 +
1.2271 + include_once($phpbb_root_path . 'includes/acp/auth.' . $phpEx);
1.2272 +
1.2273 + $auth_admin = new auth_admin();
1.2274 +
1.2275 + $user->add_lang('acp/permissions');
1.2276 + add_permission_language();
1.2277 +
1.2278 + $forum_id = request_var('f', 0);
1.2279 +
1.2280 + // Global Permissions
1.2281 + if (!$forum_id)
1.2282 + {
1.2283 + // Select auth options
1.2284 + $sql = 'SELECT auth_option, is_local, is_global
1.2285 + FROM ' . ACL_OPTIONS_TABLE . '
1.2286 + WHERE auth_option ' . $db->sql_like_expression($db->any_char . '_') . '
1.2287 + AND is_global = 1
1.2288 + ORDER BY auth_option';
1.2289 + $result = $db->sql_query($sql);
1.2290 +
1.2291 + $hold_ary = array();
1.2292 +
1.2293 + while ($row = $db->sql_fetchrow($result))
1.2294 + {
1.2295 + $hold_ary = $auth_admin->get_mask('view', $user_id, false, false, $row['auth_option'], 'global', ACL_NEVER);
1.2296 + $auth_admin->display_mask('view', $row['auth_option'], $hold_ary, 'user', false, false);
1.2297 + }
1.2298 + $db->sql_freeresult($result);
1.2299 +
1.2300 + unset($hold_ary);
1.2301 + }
1.2302 + else
1.2303 + {
1.2304 + $sql = 'SELECT auth_option, is_local, is_global
1.2305 + FROM ' . ACL_OPTIONS_TABLE . "
1.2306 + WHERE auth_option " . $db->sql_like_expression($db->any_char . '_') . "
1.2307 + AND is_local = 1
1.2308 + ORDER BY is_global DESC, auth_option";
1.2309 + $result = $db->sql_query($sql);
1.2310 +
1.2311 + while ($row = $db->sql_fetchrow($result))
1.2312 + {
1.2313 + $hold_ary = $auth_admin->get_mask('view', $user_id, false, $forum_id, $row['auth_option'], 'local', ACL_NEVER);
1.2314 + $auth_admin->display_mask('view', $row['auth_option'], $hold_ary, 'user', true, false);
1.2315 + }
1.2316 + $db->sql_freeresult($result);
1.2317 + }
1.2318 +
1.2319 + $s_forum_options = '<option value="0"' . ((!$forum_id) ? ' selected="selected"' : '') . '>' . $user->lang['VIEW_GLOBAL_PERMS'] . '</option>';
1.2320 + $s_forum_options .= make_forum_select($forum_id, false, true, false, false, false);
1.2321 +
1.2322 + $template->assign_vars(array(
1.2323 + 'S_PERMISSIONS' => true,
1.2324 +
1.2325 + 'S_GLOBAL' => (!$forum_id) ? true : false,
1.2326 + 'S_FORUM_OPTIONS' => $s_forum_options,
1.2327 +
1.2328 + 'U_ACTION' => $this->u_action . '&u=' . $user_id,
1.2329 + 'U_USER_PERMISSIONS' => append_sid("{$phpbb_admin_path}index.$phpEx" ,'i=permissions&mode=setting_user_global&user_id[]=' . $user_id),
1.2330 + 'U_USER_FORUM_PERMISSIONS' => append_sid("{$phpbb_admin_path}index.$phpEx", 'i=permissions&mode=setting_user_local&user_id[]=' . $user_id))
1.2331 + );
1.2332 +
1.2333 + break;
1.2334 +
1.2335 + }
1.2336 +
1.2337 + // Assign general variables
1.2338 + $template->assign_vars(array(
1.2339 + 'S_ERROR' => (sizeof($error)) ? true : false,
1.2340 + 'ERROR_MSG' => (sizeof($error)) ? implode('<br />', $error) : '')
1.2341 + );
1.2342 + }
1.2343 +
1.2344 + /**
1.2345 + * Optionset replacement for this module based on $user->optionset
1.2346 + */
1.2347 + function optionset(&$user_row, $key, $value, $data = false)
1.2348 + {
1.2349 + global $user;
1.2350 +
1.2351 + $var = ($data) ? $data : $user_row['user_options'];
1.2352 +
1.2353 + if ($value && !($var & 1 << $user->keyoptions[$key]))
1.2354 + {
1.2355 + $var += 1 << $user->keyoptions[$key];
1.2356 + }
1.2357 + else if (!$value && ($var & 1 << $user->keyoptions[$key]))
1.2358 + {
1.2359 + $var -= 1 << $user->keyoptions[$key];
1.2360 + }
1.2361 + else
1.2362 + {
1.2363 + return ($data) ? $var : false;
1.2364 + }
1.2365 +
1.2366 + if (!$data)
1.2367 + {
1.2368 + $user_row['user_options'] = $var;
1.2369 + return true;
1.2370 + }
1.2371 + else
1.2372 + {
1.2373 + return $var;
1.2374 + }
1.2375 + }
1.2376 +
1.2377 + /**
1.2378 + * Optionget replacement for this module based on $user->optionget
1.2379 + */
1.2380 + function optionget(&$user_row, $key, $data = false)
1.2381 + {
1.2382 + global $user;
1.2383 +
1.2384 + $var = ($data) ? $data : $user_row['user_options'];
1.2385 + return ($var & 1 << $user->keyoptions[$key]) ? true : false;
1.2386 + }
1.2387 +}
1.2388 +
1.2389 +?>
1.2390 \ No newline at end of file