/forum/includes/acp/acp_users.php
PHP | 2392 lines | 1859 code | 440 blank | 93 comment | 318 complexity | bd0d21dc4f16bb5a5b4e38a292dcb591 MD5 | raw file
Possible License(s): AGPL-1.0, GPL-2.0
Large files files are truncated, but you can click here to view the full file
- <?php
- /**
- *
- * @package acp
- * @version $Id$
- * @copyright (c) 2005 phpBB Group
- * @license http://opensource.org/licenses/gpl-license.php GNU Public License
- *
- */
-
- /**
- * @ignore
- */
- if (!defined('IN_PHPBB'))
- {
- exit;
- }
-
- /**
- * @package acp
- */
- class acp_users
- {
- var $u_action;
- var $p_master;
-
- function acp_users(&$p_master)
- {
- $this->p_master = &$p_master;
- }
-
- function main($id, $mode)
- {
- global $config, $db, $user, $auth, $template, $cache;
- global $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix, $file_uploads;
-
- $user->add_lang(array('posting', 'ucp', 'acp/users'));
- $this->tpl_name = 'acp_users';
- $this->page_title = 'ACP_USER_' . strtoupper($mode);
-
- $error = array();
- $username = utf8_normalize_nfc(request_var('username', '', true));
- $user_id = request_var('u', 0);
- $action = request_var('action', '');
-
- $submit = (isset($_POST['update']) && !isset($_POST['cancel'])) ? true : false;
-
- $form_name = 'acp_users';
- add_form_key($form_name);
-
- // Whois (special case)
- if ($action == 'whois')
- {
- include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
-
- $this->page_title = 'WHOIS';
- $this->tpl_name = 'simple_body';
-
- $user_ip = request_var('user_ip', '');
- $domain = gethostbyaddr($user_ip);
- $ipwhois = user_ipwhois($user_ip);
-
- $template->assign_vars(array(
- 'MESSAGE_TITLE' => sprintf($user->lang['IP_WHOIS_FOR'], $domain),
- 'MESSAGE_TEXT' => nl2br($ipwhois))
- );
-
- return;
- }
-
- // Show user selection mask
- if (!$username && !$user_id)
- {
- $this->page_title = 'SELECT_USER';
-
- $template->assign_vars(array(
- 'U_ACTION' => $this->u_action,
- 'ANONYMOUS_USER_ID' => ANONYMOUS,
-
- 'S_SELECT_USER' => true,
- 'U_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser&form=select_user&field=username&select_single=true'),
- ));
-
- return;
- }
-
- if (!$user_id)
- {
- $sql = 'SELECT user_id
- FROM ' . USERS_TABLE . "
- WHERE username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'";
- $result = $db->sql_query($sql);
- $user_id = (int) $db->sql_fetchfield('user_id');
- $db->sql_freeresult($result);
-
- if (!$user_id)
- {
- trigger_error($user->lang['NO_USER'] . adm_back_link($this->u_action), E_USER_WARNING);
- }
- }
-
- // Generate content for all modes
- $sql = 'SELECT u.*, s.*
- FROM ' . USERS_TABLE . ' u
- LEFT JOIN ' . SESSIONS_TABLE . ' s ON (s.session_user_id = u.user_id)
- WHERE u.user_id = ' . $user_id . '
- ORDER BY s.session_time DESC';
- $result = $db->sql_query_limit($sql, 1);
- $user_row = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
-
- if (!$user_row)
- {
- trigger_error($user->lang['NO_USER'] . adm_back_link($this->u_action), E_USER_WARNING);
- }
-
- // Generate overall "header" for user admin
- $s_form_options = '';
-
- // Build modes dropdown list
- $sql = 'SELECT module_mode, module_auth
- FROM ' . MODULES_TABLE . "
- WHERE module_basename = 'users'
- AND module_enabled = 1
- AND module_class = 'acp'
- ORDER BY left_id, module_mode";
- $result = $db->sql_query($sql);
-
- $dropdown_modes = array();
- while ($row = $db->sql_fetchrow($result))
- {
- if (!$this->p_master->module_auth($row['module_auth']))
- {
- continue;
- }
-
- $dropdown_modes[$row['module_mode']] = true;
- }
- $db->sql_freeresult($result);
-
- foreach ($dropdown_modes as $module_mode => $null)
- {
- $selected = ($mode == $module_mode) ? ' selected="selected"' : '';
- $s_form_options .= '<option value="' . $module_mode . '"' . $selected . '>' . $user->lang['ACP_USER_' . strtoupper($module_mode)] . '</option>';
- }
-
- $template->assign_vars(array(
- 'U_BACK' => $this->u_action,
- 'U_MODE_SELECT' => append_sid("{$phpbb_admin_path}index.$phpEx", "i=$id&u=$user_id"),
- 'U_ACTION' => $this->u_action . '&u=' . $user_id,
- 'S_FORM_OPTIONS' => $s_form_options,
- 'MANAGED_USERNAME' => $user_row['username'])
- );
-
- // Prevent normal users/admins change/view founders if they are not a founder by themselves
- if ($user->data['user_type'] != USER_FOUNDER && $user_row['user_type'] == USER_FOUNDER)
- {
- trigger_error($user->lang['NOT_MANAGE_FOUNDER'] . adm_back_link($this->u_action), E_USER_WARNING);
- }
-
- switch ($mode)
- {
- case 'overview':
-
- include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
-
- $user->add_lang('acp/ban');
-
- $delete = request_var('delete', 0);
- $delete_type = request_var('delete_type', '');
- $ip = request_var('ip', 'ip');
-
- if ($submit)
- {
- // You can't delete the founder
- if ($delete && $user_row['user_type'] != USER_FOUNDER)
- {
- if (!$auth->acl_get('a_userdel'))
- {
- trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
- }
-
- // Check if the user wants to remove himself or the guest user account
- if ($user_id == ANONYMOUS)
- {
- trigger_error($user->lang['CANNOT_REMOVE_ANONYMOUS'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
- }
-
- if ($user_id == $user->data['user_id'])
- {
- trigger_error($user->lang['CANNOT_REMOVE_YOURSELF'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
- }
-
- if ($delete_type)
- {
- if (confirm_box(true))
- {
- user_delete($delete_type, $user_id, $user_row['username']);
-
- add_log('admin', 'LOG_USER_DELETED', $user_row['username']);
- trigger_error($user->lang['USER_DELETED'] . adm_back_link($this->u_action));
- }
- else
- {
- confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array(
- 'u' => $user_id,
- 'i' => $id,
- 'mode' => $mode,
- 'action' => $action,
- 'update' => true,
- 'delete' => 1,
- 'delete_type' => $delete_type))
- );
- }
- }
- else
- {
- trigger_error($user->lang['NO_MODE'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
- }
- }
-
- // Handle quicktool actions
- switch ($action)
- {
- case 'banuser':
- case 'banemail':
- case 'banip':
-
- if ($user_id == $user->data['user_id'])
- {
- trigger_error($user->lang['CANNOT_BAN_YOURSELF'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
- }
-
- if ($user_id == ANONYMOUS)
- {
- trigger_error($user->lang['CANNOT_BAN_ANONYMOUS'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
- }
-
- if ($user_row['user_type'] == USER_FOUNDER)
- {
- trigger_error($user->lang['CANNOT_BAN_FOUNDER'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
- }
-
- if (!check_form_key($form_name))
- {
- trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
- }
-
- $ban = array();
-
- switch ($action)
- {
- case 'banuser':
- $ban[] = $user_row['username'];
- $reason = 'USER_ADMIN_BAN_NAME_REASON';
- $log = 'LOG_USER_BAN_USER';
- break;
-
- case 'banemail':
- $ban[] = $user_row['user_email'];
- $reason = 'USER_ADMIN_BAN_EMAIL_REASON';
- $log = 'LOG_USER_BAN_EMAIL';
- break;
-
- case 'banip':
- $ban[] = $user_row['user_ip'];
-
- $sql = 'SELECT DISTINCT poster_ip
- FROM ' . POSTS_TABLE . "
- WHERE poster_id = $user_id";
- $result = $db->sql_query($sql);
-
- while ($row = $db->sql_fetchrow($result))
- {
- $ban[] = $row['poster_ip'];
- }
- $db->sql_freeresult($result);
-
- $reason = 'USER_ADMIN_BAN_IP_REASON';
- $log = 'LOG_USER_BAN_IP';
- break;
- }
-
- $ban_reason = utf8_normalize_nfc(request_var('ban_reason', $user->lang[$reason], true));
- $ban_give_reason = utf8_normalize_nfc(request_var('ban_give_reason', '', true));
-
- // Log not used at the moment, we simply utilize the ban function.
- $result = user_ban(substr($action, 3), $ban, 0, 0, 0, $ban_reason, $ban_give_reason);
-
- trigger_error((($result === false) ? $user->lang['BAN_ALREADY_ENTERED'] : $user->lang['BAN_SUCCESSFUL']) . adm_back_link($this->u_action . '&u=' . $user_id));
-
- break;
-
- case 'reactivate':
-
- if ($user_id == $user->data['user_id'])
- {
- trigger_error($user->lang['CANNOT_FORCE_REACT_YOURSELF'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
- }
-
- if (!check_form_key($form_name))
- {
- trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
- }
-
- if ($user_row['user_type'] == USER_FOUNDER)
- {
- trigger_error($user->lang['CANNOT_FORCE_REACT_FOUNDER'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
- }
-
- if ($user_row['user_type'] == USER_IGNORE)
- {
- trigger_error($user->lang['CANNOT_FORCE_REACT_BOT'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
- }
-
- if ($config['email_enable'])
- {
- include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
-
- $server_url = generate_board_url();
-
- $user_actkey = gen_rand_string(mt_rand(6, 10));
- $email_template = ($user_row['user_type'] == USER_NORMAL) ? 'user_reactivate_account' : 'user_resend_inactive';
-
- if ($user_row['user_type'] == USER_NORMAL)
- {
- user_active_flip('deactivate', $user_id, INACTIVE_REMIND);
-
- $sql = 'UPDATE ' . USERS_TABLE . "
- SET user_actkey = '" . $db->sql_escape($user_actkey) . "'
- WHERE user_id = $user_id";
- $db->sql_query($sql);
- }
- else
- {
- // Grabbing the last confirm key - we only send a reminder
- $sql = 'SELECT user_actkey
- FROM ' . USERS_TABLE . '
- WHERE user_id = ' . $user_id;
- $result = $db->sql_query($sql);
- $user_actkey = (string) $db->sql_fetchfield('user_actkey');
- $db->sql_freeresult($result);
- }
-
- $messenger = new messenger(false);
-
- $messenger->template($email_template, $user_row['user_lang']);
-
- $messenger->to($user_row['user_email'], $user_row['username']);
-
- $messenger->headers('X-AntiAbuse: Board servername - ' . $config['server_name']);
- $messenger->headers('X-AntiAbuse: User_id - ' . $user->data['user_id']);
- $messenger->headers('X-AntiAbuse: Username - ' . $user->data['username']);
- $messenger->headers('X-AntiAbuse: User IP - ' . $user->ip);
-
- $messenger->assign_vars(array(
- 'WELCOME_MSG' => htmlspecialchars_decode(sprintf($user->lang['WELCOME_SUBJECT'], $config['sitename'])),
- 'USERNAME' => htmlspecialchars_decode($user_row['username']),
- 'U_ACTIVATE' => "$server_url/ucp.$phpEx?mode=activate&u={$user_row['user_id']}&k=$user_actkey")
- );
-
- $messenger->send(NOTIFY_EMAIL);
-
- add_log('admin', 'LOG_USER_REACTIVATE', $user_row['username']);
- add_log('user', $user_id, 'LOG_USER_REACTIVATE_USER');
-
- trigger_error($user->lang['FORCE_REACTIVATION_SUCCESS'] . adm_back_link($this->u_action . '&u=' . $user_id));
- }
-
- break;
-
- case 'active':
-
- if ($user_id == $user->data['user_id'])
- {
- // It is only deactivation since the user is already activated (else he would not have reached this page)
- trigger_error($user->lang['CANNOT_DEACTIVATE_YOURSELF'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
- }
-
- if (!check_form_key($form_name))
- {
- trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
- }
-
- if ($user_row['user_type'] == USER_FOUNDER)
- {
- trigger_error($user->lang['CANNOT_DEACTIVATE_FOUNDER'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
- }
-
- if ($user_row['user_type'] == USER_IGNORE)
- {
- trigger_error($user->lang['CANNOT_DEACTIVATE_BOT'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
- }
-
- user_active_flip('flip', $user_id);
-
- if ($user_row['user_type'] == USER_INACTIVE)
- {
- if ($config['require_activation'] == USER_ACTIVATION_ADMIN)
- {
- include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
-
- $messenger = new messenger(false);
-
- $messenger->template('admin_welcome_activated', $user_row['user_lang']);
-
- $messenger->to($user_row['user_email'], $user_row['username']);
-
- $messenger->headers('X-AntiAbuse: Board servername - ' . $config['server_name']);
- $messenger->headers('X-AntiAbuse: User_id - ' . $user->data['user_id']);
- $messenger->headers('X-AntiAbuse: Username - ' . $user->data['username']);
- $messenger->headers('X-AntiAbuse: User IP - ' . $user->ip);
-
- $messenger->assign_vars(array(
- 'USERNAME' => htmlspecialchars_decode($user_row['username']))
- );
-
- $messenger->send(NOTIFY_EMAIL);
- }
- }
-
- $message = ($user_row['user_type'] == USER_INACTIVE) ? 'USER_ADMIN_ACTIVATED' : 'USER_ADMIN_DEACTIVED';
- $log = ($user_row['user_type'] == USER_INACTIVE) ? 'LOG_USER_ACTIVE' : 'LOG_USER_INACTIVE';
-
- add_log('admin', $log, $user_row['username']);
- add_log('user', $user_id, $log . '_USER');
-
- trigger_error($user->lang[$message] . adm_back_link($this->u_action . '&u=' . $user_id));
-
- break;
-
- case 'delsig':
-
- if (!check_form_key($form_name))
- {
- trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
- }
-
- $sql_ary = array(
- 'user_sig' => '',
- 'user_sig_bbcode_uid' => '',
- 'user_sig_bbcode_bitfield' => ''
- );
-
- $sql = 'UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "
- WHERE user_id = $user_id";
- $db->sql_query($sql);
-
- add_log('admin', 'LOG_USER_DEL_SIG', $user_row['username']);
- add_log('user', $user_id, 'LOG_USER_DEL_SIG_USER');
-
- trigger_error($user->lang['USER_ADMIN_SIG_REMOVED'] . adm_back_link($this->u_action . '&u=' . $user_id));
-
- break;
-
- case 'delavatar':
-
- if (!check_form_key($form_name))
- {
- trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
- }
-
- $sql_ary = array(
- 'user_avatar' => '',
- 'user_avatar_type' => 0,
- 'user_avatar_width' => 0,
- 'user_avatar_height' => 0,
- );
-
- $sql = 'UPDATE ' . USERS_TABLE . '
- SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "
- WHERE user_id = $user_id";
- $db->sql_query($sql);
-
- // Delete old avatar if present
- if ($user_row['user_avatar'] && $user_row['user_avatar_type'] != AVATAR_GALLERY)
- {
- avatar_delete('user', $user_row);
- }
-
- add_log('admin', 'LOG_USER_DEL_AVATAR', $user_row['username']);
- add_log('user', $user_id, 'LOG_USER_DEL_AVATAR_USER');
-
- trigger_error($user->lang['USER_ADMIN_AVATAR_REMOVED'] . adm_back_link($this->u_action . '&u=' . $user_id));
- break;
-
- case 'delposts':
-
- if (confirm_box(true))
- {
- // Delete posts, attachments, etc.
- delete_posts('poster_id', $user_id);
-
- add_log('admin', 'LOG_USER_DEL_POSTS', $user_row['username']);
- trigger_error($user->lang['USER_POSTS_DELETED'] . adm_back_link($this->u_action . '&u=' . $user_id));
- }
- else
- {
- confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array(
- 'u' => $user_id,
- 'i' => $id,
- 'mode' => $mode,
- 'action' => $action,
- 'update' => true))
- );
- }
-
- break;
-
- case 'delattach':
-
- if (confirm_box(true))
- {
- delete_attachments('user', $user_id);
-
- add_log('admin', 'LOG_USER_DEL_ATTACH', $user_row['username']);
- trigger_error($user->lang['USER_ATTACHMENTS_REMOVED'] . adm_back_link($this->u_action . '&u=' . $user_id));
- }
- else
- {
- confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array(
- 'u' => $user_id,
- 'i' => $id,
- 'mode' => $mode,
- 'action' => $action,
- 'update' => true))
- );
- }
-
- break;
-
- case 'deloutbox':
-
- if (confirm_box(true))
- {
- $msg_ids = array();
- $lang = 'EMPTY';
-
- $sql = 'SELECT msg_id
- FROM ' . PRIVMSGS_TO_TABLE . "
- WHERE author_id = $user_id
- AND folder_id = " . PRIVMSGS_OUTBOX;
- $result = $db->sql_query($sql);
-
- if ($row = $db->sql_fetchrow($result))
- {
- if (!function_exists('delete_pm'))
- {
- include($phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx);
- }
-
- do
- {
- $msg_ids[] = (int) $row['msg_id'];
- }
- while ($row = $db->sql_fetchrow($result));
-
- $db->sql_freeresult($result);
-
- delete_pm($user_id, $msg_ids, PRIVMSGS_OUTBOX);
-
- add_log('admin', 'LOG_USER_DEL_OUTBOX', $user_row['username']);
-
- $lang = 'EMPTIED';
- }
- $db->sql_freeresult($result);
-
- trigger_error($user->lang['USER_OUTBOX_' . $lang] . adm_back_link($this->u_action . '&u=' . $user_id));
- }
- else
- {
- confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array(
- 'u' => $user_id,
- 'i' => $id,
- 'mode' => $mode,
- 'action' => $action,
- 'update' => true))
- );
- }
- break;
-
- case 'moveposts':
-
- if (!check_form_key($form_name))
- {
- trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
- }
-
- $user->add_lang('acp/forums');
-
- $new_forum_id = request_var('new_f', 0);
-
- if (!$new_forum_id)
- {
- $this->page_title = 'USER_ADMIN_MOVE_POSTS';
-
- $template->assign_vars(array(
- 'S_SELECT_FORUM' => true,
- 'U_ACTION' => $this->u_action . "&action=$action&u=$user_id",
- 'U_BACK' => $this->u_action . "&u=$user_id",
- 'S_FORUM_OPTIONS' => make_forum_select(false, false, false, true))
- );
-
- return;
- }
-
- // Is the new forum postable to?
- $sql = 'SELECT forum_name, forum_type
- FROM ' . FORUMS_TABLE . "
- WHERE forum_id = $new_forum_id";
- $result = $db->sql_query($sql);
- $forum_info = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
-
- if (!$forum_info)
- {
- trigger_error($user->lang['NO_FORUM'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
- }
-
- if ($forum_info['forum_type'] != FORUM_POST)
- {
- trigger_error($user->lang['MOVE_POSTS_NO_POSTABLE_FORUM'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
- }
-
- // Two stage?
- // Move topics comprising only posts from this user
- $topic_id_ary = $move_topic_ary = $move_post_ary = $new_topic_id_ary = array();
- $forum_id_ary = array($new_forum_id);
-
- $sql = 'SELECT topic_id, COUNT(post_id) AS total_posts
- FROM ' . POSTS_TABLE . "
- WHERE poster_id = $user_id
- AND forum_id <> $new_forum_id
- GROUP BY topic_id";
- $result = $db->sql_query($sql);
-
- while ($row = $db->sql_fetchrow($result))
- {
- $topic_id_ary[$row['topic_id']] = $row['total_posts'];
- }
- $db->sql_freeresult($result);
-
- if (sizeof($topic_id_ary))
- {
- $sql = 'SELECT topic_id, forum_id, topic_title, topic_replies, topic_replies_real, topic_attachment
- FROM ' . TOPICS_TABLE . '
- WHERE ' . $db->sql_in_set('topic_id', array_keys($topic_id_ary));
- $result = $db->sql_query($sql);
-
- while ($row = $db->sql_fetchrow($result))
- {
- if (max($row['topic_replies'], $row['topic_replies_real']) + 1 == $topic_id_ary[$row['topic_id']])
- {
- $move_topic_ary[] = $row['topic_id'];
- }
- else
- {
- $move_post_ary[$row['topic_id']]['title'] = $row['topic_title'];
- $move_post_ary[$row['topic_id']]['attach'] = ($row['topic_attachment']) ? 1 : 0;
- }
-
- $forum_id_ary[] = $row['forum_id'];
- }
- $db->sql_freeresult($result);
- }
-
- // Entire topic comprises posts by this user, move these topics
- if (sizeof($move_topic_ary))
- {
- move_topics($move_topic_ary, $new_forum_id, false);
- }
-
- if (sizeof($move_post_ary))
- {
- // Create new topic
- // Update post_ids, report_ids, attachment_ids
- foreach ($move_post_ary as $topic_id => $post_ary)
- {
- // Create new topic
- $sql = 'INSERT INTO ' . TOPICS_TABLE . ' ' . $db->sql_build_array('INSERT', array(
- 'topic_poster' => $user_id,
- 'topic_time' => time(),
- 'forum_id' => $new_forum_id,
- 'icon_id' => 0,
- 'topic_approved' => 1,
- 'topic_title' => $post_ary['title'],
- 'topic_first_poster_name' => $user_row['username'],
- 'topic_type' => POST_NORMAL,
- 'topic_time_limit' => 0,
- 'topic_attachment' => $post_ary['attach'])
- );
- $db->sql_query($sql);
-
- $new_topic_id = $db->sql_nextid();
-
- // Move posts
- $sql = 'UPDATE ' . POSTS_TABLE . "
- SET forum_id = $new_forum_id, topic_id = $new_topic_id
- WHERE topic_id = $topic_id
- AND poster_id = $user_id";
- $db->sql_query($sql);
-
- if ($post_ary['attach'])
- {
- $sql = 'UPDATE ' . ATTACHMENTS_TABLE . "
- SET topic_id = $new_topic_id
- WHERE topic_id = $topic_id
- AND poster_id = $user_id";
- $db->sql_query($sql);
- }
-
- $new_topic_id_ary[] = $new_topic_id;
- }
- }
-
- $forum_id_ary = array_unique($forum_id_ary);
- $topic_id_ary = array_unique(array_merge(array_keys($topic_id_ary), $new_topic_id_ary));
-
- if (sizeof($topic_id_ary))
- {
- sync('topic_reported', 'topic_id', $topic_id_ary);
- sync('topic', 'topic_id', $topic_id_ary);
- }
-
- if (sizeof($forum_id_ary))
- {
- sync('forum', 'forum_id', $forum_id_ary, false, true);
- }
-
-
- add_log('admin', 'LOG_USER_MOVE_POSTS', $user_row['username'], $forum_info['forum_name']);
- add_log('user', $user_id, 'LOG_USER_MOVE_POSTS_USER', $forum_info['forum_name']);
-
- trigger_error($user->lang['USER_POSTS_MOVED'] . adm_back_link($this->u_action . '&u=' . $user_id));
-
- break;
-
- case 'leave_nr':
-
- if (confirm_box(true))
- {
- remove_newly_registered($user_id, $user_row);
-
- add_log('admin', 'LOG_USER_REMOVED_NR', $user_row['username']);
- trigger_error($user->lang['USER_LIFTED_NR'] . adm_back_link($this->u_action . '&u=' . $user_id));
- }
- else
- {
- confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array(
- 'u' => $user_id,
- 'i' => $id,
- 'mode' => $mode,
- 'action' => $action,
- 'update' => true))
- );
- }
-
- break;
- }
-
- // Handle registration info updates
- $data = array(
- 'username' => utf8_normalize_nfc(request_var('user', $user_row['username'], true)),
- 'user_founder' => request_var('user_founder', ($user_row['user_type'] == USER_FOUNDER) ? 1 : 0),
- 'email' => strtolower(request_var('user_email', $user_row['user_email'])),
- 'email_confirm' => strtolower(request_var('email_confirm', '')),
- 'new_password' => request_var('new_password', '', true),
- 'password_confirm' => request_var('password_confirm', '', true),
- );
-
- // Validation data - we do not check the password complexity setting here
- $check_ary = array(
- 'new_password' => array(
- array('string', true, $config['min_pass_chars'], $config['max_pass_chars']),
- array('password')),
- 'password_confirm' => array('string', true, $config['min_pass_chars'], $config['max_pass_chars']),
- );
-
- // Check username if altered
- if ($data['username'] != $user_row['username'])
- {
- $check_ary += array(
- 'username' => array(
- array('string', false, $config['min_name_chars'], $config['max_name_chars']),
- array('username', $user_row['username'])
- ),
- );
- }
-
- // Check email if altered
- if ($data['email'] != $user_row['user_email'])
- {
- $check_ary += array(
- 'email' => array(
- array('string', false, 6, 60),
- array('email', $user_row['user_email'])
- ),
- 'email_confirm' => array('string', true, 6, 60)
- );
- }
-
- $error = validate_data($data, $check_ary);
-
- if ($data['new_password'] && $data['password_confirm'] != $data['new_password'])
- {
- $error[] = 'NEW_PASSWORD_ERROR';
- }
-
- if ($data['email'] != $user_row['user_email'] && $data['email_confirm'] != $data['email'])
- {
- $error[] = 'NEW_EMAIL_ERROR';
- }
-
- if (!check_form_key($form_name))
- {
- $error[] = 'FORM_INVALID';
- }
-
- // Which updates do we need to do?
- $update_username = ($user_row['username'] != $data['username']) ? $data['username'] : false;
- $update_password = ($data['new_password'] && !phpbb_check_hash($user_row['user_password'], $data['new_password'])) ? true : false;
- $update_email = ($data['email'] != $user_row['user_email']) ? $data['email'] : false;
-
- if (!sizeof($error))
- {
- $sql_ary = array();
-
- if ($user_row['user_type'] != USER_FOUNDER || $user->data['user_type'] == USER_FOUNDER)
- {
- // Only allow founders updating the founder status...
- if ($user->data['user_type'] == USER_FOUNDER)
- {
- // Setting a normal member to be a founder
- if ($data['user_founder'] && $user_row['user_type'] != USER_FOUNDER)
- {
- // Make sure the user is not setting an Inactive or ignored user to be a founder
- if ($user_row['user_type'] == USER_IGNORE)
- {
- trigger_error($user->lang['CANNOT_SET_FOUNDER_IGNORED'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
- }
-
- if ($user_row['user_type'] == USER_INACTIVE)
- {
- trigger_error($user->lang['CANNOT_SET_FOUNDER_INACTIVE'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
- }
-
- $sql_ary['user_type'] = USER_FOUNDER;
- }
- else if (!$data['user_founder'] && $user_row['user_type'] == USER_FOUNDER)
- {
- // Check if at least one founder is present
- $sql = 'SELECT user_id
- FROM ' . USERS_TABLE . '
- WHERE user_type = ' . USER_FOUNDER . '
- AND user_id <> ' . $user_id;
- $result = $db->sql_query_limit($sql, 1);
- $row = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
-
- if ($row)
- {
- $sql_ary['user_type'] = USER_NORMAL;
- }
- else
- {
- trigger_error($user->lang['AT_LEAST_ONE_FOUNDER'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
- }
- }
- }
- }
-
- if ($update_username !== false)
- {
- $sql_ary['username'] = $update_username;
- $sql_ary['username_clean'] = utf8_clean_string($update_username);
-
- add_log('user', $user_id, 'LOG_USER_UPDATE_NAME', $user_row['username'], $update_username);
- }
-
- if ($update_email !== false)
- {
- $sql_ary += array(
- 'user_email' => $update_email,
- 'user_email_hash' => phpbb_email_hash($update_email),
- );
-
- add_log('user', $user_id, 'LOG_USER_UPDATE_EMAIL', $user_row['username'], $user_row['user_email'], $update_email);
- }
-
- if ($update_password)
- {
- $sql_ary += array(
- 'user_password' => phpbb_hash($data['new_password']),
- 'user_passchg' => time(),
- 'user_pass_convert' => 0,
- );
-
- $user->reset_login_keys($user_id);
- add_log('user', $user_id, 'LOG_USER_NEW_PASSWORD', $user_row['username']);
- }
-
- if (sizeof($sql_ary))
- {
- $sql = 'UPDATE ' . USERS_TABLE . '
- SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
- WHERE user_id = ' . $user_id;
- $db->sql_query($sql);
- }
-
- if ($update_username)
- {
- user_update_name($user_row['username'], $update_username);
- }
-
- // Let the users permissions being updated
- $auth->acl_clear_prefetch($user_id);
-
- add_log('admin', 'LOG_USER_USER_UPDATE', $data['username']);
-
- trigger_error($user->lang['USER_OVERVIEW_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_id));
- }
-
- // Replace "error" strings with their real, localised form
- $error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error);
- }
-
- if ($user_id == $user->data['user_id'])
- {
- $quick_tool_ary = array('delsig' => 'DEL_SIG', 'delavatar' => 'DEL_AVATAR', 'moveposts' => 'MOVE_POSTS', 'delposts' => 'DEL_POSTS', 'delattach' => 'DEL_ATTACH', 'deloutbox' => 'DEL_OUTBOX');
- if ($user_row['user_new'])
- {
- $quick_tool_ary['leave_nr'] = 'LEAVE_NR';
- }
- }
- else
- {
- $quick_tool_ary = array();
-
- if ($user_row['user_type'] != USER_FOUNDER)
- {
- $quick_tool_ary += array('banuser' => 'BAN_USER', 'banemail' => 'BAN_EMAIL', 'banip' => 'BAN_IP');
- }
-
- if ($user_row['user_type'] != USER_FOUNDER && $user_row['user_type'] != USER_IGNORE)
- {
- $quick_tool_ary += array('active' => (($user_row['user_type'] == USER_INACTIVE) ? 'ACTIVATE' : 'DEACTIVATE'));
- }
-
- $quick_tool_ary += array('delsig' => 'DEL_SIG', 'delavatar' => 'DEL_AVATAR', 'moveposts' => 'MOVE_POSTS', 'delposts' => 'DEL_POSTS', 'delattach' => 'DEL_ATTACH', 'deloutbox' => 'DEL_OUTBOX');
-
- if ($config['email_enable'] && ($user_row['user_type'] == USER_NORMAL || $user_row['user_type'] == USER_INACTIVE))
- {
- $quick_tool_ary['reactivate'] = 'FORCE';
- }
-
- if ($user_row['user_new'])
- {
- $quick_tool_ary['leave_nr'] = 'LEAVE_NR';
- }
- }
-
- $s_action_options = '<option class="sep" value="">' . $user->lang['SELECT_OPTION'] . '</option>';
- foreach ($quick_tool_ary as $value => $lang)
- {
- $s_action_options .= '<option value="' . $value . '">' . $user->lang['USER_ADMIN_' . $lang] . '</option>';
- }
-
- if ($config['load_onlinetrack'])
- {
- $sql = 'SELECT MAX(session_time) AS session_time, MIN(session_viewonline) AS session_viewonline
- FROM ' . SESSIONS_TABLE . "
- WHERE session_user_id = $user_id";
- $result = $db->sql_query($sql);
- $row = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
-
- $user_row['session_time'] = (isset($row['session_time'])) ? $row['session_time'] : 0;
- $user_row['session_viewonline'] = (isset($row['session_viewonline'])) ? $row['session_viewonline'] : 0;
- unset($row);
- }
-
- $last_visit = (!empty($user_row['session_time'])) ? $user_row['session_time'] : $user_row['user_lastvisit'];
-
- $inactive_reason = '';
- if ($user_row['user_type'] == USER_INACTIVE)
- {
- $inactive_reason = $user->lang['INACTIVE_REASON_UNKNOWN'];
-
- switch ($user_row['user_inactive_reason'])
- {
- case INACTIVE_REGISTER:
- $inactive_reason = $user->lang['INACTIVE_REASON_REGISTER'];
- break;
-
- case INACTIVE_PROFILE:
- $inactive_reason = $user->lang['INACTIVE_REASON_PROFILE'];
- break;
-
- case INACTIVE_MANUAL:
- $inactive_reason = $user->lang['INACTIVE_REASON_MANUAL'];
- break;
-
- case INACTIVE_REMIND:
- $inactive_reason = $user->lang['INACTIVE_REASON_REMIND'];
- break;
- }
- }
-
- // Posts in Queue
- $sql = 'SELECT COUNT(post_id) as posts_in_queue
- FROM ' . POSTS_TABLE . '
- WHERE poster_id = ' . $user_id . '
- AND post_approved = 0';
- $result = $db->sql_query($sql);
- $user_row['posts_in_queue'] = (int) $db->sql_fetchfield('posts_in_queue');
- $db->sql_freeresult($result);
-
- $template->assign_vars(array(
- 'L_NAME_CHARS_EXPLAIN' => sprintf($user->lang[$config['allow_name_chars'] . '_EXPLAIN'], $config['min_name_chars'], $config['max_name_chars']),
- 'L_CHANGE_PASSWORD_EXPLAIN' => sprintf($user->lang[$config['pass_complex'] . '_EXPLAIN'], $config['min_pass_chars'], $config['max_pass_chars']),
- 'L_POSTS_IN_QUEUE' => $user->lang('NUM_POSTS_IN_QUEUE', $user_row['posts_in_queue']),
- 'S_FOUNDER' => ($user->data['user_type'] == USER_FOUNDER) ? true : false,
-
- 'S_OVERVIEW' => true,
- 'S_USER_IP' => ($user_row['user_ip']) ? true : false,
- 'S_USER_FOUNDER' => ($user_row['user_type'] == USER_FOUNDER) ? true : false,
- 'S_ACTION_OPTIONS' => $s_action_options,
- 'S_OWN_ACCOUNT' => ($user_id == $user->data['user_id']) ? true : false,
- 'S_USER_INACTIVE' => ($user_row['user_type'] == USER_INACTIVE) ? true : false,
-
- 'U_SHOW_IP' => $this->u_action . "&u=$user_id&ip=" . (($ip == 'ip') ? 'hostname' : 'ip'),
- 'U_WHOIS' => $this->u_action . "&action=whois&user_ip={$user_row['user_ip']}",
- 'U_MCP_QUEUE' => ($auth->acl_getf_global('m_approve')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue', true, $user->session_id) : '',
-
- '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')) : '',
-
- 'POSTS_IN_QUEUE' => $user_row['posts_in_queue'],
- 'USER' => $user_row['username'],
- 'USER_REGISTERED' => $user->format_date($user_row['user_regdate']),
- 'REGISTERED_IP' => ($ip == 'hostname') ? gethostbyaddr($user_row['user_ip']) : $user_row['user_ip'],
- 'USER_LASTACTIVE' => ($last_visit) ? $user->format_date($last_visit) : ' - ',
- 'USER_EMAIL' => $user_row['user_email'],
- 'USER_WARNINGS' => $user_row['user_warnings'],
- 'USER_POSTS' => $user_row['user_posts'],
- 'USER_INACTIVE_REASON' => $inactive_reason,
- ));
-
- break;
-
- case 'feedback':
-
- $user->add_lang('mcp');
-
- // Set up general vars
- $start = request_var('start', 0);
- $deletemark = (isset($_POST['delmarked'])) ? true : false;
- $deleteall = (isset($_POST['delall'])) ? true : false;
- $marked = request_var('mark', array(0));
- $message = utf8_normalize_nfc(request_var('message', '', true));
-
- // Sort keys
- $sort_days = request_var('st', 0);
- $sort_key = request_var('sk', 't');
- $sort_dir = request_var('sd', 'd');
-
- // Delete entries if requested and able
- if (($deletemark || $deleteall) && $auth->acl_get('a_clearlogs'))
- {
- if (!check_form_key($form_name))
- {
- trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
- }
-
- $where_sql = '';
- if ($deletemark && $marked)
- {
- $sql_in = array();
- foreach ($marked as $mark)
- {
- $sql_in[] = $mark;
- }
- $where_sql = ' AND ' . $db->sql_in_set('log_id', $sql_in);
- unset($sql_in);
- }
-
- if ($where_sql || $deleteall)
- {
- $sql = 'DELETE FROM ' . LOG_TABLE . '
- WHERE log_type = ' . LOG_USERS . "
- AND reportee_id = $user_id
- $where_sql";
- $db->sql_query($sql);
-
- add_log('admin', 'LOG_CLEAR_USER', $user_row['username']);
- }
- }
-
- if ($submit && $message)
- {
- if (!check_form_key($form_name))
- {
- trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
- }
-
- add_log('admin', 'LOG_USER_FEEDBACK', $user_row['username']);
- add_log('mod', 0, 0, 'LOG_USER_FEEDBACK', $user_row['username']);
- add_log('user', $user_id, 'LOG_USER_GENERAL', $message);
-
- trigger_error($user->lang['USER_FEEDBACK_ADDED'] . adm_back_link($this->u_action . '&u=' . $user_id));
- }
-
- // Sorting
- $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']);
- $sort_by_text = array('u' => $user->lang['SORT_USERNAME'], 't' => $user->lang['SORT_DATE'], 'i' => $user->lang['SORT_IP'], 'o' => $user->lang['SORT_ACTION']);
- $sort_by_sql = array('u' => 'u.username_clean', 't' => 'l.log_time', 'i' => 'l.log_ip', 'o' => 'l.log_operation');
-
- $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';
- 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);
-
- // Define where and sort sql for use in displaying logs
- $sql_where = ($sort_days) ? (time() - ($sort_days * 86400)) : 0;
- $sql_sort = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC');
-
- // Grab log data
- $log_data = array();
- $log_count = 0;
- view_log('user', $log_data, $log_count, $config['topics_per_page'], $start, 0, 0, $user_id, $sql_where, $sql_sort);
-
- $template->assign_vars(array(
- 'S_FEEDBACK' => true,
- 'S_ON_PAGE' => on_page($log_count, $config['topics_per_page'], $start),
- 'PAGINATION' => generate_pagination($this->u_action . "&u=$user_id&$u_sort_param", $log_count, $config['topics_per_page'], $start, true),
-
- 'S_LIMIT_DAYS' => $s_limit_days,
- 'S_SORT_KEY' => $s_sort_key,
- 'S_SORT_DIR' => $s_sort_dir,
- 'S_CLEARLOGS' => $auth->acl_get('a_clearlogs'))
- );
-
- foreach ($log_data as $row)
- {
- $template->assign_block_vars('log', array(
- 'USERNAME' => $row['username_full'],
- 'IP' => $row['ip'],
- 'DATE' => $user->format_date($row['time']),
- 'ACTION' => nl2br($row['action']),
- 'ID' => $row['id'])
- );
- }
-
- break;
-
- case 'warnings':
- $user->add_lang('mcp');
-
- // Set up general vars
- $start = request_var('start', 0);
- $deletemark = (isset($_POST['delmarked'])) ? true : false;
- $deleteall = (isset($_POST['delall'])) ? true : false;
- $confirm = (isset($_POST['confirm'])) ? true : false;
- $marked = request_var('mark', array(0));
- $message = utf8_normalize_nfc(request_var('message', '', true));
-
- // Sort keys
- $sort_days = request_var('st', 0);
- $sort_key = request_var('sk', 't');
- $sort_dir = request_var('sd', 'd');
-
- // Delete entries if requested and able
- if ($deletemark || $deleteall || $confirm)
- {
- if (confirm_box(true))
- {
- $where_sql = '';
- $deletemark = request_var('delmarked', 0);
- $deleteall = request_var('delall', 0);
- if ($deletemark && $marked)
- {
- $where_sql = ' AND ' . $db->sql_in_set('warning_id', array_values($marked));
- }
-
- if ($where_sql || $deleteall)
- {
- $sql = 'DELETE FROM ' . WARNINGS_TABLE . "
- WHERE user_id = $user_id
- $where_sql";
- $db->sql_query($sql);
-
- if ($deleteall)
- {
- $log_warnings = $deleted_warnings = 0;
- }
- else
- {
- $num_warnings = (int) $db->sql_affectedrows();
- $deleted_warnings = ' user_warnings - ' . $num_warnings;
- $log_warnings = ($num_warnings > 2) ? 2 : $num_warnings;
- }
-
- $sql = 'UPDATE ' . USERS_TABLE . "
- SET user_warnings = $deleted_warnings
- WHERE user_id = $user_id";
- $db->sql_query($sql);
-
- switch ($log_warnings)
- {
- case 2:
- add_log('admin', 'LOG_WARNINGS_DELETED', $user_row['username'], $num_warnings);
- break;
- case 1:
- add_log('admin', 'LOG_WARNING_DELETED', $user_row['username']);
- break;
- default:
- add_log('admin', 'LOG_WARNINGS_DELETED_ALL', $user_row['username']);
- break;
- }
- }
- }
- else
- {
- $s_hidden_fields = array(
- 'i' => $id,
- 'mode' => $mode,
- 'u' => $user_id,
- 'mark' => $marked,
- );
- if (isset($_POST['delmarked']))
- {
- $s_hidden_fields['delmarked'] = 1;
- }
- if (isset($_POST['delall']))
- {
- $s_hidden_fields['delall'] = 1;
- }
- if (isset($_POST['delall']) || (isset($_POST['delmarked']) && sizeof($marked)))
- {
- confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields($s_hidden_fields));
- }
- }
- }
-
- $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
- FROM ' . WARNINGS_TABLE . ' w
- LEFT JOIN ' . LOG_TABLE . ' l
- ON (w.log_id = l.log_id)
- LEFT JOIN ' . USERS_TABLE . ' m
- ON (l.user_id = m.user_id)
- WHERE w.user_id = ' . $user_id . '
- ORDER BY w.warning_time DESC';
- $result = $db->sql_query($sql);
-
- while ($row = $db->sql_fetchrow($result))
- {
- if (!$row['log_operation'])
- {
- // We do not have a log-entry anymore, so there is no data available
- $row['action'] = $user->lang['USER_WARNING_LOG_DELETED'];
- }
- else
- {
- $row['action'] = (isset($user->lang[$row['log_operation']])) ? $user->lang[$row['log_operation']] : '{' . ucfirst(str_replace('_', ' ', $row['log_operation'])) . '}';
- if (!empty($row['log_data']))
- {
- $log_data_ary = @unserialize($row['log_data']);
- $log_data_ary = ($log_data_ary === false) ? array() : $log_data_ary;
-
- if (isset($user->lang[$row['log_operation']]))
- {
- // Check if there are more occurrences of % than arguments, if there are we fill out the arguments array
- // It doesn't matter if we add more arguments than placeholders
- if ((substr_count($row['action'], '%') - sizeof($log_data_ary)) > 0)
- {
- $log_data_ary = array_merge($log_data_ary, array_fill(0, substr_count($row['action'], '%') - sizeof($log_data_ary), ''));
- }
- $row['action'] = vsprintf($row['action'], $log_data_ary);
- $row['action'] = bbcode_nl2br(censor_text($row['action']));
- }
- else if (!empty($log_data_ary))
- {
- $row['action'] .= '<br />' . implode('', $log_data_ary);
- }
- }
- }
-
-
- $template->assign_block_vars('warn', array(
- 'ID' => $row['warning_id'],
- 'USERNAME' => ($row['log_operation']) ? get_username_string('full', $row['mod_user_id'], $row['mod_username'], $row['mod_user_colour']) : '-',
- 'ACTION' => make_clickable($row['action']),
- 'DATE' => $user->format_date($row['warning_time']),
- ));
- }
- $db->sql_freeresult($result);
-
- $template->assign_vars(array(
- 'S_WARNINGS' => true,
- ));
-
- break;
-
- case 'profile':
-
- include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
- include($phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx);
-
- $cp = new custom_profile();
-
- $cp_data = $cp_error = array();
-
- $sql = 'SELECT lang_id
- FROM ' . LANG_TABLE . "
- WHERE lang_iso = '" . $db->sql_escape($user->data['user_lang']) . "'";
- $result = $db->sql_query($sql);
- $row = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
-
- $user_row['iso_lang_id'] = $row['lang_id'];
-
- $data = array(
- 'icq' => request_var('icq', $user_row['user_icq']),
- 'aim' => request_var('aim', $user_row['user_aim']),
- 'msn' => request_var('msn', $user_row['user_msnm']),
- 'yim' => request_var('yim', $user_row['user_yim']),
- 'jabber' => utf8_normalize_nfc(request_var('jabber', $user_row['user_jabber'], true)),
- 'website' => request_var('website', $user_row['user_website']),
- 'location' => utf8_normalize_nfc(request_var('location', $user_row['user_from'], true)),
- 'occupation' => utf8_normalize_nfc(request_var('occupation', $user_row['user_occ'], true)),
- 'interests' => utf8_normalize_nfc(request_var('interests', $user_row['user_interests'], true)),
- 'bday_day' => 0,
- 'bday_month' => 0,
- 'bday_year' => 0,
- );
-
- if ($user_row['user_birthday'])
- {
- list($data['bday_day'], $data['bday_month'], $data['bday_year']) = explode('-', $user_row['user_birthday']);
- }
-
- $data['bday_day'] = request_var('bday_day', $data['bday_day']);
- $data['bday_month'] = request_var('bday_month', $data['bday_month']);
- $data['bday_year'] = request_var('bday_year', $data['bday_year']);
- $data['user_birthday'] = sprintf('%2d-%2d-%4d', $data['bday_day'], $data['bday_month'], $data['bday_year']);
-
-
- if ($submit)
- {
- $error = validate_data($data, array(
- 'icq' => array(
- array('string', true, 3, 15),
- array('match', true, '#^[0-9]+$#i')),
- 'aim' => array('string', true, 3, 255),
- 'msn' => array('string', true, 5, 255),
- 'jabber' => array(
- array('string', true, 5, 255),
- array('jabber')),
- 'yim' => array('string', true, 5, 255),
- 'website' => array(
- array('string', true, 12, 255),
- array('match', true, '#^http[s]?://(.*?\.)*?[a-z0-9\-]+\.[a-z]{2,4}#i')),
- 'location' => array('string', true, 2, 100),
- 'occupation' => array('string', true, 2, 500),
- 'interests' => array('string', true, 2, 500),
- 'bday_day' => array('num', true, 1, 31),
- 'bday_month' => array('num', true, 1, 12),
- 'bday_year' => array('num', true, 1901, gmdate('Y', time())),
- 'user_birthday' => array('date', true),
- ));
-
- // validate custom profile fields
- $cp->submit_cp_field('profile', $user_row['iso_lang_id'], $cp_data, $cp_error);
-
- if (sizeof($cp_error))
- {
- $error = array_merge($error, $cp_error);
- }
- if (!check_form_key($form_name))
- {
- $error[] = 'FORM_INVALID';
- }
-
- if (!sizeof($error))
- {
- $sql_ary = array(
- 'user_icq' => $data['icq'],
- 'user_aim' => $data['aim'],
- 'user_msnm' => $data['msn'],
- 'user_yim' => $data['yim'],
- 'user_jabber' => $data['jabber'],
- 'user_website' => $data['website'],
- 'user_from' => $data['location'],
- 'user_occ' => $data['occupation'],
- 'user_interests'=> $data['interests'],
- 'user_birthday' => $data['user_birthday'],
- );
-
- $sql = 'UPDATE ' . USERS_TABLE . '
- SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "
- WHERE user_id = $user_id";
- $db->sql_query($sql);
-
- // Update Custom Fields
- $cp->update_profile_field_data($user_id, $cp_data);
-
- trigger_error($user->lang['USER_PROFILE_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_id));
- }
-
- // Replace "error" strings with their real, localised form
- $error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error);
- }
-
- $s_birthday_day_options = '<option value="0"' . ((!$data['bday_day']) ? ' selected="selected"' : '') . '>--</option>';
- for ($i = 1; $i < 32; $i++)
- {
- $selected = ($i == $data['bday_day']) ? ' selected="selected"' : '';
- $s_birthday_day_options .= "<option value=\"$i\"$selected>$i</option>";
- }
-
- $s_birthday_month_options = '<option value="0"' . ((!$data['bday_month']) ? ' selected="selected"' : '') . '>--</option>';
- for ($i = 1; $i < 13; $i++)
- {
- $selected = ($i == $data['bday_month']) ? ' selected="selected"' : '';
- $s_birthday_month_options .= "<option value=\"$i\"$selected>$i</option>";
- }
- $s_birthday_year_options = '';
-
- $now = getdate();
- $s_birthday_year_options = '<option value="0"' . ((!$data['bday_year']) ? ' selected="selected"' : '') . '>--</option>';
- for ($i = $now['year'] - 100; $i <= $now['year']; $i++)
- {
- $selected = ($i == $data['bday_year']) ? ' selected="selected"' : ''…
Large files files are truncated, but you can click here to view the full file