function main($id, $mode) { global $config, $db, $user, $auth, $template, $phpbb_root_path, $phpEx; $submit = isset($_POST['submit']) ? true : false; $error = $data = array(); $s_hidden_fields = ''; switch ($mode) { case 'personal': add_form_key('ucp_prefs_personal'); $data = array('notifymethod' => request_var('notifymethod', $user->data['user_notify_type']), 'dateformat' => request_var('dateformat', $user->data['user_dateformat'], true), 'lang' => basename(request_var('lang', $user->data['user_lang'])), 'style' => request_var('style', (int) $user->data['user_style']), 'tz' => request_var('tz', (double) $user->data['user_timezone']), 'dst' => request_var('dst', (bool) $user->data['user_dst']), 'viewemail' => request_var('viewemail', (bool) $user->data['user_allow_viewemail']), 'massemail' => request_var('massemail', (bool) $user->data['user_allow_massemail']), 'hideonline' => request_var('hideonline', (bool) (!$user->data['user_allow_viewonline'])), 'notifypm' => request_var('notifypm', (bool) $user->data['user_notify_pm']), 'popuppm' => request_var('popuppm', (bool) $user->optionget('popuppm')), 'allowpm' => request_var('allowpm', (bool) $user->data['user_allow_pm'])); if ($data['notifymethod'] == NOTIFY_IM && (!$config['jab_enable'] || !$user->data['user_jabber'] || !@extension_loaded('xml'))) { // Jabber isnt enabled, or no jabber field filled in. Update the users table to be sure its correct. $data['notifymethod'] = NOTIFY_BOTH; } if ($submit) { $data['style'] = $config['override_user_style'] ? $config['default_style'] : $data['style']; $error = validate_data($data, array('dateformat' => array('string', false, 1, 30), 'lang' => array('match', false, '#^[a-z0-9_\\-]{2,}$#i'), 'tz' => array('num', false, -14, 14))); if (!check_form_key('ucp_prefs_personal')) { $error[] = 'FORM_INVALID'; } if (!sizeof($error)) { $user->optionset('popuppm', $data['popuppm']); $sql_ary = array('user_allow_pm' => $data['allowpm'], 'user_allow_viewemail' => $data['viewemail'], 'user_allow_massemail' => $data['massemail'], 'user_allow_viewonline' => $auth->acl_get('u_hideonline') ? !$data['hideonline'] : $user->data['user_allow_viewonline'], 'user_notify_type' => $data['notifymethod'], 'user_notify_pm' => $data['notifypm'], 'user_options' => $user->data['user_options'], 'user_dst' => $data['dst'], 'user_dateformat' => $data['dateformat'], 'user_lang' => $data['lang'], 'user_timezone' => $data['tz'], 'user_style' => $data['style']); $sql = 'UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' WHERE user_id = ' . $user->data['user_id']; $db->sql_query($sql); meta_refresh(3, $this->u_action); $message = $user->lang['PREFERENCES_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>'); trigger_error($message); } // Replace "error" strings with their real, localised form $error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error); } $dateformat_options = ''; foreach ($user->lang['dateformats'] as $format => $null) { $dateformat_options .= '<option value="' . $format . '"' . ($format == $data['dateformat'] ? ' selected="selected"' : '') . '>'; $dateformat_options .= $user->format_date(time(), $format, false) . (strpos($format, '|') !== false ? $user->lang['VARIANT_DATE_SEPARATOR'] . $user->format_date(time(), $format, true) : ''); $dateformat_options .= '</option>'; } $s_custom = false; $dateformat_options .= '<option value="custom"'; if (!isset($user->lang['dateformats'][$data['dateformat']])) { $dateformat_options .= ' selected="selected"'; $s_custom = true; } $dateformat_options .= '>' . $user->lang['CUSTOM_DATEFORMAT'] . '</option>'; $template->assign_vars(array('ERROR' => sizeof($error) ? implode('<br />', $error) : '', 'S_NOTIFY_EMAIL' => $data['notifymethod'] == NOTIFY_EMAIL ? true : false, 'S_NOTIFY_IM' => $data['notifymethod'] == NOTIFY_IM ? true : false, 'S_NOTIFY_BOTH' => $data['notifymethod'] == NOTIFY_BOTH ? true : false, 'S_VIEW_EMAIL' => $data['viewemail'], 'S_MASS_EMAIL' => $data['massemail'], 'S_ALLOW_PM' => $data['allowpm'], 'S_HIDE_ONLINE' => $data['hideonline'], 'S_NOTIFY_PM' => $data['notifypm'], 'S_POPUP_PM' => $data['popuppm'], 'S_DST' => $data['dst'], 'DATE_FORMAT' => $data['dateformat'], 'A_DATE_FORMAT' => addslashes($data['dateformat']), 'S_DATEFORMAT_OPTIONS' => $dateformat_options, 'S_CUSTOM_DATEFORMAT' => $s_custom, 'DEFAULT_DATEFORMAT' => $config['default_dateformat'], 'A_DEFAULT_DATEFORMAT' => addslashes($config['default_dateformat']), 'S_LANG_OPTIONS' => language_select($data['lang']), 'S_STYLE_OPTIONS' => $config['override_user_style'] ? '' : style_select($data['style']), 'S_TZ_OPTIONS' => tz_select($data['tz'], true), 'S_CAN_HIDE_ONLINE' => $auth->acl_get('u_hideonline') ? true : false, 'S_SELECT_NOTIFY' => $config['jab_enable'] && $user->data['user_jabber'] && @extension_loaded('xml') ? true : false)); break; case 'view': add_form_key('ucp_prefs_view'); $data = array('topic_sk' => request_var('topic_sk', !empty($user->data['user_topic_sortby_type']) ? $user->data['user_topic_sortby_type'] : 't'), 'topic_sd' => request_var('topic_sd', !empty($user->data['user_topic_sortby_dir']) ? $user->data['user_topic_sortby_dir'] : 'd'), 'topic_st' => request_var('topic_st', !empty($user->data['user_topic_show_days']) ? $user->data['user_topic_show_days'] : 0), 'post_sk' => request_var('post_sk', !empty($user->data['user_post_sortby_type']) ? $user->data['user_post_sortby_type'] : 't'), 'post_sd' => request_var('post_sd', !empty($user->data['user_post_sortby_dir']) ? $user->data['user_post_sortby_dir'] : 'a'), 'post_st' => request_var('post_st', !empty($user->data['user_post_show_days']) ? $user->data['user_post_show_days'] : 0), 'images' => request_var('images', (bool) $user->optionget('viewimg')), 'flash' => request_var('flash', (bool) $user->optionget('viewflash')), 'smilies' => request_var('smilies', (bool) $user->optionget('viewsmilies')), 'sigs' => request_var('sigs', (bool) $user->optionget('viewsigs')), 'avatars' => request_var('avatars', (bool) $user->optionget('viewavatars')), 'wordcensor' => request_var('wordcensor', (bool) $user->optionget('viewcensors'))); if ($submit) { $error = validate_data($data, array('topic_sk' => array('string', false, 1, 1), 'topic_sd' => array('string', false, 1, 1), 'post_sk' => array('string', false, 1, 1), 'post_sd' => array('string', false, 1, 1))); if (!check_form_key('ucp_prefs_view')) { $error[] = 'FORM_INVALID'; } if (!sizeof($error)) { $user->optionset('viewimg', $data['images']); $user->optionset('viewflash', $data['flash']); $user->optionset('viewsmilies', $data['smilies']); $user->optionset('viewsigs', $data['sigs']); $user->optionset('viewavatars', $data['avatars']); if ($auth->acl_get('u_chgcensors')) { $user->optionset('viewcensors', $data['wordcensor']); } $sql_ary = array('user_options' => $user->data['user_options'], 'user_topic_sortby_type' => $data['topic_sk'], 'user_post_sortby_type' => $data['post_sk'], 'user_topic_sortby_dir' => $data['topic_sd'], 'user_post_sortby_dir' => $data['post_sd'], 'user_topic_show_days' => $data['topic_st'], 'user_post_show_days' => $data['post_st']); $sql = 'UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' WHERE user_id = ' . $user->data['user_id']; $db->sql_query($sql); meta_refresh(3, $this->u_action); $message = $user->lang['PREFERENCES_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>'); trigger_error($message); } // Replace "error" strings with their real, localised form $error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error); } $sort_dir_text = array('a' => $user->lang['ASCENDING'], 'd' => $user->lang['DESCENDING']); // Topic ordering options $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']); $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']); $sort_by_topic_sql = array('a' => 't.topic_first_poster_name', 't' => 't.topic_last_post_time', 'r' => 't.topic_replies', 's' => 't.topic_title', 'v' => 't.topic_views'); // Post ordering options $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']); $sort_by_post_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 's' => $user->lang['SUBJECT']); $sort_by_post_sql = array('a' => 'u.username_clean', 't' => 'p.post_id', 's' => 'p.post_subject'); $_options = array('topic', 'post'); foreach ($_options as $sort_option) { ${'s_limit_' . $sort_option . '_days'} = '<select name="' . $sort_option . '_st">'; foreach (${'limit_' . $sort_option . '_days'} as $day => $text) { $selected = $data[$sort_option . '_st'] == $day ? ' selected="selected"' : ''; ${'s_limit_' . $sort_option . '_days'} .= '<option value="' . $day . '"' . $selected . '>' . $text . '</option>'; } ${'s_limit_' . $sort_option . '_days'} .= '</select>'; ${'s_sort_' . $sort_option . '_key'} = '<select name="' . $sort_option . '_sk">'; foreach (${'sort_by_' . $sort_option . '_text'} as $key => $text) { $selected = $data[$sort_option . '_sk'] == $key ? ' selected="selected"' : ''; ${'s_sort_' . $sort_option . '_key'} .= '<option value="' . $key . '"' . $selected . '>' . $text . '</option>'; } ${'s_sort_' . $sort_option . '_key'} .= '</select>'; ${'s_sort_' . $sort_option . '_dir'} = '<select name="' . $sort_option . '_sd">'; foreach ($sort_dir_text as $key => $value) { $selected = $data[$sort_option . '_sd'] == $key ? ' selected="selected"' : ''; ${'s_sort_' . $sort_option . '_dir'} .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>'; } ${'s_sort_' . $sort_option . '_dir'} .= '</select>'; } $template->assign_vars(array('ERROR' => sizeof($error) ? implode('<br />', $error) : '', 'S_IMAGES' => $data['images'], 'S_FLASH' => $data['flash'], 'S_SMILIES' => $data['smilies'], 'S_SIGS' => $data['sigs'], 'S_AVATARS' => $data['avatars'], 'S_DISABLE_CENSORS' => $data['wordcensor'], 'S_CHANGE_CENSORS' => $auth->acl_get('u_chgcensors') && $config['allow_nocensors'] ? true : false, 'S_TOPIC_SORT_DAYS' => $s_limit_topic_days, 'S_TOPIC_SORT_KEY' => $s_sort_topic_key, 'S_TOPIC_SORT_DIR' => $s_sort_topic_dir, 'S_POST_SORT_DAYS' => $s_limit_post_days, 'S_POST_SORT_KEY' => $s_sort_post_key, 'S_POST_SORT_DIR' => $s_sort_post_dir)); break; case 'post': $data = array('bbcode' => request_var('bbcode', $user->optionget('bbcode')), 'smilies' => request_var('smilies', $user->optionget('smilies')), 'sig' => request_var('sig', $user->optionget('attachsig')), 'notify' => request_var('notify', (bool) $user->data['user_notify'])); add_form_key('ucp_prefs_post'); if ($submit) { if (check_form_key('ucp_prefs_post')) { $user->optionset('bbcode', $data['bbcode']); $user->optionset('smilies', $data['smilies']); $user->optionset('attachsig', $data['sig']); $sql_ary = array('user_options' => $user->data['user_options'], 'user_notify' => $data['notify']); $sql = 'UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' WHERE user_id = ' . $user->data['user_id']; $db->sql_query($sql); $msg = $user->lang['PREFERENCES_UPDATED']; } else { $msg = $user->lang['FORM_INVALID']; } meta_refresh(3, $this->u_action); $message = $msg . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>'); trigger_error($message); } $template->assign_vars(array('S_BBCODE' => $data['bbcode'], 'S_SMILIES' => $data['smilies'], 'S_SIG' => $data['sig'], 'S_NOTIFY' => $data['notify'])); break; } $template->assign_vars(array('L_TITLE' => $user->lang['UCP_PREFS_' . strtoupper($mode)], 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'S_UCP_ACTION' => $this->u_action)); $this->tpl_name = 'ucp_prefs_' . $mode; $this->page_title = 'UCP_PREFS_' . strtoupper($mode); }
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); include $phpbb_root_path . 'includes/functions_user.' . $phpEx; include $phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx; $error = array(); $username = request_var('username', '', true); $user_id = request_var('u', 0); $action = request_var('action', ''); $submit = isset($_POST['update']) ? true : false; // Whois (special case) if ($action == 'whois') { $this->page_title = 'WHOIS'; $this->tpl_name = 'simple_body'; $user_ip = request_var('user_ip', ''); $domain = gethostbyaddr($user_ip); $ipwhois = ''; if ($ipwhois = user_ipwhois($user_ip)) { $ipwhois = preg_replace('#(\\s)([\\w\\-\\._\\+]+@[\\w\\-\\.]+)(\\s)#', '\\1<a href="mailto:\\2">\\2</a>\\3', $ipwhois); $ipwhois = preg_replace('#(\\s)(http:/{2}[^\\s]*)(\\s)#', '\\1<a href="\\2" target="_blank">\\2</a>\\3', $ipwhois); } $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'))); return; } if (!$user_id) { $sql = 'SELECT user_id FROM ' . USERS_TABLE . "\n\t\t\t\tWHERE 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)); } } // 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($sql); $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)); } // Generate overall "header" for user admin $s_form_options = ''; // Include info file... include_once $phpbb_root_path . 'includes/acp/info/acp_users.' . $phpEx; $forms_ary = acp_users_info::module(); foreach ($forms_ary['modes'] as $value => $ary) { if (!$this->is_authed($ary['auth'])) { continue; } $selected = $mode == $value ? ' selected="selected"' : ''; $s_form_options .= '<option value="' . $value . '"' . $selected . '>' . $user->lang['ACP_USER_' . strtoupper($value)] . '</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)); // 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)); } switch ($mode) { case 'overview': $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_ADMIN'] . adm_back_link($this->u_action . '&u=' . $user_id)); } // 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)); } if ($user_id == $user->data['user_id']) { trigger_error($user->lang['CANNOT_REMOVE_YOURSELF'] . adm_back_link($this->u_action . '&u=' . $user_id)); } if (confirm_box(true)) { user_delete($delete_type, $user_id); 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))); } } // Handle quicktool actions switch ($action) { case 'banuser': case 'banemail': case 'banip': $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 . "\n\t\t\t\t\t\t\t\t\t\tWHERE 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; } user_ban(substr($action, 3), $ban, 0, 0, 0, $user->lang[$reason]); add_log('admin', $log, $user->lang[$reason]); add_log('user', $user_id, $log, $user->lang[$reason]); trigger_error($user->lang['BAN_SUCCESSFUL'] . adm_back_link($this->u_action . '&u=' . $user_id)); break; case 'reactivate': if ($config['email_enable']) { include_once $phpbb_root_path . 'includes/functions_messenger.' . $phpEx; $server_url = generate_board_url(); $user_actkey = gen_rand_string(10); $key_len = 54 - strlen($server_url); $key_len = $key_len > 6 ? $key_len : 6; $user_actkey = substr($user_actkey, 0, $key_len); if ($user_row['user_type'] != USER_INACTIVE) { user_active_flip($user_id, $user_row['user_type'], $user_actkey, $user_row['username']); } $messenger = new messenger(false); $messenger->template('user_resend_inactive', $user_row['user_lang']); $messenger->replyto($config['board_contact']); $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('SITENAME' => $config['sitename'], 'WELCOME_MSG' => sprintf($user->lang['WELCOME_SUBJECT'], $config['sitename']), 'USERNAME' => html_entity_decode($user_row['username']), 'EMAIL_SIG' => str_replace('<br />', "\n", "-- \n" . $config['board_email_sig']), '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': user_active_flip($user_id, $user_row['user_type'], false, $user_row['username']); $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('user', $user_id, $log . '_USER'); if ($user_row['user_type'] == USER_INACTIVE) { set_config('num_users', $config['num_users'] + 1, true); } else { set_config('num_users', $config['num_users'] - 1, true); } // Update latest username update_last_username(); trigger_error($user->lang[$message] . adm_back_link($this->u_action . '&u=' . $user_id)); break; case 'delsig': $sql_ary = array('user_sig' => '', 'user_sig_bbcode_uid' => '', 'user_sig_bbcode_bitfield' => 0); $sql = 'UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "\n\t\t\t\t\t\t\t\tWHERE 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': $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) . "\n\t\t\t\t\t\t\t\tWHERE 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_row['user_avatar']); } 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)) { $sql = 'SELECT topic_id, COUNT(post_id) AS total_posts FROM ' . POSTS_TABLE . "\n\t\t\t\t\t\t\t\t\tWHERE poster_id = {$user_id}\n\t\t\t\t\t\t\t\t\tGROUP BY topic_id"; $result = $db->sql_query($sql); $topic_id_ary = array(); 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, topic_replies, topic_replies_real FROM ' . TOPICS_TABLE . ' WHERE topic_id IN (' . implode(', ', array_keys($topic_id_ary)) . ')'; $result = $db->sql_query($sql); $del_topic_ary = array(); while ($row = $db->sql_fetchrow($result)) { if (max($row['topic_replies'], $row['topic_replies_real']) + 1 == $topic_id_ary[$row['topic_id']]) { $del_topic_ary[] = $row['topic_id']; } } $db->sql_freeresult($result); if (sizeof($del_topic_ary)) { $sql = 'DELETE FROM ' . TOPICS_TABLE . ' WHERE topic_id IN (' . implode(', ', $del_topic_ary) . ')'; $db->sql_query($sql); } } // 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 'moveposts': $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; } // 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 . "\n\t\t\t\t\t\t\t\tWHERE poster_id = {$user_id}\n\t\t\t\t\t\t\t\t\tAND forum_id <> {$new_forum_id}\n\t\t\t\t\t\t\t\tGROUP 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 FROM ' . TOPICS_TABLE . ' WHERE topic_id IN (' . implode(', ', 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['attach'] ? 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 . "\n\t\t\t\t\t\t\t\t\t\tSET forum_id = {$new_forum_id}, topic_id = {$new_topic_id}\n\t\t\t\t\t\t\t\t\t\tWHERE topic_id = {$topic_id}\n\t\t\t\t\t\t\t\t\t\t\tAND poster_id = {$user_id}"; $db->sql_query($sql); if ($post_ary['attach']) { $sql = 'UPDATE ' . ATTACHMENTS_TABLE . "\n\t\t\t\t\t\t\t\t\t\t\tSET topic_id = {$new_topic_id}\n\t\t\t\t\t\t\t\t\t\t\tWHERE topic_id = {$topic_id}\n\t\t\t\t\t\t\t\t\t\t\t\tAND 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($topic_id_ary, $new_topic_id_ary)); if (sizeof($topic_id_ary)) { sync('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); } $sql = 'SELECT forum_name FROM ' . FORUMS_TABLE . "\n\t\t\t\t\t\t\t\tWHERE forum_id = {$new_forum_id}"; $result = $db->sql_query($sql, 3600); $forum_info = $db->sql_fetchrow($result); $db->sql_freeresult($result); 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; } $data = array(); // Handle registration info updates $var_ary = array('user' => (string) $user_row['username'], 'user_founder' => (int) ($user_row['user_type'] == USER_FOUNDER ? 1 : 0), 'user_email' => (string) $user_row['user_email'], 'email_confirm' => (string) '', 'user_password' => (string) '', 'password_confirm' => (string) '', 'warnings' => (int) $user_row['user_warnings']); // Get the data from the form. Use data from the database if no info is provided foreach ($var_ary as $var => $default) { $data[$var] = request_var($var, $default); } // We use user within the form to circumvent auto filling $data['username'] = $data['user']; unset($data['user']); // Validation data $var_ary = array('password_confirm' => array('string', true, $config['min_pass_chars'], $config['max_pass_chars']), 'user_password' => array('string', true, $config['min_pass_chars'], $config['max_pass_chars']), 'warnings' => array('num')); // Check username if altered if ($data['username'] != $user_row['username']) { $var_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['user_email'] != $user_row['user_email']) { $var_ary += array('user_email' => array(array('string', false, 6, 60), array('email', $user_row['user_email'])), 'email_confirm' => array('string', true, 6, 60)); } $error = validate_data($data, $var_ary); if ($data['user_password'] && $data['password_confirm'] != $data['user_password']) { $error[] = 'NEW_PASSWORD_ERROR'; } if ($data['user_email'] != $user_row['user_email'] && $data['email_confirm'] != $data['user_email']) { $error[] = 'NEW_EMAIL_ERROR'; } // Which updates do we need to do? $update_warning = $user_row['user_warnings'] != $data['warnings'] ? true : false; $update_username = $user_row['username'] != $data['username'] ? $data['username'] : false; $update_password = $data['user_password'] && $user_row['user_password'] != md5($data['user_password']) ? true : false; $update_email = $data['user_email'] != $user_row['user_email'] ? $data['user_email'] : false; if (!sizeof($error)) { $sql_ary = array(); if ($user_row['user_type'] != USER_FOUNDER || $user->data['user_type'] == USER_FOUNDER) { if ($update_warning) { $sql_ary['user_warnings'] = $data['warnings']; } if ($user_row['user_type'] == USER_FOUNDER && !$data['user_founder'] || $user_row['user_type'] != USER_FOUNDER && $data['user_founder']) { $sql_ary['user_type'] = $data['user_founder'] ? USER_FOUNDER : USER_NORMAL; } } if ($update_username !== false) { $sql_ary['username'] = $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' => crc32(strtolower($update_email)) . strlen($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' => md5($data['user_password']), 'user_passchg' => time()); $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); } /** * @todo adjust every data based in the number of user warnings */ if ($update_warning) { } if ($update_username) { user_update_name($user_row['username'], $update_username); } 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); } $user_char_ary = array('.*' => 'USERNAME_CHARS_ANY', '[\\w]+' => 'USERNAME_ALPHA_ONLY', '[\\w_\\+\\. \\-\\[\\]]+' => 'USERNAME_ALPHA_SPACERS'); $quick_tool_ary = array('banuser' => 'BAN_USER', 'banemail' => 'BAN_EMAIL', 'banip' => 'BAN_IP', 'active' => $user_row['user_type'] == USER_INACTIVE ? 'ACTIVATE' : 'DEACTIVATE', 'delsig' => 'DEL_SIG', 'delavatar' => 'DEL_AVATAR', 'moveposts' => 'MOVE_POSTS', 'delposts' => 'DEL_POSTS', 'delattach' => 'DEL_ATTACH'); if ($config['email_enable']) { $quick_tool_ary['reactivate'] = 'FORCE'; } $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>'; } $template->assign_vars(array('L_NAME_CHARS_EXPLAIN' => sprintf($user->lang[$user_char_ary[$config['allow_name_chars']] . '_EXPLAIN'], $config['min_name_chars'], $config['max_name_chars']), 'L_CHANGE_PASSWORD_EXPLAIN' => sprintf($user->lang['CHANGE_PASSWORD_EXPLAIN'], $config['min_pass_chars'], $config['max_pass_chars']), '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, '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_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']}") : '', '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' => $user_row['user_lastvisit'] ? $user->format_date($user_row['user_lastvisit']) : ' - ', 'USER_EMAIL' => $user_row['user_email'], 'USER_WARNINGS' => $user_row['user_warnings'])); 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 = 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')) { $where_sql = ''; if ($deletemark && $marked) { $sql_in = array(); foreach ($marked as $mark) { $sql_in[] = $mark; } $where_sql = ' AND log_id IN (' . implode(', ', $sql_in) . ')'; unset($sql_in); } if ($where_sql || $deleteall) { $sql = 'DELETE FROM ' . LOG_TABLE . ' WHERE log_type = ' . LOG_USERS . "\n\t\t\t\t\t\t\t{$where_sql}"; $db->sql_query($sql); add_log('admin', 'LOG_CLEAR_USER', $user_row['username']); } } if ($submit && $message) { add_log('admin', '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' => 'l.user_id', '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'], 'IP' => $row['ip'], 'DATE' => $user->format_date($row['time']), 'ACTION' => nl2br($row['action']), 'ID' => $row['id'])); } break; case 'profile': $cp = new custom_profile(); $cp_data = $cp_error = array(); $data = array(); $sql = 'SELECT lang_id FROM ' . LANG_TABLE . "\n\t\t\t\t\tWHERE lang_iso = '" . $db->sql_escape($user_row['user_lang']) . "'"; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); $user_row['iso_lang_id'] = $row['lang_id']; if ($submit) { $var_ary = array('icq' => (string) '', 'aim' => (string) '', 'msn' => (string) '', 'yim' => (string) '', 'jabber' => (string) '', 'website' => (string) '', 'location' => (string) '', 'occupation' => (string) '', 'interests' => (string) '', 'bday_day' => 0, 'bday_month' => 0, 'bday_year' => 0); foreach ($var_ary as $var => $default) { $data[$var] = in_array($var, array('location', 'occupation', 'interests')) ? request_var($var, $default, true) : ($data[$var] = request_var($var, $default)); } $var_ary = array('icq' => array(array('string', true, 3, 15), array('match', true, '#^[0-9]+$#i')), 'aim' => array('string', true, 3, 17), 'msn' => array('string', true, 5, 255), 'jabber' => array(array('string', true, 5, 255), array('match', true, '#^[a-z0-9\\.\\-_\\+]+?@(.*?\\.)*?[a-z0-9\\-_]+?\\.[a-z]{2,4}(/.*)?$#i')), '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, 255), '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()))); $error = validate_data($data, $var_ary); // 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 (!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' => sprintf('%2d-%2d-%4d', $data['bday_day'], $data['bday_month'], $data['bday_year'])); $sql = 'UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "\n\t\t\t\t\t\t\tWHERE user_id = {$user_id}"; $db->sql_query($sql); // Update Custom Fields if (sizeof($cp_data)) { $sql = 'UPDATE ' . PROFILE_FIELDS_DATA_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $cp_data) . "\n\t\t\t\t\t\t\t\tWHERE user_id = {$user_id}"; $db->sql_query($sql); if (!$db->sql_affectedrows()) { $cp_data['user_id'] = (int) $user_id; $db->return_on_error = true; $sql = 'INSERT INTO ' . PROFILE_FIELDS_DATA_TABLE . ' ' . $db->sql_build_array('INSERT', $cp_data); $db->sql_query($sql); $db->return_on_error = false; } } 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); } if (!isset($data['bday_day'])) { if ($user_row['user_birthday']) { list($data['bday_day'], $data['bday_month'], $data['bday_year']) = explode('-', $user_row['user_birthday']); } else { $data['bday_day'] = $data['bday_month'] = $data['bday_year'] = 0; } } $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"' : ''; $s_birthday_year_options .= "<option value=\"{$i}\"{$selected}>{$i}</option>"; } unset($now); $template->assign_vars(array('ICQ' => isset($data['icq']) ? $data['icq'] : $user_row['user_icq'], 'YIM' => isset($data['yim']) ? $data['yim'] : $user_row['user_yim'], 'AIM' => isset($data['aim']) ? $data['aim'] : $user_row['user_aim'], 'MSN' => isset($data['msn']) ? $data['msn'] : $user_row['user_msnm'], 'JABBER' => isset($data['jabber']) ? $data['jabber'] : $user_row['user_jabber'], 'WEBSITE' => isset($data['website']) ? $data['website'] : $user_row['user_website'], 'LOCATION' => isset($data['location']) ? $data['location'] : $user_row['user_from'], 'OCCUPATION' => isset($data['occupation']) ? $data['occupation'] : $user_row['user_occ'], 'INTERESTS' => isset($data['interests']) ? $data['interests'] : $user_row['user_interests'], 'S_BIRTHDAY_DAY_OPTIONS' => $s_birthday_day_options, 'S_BIRTHDAY_MONTH_OPTIONS' => $s_birthday_month_options, 'S_BIRTHDAY_YEAR_OPTIONS' => $s_birthday_year_options, 'S_PROFILE' => true)); // Get additional profile fields and assign them to the template block var 'profile_fields' $user->get_profile_fields($user_id); $cp->generate_profile_fields('profile', $user_row['iso_lang_id']); break; case 'prefs': $data = array(); if ($submit) { $var_ary = array('dateformat' => (string) $config['default_dateformat'], 'lang' => (string) $config['default_lang'], 'tz' => (double) $config['board_timezone'], 'style' => (int) $config['default_style'], 'dst' => (bool) $config['board_dst'], 'viewemail' => false, 'massemail' => true, 'hideonline' => false, 'notifymethod' => 0, 'notifypm' => true, 'popuppm' => false, 'allowpm' => true, 'topic_sk' => (string) 't', 'topic_sd' => (string) 'd', 'topic_st' => 0, 'post_sk' => (string) 't', 'post_sd' => (string) 'a', 'post_st' => 0, 'view_images' => true, 'view_flash' => false, 'view_smilies' => true, 'view_sigs' => true, 'view_avatars' => true, 'view_wordcensor' => false, 'bbcode' => true, 'smilies' => true, 'sig' => true, 'notify' => false); foreach ($var_ary as $var => $default) { $data[$var] = request_var($var, $default); } $var_ary = array('dateformat' => array('string', false, 3, 30), 'lang' => array('match', false, '#^[a-z_]{2,}$#i'), 'tz' => array('num', false, -14, 14), 'topic_sk' => array('string', false, 1, 1), 'topic_sd' => array('string', false, 1, 1), 'post_sk' => array('string', false, 1, 1), 'post_sd' => array('string', false, 1, 1)); $error = validate_data($data, $var_ary); if (!sizeof($error)) { $this->optionset($user_row, 'popuppm', $data['popuppm']); $this->optionset($user_row, 'viewimg', $data['view_images']); $this->optionset($user_row, 'viewflash', $data['view_flash']); $this->optionset($user_row, 'viewsmilies', $data['view_smilies']); $this->optionset($user_row, 'viewsigs', $data['view_sigs']); $this->optionset($user_row, 'viewavatars', $data['view_avatars']); $this->optionset($user_row, 'viewcensors', $data['view_wordcensor']); $this->optionset($user_row, 'bbcode', $data['bbcode']); $this->optionset($user_row, 'smilies', $data['smilies']); $this->optionset($user_row, 'attachsig', $data['sig']); $sql_ary = array('user_options' => $user_row['user_options'], 'user_allow_pm' => $data['allowpm'], 'user_allow_viewemail' => $data['viewemail'], 'user_allow_massemail' => $data['massemail'], 'user_allow_viewonline' => !$data['hideonline'], 'user_notify_type' => $data['notifymethod'], 'user_notify_pm' => $data['notifypm'], 'user_dst' => $data['dst'], 'user_dateformat' => $data['dateformat'], 'user_lang' => $data['lang'], 'user_timezone' => $data['tz'], 'user_style' => $data['style'], 'user_topic_sortby_type' => $data['topic_sk'], 'user_post_sortby_type' => $data['post_sk'], 'user_topic_sortby_dir' => $data['topic_sd'], 'user_post_sortby_dir' => $data['post_sd'], 'user_topic_show_days' => $data['topic_st'], 'user_post_show_days' => $data['post_st'], 'user_notify' => $data['notify']); $sql = 'UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "\n\t\t\t\t\t\t\tWHERE user_id = {$user_id}"; $db->sql_query($sql); trigger_error($user->lang['USER_PREFS_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); } $notify_method = isset($data['notifymethod']) ? $data['notifymethod'] : $user_row['user_notify_type']; $dateformat = isset($data['dateformat']) ? $data['dateformat'] : $user_row['user_dateformat']; $lang = isset($data['lang']) ? $data['lang'] : $user_row['user_lang']; $style = isset($data['style']) ? $data['style'] : $user_row['user_style']; $tz = isset($data['tz']) ? $data['tz'] : $user_row['user_timezone']; $dateformat_options = ''; foreach ($user->lang['dateformats'] as $format => $null) { $dateformat_options .= '<option value="' . $format . '"' . ($format == $dateformat ? ' selected="selected"' : '') . '>'; $dateformat_options .= $user->format_date(time(), $format, true) . (strpos($format, '|') !== false ? ' [' . $user->lang['RELATIVE_DAYS'] . ']' : ''); $dateformat_options .= '</option>'; } $s_custom = false; $dateformat_options .= '<option value="custom"'; if (!in_array($dateformat, array_keys($user->lang['dateformats']))) { $dateformat_options .= ' selected="selected"'; $s_custom = true; } $dateformat_options .= '>' . $user->lang['CUSTOM_DATEFORMAT'] . '</option>'; $topic_sk = isset($data['topic_sk']) ? $data['topic_sk'] : ($user_row['user_topic_sortby_type'] ? $user_row['user_topic_sortby_type'] : 't'); $post_sk = isset($data['post_sk']) ? $data['post_sk'] : ($user_row['user_post_sortby_type'] ? $user_row['user_post_sortby_type'] : 't'); $topic_sd = isset($data['topic_sd']) ? $data['topic_sd'] : ($user_row['user_topic_sortby_dir'] ? $user_row['user_topic_sortby_dir'] : 'd'); $post_sd = isset($data['post_sd']) ? $data['post_sd'] : ($user_row['user_post_sortby_dir'] ? $user_row['user_post_sortby_dir'] : 'd'); $topic_st = isset($data['topic_st']) ? $data['topic_st'] : ($user_row['user_topic_show_days'] ? $user_row['user_topic_show_days'] : 0); $post_st = isset($data['post_st']) ? $data['post_st'] : ($user_row['user_post_show_days'] ? $user_row['user_post_show_days'] : 0); $sort_dir_text = array('a' => $user->lang['ASCENDING'], 'd' => $user->lang['DESCENDING']); // Topic ordering options $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']); $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']); // Post ordering options $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']); $sort_by_post_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 's' => $user->lang['SUBJECT']); $_options = array('topic', 'post'); foreach ($_options as $sort_option) { ${'s_limit_' . $sort_option . '_days'} = '<select name="' . $sort_option . '_st">'; foreach (${'limit_' . $sort_option . '_days'} as $day => $text) { $selected = ${$sort_option . '_st'} == $day ? ' selected="selected"' : ''; ${'s_limit_' . $sort_option . '_days'} .= '<option value="' . $day . '"' . $selected . '>' . $text . '</option>'; } ${'s_limit_' . $sort_option . '_days'} .= '</select>'; ${'s_sort_' . $sort_option . '_key'} = '<select name="' . $sort_option . '_sk">'; foreach (${'sort_by_' . $sort_option . '_text'} as $key => $text) { $selected = ${$sort_option . '_sk'} == $key ? ' selected="selected"' : ''; ${'s_sort_' . $sort_option . '_key'} .= '<option value="' . $key . '"' . $selected . '>' . $text . '</option>'; } ${'s_sort_' . $sort_option . '_key'} .= '</select>'; ${'s_sort_' . $sort_option . '_dir'} = '<select name="' . $sort_option . '_sd">'; foreach ($sort_dir_text as $key => $value) { $selected = ${$sort_option . '_sd'} == $key ? ' selected="selected"' : ''; ${'s_sort_' . $sort_option . '_dir'} .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>'; } ${'s_sort_' . $sort_option . '_dir'} .= '</select>'; } $template->assign_vars(array('S_PREFS' => true, 'S_JABBER_DISABLED' => $config['jab_enable'] && $user->data['user_jabber'] && @extension_loaded('xml') ? false : true, 'VIEW_EMAIL' => isset($data['viewemail']) ? $data['viewemail'] : $user_row['user_allow_viewemail'], 'MASS_EMAIL' => isset($data['massemail']) ? $data['massemail'] : $user_row['user_allow_massemail'], 'ALLOW_PM' => isset($data['allowpm']) ? $data['allowpm'] : $user_row['user_allow_pm'], 'HIDE_ONLINE' => isset($data['hideonline']) ? $data['hideonline'] : !$user_row['user_allow_viewonline'], 'NOTIFY_EMAIL' => $notify_method == NOTIFY_EMAIL ? true : false, 'NOTIFY_IM' => $notify_method == NOTIFY_IM ? true : false, 'NOTIFY_BOTH' => $notify_method == NOTIFY_BOTH ? true : false, 'NOTIFY_PM' => isset($data['notifypm']) ? $data['notifypm'] : $user_row['user_notify_pm'], 'POPUP_PM' => isset($data['popuppm']) ? $data['popuppm'] : $this->optionget($user_row, 'popuppm'), 'DST' => isset($data['dst']) ? $data['dst'] : $user_row['user_dst'], 'BBCODE' => isset($data['bbcode']) ? $data['bbcode'] : $this->optionget($user_row, 'bbcode'), 'SMILIES' => isset($data['smilies']) ? $data['smilies'] : $this->optionget($user_row, 'smilies'), 'ATTACH_SIG' => isset($data['sig']) ? $data['sig'] : $this->optionget($user_row, 'attachsig'), 'NOTIFY' => isset($data['notify']) ? $data['notify'] : $user_row['user_notify'], 'VIEW_IMAGES' => isset($data['view_images']) ? $data['view_images'] : $this->optionget($user_row, 'viewimg'), 'VIEW_FLASH' => isset($data['view_flash']) ? $data['view_flash'] : $this->optionget($user_row, 'viewflash'), 'VIEW_SMILIES' => isset($data['view_smilies']) ? $data['view_smilies'] : $this->optionget($user_row, 'viewsmilies'), 'VIEW_SIGS' => isset($data['view_sigs']) ? $data['view_sigs'] : $this->optionget($user_row, 'viewsigs'), 'VIEW_AVATARS' => isset($data['view_avatars']) ? $data['view_avatars'] : $this->optionget($user_row, 'viewavatars'), 'VIEW_WORDCENSOR' => isset($data['view_wordcensor']) ? $data['view_wordcensor'] : $this->optionget($user_row, 'viewcensors'), 'S_TOPIC_SORT_DAYS' => $s_limit_topic_days, 'S_TOPIC_SORT_KEY' => $s_sort_topic_key, 'S_TOPIC_SORT_DIR' => $s_sort_topic_dir, 'S_POST_SORT_DAYS' => $s_limit_post_days, 'S_POST_SORT_KEY' => $s_sort_post_key, 'S_POST_SORT_DIR' => $s_sort_post_dir, 'DATE_FORMAT' => $dateformat, 'S_DATEFORMAT_OPTIONS' => $dateformat_options, 'S_CUSTOM_DATEFORMAT' => $s_custom, 'DEFAULT_DATEFORMAT' => $config['default_dateformat'], 'A_DEFAULT_DATEFORMAT' => addslashes($config['default_dateformat']), 'S_LANG_OPTIONS' => language_select($lang), 'S_STYLE_OPTIONS' => style_select($style), 'S_TZ_OPTIONS' => tz_select($tz))); break; case 'avatar': $avatar_select = basename(request_var('avatar_select', '')); $category = basename(request_var('category', '')); $can_upload = file_exists($phpbb_root_path . $config['avatar_path']) && is_writeable($phpbb_root_path . $config['avatar_path']) && $file_uploads ? true : false; $data = array(); if ($submit) { $delete = request_var('delete', ''); $var_ary = array('uploadurl' => (string) '', 'remotelink' => (string) '', 'width' => (string) '', 'height' => (string) ''); foreach ($var_ary as $var => $default) { $data[$var] = request_var($var, $default); } $var_ary = array('uploadurl' => array('string', true, 5, 255), 'remotelink' => array('string', true, 5, 255), 'width' => array('string', true, 1, 3), 'height' => array('string', true, 1, 3)); $error = validate_data($data, $var_ary); if (!sizeof($error)) { $data['user_id'] = $user_id; if ((!empty($_FILES['uploadfile']['name']) || $data['uploadurl']) && $can_upload && $config['allow_avatar_upload']) { list($type, $filename, $width, $height) = avatar_upload($data, $error); } else { if ($data['remotelink'] && $config['allow_avatar_remote']) { list($type, $filename, $width, $height) = avatar_remote($data, $error); } else { if ($avatar_select && $config['allow_avatar_local']) { $type = AVATAR_GALLERY; $filename = $avatar_select; // check avatar gallery if (!is_dir($phpbb_root_path . $config['avatar_gallery_path'] . '/' . $category)) { $type = $width = $height = 0; $filename = ''; } else { list($width, $height) = getimagesize($phpbb_root_path . $config['avatar_gallery_path'] . '/' . $category . '/' . $filename); $filename = $category . '/' . $filename; } } else { if ($delete) { $filename = ''; $type = $width = $height = 0; } else { $data = array(); } } } } } if (!sizeof($error)) { // Do we actually have any data to update? if (sizeof($data)) { $sql_ary = array('user_avatar' => $filename, 'user_avatar_type' => $type, 'user_avatar_width' => $width, 'user_avatar_height' => $height); $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'] && $filename != $user_row['user_avatar'] && $user_row['user_avatar_type'] != AVATAR_GALLERY) { avatar_delete($user_row['user_avatar']); } } trigger_error($user->lang['USER_AVATAR_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); } // Generate users avatar if ($user_row['user_avatar']) { $avatar_img = ''; switch ($user_row['user_avatar_type']) { case AVATAR_UPLOAD: $avatar_img = $phpbb_root_path . $config['avatar_path'] . '/'; break; case AVATAR_GALLERY: $avatar_img = $phpbb_root_path . $config['avatar_gallery_path'] . '/'; break; } $avatar_img .= $user_row['user_avatar']; $avatar_img = '<img src="' . $avatar_img . '" width="' . $user_row['user_avatar_width'] . '" height="' . $user_row['user_avatar_height'] . '" alt="" />'; } else { $avatar_img = '<img src="' . $phpbb_admin_path . 'images/no_avatar.gif" alt="" />'; } $display_gallery = isset($_POST['display_gallery']) ? true : false; if ($config['allow_avatar_local'] && $display_gallery) { avatar_gallery($category, $avatar_select, 4); } $template->assign_vars(array('S_AVATAR' => true, 'S_CAN_UPLOAD' => $can_upload && $config['allow_avatar_upload'] ? true : false, 'S_ALLOW_REMOTE' => $config['allow_avatar_remote'] ? true : false, 'S_DISPLAY_GALLERY' => $config['allow_avatar_local'] && !$display_gallery ? true : false, 'S_IN_GALLERY' => $config['allow_avatar_local'] && $display_gallery ? true : false, 'AVATAR_IMAGE' => $avatar_img, 'AVATAR_MAX_FILESIZE' => $config['avatar_filesize'], 'USER_AVATAR_WIDTH' => $user_row['user_avatar_width'], 'USER_AVATAR_HEIGHT' => $user_row['user_avatar_height'], 'L_AVATAR_EXPLAIN' => sprintf($user->lang['AVATAR_EXPLAIN'], $config['avatar_max_width'], $config['avatar_max_height'], round($config['avatar_filesize'] / 1024)))); break; case 'rank': if ($submit) { $rank_id = request_var('user_rank', 0); $sql = 'UPDATE ' . USERS_TABLE . "\n\t\t\t\t\t\tSET user_rank = {$rank_id}\n\t\t\t\t\t\tWHERE user_id = {$user_id}"; $db->sql_query($sql); trigger_error($user->lang['USER_RANK_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_id)); } $sql = 'SELECT * FROM ' . RANKS_TABLE . ' WHERE rank_special = 1 ORDER BY rank_title'; $result = $db->sql_query($sql); $s_rank_options = '<option value="0"' . (!$user_row['user_rank'] ? ' selected="selected"' : '') . '>' . $user->lang['NO_SPECIAL_RANK'] . '</option>'; while ($row = $db->sql_fetchrow($result)) { $selected = $user_row['user_rank'] && $row['rank_id'] == $user_row['user_rank'] ? ' selected="selected"' : ''; $s_rank_options .= '<option value="' . $row['rank_id'] . '"' . $selected . '>' . $row['rank_title'] . '</option>'; } $db->sql_freeresult($result); $template->assign_vars(array('S_RANK' => true, 'S_RANK_OPTIONS' => $s_rank_options)); break; case 'sig': include_once $phpbb_root_path . 'includes/functions_posting.' . $phpEx; $enable_bbcode = $config['allow_sig_bbcode'] ? request_var('enable_bbcode', $this->optionget($user_row, 'bbcode')) : false; $enable_smilies = $config['allow_sig_smilies'] ? request_var('enable_smilies', $this->optionget($user_row, 'smilies')) : false; $enable_urls = request_var('enable_urls', true); $signature = request_var('signature', $user_row['user_sig'], true); $preview = isset($_POST['preview']) ? true : false; if ($submit || $preview) { include_once $phpbb_root_path . 'includes/message_parser.' . $phpEx; $message_parser = new parse_message($signature); // Allowing Quote BBCode $message_parser->parse($enable_bbcode, $enable_urls, $enable_smilies, $config['allow_sig_img'], $config['allow_sig_flash'], true, true, 'sig'); if (sizeof($message_parser->warn_msg)) { $error[] = implode('<br />', $message_parser->warn_msg); } if (!sizeof($error) && $submit) { $sql_ary = array('user_sig' => (string) $message_parser->message, 'user_sig_bbcode_uid' => (string) $message_parser->bbcode_uid, 'user_sig_bbcode_bitfield' => (int) $message_parser->bbcode_bitfield); $sql = 'UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' WHERE user_id = ' . $user_id; $db->sql_query($sql); trigger_error($user->lang['USER_SIG_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); } $signature_preview = ''; if ($preview) { // Now parse it for displaying $signature_preview = $message_parser->format_display($enable_bbcode, $enable_urls, $enable_smilies, false); unset($message_parser); } decode_message($signature, $user_row['user_sig_bbcode_uid']); $template->assign_vars(array('S_SIGNATURE' => true, 'SIGNATURE' => $signature, 'SIGNATURE_PREVIEW' => $signature_preview, 'S_BBCODE_CHECKED' => !$enable_bbcode ? 'checked="checked"' : '', 'S_SMILIES_CHECKED' => !$enable_smilies ? 'checked="checked"' : '', 'S_MAGIC_URL_CHECKED' => !$enable_urls ? 'checked="checked"' : '', 'BBCODE_STATUS' => $config['allow_sig_bbcode'] ? sprintf($user->lang['BBCODE_IS_ON'], '<a href="' . append_sid("{$phpbb_root_path}faq.{$phpEx}", 'mode=bbcode') . '" onclick="target=\'_phpbbcode\';">', '</a>') : sprintf($user->lang['BBCODE_IS_OFF'], '<a href="' . append_sid("{$phpbb_root_path}faq.{$phpEx}", 'mode=bbcode') . '" onclick="target=\'_phpbbcode\';">', '</a>'), 'SMILIES_STATUS' => $config['allow_sig_smilies'] ? $user->lang['SMILIES_ARE_ON'] : $user->lang['SMILIES_ARE_OFF'], 'IMG_STATUS' => $config['allow_sig_img'] ? $user->lang['IMAGES_ARE_ON'] : $user->lang['IMAGES_ARE_OFF'], 'FLASH_STATUS' => $config['allow_sig_flash'] ? $user->lang['FLASH_IS_ON'] : $user->lang['FLASH_IS_OFF'], 'L_SIGNATURE_EXPLAIN' => sprintf($user->lang['SIGNATURE_EXPLAIN'], $config['max_sig_chars']), 'S_BBCODE_ALLOWED' => $config['allow_sig_bbcode'], 'S_SMILIES_ALLOWED' => $config['allow_sig_smilies'])); break; case 'attach': $start = request_var('start', 0); $deletemark = isset($_POST['delmarked']) ? true : false; $marked = request_var('mark', array(0)); // Sort keys $sort_key = request_var('sk', 'a'); $sort_dir = request_var('sd', 'd'); if ($deletemark && sizeof($marked)) { if (confirm_box(true)) { $sql = 'SELECT real_filename FROM ' . ATTACHMENTS_TABLE . ' WHERE attach_id IN (' . implode(', ', $marked) . ')'; $result = $db->sql_query($sql); $log_attachments = array(); while ($row = $db->sql_fetchrow($result)) { $log_attachments[] = $row['real_filename']; } $db->sql_freeresult($result); delete_attachments('attach', $marked); $log = sizeof($log_attachments) == 1 ? 'ATTACHMENT_DELETED' : 'ATTACHMENTS_DELETED'; $message = sizeof($log_attachments) == 1 ? $user->lang['ATTACHMENT_DELETED'] : $user->lang['ATTACHMENTS_DELETED']; add_log('admin', $log, implode(', ', $log_attachments)); trigger_error($message . 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, 'deletemark' => true, 'mark' => $marked))); } } $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']); $sk_sql = array('a' => 'a.real_filename', 'c' => 'a.extension', 'd' => 'a.filesize', 'e' => 'a.download_count', 'f' => 'a.filetime', 'g' => 't.topic_title'); $sd_text = array('a' => $user->lang['ASCENDING'], 'd' => $user->lang['DESCENDING']); $s_sort_key = ''; foreach ($sk_text as $key => $value) { $selected = $sort_key == $key ? ' selected="selected"' : ''; $s_sort_key .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>'; } $s_sort_dir = ''; foreach ($sd_text as $key => $value) { $selected = $sort_dir == $key ? ' selected="selected"' : ''; $s_sort_dir .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>'; } $order_by = $sk_sql[$sort_key] . ' ' . ($sort_dir == 'a' ? 'ASC' : 'DESC'); $sql = 'SELECT COUNT(attach_id) as num_attachments FROM ' . ATTACHMENTS_TABLE . "\n\t\t\t\t\tWHERE poster_id = {$user_id}"; $result = $db->sql_query_limit($sql, 1); $num_attachments = (int) $db->sql_fetchfield('num_attachments'); $db->sql_freeresult($result); $sql = 'SELECT a.*, t.topic_title, p.message_subject as message_title FROM ' . ATTACHMENTS_TABLE . ' a LEFT JOIN ' . TOPICS_TABLE . ' t ON (a.topic_id = t.topic_id AND a.in_message = 0) LEFT JOIN ' . PRIVMSGS_TABLE . ' p ON (a.post_msg_id = p.msg_id AND a.in_message = 1) WHERE a.poster_id = ' . $user_id . "\n\t\t\t\t\tORDER BY {$order_by}"; $result = $db->sql_query_limit($sql, $config['posts_per_page'], $start); while ($row = $db->sql_fetchrow($result)) { if ($row['in_message']) { $view_topic = append_sid("{$phpbb_root_path}ucp.{$phpEx}", "i=pm&p={$row['post_msg_id']}"); } else { $view_topic = append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", "t={$row['topic_id']}&p={$row['post_msg_id']}#{$row['post_msg_id']}"); } $template->assign_block_vars('attach', array('REAL_FILENAME' => $row['real_filename'], 'COMMENT' => nl2br($row['comment']), 'EXTENSION' => $row['extension'], 'SIZE' => $row['filesize'] >= 1048576 ? ($row['filesize'] >> 20) . ' ' . $user->lang['MB'] : ($row['filesize'] >= 1024 ? ($row['filesize'] >> 10) . ' ' . $user->lang['KB'] : $row['filesize'] . ' ' . $user->lang['BYTES']), 'DOWNLOAD_COUNT' => $row['download_count'], 'POST_TIME' => $user->format_date($row['filetime']), 'TOPIC_TITLE' => $row['in_message'] ? $row['message_title'] : $row['topic_title'], 'ATTACH_ID' => $row['attach_id'], 'POST_ID' => $row['post_msg_id'], 'TOPIC_ID' => $row['topic_id'], 'S_IN_MESSAGE' => $row['in_message'], 'U_DOWNLOAD' => append_sid("{$phpbb_root_path}download.{$phpEx}", 'id=' . $row['attach_id']), 'U_VIEW_TOPIC' => $view_topic)); } $db->sql_freeresult($result); $template->assign_vars(array('S_ATTACHMENTS' => true, 'S_ON_PAGE' => on_page($num_attachments, $config['topics_per_page'], $start), 'S_SORT_KEY' => $s_sort_key, 'S_SORT_DIR' => $s_sort_dir, 'PAGINATION' => generate_pagination($this->u_action . "&sk={$sort_key}&sd={$sort_dir}", $num_attachments, $config['topics_per_page'], $start, true))); break; case 'groups': $user->add_lang(array('groups', 'acp/groups')); $group_id = request_var('g', 0); switch ($action) { case 'demote': case 'promote': case 'default': group_user_attributes($action, $group_id, $user_id); if ($action == 'default') { $user_row['group_id'] = $group_id; } break; case 'delete': if (confirm_box(true)) { if (!$group_id) { trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action . '&u=' . $user_id)); } if ($error = group_user_del($group_id, $user_id)) { trigger_error($user->lang[$error] . adm_back_link($this->u_action . '&u=' . $user_id)); } $error = array(); } else { confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array('u' => $user_id, 'i' => $id, 'mode' => $mode, 'action' => $action, 'g' => $group_id))); } break; } // Add user to group? if ($submit) { if (!$group_id) { trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action . '&u=' . $user_id)); } // Add user/s to group if ($error = group_user_add($group_id, $user_id)) { trigger_error($user->lang[$error] . adm_back_link($this->u_action . '&u=' . $user_id)); } $error = array(); } $sql = 'SELECT ug.*, g.* FROM ' . GROUPS_TABLE . ' g, ' . USER_GROUP_TABLE . " ug\n\t\t\t\t\tWHERE ug.user_id = {$user_id}\n\t\t\t\t\t\tAND g.group_id = ug.group_id\n\t\t\t\t\tORDER BY g.group_type DESC, ug.user_pending ASC, g.group_name"; $result = $db->sql_query($sql); $i = 0; $group_data = $id_ary = array(); while ($row = $db->sql_fetchrow($result)) { $type = $row['group_type'] == GROUP_SPECIAL ? 'special' : ($row['user_pending'] ? 'pending' : 'normal'); $group_data[$type][$i]['group_id'] = $row['group_id']; $group_data[$type][$i]['group_name'] = $row['group_name']; $group_data[$type][$i]['group_leader'] = $row['group_leader'] ? 1 : 0; $id_ary[] = $row['group_id']; $i++; } $db->sql_freeresult($result); // Select box for other groups $sql = 'SELECT group_id, group_name, group_type FROM ' . GROUPS_TABLE . ' ' . (sizeof($id_ary) ? 'WHERE group_id NOT IN (' . implode(', ', $id_ary) . ')' : '') . ' ORDER BY group_type DESC, group_name ASC'; $result = $db->sql_query($sql); $s_group_options = ''; while ($row = $db->sql_fetchrow($result)) { if ($config['coppa_hide_groups'] && in_array($row['group_name'], array('INACTIVE_COPPA', 'REGISTERED_COPPA'))) { continue; } $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>'; } $db->sql_freeresult($result); $current_type = ''; foreach ($group_data as $group_type => $data_ary) { if ($current_type != $group_type) { $template->assign_block_vars('group', array('S_NEW_GROUP_TYPE' => true, 'GROUP_TYPE' => $user->lang['USER_GROUP_' . strtoupper($group_type)])); } foreach ($data_ary as $data) { $template->assign_block_vars('group', array('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"), 'U_DEFAULT' => $this->u_action . "&action=default&u={$user_id}&g=" . $data['group_id'], 'U_DEMOTE_PROMOTE' => $this->u_action . '&action=' . ($data['group_leader'] ? 'demote' : 'promote') . "&u={$user_id}&g=" . $data['group_id'], 'U_DELETE' => $this->u_action . "&action=delete&u={$user_id}&g=" . $data['group_id'], 'GROUP_NAME' => $group_type == 'special' ? $user->lang['G_' . $data['group_name']] : $data['group_name'], 'L_DEMOTE_PROMOTE' => $data['group_leader'] ? $user->lang['GROUP_DEMOTE'] : $user->lang['GROUP_PROMOTE'], 'S_NO_DEFAULT' => $user_row['group_id'] != $data['group_id'] ? true : false, 'S_SPECIAL_GROUP' => $group_type == 'special' ? true : false)); } } $template->assign_vars(array('S_GROUPS' => true, 'S_GROUP_OPTIONS' => $s_group_options)); break; case 'perm': include_once $phpbb_root_path . 'includes/acp/auth.' . $phpEx; $auth_admin = new auth_admin(); $user->add_lang('acp/permissions'); $user->add_lang('acp/permissions_phpbb'); // Select auth options $sql = 'SELECT auth_option, is_local, is_global FROM ' . ACL_OPTIONS_TABLE . "\n\t\t\t\t\tWHERE auth_option LIKE '%\\_'\n\t\t\t\t\t\tAND is_global = 1\n\t\t\t\t\tORDER BY auth_option"; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $hold_ary = $auth_admin->get_mask('view', $user_id, false, false, $row['auth_option'], 'global', ACL_NO); $auth_admin->display_mask('view', $row['auth_option'], $hold_ary, 'user', false, false); } $db->sql_freeresult($result); $sql = 'SELECT auth_option, is_local, is_global FROM ' . ACL_OPTIONS_TABLE . "\n\t\t\t\t\tWHERE auth_option LIKE '%\\_'\n\t\t\t\t\t\tAND is_local = 1\n\t\t\t\t\tORDER BY is_global DESC, auth_option"; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $hold_ary = $auth_admin->get_mask('view', $user_id, false, false, $row['auth_option'], 'local', ACL_NO); $auth_admin->display_mask('view', $row['auth_option'], $hold_ary, 'user', true, false); } $db->sql_freeresult($result); $template->assign_vars(array('S_PERMISSIONS' => true, 'U_USER_PERMISSIONS' => append_sid("{$phpbb_admin_path}index.{$phpEx}", 'i=permissions&mode=setting_user_global&user_id[]=' . $user_id), 'U_USER_FORUM_PERMISSIONS' => append_sid("{$phpbb_admin_path}index.{$phpEx}", 'i=permissions&mode=setting_user_local&user_id[]=' . $user_id))); break; } // Assign general variables $template->assign_vars(array('S_ERROR' => sizeof($error) ? true : false, 'ERROR_MSG' => sizeof($error) ? implode('<br />', $error) : '')); }
function main($id, $mode) { global $config, $db, $user, $auth, $template, $phpbb_root_path, $phpEx; // if ($config['require_activation'] == USER_ACTIVATION_DISABLE) { trigger_error('UCP_REGISTER_DISABLE'); } include $phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx; $coppa = isset($_REQUEST['coppa']) ? !empty($_REQUEST['coppa']) ? 1 : 0 : false; $agreed = !empty($_POST['agreed']) ? 1 : 0; $submit = isset($_POST['submit']) ? true : false; $change_lang = request_var('change_lang', ''); $user_lang = request_var('lang', $user->lang_name); if ($agreed) { add_form_key('ucp_register'); } else { add_form_key('ucp_register_terms'); } if ($change_lang || $user_lang != $config['default_lang']) { $use_lang = $change_lang ? basename($change_lang) : basename($user_lang); if (!validate_language_iso_name($use_lang)) { if ($change_lang) { $submit = false; // Setting back agreed to let the user view the agreement in his/her language $agreed = empty($_GET['change_lang']) ? 0 : $agreed; } $user->lang_name = $user_lang = $use_lang; $user->lang = array(); $user->data['user_lang'] = $user->lang_name; $user->add_lang(array('common', 'ucp')); } else { $change_lang = ''; $user_lang = $user->lang_name; } } $cp = new custom_profile(); $error = $cp_data = $cp_error = array(); if (!$agreed || $coppa === false && $config['coppa_enable'] || $coppa && !$config['coppa_enable']) { $add_lang = $change_lang ? '&change_lang=' . urlencode($change_lang) : ''; $add_coppa = $coppa !== false ? '&coppa=' . $coppa : ''; $s_hidden_fields = array('change_lang' => $change_lang); // If we change the language, we want to pass on some more possible parameter. if ($change_lang) { // We do not include the password $s_hidden_fields = array_merge($s_hidden_fields, array('username' => utf8_normalize_nfc(request_var('username', '', true)), 'email' => strtolower(request_var('email', '')), 'email_confirm' => strtolower(request_var('email_confirm', '')), 'lang' => $user->lang_name, 'tz' => request_var('tz', (double) $config['board_timezone']))); } // Checking amount of available languages $sql = 'SELECT lang_id FROM ' . LANG_TABLE; $result = $db->sql_query($sql); $lang_row = array(); while ($row = $db->sql_fetchrow($result)) { $lang_row[] = $row; } $db->sql_freeresult($result); if ($coppa === false && $config['coppa_enable']) { $now = getdate(); $coppa_birthday = $user->format_date(mktime($now['hours'] + $user->data['user_dst'], $now['minutes'], $now['seconds'], $now['mon'], $now['mday'] - 1, $now['year'] - 13), $user->lang['DATE_FORMAT']); unset($now); $template->assign_vars(array('S_LANG_OPTIONS' => sizeof($lang_row) > 1 ? language_select($user_lang) : '', 'L_COPPA_NO' => sprintf($user->lang['UCP_COPPA_BEFORE'], $coppa_birthday), 'L_COPPA_YES' => sprintf($user->lang['UCP_COPPA_ON_AFTER'], $coppa_birthday), 'U_COPPA_NO' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=register&coppa=0' . $add_lang), 'U_COPPA_YES' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=register&coppa=1' . $add_lang), 'S_SHOW_COPPA' => true, 'S_HIDDEN_FIELDS' => build_hidden_fields($s_hidden_fields), 'S_UCP_ACTION' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=register' . $add_lang))); } else { $template->assign_vars(array('S_LANG_OPTIONS' => sizeof($lang_row) > 1 ? language_select($user_lang) : '', 'L_TERMS_OF_USE' => sprintf($user->lang['TERMS_OF_USE_CONTENT'], $config['sitename'], generate_board_url()), 'S_SHOW_COPPA' => false, 'S_REGISTRATION' => true, 'S_HIDDEN_FIELDS' => build_hidden_fields($s_hidden_fields), 'S_UCP_ACTION' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=register' . $add_lang . $add_coppa))); } unset($lang_row); $this->tpl_name = 'ucp_agreement'; return; } // The CAPTCHA kicks in here. We can't help that the information gets lost on language change. if ($config['enable_confirm']) { include $phpbb_root_path . 'includes/captcha/captcha_factory.' . $phpEx; $captcha =& phpbb_captcha_factory::get_instance($config['captcha_plugin']); $captcha->init(CONFIRM_REG); } // Try to manually determine the timezone and adjust the dst if the server date/time complies with the default setting +/- 1 $timezone = date('Z') / 3600; $is_dst = date('I'); if ($config['board_timezone'] == $timezone || $config['board_timezone'] == $timezone - 1) { $timezone = $is_dst ? $timezone - 1 : $timezone; if (!isset($user->lang['tz_zones'][(string) $timezone])) { $timezone = $config['board_timezone']; } } else { $is_dst = $config['board_dst']; $timezone = $config['board_timezone']; } $data = array('username' => utf8_normalize_nfc(request_var('username', '', true)), 'new_password' => request_var('new_password', '', true), 'password_confirm' => request_var('password_confirm', '', true), 'email' => strtolower(request_var('email', '')), 'email_confirm' => strtolower(request_var('email_confirm', '')), 'lang' => basename(request_var('lang', $user->lang_name)), 'tz' => request_var('tz', (double) $timezone)); // Check and initialize some variables if needed if ($submit) { $error = validate_data($data, array('username' => array(array('string', false, $config['min_name_chars'], $config['max_name_chars']), array('username', '')), 'new_password' => array(array('string', false, $config['min_pass_chars'], $config['max_pass_chars']), array('password')), 'password_confirm' => array('string', false, $config['min_pass_chars'], $config['max_pass_chars']), 'email' => array(array('string', false, 6, 60), array('email')), 'email_confirm' => array('string', false, 6, 60), 'tz' => array('num', false, -14, 14), 'lang' => array('language_iso_name'))); if (!check_form_key('ucp_register')) { $error[] = $user->lang['FORM_INVALID']; } // Replace "error" strings with their real, localised form $error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error); if ($config['enable_confirm']) { $vc_response = $captcha->validate($data); if ($vc_response !== false) { $error[] = $vc_response; } if ($config['max_reg_attempts'] && $captcha->get_attempt_count() > $config['max_reg_attempts']) { $error[] = $user->lang['TOO_MANY_REGISTERS']; } } // DNSBL check if ($config['check_dnsbl']) { if (($dnsbl = $user->check_dnsbl('register')) !== false) { $error[] = sprintf($user->lang['IP_BLACKLISTED'], $user->ip, $dnsbl[1]); } } // validate custom profile fields $cp->submit_cp_field('register', $user->get_iso_lang_id(), $cp_data, $error); if (!sizeof($error)) { if ($data['new_password'] != $data['password_confirm']) { $error[] = $user->lang['NEW_PASSWORD_ERROR']; } if ($data['email'] != $data['email_confirm']) { $error[] = $user->lang['NEW_EMAIL_ERROR']; } } if (!sizeof($error)) { $server_url = generate_board_url(); // Which group by default? $group_name = $coppa ? 'REGISTERED_COPPA' : 'REGISTERED'; $sql = 'SELECT group_id FROM ' . GROUPS_TABLE . "\n\t\t\t\t\tWHERE group_name = '" . $db->sql_escape($group_name) . "'\n\t\t\t\t\t\tAND group_type = " . GROUP_SPECIAL; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); if (!$row) { trigger_error('NO_GROUP'); } $group_id = $row['group_id']; if (($coppa || $config['require_activation'] == USER_ACTIVATION_SELF || $config['require_activation'] == USER_ACTIVATION_ADMIN) && $config['email_enable']) { $user_actkey = gen_rand_string(mt_rand(6, 10)); $user_type = USER_INACTIVE; $user_inactive_reason = INACTIVE_REGISTER; $user_inactive_time = time(); } else { $user_type = USER_NORMAL; $user_actkey = ''; $user_inactive_reason = 0; $user_inactive_time = 0; } $user_row = array('username' => $data['username'], 'user_password' => phpbb_hash($data['new_password']), 'user_email' => $data['email'], 'group_id' => (int) $group_id, 'user_timezone' => (double) $data['tz'], 'user_dst' => $is_dst, 'user_lang' => $data['lang'], 'user_type' => $user_type, 'user_actkey' => $user_actkey, 'user_ip' => $user->ip, 'user_regdate' => time(), 'user_inactive_reason' => $user_inactive_reason, 'user_inactive_time' => $user_inactive_time); if ($config['new_member_post_limit']) { $user_row['user_new'] = 1; } // Register user... $user_id = user_add($user_row, $cp_data); // This should not happen, because the required variables are listed above... if ($user_id === false) { trigger_error('NO_USER', E_USER_ERROR); } // Okay, captcha, your job is done. if ($config['enable_confirm'] && isset($captcha)) { $captcha->reset(); } if ($coppa && $config['email_enable']) { $message = $user->lang['ACCOUNT_COPPA']; $email_template = 'coppa_welcome_inactive'; } else { if ($config['require_activation'] == USER_ACTIVATION_SELF && $config['email_enable']) { $message = $user->lang['ACCOUNT_INACTIVE']; $email_template = 'user_welcome_inactive'; } else { if ($config['require_activation'] == USER_ACTIVATION_ADMIN && $config['email_enable']) { $message = $user->lang['ACCOUNT_INACTIVE_ADMIN']; $email_template = 'admin_welcome_inactive'; } else { $message = $user->lang['ACCOUNT_ADDED']; $email_template = 'user_welcome'; } } } if ($config['email_enable']) { include_once $phpbb_root_path . 'includes/functions_messenger.' . $phpEx; $messenger = new messenger(false); $messenger->template($email_template, $data['lang']); $messenger->to($data['email'], $data['username']); $messenger->anti_abuse_headers($config, $user); $messenger->assign_vars(array('WELCOME_MSG' => htmlspecialchars_decode(sprintf($user->lang['WELCOME_SUBJECT'], $config['sitename'])), 'USERNAME' => htmlspecialchars_decode($data['username']), 'PASSWORD' => htmlspecialchars_decode($data['new_password']), 'U_ACTIVATE' => "{$server_url}/ucp.{$phpEx}?mode=activate&u={$user_id}&k={$user_actkey}")); if ($coppa) { $messenger->assign_vars(array('FAX_INFO' => $config['coppa_fax'], 'MAIL_INFO' => $config['coppa_mail'], 'EMAIL_ADDRESS' => $data['email'])); } $messenger->send(NOTIFY_EMAIL); if ($config['require_activation'] == USER_ACTIVATION_ADMIN) { // Grab an array of user_id's with a_user permissions ... these users can activate a user $admin_ary = $auth->acl_get_list(false, 'a_user', false); $admin_ary = !empty($admin_ary[0]['a_user']) ? $admin_ary[0]['a_user'] : array(); // Also include founders $where_sql = ' WHERE user_type = ' . USER_FOUNDER; if (sizeof($admin_ary)) { $where_sql .= ' OR ' . $db->sql_in_set('user_id', $admin_ary); } $sql = 'SELECT user_id, username, user_email, user_lang, user_jabber, user_notify_type FROM ' . USERS_TABLE . ' ' . $where_sql; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $messenger->template('admin_activate', $row['user_lang']); $messenger->to($row['user_email'], $row['username']); $messenger->im($row['user_jabber'], $row['username']); $messenger->assign_vars(array('USERNAME' => htmlspecialchars_decode($data['username']), 'U_USER_DETAILS' => "{$server_url}/memberlist.{$phpEx}?mode=viewprofile&u={$user_id}", 'U_ACTIVATE' => "{$server_url}/ucp.{$phpEx}?mode=activate&u={$user_id}&k={$user_actkey}")); $messenger->send($row['user_notify_type']); } $db->sql_freeresult($result); } } $message = $message . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid("{$phpbb_root_path}index.{$phpEx}") . '">', '</a>'); trigger_error($message); } } $s_hidden_fields = array('agreed' => 'true', 'change_lang' => 0); if ($config['coppa_enable']) { $s_hidden_fields['coppa'] = $coppa; } if ($config['enable_confirm']) { $s_hidden_fields = array_merge($s_hidden_fields, $captcha->get_hidden_fields()); } $s_hidden_fields = build_hidden_fields($s_hidden_fields); $confirm_image = ''; // Visual Confirmation - Show images if ($config['enable_confirm']) { $template->assign_vars(array('CAPTCHA_TEMPLATE' => $captcha->get_template())); } // $l_reg_cond = ''; switch ($config['require_activation']) { case USER_ACTIVATION_SELF: $l_reg_cond = $user->lang['UCP_EMAIL_ACTIVATE']; break; case USER_ACTIVATION_ADMIN: $l_reg_cond = $user->lang['UCP_ADMIN_ACTIVATE']; break; } $template->assign_vars(array('ERROR' => sizeof($error) ? implode('<br />', $error) : '', 'USERNAME' => $data['username'], 'PASSWORD' => $data['new_password'], 'PASSWORD_CONFIRM' => $data['password_confirm'], 'EMAIL' => $data['email'], 'EMAIL_CONFIRM' => $data['email_confirm'], 'L_REG_COND' => $l_reg_cond, 'L_USERNAME_EXPLAIN' => sprintf($user->lang[$config['allow_name_chars'] . '_EXPLAIN'], $config['min_name_chars'], $config['max_name_chars']), 'L_PASSWORD_EXPLAIN' => sprintf($user->lang[$config['pass_complex'] . '_EXPLAIN'], $config['min_pass_chars'], $config['max_pass_chars']), 'S_LANG_OPTIONS' => language_select($data['lang']), 'S_TZ_OPTIONS' => tz_select($data['tz']), 'S_CONFIRM_REFRESH' => $config['enable_confirm'] && $config['confirm_refresh'] ? true : false, 'S_REGISTRATION' => true, 'S_COPPA' => $coppa, 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'S_UCP_ACTION' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=register'))); // $user->profile_fields = array(); // Generate profile fields -> Template Block Variable profile_fields $cp->generate_profile_fields('register', $user->get_iso_lang_id()); // $this->tpl_name = 'ucp_register'; $this->page_title = 'UCP_REGISTRATION'; }
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 . "\n\t\t\t\tWHERE 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 . "\n\t\t\tWHERE module_basename = 'users'\n\t\t\t\tAND module_enabled = 1\n\t\t\t\tAND module_class = 'acp'\n\t\t\tORDER 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 . "\n\t\t\t\t\t\t\t\t\t\tWHERE 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 . "\n\t\t\t\t\t\t\t\t\t\tSET user_actkey = '" . $db->sql_escape($user_actkey) . "'\n\t\t\t\t\t\t\t\t\t\tWHERE 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) . "\n\t\t\t\t\t\t\t\tWHERE 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) . "\n\t\t\t\t\t\t\t\tWHERE 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 . "\n\t\t\t\t\t\t\t\t\tWHERE author_id = {$user_id}\n\t\t\t\t\t\t\t\t\t\tAND 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 . "\n\t\t\t\t\t\t\t\tWHERE 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 . "\n\t\t\t\t\t\t\t\tWHERE poster_id = {$user_id}\n\t\t\t\t\t\t\t\t\tAND forum_id <> {$new_forum_id}\n\t\t\t\t\t\t\t\tGROUP 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 . "\n\t\t\t\t\t\t\t\t\t\tSET forum_id = {$new_forum_id}, topic_id = {$new_topic_id}\n\t\t\t\t\t\t\t\t\t\tWHERE topic_id = {$topic_id}\n\t\t\t\t\t\t\t\t\t\t\tAND poster_id = {$user_id}"; $db->sql_query($sql); if ($post_ary['attach']) { $sql = 'UPDATE ' . ATTACHMENTS_TABLE . "\n\t\t\t\t\t\t\t\t\t\t\tSET topic_id = {$new_topic_id}\n\t\t\t\t\t\t\t\t\t\t\tWHERE topic_id = {$topic_id}\n\t\t\t\t\t\t\t\t\t\t\t\tAND 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 . "\n\t\t\t\t\t\tWHERE 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 . "\n\t\t\t\t\t\t\tAND reportee_id = {$user_id}\n\t\t\t\t\t\t\t{$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 . "\n\t\t\t\t\t\t\t\tWHERE user_id = {$user_id}\n\t\t\t\t\t\t\t\t\t{$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 . "\n\t\t\t\t\t\t\t\tSET user_warnings = {$deleted_warnings}\n\t\t\t\t\t\t\t\tWHERE 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 . "\n\t\t\t\t\tWHERE 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) . "\n\t\t\t\t\t\t\tWHERE 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"' : ''; $s_birthday_year_options .= "<option value=\"{$i}\"{$selected}>{$i}</option>"; } unset($now); $template->assign_vars(array('ICQ' => $data['icq'], 'YIM' => $data['yim'], 'AIM' => $data['aim'], 'MSN' => $data['msn'], 'JABBER' => $data['jabber'], 'WEBSITE' => $data['website'], 'LOCATION' => $data['location'], 'OCCUPATION' => $data['occupation'], 'INTERESTS' => $data['interests'], 'S_BIRTHDAY_DAY_OPTIONS' => $s_birthday_day_options, 'S_BIRTHDAY_MONTH_OPTIONS' => $s_birthday_month_options, 'S_BIRTHDAY_YEAR_OPTIONS' => $s_birthday_year_options, 'S_PROFILE' => true)); // Get additional profile fields and assign them to the template block var 'profile_fields' $user->get_profile_fields($user_id); $cp->generate_profile_fields('profile', $user_row['iso_lang_id']); break; case 'prefs': include $phpbb_root_path . 'includes/functions_user.' . $phpEx; $data = array('dateformat' => utf8_normalize_nfc(request_var('dateformat', $user_row['user_dateformat'], true)), 'lang' => basename(request_var('lang', $user_row['user_lang'])), 'tz' => request_var('tz', (double) $user_row['user_timezone']), 'style' => request_var('style', $user_row['user_style']), 'dst' => request_var('dst', $user_row['user_dst']), 'viewemail' => request_var('viewemail', $user_row['user_allow_viewemail']), 'massemail' => request_var('massemail', $user_row['user_allow_massemail']), 'hideonline' => request_var('hideonline', !$user_row['user_allow_viewonline']), 'notifymethod' => request_var('notifymethod', $user_row['user_notify_type']), 'notifypm' => request_var('notifypm', $user_row['user_notify_pm']), 'popuppm' => request_var('popuppm', $this->optionget($user_row, 'popuppm')), 'allowpm' => request_var('allowpm', $user_row['user_allow_pm']), 'topic_sk' => request_var('topic_sk', $user_row['user_topic_sortby_type'] ? $user_row['user_topic_sortby_type'] : 't'), 'topic_sd' => request_var('topic_sd', $user_row['user_topic_sortby_dir'] ? $user_row['user_topic_sortby_dir'] : 'd'), 'topic_st' => request_var('topic_st', $user_row['user_topic_show_days'] ? $user_row['user_topic_show_days'] : 0), 'post_sk' => request_var('post_sk', $user_row['user_post_sortby_type'] ? $user_row['user_post_sortby_type'] : 't'), 'post_sd' => request_var('post_sd', $user_row['user_post_sortby_dir'] ? $user_row['user_post_sortby_dir'] : 'a'), 'post_st' => request_var('post_st', $user_row['user_post_show_days'] ? $user_row['user_post_show_days'] : 0), 'view_images' => request_var('view_images', $this->optionget($user_row, 'viewimg')), 'view_flash' => request_var('view_flash', $this->optionget($user_row, 'viewflash')), 'view_smilies' => request_var('view_smilies', $this->optionget($user_row, 'viewsmilies')), 'view_sigs' => request_var('view_sigs', $this->optionget($user_row, 'viewsigs')), 'view_avatars' => request_var('view_avatars', $this->optionget($user_row, 'viewavatars')), 'view_wordcensor' => request_var('view_wordcensor', $this->optionget($user_row, 'viewcensors')), 'bbcode' => request_var('bbcode', $this->optionget($user_row, 'bbcode')), 'smilies' => request_var('smilies', $this->optionget($user_row, 'smilies')), 'sig' => request_var('sig', $this->optionget($user_row, 'attachsig')), 'notify' => request_var('notify', $user_row['user_notify'])); if ($submit) { $error = validate_data($data, array('dateformat' => array('string', false, 1, 30), 'lang' => array('match', false, '#^[a-z_\\-]{2,}$#i'), 'tz' => array('num', false, -14, 14), 'topic_sk' => array('string', false, 1, 1), 'topic_sd' => array('string', false, 1, 1), 'post_sk' => array('string', false, 1, 1), 'post_sd' => array('string', false, 1, 1))); if (!check_form_key($form_name)) { $error[] = 'FORM_INVALID'; } if (!sizeof($error)) { $this->optionset($user_row, 'popuppm', $data['popuppm']); $this->optionset($user_row, 'viewimg', $data['view_images']); $this->optionset($user_row, 'viewflash', $data['view_flash']); $this->optionset($user_row, 'viewsmilies', $data['view_smilies']); $this->optionset($user_row, 'viewsigs', $data['view_sigs']); $this->optionset($user_row, 'viewavatars', $data['view_avatars']); $this->optionset($user_row, 'viewcensors', $data['view_wordcensor']); $this->optionset($user_row, 'bbcode', $data['bbcode']); $this->optionset($user_row, 'smilies', $data['smilies']); $this->optionset($user_row, 'attachsig', $data['sig']); $sql_ary = array('user_options' => $user_row['user_options'], 'user_allow_pm' => $data['allowpm'], 'user_allow_viewemail' => $data['viewemail'], 'user_allow_massemail' => $data['massemail'], 'user_allow_viewonline' => !$data['hideonline'], 'user_notify_type' => $data['notifymethod'], 'user_notify_pm' => $data['notifypm'], 'user_dst' => $data['dst'], 'user_dateformat' => $data['dateformat'], 'user_lang' => $data['lang'], 'user_timezone' => $data['tz'], 'user_style' => $data['style'], 'user_topic_sortby_type' => $data['topic_sk'], 'user_post_sortby_type' => $data['post_sk'], 'user_topic_sortby_dir' => $data['topic_sd'], 'user_post_sortby_dir' => $data['post_sd'], 'user_topic_show_days' => $data['topic_st'], 'user_post_show_days' => $data['post_st'], 'user_notify' => $data['notify']); $sql = 'UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "\n\t\t\t\t\t\t\tWHERE user_id = {$user_id}"; $db->sql_query($sql); // Check if user has an active session if ($user_row['session_id']) { // We'll update the session if user_allow_viewonline has changed and the user is a bot // Or if it's a regular user and the admin set it to hide the session if ($user_row['user_allow_viewonline'] != $sql_ary['user_allow_viewonline'] && $user_row['user_type'] == USER_IGNORE || $user_row['user_allow_viewonline'] && !$sql_ary['user_allow_viewonline']) { // We also need to check if the user has the permission to cloak. $user_auth = new auth(); $user_auth->acl($user_row); $session_sql_ary = array('session_viewonline' => $user_auth->acl_get('u_hideonline') ? $sql_ary['user_allow_viewonline'] : true); $sql = 'UPDATE ' . SESSIONS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $session_sql_ary) . "\n\t\t\t\t\t\t\t\t\tWHERE session_user_id = {$user_id}"; $db->sql_query($sql); unset($user_auth); } } trigger_error($user->lang['USER_PREFS_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); } $dateformat_options = ''; foreach ($user->lang['dateformats'] as $format => $null) { $dateformat_options .= '<option value="' . $format . '"' . ($format == $data['dateformat'] ? ' selected="selected"' : '') . '>'; $dateformat_options .= $user->format_date(time(), $format, false) . (strpos($format, '|') !== false ? $user->lang['VARIANT_DATE_SEPARATOR'] . $user->format_date(time(), $format, true) : ''); $dateformat_options .= '</option>'; } $s_custom = false; $dateformat_options .= '<option value="custom"'; if (!isset($user->lang['dateformats'][$data['dateformat']])) { $dateformat_options .= ' selected="selected"'; $s_custom = true; } $dateformat_options .= '>' . $user->lang['CUSTOM_DATEFORMAT'] . '</option>'; $sort_dir_text = array('a' => $user->lang['ASCENDING'], 'd' => $user->lang['DESCENDING']); // Topic ordering options $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']); $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']); // Post ordering options $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']); $sort_by_post_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 's' => $user->lang['SUBJECT']); $_options = array('topic', 'post'); foreach ($_options as $sort_option) { ${'s_limit_' . $sort_option . '_days'} = '<select name="' . $sort_option . '_st">'; foreach (${'limit_' . $sort_option . '_days'} as $day => $text) { $selected = $data[$sort_option . '_st'] == $day ? ' selected="selected"' : ''; ${'s_limit_' . $sort_option . '_days'} .= '<option value="' . $day . '"' . $selected . '>' . $text . '</option>'; } ${'s_limit_' . $sort_option . '_days'} .= '</select>'; ${'s_sort_' . $sort_option . '_key'} = '<select name="' . $sort_option . '_sk">'; foreach (${'sort_by_' . $sort_option . '_text'} as $key => $text) { $selected = $data[$sort_option . '_sk'] == $key ? ' selected="selected"' : ''; ${'s_sort_' . $sort_option . '_key'} .= '<option value="' . $key . '"' . $selected . '>' . $text . '</option>'; } ${'s_sort_' . $sort_option . '_key'} .= '</select>'; ${'s_sort_' . $sort_option . '_dir'} = '<select name="' . $sort_option . '_sd">'; foreach ($sort_dir_text as $key => $value) { $selected = $data[$sort_option . '_sd'] == $key ? ' selected="selected"' : ''; ${'s_sort_' . $sort_option . '_dir'} .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>'; } ${'s_sort_' . $sort_option . '_dir'} .= '</select>'; } $template->assign_vars(array('S_PREFS' => true, 'S_JABBER_DISABLED' => $config['jab_enable'] && $user_row['user_jabber'] && @extension_loaded('xml') ? false : true, 'VIEW_EMAIL' => $data['viewemail'], 'MASS_EMAIL' => $data['massemail'], 'ALLOW_PM' => $data['allowpm'], 'HIDE_ONLINE' => $data['hideonline'], 'NOTIFY_EMAIL' => $data['notifymethod'] == NOTIFY_EMAIL ? true : false, 'NOTIFY_IM' => $data['notifymethod'] == NOTIFY_IM ? true : false, 'NOTIFY_BOTH' => $data['notifymethod'] == NOTIFY_BOTH ? true : false, 'NOTIFY_PM' => $data['notifypm'], 'POPUP_PM' => $data['popuppm'], 'DST' => $data['dst'], 'BBCODE' => $data['bbcode'], 'SMILIES' => $data['smilies'], 'ATTACH_SIG' => $data['sig'], 'NOTIFY' => $data['notify'], 'VIEW_IMAGES' => $data['view_images'], 'VIEW_FLASH' => $data['view_flash'], 'VIEW_SMILIES' => $data['view_smilies'], 'VIEW_SIGS' => $data['view_sigs'], 'VIEW_AVATARS' => $data['view_avatars'], 'VIEW_WORDCENSOR' => $data['view_wordcensor'], 'S_TOPIC_SORT_DAYS' => $s_limit_topic_days, 'S_TOPIC_SORT_KEY' => $s_sort_topic_key, 'S_TOPIC_SORT_DIR' => $s_sort_topic_dir, 'S_POST_SORT_DAYS' => $s_limit_post_days, 'S_POST_SORT_KEY' => $s_sort_post_key, 'S_POST_SORT_DIR' => $s_sort_post_dir, 'DATE_FORMAT' => $data['dateformat'], 'S_DATEFORMAT_OPTIONS' => $dateformat_options, 'S_CUSTOM_DATEFORMAT' => $s_custom, 'DEFAULT_DATEFORMAT' => $config['default_dateformat'], 'A_DEFAULT_DATEFORMAT' => addslashes($config['default_dateformat']), 'S_LANG_OPTIONS' => language_select($data['lang']), 'S_STYLE_OPTIONS' => style_select($data['style']), 'S_TZ_OPTIONS' => tz_select($data['tz'], true))); break; case 'avatar': include $phpbb_root_path . 'includes/functions_display.' . $phpEx; include $phpbb_root_path . 'includes/functions_user.' . $phpEx; $can_upload = file_exists($phpbb_root_path . $config['avatar_path']) && phpbb_is_writable($phpbb_root_path . $config['avatar_path']) && $file_uploads ? true : false; if ($submit) { 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 (avatar_process_user($error, $user_row, $can_upload)) { trigger_error($user->lang['USER_AVATAR_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_row['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 (!$config['allow_avatar'] && $user_row['user_avatar_type']) { $error[] = $user->lang['USER_AVATAR_NOT_ALLOWED']; } else { if ($user_row['user_avatar_type'] == AVATAR_UPLOAD && !$config['allow_avatar_upload'] || $user_row['user_avatar_type'] == AVATAR_REMOTE && !$config['allow_avatar_remote'] || $user_row['user_avatar_type'] == AVATAR_GALLERY && !$config['allow_avatar_local']) { $error[] = $user->lang['USER_AVATAR_TYPE_NOT_ALLOWED']; } } // Generate users avatar $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="" />'; $display_gallery = isset($_POST['display_gallery']) ? true : false; $avatar_select = basename(request_var('avatar_select', '')); $category = basename(request_var('category', '')); if ($config['allow_avatar_local'] && $display_gallery) { avatar_gallery($category, $avatar_select, 4); } $template->assign_vars(array('S_AVATAR' => true, 'S_CAN_UPLOAD' => $can_upload, 'S_UPLOAD_FILE' => $config['allow_avatar'] && $can_upload && $config['allow_avatar_upload'] ? true : false, 'S_REMOTE_UPLOAD' => $config['allow_avatar'] && $can_upload && $config['allow_avatar_remote_upload'] ? true : false, 'S_ALLOW_REMOTE' => $config['allow_avatar'] && $config['allow_avatar_remote'] ? true : false, 'S_DISPLAY_GALLERY' => $config['allow_avatar'] && $config['allow_avatar_local'] && !$display_gallery ? true : false, 'S_IN_GALLERY' => $config['allow_avatar'] && $config['allow_avatar_local'] && $display_gallery ? true : false, 'AVATAR_IMAGE' => $avatar_img, 'AVATAR_MAX_FILESIZE' => $config['avatar_filesize'], 'USER_AVATAR_WIDTH' => $user_row['user_avatar_width'], 'USER_AVATAR_HEIGHT' => $user_row['user_avatar_height'], 'L_AVATAR_EXPLAIN' => sprintf($user->lang['AVATAR_EXPLAIN'], $config['avatar_max_width'], $config['avatar_max_height'], round($config['avatar_filesize'] / 1024)))); break; case 'rank': if ($submit) { if (!check_form_key($form_name)) { trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } $rank_id = request_var('user_rank', 0); $sql = 'UPDATE ' . USERS_TABLE . "\n\t\t\t\t\t\tSET user_rank = {$rank_id}\n\t\t\t\t\t\tWHERE user_id = {$user_id}"; $db->sql_query($sql); trigger_error($user->lang['USER_RANK_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_id)); } $sql = 'SELECT * FROM ' . RANKS_TABLE . ' WHERE rank_special = 1 ORDER BY rank_title'; $result = $db->sql_query($sql); $s_rank_options = '<option value="0"' . (!$user_row['user_rank'] ? ' selected="selected"' : '') . '>' . $user->lang['NO_SPECIAL_RANK'] . '</option>'; while ($row = $db->sql_fetchrow($result)) { $selected = $user_row['user_rank'] && $row['rank_id'] == $user_row['user_rank'] ? ' selected="selected"' : ''; $s_rank_options .= '<option value="' . $row['rank_id'] . '"' . $selected . '>' . $row['rank_title'] . '</option>'; } $db->sql_freeresult($result); $template->assign_vars(array('S_RANK' => true, 'S_RANK_OPTIONS' => $s_rank_options)); break; case 'sig': include_once $phpbb_root_path . 'includes/functions_posting.' . $phpEx; include_once $phpbb_root_path . 'includes/functions_display.' . $phpEx; $enable_bbcode = $config['allow_sig_bbcode'] ? (bool) $this->optionget($user_row, 'sig_bbcode') : false; $enable_smilies = $config['allow_sig_smilies'] ? (bool) $this->optionget($user_row, 'sig_smilies') : false; $enable_urls = $config['allow_sig_links'] ? (bool) $this->optionget($user_row, 'sig_links') : false; $signature = utf8_normalize_nfc(request_var('signature', (string) $user_row['user_sig'], true)); $preview = isset($_POST['preview']) ? true : false; if ($submit || $preview) { include_once $phpbb_root_path . 'includes/message_parser.' . $phpEx; $enable_bbcode = $config['allow_sig_bbcode'] ? request_var('disable_bbcode', false) ? false : true : false; $enable_smilies = $config['allow_sig_smilies'] ? request_var('disable_smilies', false) ? false : true : false; $enable_urls = $config['allow_sig_links'] ? request_var('disable_magic_url', false) ? false : true : false; $message_parser = new parse_message($signature); // Allowing Quote BBCode $message_parser->parse($enable_bbcode, $enable_urls, $enable_smilies, $config['allow_sig_img'], $config['allow_sig_flash'], true, $config['allow_sig_links'], true, 'sig'); if (sizeof($message_parser->warn_msg)) { $error[] = implode('<br />', $message_parser->warn_msg); } if (!check_form_key($form_name)) { $error = 'FORM_INVALID'; } if (!sizeof($error) && $submit) { $this->optionset($user_row, 'sig_bbcode', $enable_bbcode); $this->optionset($user_row, 'sig_smilies', $enable_smilies); $this->optionset($user_row, 'sig_links', $enable_urls); $sql_ary = array('user_sig' => (string) $message_parser->message, 'user_options' => $user_row['user_options'], 'user_sig_bbcode_uid' => (string) $message_parser->bbcode_uid, 'user_sig_bbcode_bitfield' => (string) $message_parser->bbcode_bitfield); $sql = 'UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' WHERE user_id = ' . $user_id; $db->sql_query($sql); trigger_error($user->lang['USER_SIG_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); } $signature_preview = ''; if ($preview) { // Now parse it for displaying $signature_preview = $message_parser->format_display($enable_bbcode, $enable_urls, $enable_smilies, false); unset($message_parser); } decode_message($signature, $user_row['user_sig_bbcode_uid']); $template->assign_vars(array('S_SIGNATURE' => true, 'SIGNATURE' => $signature, 'SIGNATURE_PREVIEW' => $signature_preview, 'S_BBCODE_CHECKED' => !$enable_bbcode ? ' checked="checked"' : '', 'S_SMILIES_CHECKED' => !$enable_smilies ? ' checked="checked"' : '', 'S_MAGIC_URL_CHECKED' => !$enable_urls ? ' checked="checked"' : '', '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>'), 'SMILIES_STATUS' => $config['allow_sig_smilies'] ? $user->lang['SMILIES_ARE_ON'] : $user->lang['SMILIES_ARE_OFF'], 'IMG_STATUS' => $config['allow_sig_img'] ? $user->lang['IMAGES_ARE_ON'] : $user->lang['IMAGES_ARE_OFF'], 'FLASH_STATUS' => $config['allow_sig_flash'] ? $user->lang['FLASH_IS_ON'] : $user->lang['FLASH_IS_OFF'], 'URL_STATUS' => $config['allow_sig_links'] ? $user->lang['URL_IS_ON'] : $user->lang['URL_IS_OFF'], 'L_SIGNATURE_EXPLAIN' => sprintf($user->lang['SIGNATURE_EXPLAIN'], $config['max_sig_chars']), 'S_BBCODE_ALLOWED' => $config['allow_sig_bbcode'], 'S_SMILIES_ALLOWED' => $config['allow_sig_smilies'], 'S_BBCODE_IMG' => $config['allow_sig_img'] ? true : false, 'S_BBCODE_FLASH' => $config['allow_sig_flash'] ? true : false, 'S_LINKS_ALLOWED' => $config['allow_sig_links'] ? true : false)); // Assigning custom bbcodes display_custom_bbcodes(); break; case 'attach': $start = request_var('start', 0); $deletemark = isset($_POST['delmarked']) ? true : false; $marked = request_var('mark', array(0)); // Sort keys $sort_key = request_var('sk', 'a'); $sort_dir = request_var('sd', 'd'); if ($deletemark && sizeof($marked)) { $sql = 'SELECT attach_id FROM ' . ATTACHMENTS_TABLE . ' WHERE poster_id = ' . $user_id . ' AND is_orphan = 0 AND ' . $db->sql_in_set('attach_id', $marked); $result = $db->sql_query($sql); $marked = array(); while ($row = $db->sql_fetchrow($result)) { $marked[] = $row['attach_id']; } $db->sql_freeresult($result); } if ($deletemark && sizeof($marked)) { if (confirm_box(true)) { $sql = 'SELECT real_filename FROM ' . ATTACHMENTS_TABLE . ' WHERE ' . $db->sql_in_set('attach_id', $marked); $result = $db->sql_query($sql); $log_attachments = array(); while ($row = $db->sql_fetchrow($result)) { $log_attachments[] = $row['real_filename']; } $db->sql_freeresult($result); delete_attachments('attach', $marked); $message = sizeof($log_attachments) == 1 ? $user->lang['ATTACHMENT_DELETED'] : $user->lang['ATTACHMENTS_DELETED']; add_log('admin', 'LOG_ATTACHMENTS_DELETED', implode(', ', $log_attachments)); trigger_error($message . 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, 'delmarked' => true, 'mark' => $marked))); } } $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']); $sk_sql = array('a' => 'a.real_filename', 'c' => 'a.extension', 'd' => 'a.filesize', 'e' => 'a.download_count', 'f' => 'a.filetime', 'g' => 't.topic_title'); $sd_text = array('a' => $user->lang['ASCENDING'], 'd' => $user->lang['DESCENDING']); $s_sort_key = ''; foreach ($sk_text as $key => $value) { $selected = $sort_key == $key ? ' selected="selected"' : ''; $s_sort_key .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>'; } $s_sort_dir = ''; foreach ($sd_text as $key => $value) { $selected = $sort_dir == $key ? ' selected="selected"' : ''; $s_sort_dir .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>'; } if (!isset($sk_sql[$sort_key])) { $sort_key = 'a'; } $order_by = $sk_sql[$sort_key] . ' ' . ($sort_dir == 'a' ? 'ASC' : 'DESC'); $sql = 'SELECT COUNT(attach_id) as num_attachments FROM ' . ATTACHMENTS_TABLE . "\n\t\t\t\t\tWHERE poster_id = {$user_id}\n\t\t\t\t\t\tAND is_orphan = 0"; $result = $db->sql_query_limit($sql, 1); $num_attachments = (int) $db->sql_fetchfield('num_attachments'); $db->sql_freeresult($result); $sql = 'SELECT a.*, t.topic_title, p.message_subject as message_title FROM ' . ATTACHMENTS_TABLE . ' a LEFT JOIN ' . TOPICS_TABLE . ' t ON (a.topic_id = t.topic_id AND a.in_message = 0) LEFT JOIN ' . PRIVMSGS_TABLE . ' p ON (a.post_msg_id = p.msg_id AND a.in_message = 1) WHERE a.poster_id = ' . $user_id . "\n\t\t\t\t\t\tAND a.is_orphan = 0\n\t\t\t\t\tORDER BY {$order_by}"; $result = $db->sql_query_limit($sql, $config['posts_per_page'], $start); while ($row = $db->sql_fetchrow($result)) { if ($row['in_message']) { $view_topic = append_sid("{$phpbb_root_path}ucp.{$phpEx}", "i=pm&p={$row['post_msg_id']}"); } else { $view_topic = append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", "t={$row['topic_id']}&p={$row['post_msg_id']}") . '#p' . $row['post_msg_id']; } $template->assign_block_vars('attach', array('REAL_FILENAME' => $row['real_filename'], 'COMMENT' => nl2br($row['attach_comment']), 'EXTENSION' => $row['extension'], 'SIZE' => get_formatted_filesize($row['filesize']), 'DOWNLOAD_COUNT' => $row['download_count'], 'POST_TIME' => $user->format_date($row['filetime']), 'TOPIC_TITLE' => $row['in_message'] ? $row['message_title'] : $row['topic_title'], 'ATTACH_ID' => $row['attach_id'], 'POST_ID' => $row['post_msg_id'], 'TOPIC_ID' => $row['topic_id'], 'S_IN_MESSAGE' => $row['in_message'], 'U_DOWNLOAD' => append_sid("{$phpbb_root_path}download/file.{$phpEx}", 'mode=view&id=' . $row['attach_id']), 'U_VIEW_TOPIC' => $view_topic)); } $db->sql_freeresult($result); $template->assign_vars(array('S_ATTACHMENTS' => true, 'S_ON_PAGE' => on_page($num_attachments, $config['topics_per_page'], $start), 'S_SORT_KEY' => $s_sort_key, 'S_SORT_DIR' => $s_sort_dir, 'PAGINATION' => generate_pagination($this->u_action . "&u={$user_id}&sk={$sort_key}&sd={$sort_dir}", $num_attachments, $config['topics_per_page'], $start, true))); break; case 'groups': include $phpbb_root_path . 'includes/functions_user.' . $phpEx; $user->add_lang(array('groups', 'acp/groups')); $group_id = request_var('g', 0); if ($group_id) { // Check the founder only entry for this group to make sure everything is well $sql = 'SELECT group_founder_manage FROM ' . GROUPS_TABLE . ' WHERE group_id = ' . $group_id; $result = $db->sql_query($sql); $founder_manage = (int) $db->sql_fetchfield('group_founder_manage'); $db->sql_freeresult($result); if ($user->data['user_type'] != USER_FOUNDER && $founder_manage) { trigger_error($user->lang['NOT_ALLOWED_MANAGE_GROUP'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } } else { $founder_manage = 0; } switch ($action) { case 'demote': case 'promote': case 'default': if (!$group_id) { trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } group_user_attributes($action, $group_id, $user_id); if ($action == 'default') { $user_row['group_id'] = $group_id; } break; case 'delete': if (confirm_box(true)) { if (!$group_id) { trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } if ($error = group_user_del($group_id, $user_id)) { trigger_error($user->lang[$error] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } $error = array(); // The delete action was successful - therefore update the user row... $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); } else { confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array('u' => $user_id, 'i' => $id, 'mode' => $mode, 'action' => $action, 'g' => $group_id))); } break; case 'approve': if (confirm_box(true)) { if (!$group_id) { trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } group_user_attributes($action, $group_id, $user_id); } else { confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array('u' => $user_id, 'i' => $id, 'mode' => $mode, 'action' => $action, 'g' => $group_id))); } break; } // Add user to group? if ($submit) { 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 (!$group_id) { trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } // Add user/s to group if ($error = group_user_add($group_id, $user_id)) { trigger_error($user->lang[$error] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } $error = array(); } $sql = 'SELECT ug.*, g.* FROM ' . GROUPS_TABLE . ' g, ' . USER_GROUP_TABLE . " ug\n\t\t\t\t\tWHERE ug.user_id = {$user_id}\n\t\t\t\t\t\tAND g.group_id = ug.group_id\n\t\t\t\t\tORDER BY g.group_type DESC, ug.user_pending ASC, g.group_name"; $result = $db->sql_query($sql); $i = 0; $group_data = $id_ary = array(); while ($row = $db->sql_fetchrow($result)) { $type = $row['group_type'] == GROUP_SPECIAL ? 'special' : ($row['user_pending'] ? 'pending' : 'normal'); $group_data[$type][$i]['group_id'] = $row['group_id']; $group_data[$type][$i]['group_name'] = $row['group_name']; $group_data[$type][$i]['group_leader'] = $row['group_leader'] ? 1 : 0; $id_ary[] = $row['group_id']; $i++; } $db->sql_freeresult($result); // Select box for other groups $sql = 'SELECT group_id, group_name, group_type, group_founder_manage FROM ' . GROUPS_TABLE . ' ' . (sizeof($id_ary) ? 'WHERE ' . $db->sql_in_set('group_id', $id_ary, true) : '') . ' ORDER BY group_type DESC, group_name ASC'; $result = $db->sql_query($sql); $s_group_options = ''; while ($row = $db->sql_fetchrow($result)) { if (!$config['coppa_enable'] && $row['group_name'] == 'REGISTERED_COPPA') { continue; } // Do not display those groups not allowed to be managed if ($user->data['user_type'] != USER_FOUNDER && $row['group_founder_manage']) { continue; } $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>'; } $db->sql_freeresult($result); $current_type = ''; foreach ($group_data as $group_type => $data_ary) { if ($current_type != $group_type) { $template->assign_block_vars('group', array('S_NEW_GROUP_TYPE' => true, 'GROUP_TYPE' => $user->lang['USER_GROUP_' . strtoupper($group_type)])); } foreach ($data_ary as $data) { $template->assign_block_vars('group', array('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"), 'U_DEFAULT' => $this->u_action . "&action=default&u={$user_id}&g=" . $data['group_id'], 'U_DEMOTE_PROMOTE' => $this->u_action . '&action=' . ($data['group_leader'] ? 'demote' : 'promote') . "&u={$user_id}&g=" . $data['group_id'], 'U_DELETE' => $this->u_action . "&action=delete&u={$user_id}&g=" . $data['group_id'], 'U_APPROVE' => $group_type == 'pending' ? $this->u_action . "&action=approve&u={$user_id}&g=" . $data['group_id'] : '', 'GROUP_NAME' => $group_type == 'special' ? $user->lang['G_' . $data['group_name']] : $data['group_name'], 'L_DEMOTE_PROMOTE' => $data['group_leader'] ? $user->lang['GROUP_DEMOTE'] : $user->lang['GROUP_PROMOTE'], 'S_IS_MEMBER' => $group_type != 'pending' ? true : false, 'S_NO_DEFAULT' => $user_row['group_id'] != $data['group_id'] ? true : false, 'S_SPECIAL_GROUP' => $group_type == 'special' ? true : false)); } } $template->assign_vars(array('S_GROUPS' => true, 'S_GROUP_OPTIONS' => $s_group_options)); break; case 'perm': include_once $phpbb_root_path . 'includes/acp/auth.' . $phpEx; $auth_admin = new auth_admin(); $user->add_lang('acp/permissions'); add_permission_language(); $forum_id = request_var('f', 0); // Global Permissions if (!$forum_id) { // Select auth options $sql = 'SELECT auth_option, is_local, is_global FROM ' . ACL_OPTIONS_TABLE . ' WHERE auth_option ' . $db->sql_like_expression($db->any_char . '_') . ' AND is_global = 1 ORDER BY auth_option'; $result = $db->sql_query($sql); $hold_ary = array(); while ($row = $db->sql_fetchrow($result)) { $hold_ary = $auth_admin->get_mask('view', $user_id, false, false, $row['auth_option'], 'global', ACL_NEVER); $auth_admin->display_mask('view', $row['auth_option'], $hold_ary, 'user', false, false); } $db->sql_freeresult($result); unset($hold_ary); } else { $sql = 'SELECT auth_option, is_local, is_global FROM ' . ACL_OPTIONS_TABLE . "\n\t\t\t\t\t\tWHERE auth_option " . $db->sql_like_expression($db->any_char . '_') . "\n\t\t\t\t\t\t\tAND is_local = 1\n\t\t\t\t\t\tORDER BY is_global DESC, auth_option"; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $hold_ary = $auth_admin->get_mask('view', $user_id, false, $forum_id, $row['auth_option'], 'local', ACL_NEVER); $auth_admin->display_mask('view', $row['auth_option'], $hold_ary, 'user', true, false); } $db->sql_freeresult($result); } $s_forum_options = '<option value="0"' . (!$forum_id ? ' selected="selected"' : '') . '>' . $user->lang['VIEW_GLOBAL_PERMS'] . '</option>'; $s_forum_options .= make_forum_select($forum_id, false, true, false, false, false); $template->assign_vars(array('S_PERMISSIONS' => true, 'S_GLOBAL' => !$forum_id ? true : false, 'S_FORUM_OPTIONS' => $s_forum_options, 'U_ACTION' => $this->u_action . '&u=' . $user_id, 'U_USER_PERMISSIONS' => append_sid("{$phpbb_admin_path}index.{$phpEx}", 'i=permissions&mode=setting_user_global&user_id[]=' . $user_id), 'U_USER_FORUM_PERMISSIONS' => append_sid("{$phpbb_admin_path}index.{$phpEx}", 'i=permissions&mode=setting_user_local&user_id[]=' . $user_id))); break; } // Assign general variables $template->assign_vars(array('S_ERROR' => sizeof($error) ? true : false, 'ERROR_MSG' => sizeof($error) ? implode('<br />', $error) : '')); }
'ALWAYS_ADD_SIGNATURE_YES' => ( $attachsig ) ? 'checked="checked"' : '', 'ALWAYS_ADD_SIGNATURE_NO' => ( !$attachsig ) ? 'checked="checked"' : '', 'NOTIFY_REPLY_YES' => ( $notifyreply ) ? 'checked="checked"' : '', 'NOTIFY_REPLY_NO' => ( !$notifyreply ) ? 'checked="checked"' : '', 'ALWAYS_ALLOW_BBCODE_YES' => ( $allowbbcode ) ? 'checked="checked"' : '', 'ALWAYS_ALLOW_BBCODE_NO' => ( !$allowbbcode ) ? 'checked="checked"' : '', 'ALWAYS_ALLOW_HTML_YES' => ( $allowhtml ) ? 'checked="checked"' : '', 'ALWAYS_ALLOW_HTML_NO' => ( !$allowhtml ) ? 'checked="checked"' : '', 'ALWAYS_ALLOW_SMILIES_YES' => ( $allowsmilies ) ? 'checked="checked"' : '', 'ALWAYS_ALLOW_SMILIES_NO' => ( !$allowsmilies ) ? 'checked="checked"' : '', 'ALLOW_AVATAR' => $board_config['allow_avatar_upload'], 'AVATAR' => $avatar_img, 'AVATAR_SIZE' => $board_config['avatar_filesize'], 'LANGUAGE_SELECT' => language_select($user_lang, 'language'), 'STYLE_SELECT' => style_select($user_style, 'style'), 'TIMEZONE_SELECT' => tz_select($user_timezone, 'timezone'), 'DATE_FORMAT' => $user_dateformat, 'HTML_STATUS' => $html_status, 'BBCODE_STATUS' => sprintf($bbcode_status, '<a href="' . append_sid("faq.php?mode=bbcode") . '" target="_phpbbcode">', '</a>'), 'SMILIES_STATUS' => $smilies_status, 'L_CURRENT_PASSWORD' => $lang['Current_password'], 'L_NEW_PASSWORD' => ( $mode == 'register' ) ? $lang['Password'] : $lang['New_password'], 'L_CONFIRM_PASSWORD' => $lang['Confirm_password'], 'L_CONFIRM_PASSWORD_EXPLAIN' => ( $mode == 'editprofile' ) ? $lang['Confirm_password_explain'] : '', 'L_PASSWORD_IF_CHANGED' => ( $mode == 'editprofile' ) ? $lang['password_if_changed'] : '', 'L_PASSWORD_CONFIRM_IF_CHANGED' => ( $mode == 'editprofile' ) ? $lang['password_confirm_if_changed'] : '', 'L_SUBMIT' => $lang['Submit'], 'L_RESET' => $lang['Reset'], 'L_ICQ_NUMBER' => $lang['ICQ'], 'L_MESSENGER' => $lang['MSNM'],
$sql = 'INSERT INTO ' . CONFIRM_TABLE . " (confirm_id, session_id, code) \n\t\t\tVALUES ('{$confirm_id}', '" . $userdata['session_id'] . "', '{$code}')"; if (!$db->sql_query($sql)) { message_die(GENERAL_ERROR, 'Could not insert new confirm code information', '', __LINE__, __FILE__, $sql); } unset($code); $confirm_image = '<img src="' . append_sid("profile.{$phpEx}?mode=confirm&id={$confirm_id}") . '" alt="" title="" />'; $s_hidden_fields .= '<input type="hidden" name="confirm_id" value="' . $confirm_id . '" />'; $template->assign_block_vars('switch_confirm', array()); } // // Let's do an overall check for settings/versions which would prevent // us from doing file uploads.... // $ini_val = phpversion() >= '4.0.0' ? 'ini_get' : 'get_cfg_var'; $form_enctype = @$ini_val('file_uploads') == '0' || strtolower(@$ini_val('file_uploads') == 'off') || phpversion() == '4.0.4pl1' || !$board_config['allow_avatar_upload'] || phpversion() < '4.0.3' && @$ini_val('open_basedir') != '' ? '' : 'enctype="multipart/form-data"'; $template->assign_vars(array('USERNAME' => isset($username) ? $username : '', 'CUR_PASSWORD' => isset($cur_password) ? $cur_password : '', 'NEW_PASSWORD' => isset($new_password) ? $new_password : '', 'PASSWORD_CONFIRM' => isset($password_confirm) ? $password_confirm : '', 'EMAIL' => isset($email) ? $email : '', 'CONFIRM_IMG' => $confirm_image, 'YIM' => $yim, 'ICQ' => $icq, 'MSN' => $msn, 'AIM' => $aim, 'OCCUPATION' => $occupation, 'INTERESTS' => $interests, 'LOCATION' => $location, 'WEBSITE' => $website, 'SIGNATURE' => str_replace('<br />', "\n", $signature), 'VIEW_EMAIL_YES' => $viewemail ? 'checked="checked"' : '', 'VIEW_EMAIL_NO' => !$viewemail ? 'checked="checked"' : '', 'HIDE_USER_YES' => !$allowviewonline ? 'checked="checked"' : '', 'HIDE_USER_NO' => $allowviewonline ? 'checked="checked"' : '', 'NOTIFY_PM_YES' => $notifypm ? 'checked="checked"' : '', 'NOTIFY_PM_NO' => !$notifypm ? 'checked="checked"' : '', 'POPUP_PM_YES' => $popup_pm ? 'checked="checked"' : '', 'POPUP_PM_NO' => !$popup_pm ? 'checked="checked"' : '', 'ALWAYS_ADD_SIGNATURE_YES' => $attachsig ? 'checked="checked"' : '', 'ALWAYS_ADD_SIGNATURE_NO' => !$attachsig ? 'checked="checked"' : '', 'NOTIFY_REPLY_YES' => $notifyreply ? 'checked="checked"' : '', 'NOTIFY_REPLY_NO' => !$notifyreply ? 'checked="checked"' : '', 'ALWAYS_ALLOW_BBCODE_YES' => $allowbbcode ? 'checked="checked"' : '', 'ALWAYS_ALLOW_BBCODE_NO' => !$allowbbcode ? 'checked="checked"' : '', 'ALWAYS_ALLOW_HTML_YES' => $allowhtml ? 'checked="checked"' : '', 'ALWAYS_ALLOW_HTML_NO' => !$allowhtml ? 'checked="checked"' : '', 'ALWAYS_ALLOW_SMILIES_YES' => $allowsmilies ? 'checked="checked"' : '', 'ALWAYS_ALLOW_SMILIES_NO' => !$allowsmilies ? 'checked="checked"' : '', 'ALLOW_AVATAR' => $board_config['allow_avatar_upload'], 'AVATAR' => $avatar_img, 'AVATAR_SIZE' => $board_config['avatar_filesize'], 'LANGUAGE_SELECT' => language_select($user_lang, 'language'), 'STYLE_SELECT' => style_select($user_style, 'style'), 'TIMEZONE_SELECT' => tz_select($user_timezone, 'timezone'), 'DATE_FORMAT' => $user_dateformat, 'HTML_STATUS' => $html_status, 'BBCODE_STATUS' => sprintf($bbcode_status, '<a href="' . append_sid("faq.{$phpEx}?mode=bbcode") . '" target="_phpbbcode">', '</a>'), 'SMILIES_STATUS' => $smilies_status, 'L_CURRENT_PASSWORD' => $lang['Current_password'], 'L_NEW_PASSWORD' => $mode == 'register' ? $lang['Password'] : $lang['New_password'], 'L_CONFIRM_PASSWORD' => $lang['Confirm_password'], 'L_CONFIRM_PASSWORD_EXPLAIN' => $mode == 'editprofile' ? $lang['Confirm_password_explain'] : '', 'L_PASSWORD_IF_CHANGED' => $mode == 'editprofile' ? $lang['password_if_changed'] : '', 'L_PASSWORD_CONFIRM_IF_CHANGED' => $mode == 'editprofile' ? $lang['password_confirm_if_changed'] : '', 'L_SUBMIT' => $lang['Submit'], 'L_RESET' => $lang['Reset'], 'L_ICQ_NUMBER' => $lang['ICQ'], 'L_MESSENGER' => $lang['MSNM'], 'L_YAHOO' => $lang['YIM'], 'L_WEBSITE' => $lang['Website'], 'L_AIM' => $lang['AIM'], 'L_LOCATION' => $lang['Location'], 'L_OCCUPATION' => $lang['Occupation'], 'L_BOARD_LANGUAGE' => $lang['Board_lang'], 'L_BOARD_STYLE' => $lang['Board_style'], 'L_TIMEZONE' => $lang['Timezone'], 'L_DATE_FORMAT' => $lang['Date_format'], 'L_DATE_FORMAT_EXPLAIN' => $lang['Date_format_explain'], 'L_YES' => $lang['Yes'], 'L_NO' => $lang['No'], 'L_INTERESTS' => $lang['Interests'], 'L_ALWAYS_ALLOW_SMILIES' => $lang['Always_smile'], 'L_ALWAYS_ALLOW_BBCODE' => $lang['Always_bbcode'], 'L_ALWAYS_ALLOW_HTML' => $lang['Always_html'], 'L_HIDE_USER' => $lang['Hide_user'], 'L_ALWAYS_ADD_SIGNATURE' => $lang['Always_add_sig'], 'L_AVATAR_PANEL' => $lang['Avatar_panel'], 'L_AVATAR_EXPLAIN' => sprintf($lang['Avatar_explain'], $board_config['avatar_max_width'], $board_config['avatar_max_height'], round($board_config['avatar_filesize'] / 1024)), 'L_UPLOAD_AVATAR_FILE' => $lang['Upload_Avatar_file'], 'L_UPLOAD_AVATAR_URL' => $lang['Upload_Avatar_URL'], 'L_UPLOAD_AVATAR_URL_EXPLAIN' => $lang['Upload_Avatar_URL_explain'], 'L_AVATAR_GALLERY' => $lang['Select_from_gallery'], 'L_SHOW_GALLERY' => $lang['View_avatar_gallery'], 'L_LINK_REMOTE_AVATAR' => $lang['Link_remote_Avatar'], 'L_LINK_REMOTE_AVATAR_EXPLAIN' => $lang['Link_remote_Avatar_explain'], 'L_DELETE_AVATAR' => $lang['Delete_Image'], 'L_CURRENT_IMAGE' => $lang['Current_Image'], 'L_SIGNATURE' => $lang['Signature'], 'L_SIGNATURE_EXPLAIN' => sprintf($lang['Signature_explain'], $board_config['max_sig_chars']), 'L_NOTIFY_ON_REPLY' => $lang['Always_notify'], 'L_NOTIFY_ON_REPLY_EXPLAIN' => $lang['Always_notify_explain'], 'L_NOTIFY_ON_PRIVMSG' => $lang['Notify_on_privmsg'], 'L_POPUP_ON_PRIVMSG' => $lang['Popup_on_privmsg'], 'L_POPUP_ON_PRIVMSG_EXPLAIN' => $lang['Popup_on_privmsg_explain'], 'L_PREFERENCES' => $lang['Preferences'], 'L_PUBLIC_VIEW_EMAIL' => $lang['Public_view_email'], 'L_ITEMS_REQUIRED' => $lang['Items_required'], 'L_REGISTRATION_INFO' => $lang['Registration_info'], 'L_PROFILE_INFO' => $lang['Profile_info'], 'L_PROFILE_INFO_NOTICE' => $lang['Profile_info_warn'], 'L_EMAIL_ADDRESS' => $lang['Email_address'], 'L_CONFIRM_CODE_IMPAIRED' => sprintf($lang['Confirm_code_impaired'], '<a href="mailto:' . $board_config['board_email'] . '">', '</a>'), 'L_CONFIRM_CODE' => $lang['Confirm_code'], 'L_CONFIRM_CODE_EXPLAIN' => $lang['Confirm_code_explain'], 'S_ALLOW_AVATAR_UPLOAD' => $board_config['allow_avatar_upload'], 'S_ALLOW_AVATAR_LOCAL' => $board_config['allow_avatar_local'], 'S_ALLOW_AVATAR_REMOTE' => $board_config['allow_avatar_remote'], 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'S_FORM_ENCTYPE' => $form_enctype, 'S_PROFILE_ACTION' => append_sid("profile.{$phpEx}"))); // // This is another cheat using the block_var capability // of the templates to 'fake' an IF...ELSE...ENDIF solution // it works well :) // if ($mode != 'register') { if ($userdata['user_allowavatar'] && ($board_config['allow_avatar_upload'] || $board_config['allow_avatar_local'] || $board_config['allow_avatar_remote'])) { $template->assign_block_vars('switch_avatar_block', array()); if ($board_config['allow_avatar_upload'] && file_exists(@phpbb_realpath('./' . $board_config['avatar_path']))) { if ($form_enctype != '') { $template->assign_block_vars('switch_avatar_block.switch_avatar_local_upload', array()); } $template->assign_block_vars('switch_avatar_block.switch_avatar_remote_upload', array()); } if ($board_config['allow_avatar_remote']) {
if (empty($class_users)) { $class_users = new class_users(); } $class_users->profile_update($target_profile_data); unset($clean_password); unset($target_profile_data); // PROFILE EDIT BRIDGE - END board_stats(); $message = $lang['Account_added']; message_die(GENERAL_MESSAGE, $message); } } // End of submit if ($error) { // If an error occured we need to htmlspecialchars again username for output on returned data $username = htmlspecialchars($username); $new_password = ''; $password_confirm = ''; } // Default pages include_once IP_ROOT_PATH . 'includes/functions_selects.' . PHP_EXT; if ($error) { $template->set_filenames(array('reg_header' => 'error_body.tpl')); $template->assign_vars(array('ERROR_MESSAGE' => $error_msg)); $template->assign_var_from_handle('ERROR_BOX', 'reg_header'); } $template->set_filenames(array('body' => ADM_TPL . 'admin_add_user_body.tpl')); // Let's do an overall check for settings/versions which would prevent us from doing file uploads.... $template->assign_vars(array('USERNAME' => $username, 'CUR_PASSWORD' => $cur_password, 'NEW_PASSWORD' => $new_password, 'PASSWORD_CONFIRM' => $password_confirm, 'EMAIL' => $email, 'LANGUAGE_SELECT' => language_select('language', $config['default_lang']), 'STYLE_SELECT' => style_select('style', $config['default_style']), 'TIMEZONE_SELECT' => tz_select('timezone', $config['board_timezone']), 'DATE_FORMAT_SELECT' => date_select('dateformat', $config['default_dateformat']), 'L_USERNAME' => $lang['Username'], 'L_CURRENT_PASSWORD' => $lang['Current_password'], 'L_NEW_PASSWORD' => $lang['Password'], 'L_CONFIRM_PASSWORD' => $lang['Confirm_password'], 'L_SUBMIT' => $lang['Submit'], 'L_RESET' => $lang['Reset'], 'L_BOARD_LANGUAGE' => $lang['Board_lang'], 'L_BOARD_STYLE' => $lang['Board_style'], 'L_TIMEZONE' => $lang['Timezone'], 'L_DATE_FORMAT' => $lang['Date_format'], 'L_DATE_FORMAT_EXPLAIN' => $lang['Date_format_explain'], 'L_YES' => $lang['Yes'], 'L_NO' => $lang['No'], 'L_ITEMS_REQUIRED' => $lang['Items_required'], 'L_PREFERENCES' => $lang['Preferences'], 'L_REGISTRATION_INFO' => $lang['Registration_info'], 'L_PROFILE_INFO' => $lang['Profile_info'], 'L_PROFILE_INFO_NOTICE' => $lang['Profile_info_warn'], 'L_EMAIL_ADDRESS' => $lang['Email_address'], 'L_VALIDATION' => $lang['Validation'], 'L_VALIDATION_EXPLAIN' => $lang['Validation_explain'], 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'S_PROFILE_ACTION' => append_sid('admin_user_register.' . PHP_EXT))); $template->pparse('body'); include IP_ROOT_PATH . ADM . '/page_footer_admin.' . PHP_EXT;
<td class='cellOne'> <label for="db_pass" class='defaultBold'><?php echo $lang_set_timezone; ?> </label> <div class="explain"><?php echo $lang_set_timezone_msg; ?> </div> </td> <td class='cellOne'> <select name="pp_timezone" id="pp_timezone"<?php echo $disabled; ?> ><?php echo tz_select('0', true, '75'); ?> </select> </td> </tr> <tr> <td class='cellOne'> <label for="db_pass" class='defaultBold'><?php echo $lang_set_tz_dst; ?> </label> <div class="explain"><?php echo $lang_set_tz_dst_msg; ?> </div> </td>
} $sql = "SELECT * FROM " . BB_RANKS . " WHERE rank_special = 1 ORDER BY rank_title"; if (!($result = DB()->sql_query($sql))) { bb_die('Could not obtain ranks data'); } $rank_select_box = ''; if (DB()->num_rows($result) != 0) { $template->assign_block_vars('ranks_exist', array()); while ($row = DB()->sql_fetchrow($result)) { $rank = $row['rank_title']; $rank_id = $row['rank_id']; $rank_select_box .= '<option value="' . $rank_id . '">' . $rank . '</option>'; } } $language_list = language_select('', 'language_type'); $timezone_list = tz_select('', 'timezone_type'); $sql = "SELECT f.forum_id, f.forum_name, f.forum_parent, c.cat_id, c.cat_title\n\t\t\t\tFROM ( " . BB_FORUMS . " AS f INNER JOIN " . BB_CATEGORIES . " AS c ON c.cat_id = f.cat_id )\n\t\t\t\tORDER BY c.cat_order, f.forum_order ASC"; if (!($result = DB()->sql_query($sql))) { bb_die('Could not select forum data'); } $forums = array(); if (DB()->num_rows($result) != 0) { $template->assign_block_vars('forums_exist', array()); $last_cat_id = -1; $forums_list = ''; while ($row = DB()->sql_fetchrow($result)) { if ($row['cat_id'] != $last_cat_id) { $forums_list .= '<optgroup label="' . htmlCHR($row['cat_title']) . '">'; $last_cat_id = $row['cat_id']; } $forums_list .= '<option value="' . $row['forum_id'] . '">' . ($row['forum_parent'] ? HTML_SF_SPACER : '') . htmlCHR($row['forum_name']) . '</option>';
function main($id, $mode) { global $config, $db, $user, $auth, $template, $phpbb_root_path, $phpEx; // if ($config['require_activation'] == USER_ACTIVATION_DISABLE) { trigger_error('UCP_REGISTER_DISABLE'); } include($phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx); $confirm_id = request_var('confirm_id', ''); $coppa = (isset($_REQUEST['coppa'])) ? ((!empty($_REQUEST['coppa'])) ? 1 : 0) : false; $agreed = (!empty($_POST['agreed'])) ? 1 : 0; $submit = (isset($_POST['submit'])) ? true : false; $change_lang = request_var('change_lang', ''); $user_lang = request_var('lang', $user->lang_name); // not so fast, buddy if (($submit && !check_form_key('ucp_register', false, '', false, $config['min_time_reg'])) || (!$submit && !check_form_key('ucp_register_terms', false, '', false, $config['min_time_terms']))) { $agreed = false; } if ($agreed) { add_form_key('ucp_register'); } else { add_form_key('ucp_register_terms'); } if ($change_lang || $user_lang != $config['default_lang']) { $use_lang = ($change_lang) ? basename($change_lang) : basename($user_lang); if (file_exists($phpbb_root_path . 'language/' . $use_lang . '/')) { if ($change_lang) { $submit = false; // Setting back agreed to let the user view the agreement in his/her language $agreed = (empty($_GET['change_lang'])) ? 0 : $agreed; } $user->lang_name = $lang = $use_lang; $user->lang_path = $phpbb_root_path . 'language/' . $lang . '/'; $user->lang = array(); $user->add_lang(array('common', 'ucp')); } else { $change_lang = ''; $user_lang = $user->lang_name; } } $cp = new custom_profile(); $error = $cp_data = $cp_error = array(); // if (!$agreed || ($coppa === false && $config['coppa_enable']) || ($coppa && !$config['coppa_enable'])) { $add_lang = ($change_lang) ? '&change_lang=' . urlencode($change_lang) : ''; $add_coppa = ($coppa !== false) ? '&coppa=' . $coppa : ''; $s_hidden_fields = ($confirm_id) ? array('confirm_id' => $confirm_id) : array(); // If we change the language, we want to pass on some more possible parameter. if ($change_lang) { // We do not include the password! $s_hidden_fields = array_merge($s_hidden_fields, array( 'username' => utf8_normalize_nfc(request_var('username', '', true)), 'email' => strtolower(request_var('email', '')), 'email_confirm' => strtolower(request_var('email_confirm', '')), 'confirm_code' => request_var('confirm_code', ''), 'lang' => $user->lang_name, 'tz' => request_var('tz', (float) $config['board_timezone']), )); } if ($coppa === false && $config['coppa_enable']) { $now = getdate(); $coppa_birthday = $user->format_date(mktime($now['hours'] + $user->data['user_dst'], $now['minutes'], $now['seconds'], $now['mon'], $now['mday'] - 1, $now['year'] - 13), $user->lang['DATE_FORMAT']); unset($now); $template->assign_vars(array( 'L_COPPA_NO' => sprintf($user->lang['UCP_COPPA_BEFORE'], $coppa_birthday), 'L_COPPA_YES' => sprintf($user->lang['UCP_COPPA_ON_AFTER'], $coppa_birthday), 'U_COPPA_NO' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=register&coppa=0' . $add_lang), 'U_COPPA_YES' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=register&coppa=1' . $add_lang), 'S_SHOW_COPPA' => true, 'S_HIDDEN_FIELDS' => build_hidden_fields($s_hidden_fields), 'S_UCP_ACTION' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=register' . $add_lang), )); } else { $template->assign_vars(array( 'L_TERMS_OF_USE' => sprintf($user->lang['TERMS_OF_USE_CONTENT'], $config['sitename'], generate_board_url()), 'S_SHOW_COPPA' => false, 'S_REGISTRATION' => true, 'S_HIDDEN_FIELDS' => build_hidden_fields($s_hidden_fields), 'S_UCP_ACTION' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=register' . $add_lang . $add_coppa), 'S_TIME' => 1000 * ((int) $config['min_time_terms']), ) ); } $this->tpl_name = 'ucp_agreement'; return; } // Try to manually determine the timezone and adjust the dst if the server date/time complies with the default setting +/- 1 $timezone = date('Z') / 3600; $is_dst = date('I'); if ($config['board_timezone'] == $timezone || $config['board_timezone'] == ($timezone - 1)) { $timezone = ($is_dst) ? $timezone - 1 : $timezone; if (!isset($user->lang['tz_zones'][(string) $timezone])) { $timezone = $config['board_timezone']; } } else { $is_dst = $config['board_dst']; $timezone = $config['board_timezone']; } $data = array( 'username' => utf8_normalize_nfc(request_var('username', '', true)), 'new_password' => request_var('new_password', '', true), 'password_confirm' => request_var('password_confirm', '', true), 'email' => strtolower(request_var('email', '')), 'email_confirm' => strtolower(request_var('email_confirm', '')), 'confirm_code' => request_var('confirm_code', ''), 'lang' => basename(request_var('lang', $user->lang_name)), 'tz' => request_var('tz', (float) $timezone), ); // Check and initialize some variables if needed if ($submit) { $error = validate_data($data, array( 'username' => array( array('string', false, $config['min_name_chars'], $config['max_name_chars']), array('username', '')), 'new_password' => array( array('string', false, $config['min_pass_chars'], $config['max_pass_chars']), array('password')), 'password_confirm' => array('string', false, $config['min_pass_chars'], $config['max_pass_chars']), 'email' => array( array('string', false, 6, 60), array('email')), 'email_confirm' => array('string', false, 6, 60), 'confirm_code' => array('string', !$config['enable_confirm'], 5, 8), 'tz' => array('num', false, -14, 14), 'lang' => array('match', false, '#^[a-z_\-]{2,}$#i'), )); // Replace "error" strings with their real, localised form $error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error); // DNSBL check if ($config['check_dnsbl']) { if (($dnsbl = $user->check_dnsbl('register')) !== false) { $error[] = sprintf($user->lang['IP_BLACKLISTED'], $user->ip, $dnsbl[1]); } } // validate custom profile fields $cp->submit_cp_field('register', $user->get_iso_lang_id(), $cp_data, $error); // Visual Confirmation handling $wrong_confirm = false; if ($config['enable_confirm']) { if (!$confirm_id) { $error[] = $user->lang['CONFIRM_CODE_WRONG']; $wrong_confirm = true; } else { $sql = 'SELECT code FROM ' . CONFIRM_TABLE . " WHERE confirm_id = '" . $db->sql_escape($confirm_id) . "' AND session_id = '" . $db->sql_escape($user->session_id) . "' AND confirm_type = " . CONFIRM_REG; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); if ($row) { if (strcasecmp($row['code'], $data['confirm_code']) === 0) { $sql = 'DELETE FROM ' . CONFIRM_TABLE . " WHERE confirm_id = '" . $db->sql_escape($confirm_id) . "' AND session_id = '" . $db->sql_escape($user->session_id) . "' AND confirm_type = " . CONFIRM_REG; $db->sql_query($sql); } else { $error[] = $user->lang['CONFIRM_CODE_WRONG']; $wrong_confirm = true; } } else { $error[] = $user->lang['CONFIRM_CODE_WRONG']; $wrong_confirm = true; } } } if (!sizeof($error)) { if ($data['new_password'] != $data['password_confirm']) { $error[] = $user->lang['NEW_PASSWORD_ERROR']; } if ($data['email'] != $data['email_confirm']) { $error[] = $user->lang['NEW_EMAIL_ERROR']; } } if (!sizeof($error)) { $server_url = generate_board_url(); // Which group by default? $group_name = ($coppa) ? 'REGISTERED_COPPA' : 'REGISTERED'; $sql = 'SELECT group_id FROM ' . GROUPS_TABLE . " WHERE group_name = '" . $db->sql_escape($group_name) . "' AND group_type = " . GROUP_SPECIAL; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); if (!$row) { trigger_error('NO_GROUP'); } $group_id = $row['group_id']; if (($coppa || $config['require_activation'] == USER_ACTIVATION_SELF || $config['require_activation'] == USER_ACTIVATION_ADMIN) && $config['email_enable']) { $user_actkey = gen_rand_string(10); $key_len = 54 - (strlen($server_url)); $key_len = ($key_len < 6) ? 6 : $key_len; $user_actkey = substr($user_actkey, 0, $key_len); $user_type = USER_INACTIVE; $user_inactive_reason = INACTIVE_REGISTER; $user_inactive_time = time(); } else { $user_type = USER_NORMAL; $user_actkey = ''; $user_inactive_reason = 0; $user_inactive_time = 0; } $user_row = array( 'username' => $data['username'], 'user_password' => phpbb_hash($data['new_password']), 'user_email' => $data['email'], 'group_id' => (int) $group_id, 'user_timezone' => (float) $data['tz'], 'user_dst' => $is_dst, 'user_lang' => $data['lang'], 'user_type' => $user_type, 'user_actkey' => $user_actkey, 'user_ip' => $user->ip, 'user_regdate' => time(), 'user_inactive_reason' => $user_inactive_reason, 'user_inactive_time' => $user_inactive_time, ); // Register user... $user_id = user_add($user_row, $cp_data); // This should not happen, because the required variables are listed above... if ($user_id === false) { trigger_error('NO_USER', E_USER_ERROR); } if ($coppa && $config['email_enable']) { $message = $user->lang['ACCOUNT_COPPA']; $email_template = 'coppa_welcome_inactive'; } else if ($config['require_activation'] == USER_ACTIVATION_SELF && $config['email_enable']) { $message = $user->lang['ACCOUNT_INACTIVE']; $email_template = 'user_welcome_inactive'; } else if ($config['require_activation'] == USER_ACTIVATION_ADMIN && $config['email_enable']) { $message = $user->lang['ACCOUNT_INACTIVE_ADMIN']; $email_template = 'admin_welcome_inactive'; } else { $message = $user->lang['ACCOUNT_ADDED']; $email_template = 'user_welcome'; } if ($config['email_enable']) { include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); $messenger = new messenger(false); $messenger->template($email_template, $data['lang']); $messenger->to($data['email'], $data['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($data['username']), 'PASSWORD' => htmlspecialchars_decode($data['new_password']), 'U_ACTIVATE' => "$server_url/ucp.$phpEx?mode=activate&u=$user_id&k=$user_actkey") ); if ($coppa) { $messenger->assign_vars(array( 'FAX_INFO' => $config['coppa_fax'], 'MAIL_INFO' => $config['coppa_mail'], 'EMAIL_ADDRESS' => $data['email']) ); } $messenger->send(NOTIFY_EMAIL); if ($config['require_activation'] == USER_ACTIVATION_ADMIN) { // Grab an array of user_id's with a_user permissions ... these users can activate a user $admin_ary = $auth->acl_get_list(false, 'a_user', false); $admin_ary = (!empty($admin_ary[0]['a_user'])) ? $admin_ary[0]['a_user'] : array(); // Also include founders $where_sql = ' WHERE user_type = ' . USER_FOUNDER; if (sizeof($admin_ary)) { $where_sql .= ' OR ' . $db->sql_in_set('user_id', $admin_ary); } $sql = 'SELECT user_id, username, user_email, user_lang, user_jabber, user_notify_type FROM ' . USERS_TABLE . ' ' . $where_sql; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $messenger->template('admin_activate', $row['user_lang']); $messenger->to($row['user_email'], $row['username']); $messenger->im($row['user_jabber'], $row['username']); $messenger->assign_vars(array( 'USERNAME' => htmlspecialchars_decode($data['username']), 'U_USER_DETAILS' => "$server_url/memberlist.$phpEx?mode=viewprofile&u=$user_id", 'U_ACTIVATE' => "$server_url/ucp.$phpEx?mode=activate&u=$user_id&k=$user_actkey") ); $messenger->send($row['user_notify_type']); } $db->sql_freeresult($result); } } $message = $message . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid("{$phpbb_root_path}index.$phpEx") . '">', '</a>'); trigger_error($message); } } $s_hidden_fields = array( 'agreed' => 'true', 'change_lang' => 0, ); if ($config['coppa_enable']) { $s_hidden_fields['coppa'] = $coppa; } $s_hidden_fields = build_hidden_fields($s_hidden_fields); $confirm_image = ''; // Visual Confirmation - Show images if ($config['enable_confirm']) { $str = ''; if (!$change_lang) { $user->confirm_gc(CONFIRM_REG); $sql = 'SELECT COUNT(session_id) AS attempts FROM ' . CONFIRM_TABLE . " WHERE session_id = '" . $db->sql_escape($user->session_id) . "' AND confirm_type = " . CONFIRM_REG; $result = $db->sql_query($sql); $attempts = (int) $db->sql_fetchfield('attempts'); $db->sql_freeresult($result); if ($config['max_reg_attempts'] && $attempts > $config['max_reg_attempts']) { trigger_error('TOO_MANY_REGISTERS'); } $code = gen_rand_string(mt_rand(5, 8)); $confirm_id = md5(unique_id($user->ip)); $seed = hexdec(substr(unique_id(), 4, 10)); // compute $seed % 0x7fffffff $seed -= 0x7fffffff * floor($seed / 0x7fffffff); $sql = 'INSERT INTO ' . CONFIRM_TABLE . ' ' . $db->sql_build_array('INSERT', array( 'confirm_id' => (string) $confirm_id, 'session_id' => (string) $user->session_id, 'confirm_type' => (int) CONFIRM_REG, 'code' => (string) $code, 'seed' => (int) $seed) ); $db->sql_query($sql); } else { $str .= '&change_lang=' . $change_lang; } $confirm_image = '<img src="' . append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=confirm&id=' . $confirm_id . '&type=' . CONFIRM_REG . $str) . '" alt="" title="" />'; $s_hidden_fields .= '<input type="hidden" name="confirm_id" value="' . $confirm_id . '" />'; } // $l_reg_cond = ''; switch ($config['require_activation']) { case USER_ACTIVATION_SELF: $l_reg_cond = $user->lang['UCP_EMAIL_ACTIVATE']; break; case USER_ACTIVATION_ADMIN: $l_reg_cond = $user->lang['UCP_ADMIN_ACTIVATE']; break; } $template->assign_vars(array( 'ERROR' => (sizeof($error)) ? implode('<br />', $error) : '', 'USERNAME' => $data['username'], 'PASSWORD' => $data['new_password'], 'PASSWORD_CONFIRM' => $data['password_confirm'], 'EMAIL' => $data['email'], 'EMAIL_CONFIRM' => $data['email_confirm'], 'CONFIRM_IMG' => $confirm_image, 'L_CONFIRM_EXPLAIN' => sprintf($user->lang['CONFIRM_EXPLAIN'], '<a href="mailto:' . htmlspecialchars($config['board_contact']) . '">', '</a>'), 'L_REG_COND' => $l_reg_cond, 'L_USERNAME_EXPLAIN' => sprintf($user->lang[$config['allow_name_chars'] . '_EXPLAIN'], $config['min_name_chars'], $config['max_name_chars']), 'L_PASSWORD_EXPLAIN' => sprintf($user->lang[$config['pass_complex'] . '_EXPLAIN'], $config['min_pass_chars'], $config['max_pass_chars']), 'S_LANG_OPTIONS' => language_select($data['lang']), 'S_TZ_OPTIONS' => tz_select($data['tz']), 'S_CONFIRM_CODE' => ($config['enable_confirm']) ? true : false, 'S_COPPA' => $coppa, 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'S_UCP_ACTION' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=register'), 'S_TIME' => 1000 * ((int) $config['min_time_reg']), ) ); // $user->profile_fields = array(); // Generate profile fields -> Template Block Variable profile_fields $cp->generate_profile_fields('register', $user->get_iso_lang_id()); // $this->tpl_name = 'ucp_register'; $this->page_title = 'UCP_REGISTRATION'; }
if ($config['ajax_checks_register'] == true) { $verify_un_js = 'onblur="verifyUsername(this.value)"'; $verify_email_js = 'onblur="verifyEmail(this.value)"'; /* $verify_un_js = 'onKeyUp="verifyUsername(this.value)"'; $verify_email_js = 'onKeyUp="verifyEmail(this.value)"'; */ } // Let's do an overall check for settings/versions which would prevent us from doing file uploads.... $ini_val = phpversion() >= '4.0.0' ? 'ini_get' : 'get_cfg_var'; $form_enctype = @$ini_val('file_uploads') == '0' || strtolower(@$ini_val('file_uploads') == 'off') || phpversion() == '4.0.4pl1' || !$config['allow_avatar_upload'] || phpversion() < '4.0.3' && @$ini_val('open_basedir') != '' ? '' : 'enctype="multipart/form-data"'; $user_sn_im_array = get_user_sn_im_array(); foreach ($user_sn_im_array as $k => $v) { $template->assign_var(strtoupper($v['form']), ${$v}['form']); } $template->assign_vars(array('S_REGISTER_MESSAGE' => empty($lang['REGISTER_MESSAGE']) ? false : true, 'L_YES' => $lang['Yes'], 'L_NO' => $lang['No'], 'USERNAME' => isset($username) ? $username : '', 'CUR_PASSWORD' => isset($cur_password) ? htmlspecialchars($cur_password) : '', 'NEW_PASSWORD' => isset($new_password) ? htmlspecialchars($new_password) : '', 'PASSWORD_CONFIRM' => isset($password_confirm) ? htmlspecialchars($password_confirm) : '', 'EMAIL' => isset($email) ? $email : '', 'SIG_EDIT_LINK' => append_sid(CMS_PAGE_PROFILE . '?mode=signature'), 'SIG_DESC' => $lang['sig_description'], 'SIG_BUTTON_DESC' => $lang['sig_edit'], 'CONFIRM_IMG' => $confirm_image, 'USER_FIRST_NAME' => $user_first_name, 'USER_LAST_NAME' => $user_last_name, 'OCCUPATION' => $occupation, 'INTERESTS' => $interests, 'FLAG_SELECT' => $flag_select, 'FLAG_START' => $flag_start_image, 'PHONE' => $phone, 'SELFDES' => str_replace('<br />', "\n", $selfdes), 'L_FLAG' => $lang['Country_Flag'], 'L_PHONE' => $lang['UserPhone'], 'L_EXTRA_PROFILE_INFO' => $lang['Extra_profile_info'], 'L_EXTRA_PROFILE_INFO_EXPLAIN' => sprintf($lang['Extra_profile_info_explain'], $config['extra_max']), 'PROFILE_VIEW_POPUP_YES' => $profile_view_popup ? 'checked="checked"' : '', 'PROFILE_VIEW_POPUP_NO' => !$profile_view_popup ? 'checked="checked"' : '', 'L_PROFILE_VIEW_POPUP' => $lang['Profile_view_option'], 'S_BIRTHDAY' => $s_birthday, 'BIRTHDAY_REQUIRED' => $config['birthday_required'] ? '*' : '', 'LOCATION' => $location, 'WEBSITE' => $website, 'SIGNATURE' => str_replace('<br />', "\n", $signature), 'LOCK_GENDER' => $mode != 'register' ? 'DISABLED' : '', 'GENDER' => $gender, 'GENDER_REQUIRED' => $config['gender_required'] ? ' *' : '', 'GENDER_NO_SPECIFY_CHECKED' => $gender_no_specify_checked, 'GENDER_MALE_CHECKED' => $gender_male_checked, 'GENDER_FEMALE_CHECKED' => $gender_female_checked, 'UPI2DB_SYSTEM' => $upi2db_which_system ? 'checked="checked"' : '', 'COOKIE_SYSTEM' => !$upi2db_which_system ? 'checked="checked"' : '', 'UPI2DB_NEW_WORD_YES' => $upi2db_new_word ? 'checked="checked"' : '', 'UPI2DB_NEW_WORD_NO' => !$upi2db_new_word ? 'checked="checked"' : '', 'UPI2DB_EDIT_WORD_YES' => $upi2db_edit_word ? 'checked="checked"' : '', 'UPI2DB_EDIT_WORD_NO' => !$upi2db_edit_word ? 'checked="checked"' : '', 'UPI2DB_UNREAD_COLOR_YES' => $upi2db_unread_color ? 'checked="checked"' : '', 'UPI2DB_UNREAD_COLOR_NO' => !$upi2db_unread_color ? 'checked="checked"' : '', 'HIDE_USER_YES' => !$allowviewonline ? 'checked="checked"' : '', 'HIDE_USER_NO' => $allowviewonline ? 'checked="checked"' : '', 'VIEW_EMAIL_YES' => $viewemail ? 'checked="checked"' : '', 'VIEW_EMAIL_NO' => !$viewemail ? 'checked="checked"' : '', 'ALLOW_MASS_EMAIL_YES' => $allowmassemail ? 'checked="checked"' : '', 'ALLOW_MASS_EMAIL_NO' => !$allowmassemail ? 'checked="checked"' : '', 'ALLOW_PM_IN_YES' => $allowpmin ? 'checked="checked"' : '', 'ALLOW_PM_IN_NO' => !$allowpmin ? 'checked="checked"' : '', 'NOTIFY_PM_YES' => $notifypm ? 'checked="checked"' : '', 'NOTIFY_PM_NO' => !$notifypm ? 'checked="checked"' : '', 'POPUP_PM_YES' => $popup_pm ? 'checked="checked"' : '', 'POPUP_PM_NO' => !$popup_pm ? 'checked="checked"' : '', 'ALWAYS_ADD_SIGNATURE_YES' => $attachsig ? 'checked="checked"' : '', 'ALWAYS_ADD_SIGNATURE_NO' => !$attachsig ? 'checked="checked"' : '', 'ALWAYS_SET_BOOKMARK_YES' => $setbm ? 'checked="checked"' : '', 'ALWAYS_SET_BOOKMARK_NO' => !$setbm ? 'checked="checked"' : '', 'NOTIFY_REPLY_YES' => $notifyreply ? 'checked="checked"' : '', 'NOTIFY_REPLY_NO' => !$notifyreply ? 'checked="checked"' : '', 'ALWAYS_ALLOW_BBCODE_YES' => $allowbbcode ? 'checked="checked"' : '', 'ALWAYS_ALLOW_BBCODE_NO' => !$allowbbcode ? 'checked="checked"' : '', 'ALWAYS_ALLOW_HTML_YES' => $allowhtml ? 'checked="checked"' : '', 'ALWAYS_ALLOW_HTML_NO' => !$allowhtml ? 'checked="checked"' : '', 'ALWAYS_ALLOW_SMILIES_YES' => $allowsmilies ? 'checked="checked"' : '', 'ALWAYS_ALLOW_SMILIES_NO' => !$allowsmilies ? 'checked="checked"' : '', 'SHOW_AVATARS_YES' => $showavatars ? 'checked="checked"' : '', 'SHOW_AVATARS_NO' => !$showavatars ? 'checked="checked"' : '', 'SHOW_SIGNATURES_YES' => $showsignatures ? 'checked="checked"' : '', 'SHOW_SIGNATURES_NO' => !$showsignatures ? 'checked="checked"' : '', 'ALWAYS_ALLOW_SWEARYWORDS_YES' => $allowswearywords ? 'checked="checked"' : '', 'ALWAYS_ALLOW_SWEARYWORDS_NO' => !$allowswearywords ? 'checked="checked"' : '', 'POSTS_PER_PAGE' => empty($user->data['user_posts_per_page']) ? $config['posts_per_page'] : intval($user->data['user_posts_per_page']), 'TOPICS_PER_PAGE' => empty($user->data['user_topics_per_page']) ? $config['topics_per_page'] : intval($user->data['user_topics_per_page']), 'HOT_TOPIC' => empty($user->data['user_hot_threshold']) ? $config['hot_threshold'] : $user->data['user_hot_threshold'], 'USER_TOPIC_SHOW_DAYS_SELECT' => $user_topic_show_days_select, 'USER_TOPIC_SORTBY_TYPE_SELECT' => $user_topic_sortby_type_select, 'USER_TOPIC_SORTBY_DIR_SELECT' => $user_topic_sortby_dir_select, 'USER_POST_SHOW_DAYS_SELECT' => $user_post_show_days_select, 'USER_POST_SORTBY_TYPE_SELECT' => $user_post_sortby_type_select, 'USER_POST_SORTBY_DIR_SELECT' => $user_post_sortby_dir_select, 'ALLOW_AVATAR' => $config['allow_avatar_upload'], 'AVATAR' => $avatar_img, 'AVATAR_SIZE' => $config['avatar_filesize'], 'GRAVATAR' => $user->data['user_avatar_type'] == USER_GRAVATAR ? $user->data['user_avatar'] : '', 'LANGUAGE_SELECT' => language_select('language', $user_lang), 'STYLE_SELECT' => style_select('style', $user_style), 'TIMEZONE_SELECT' => tz_select('timezone', $user_timezone), 'DATE_FORMAT' => date_select('dateformat', $user_dateformat), 'TIME_MODE' => $time_mode, 'TIME_MODE_MANUAL_CHECKED' => $time_mode_manual_checked, 'TIME_MODE_MANUAL_DST_CHECKED' => $time_mode_manual_dst_checked, 'TIME_MODE_SERVER_SWITCH_CHECKED' => $time_mode_server_switch_checked, 'DST_TIME_LAG' => $dst_time_lag, 'HTML_STATUS' => $html_status, 'BBCODE_STATUS' => sprintf($bbcode_status, '<a href="' . append_sid('faq.' . PHP_EXT . '?mode=bbcode') . '" target="_blank">', '</a>'), 'SMILIES_STATUS' => $smilies_status, 'L_CURRENT_PASSWORD' => $lang['Current_password'], 'L_NEW_PASSWORD' => $mode == 'register' ? $lang['Password'] : $lang['New_password'], 'L_CONFIRM_PASSWORD' => $lang['Confirm_password'], 'L_CONFIRM_PASSWORD_EXPLAIN' => $mode == 'editprofile' ? $lang['Confirm_password_explain'] : '', 'L_PASSWORD_IF_CHANGED' => $mode == 'editprofile' ? $lang['password_if_changed'] : '', 'L_PASSWORD_CONFIRM_IF_CHANGED' => $mode == 'editprofile' ? $lang['password_confirm_if_changed'] : '', 'L_SUBMIT' => $lang['Submit'], 'L_RESET' => $lang['Reset'], 'L_ICQ_NUMBER' => $lang['ICQ'], 'L_MESSENGER' => $lang['MSNM'], 'L_YAHOO' => $lang['YIM'], 'L_SKYPE' => $lang['SKYPE'], 'L_WEBSITE' => $lang['Website'], 'L_AIM' => $lang['AIM'], 'L_LOCATION' => $lang['Location'], 'L_OCCUPATION' => $lang['Occupation'], 'L_BOARD_LANGUAGE' => $lang['Board_lang'], 'L_BOARD_STYLE' => $lang['Board_style'], 'L_TIMEZONE' => $lang['Timezone'], 'L_TIME_MODE' => $lang['time_mode'], 'L_TIME_MODE_TEXT' => $lang['time_mode_text'], 'L_TIME_MODE_MANUAL' => $lang['time_mode_manual'], 'L_TIME_MODE_DST' => $lang['time_mode_dst'], 'L_TIME_MODE_DST_OFF' => $l_time_mode_0, 'L_TIME_MODE_DST_ON' => $l_time_mode_1, 'L_TIME_MODE_DST_SERVER' => $l_time_mode_2, 'L_TIME_MODE_DST_TIME_LAG' => $lang['time_mode_dst_time_lag'], 'L_TIME_MODE_DST_MN' => $lang['time_mode_dst_mn'], 'L_TIME_MODE_TIMEZONE' => $lang['time_mode_timezone'], 'L_TIME_MODE_AUTO' => $lang['time_mode_auto'], 'L_DATE_FORMAT' => $lang['Date_format'], 'L_DATE_FORMAT_EXPLAIN' => $lang['Date_format_explain'], 'L_INTERESTS' => $lang['Interests'], 'L_GENDER' => $lang['Gender'], 'L_GENDER_MALE' => $lang['Male'], 'L_GENDER_FEMALE' => $lang['Female'], 'L_GENDER_NOT_SPECIFY' => $lang['No_gender_specify'], 'L_BIRTHDAY' => $lang['Birthday'], 'L_ALWAYS_ALLOW_SMILIES' => $lang['Always_smile'], 'L_ALWAYS_ALLOW_SWEARYWORDS' => $lang['Always_swear'], 'L_ALWAYS_ALLOW_BBCODE' => $lang['Always_bbcode'], 'L_ALWAYS_ALLOW_HTML' => $lang['Always_html'], 'L_HOT_THRESHOLD' => $lang['Hot_threshold'], 'L_POSTS_PER_PAGE' => $lang['Posts_per_page'], 'L_TOPICS_PER_PAGE' => $lang['Topics_per_page'], 'L_HIDE_USER' => $lang['Hide_user'], 'L_ALWAYS_ADD_SIGNATURE' => $lang['Always_add_sig'], 'L_ALWAYS_SET_BOOKMARK' => $lang['Always_set_bm'], 'L_SHOW_AVATARS' => $lang['Show_avatars'], 'L_SHOW_SIGNATURES' => $lang['Show_signatures'], 'L_RETRO_SIG' => $lang['Retro_sig'], 'L_RETRO_SIG_EXPLAIN' => $lang['Retro_sig_explain'], 'L_RETRO_SIG_CHECKBOX' => $lang['Retro_sig_checkbox'], 'L_AVATAR_SIGNATURE' => $lang['Signature_Panel'], 'L_AVATAR_PANEL' => $lang['Avatar_panel'], 'L_AVATAR_EXPLAIN' => sprintf($lang['Avatar_explain'], $config['avatar_max_width'], $config['avatar_max_height'], round($config['avatar_filesize'] / 1024)), 'L_UPLOAD_AVATAR_FILE' => $lang['Upload_Avatar_file'], 'L_UPLOAD_AVATAR_URL' => $lang['Upload_Avatar_URL'], 'L_UPLOAD_AVATAR_URL_EXPLAIN' => $lang['Upload_Avatar_URL_explain'], 'L_AVATAR_GALLERY' => $lang['Select_from_gallery'], 'L_SHOW_GALLERY' => $lang['View_avatar_gallery'], 'L_GENERATE_AVATAR' => $lang['Create_with_generator'], 'L_AVATAR_GENERATOR' => $lang['View_avatar_generator'], 'L_LINK_REMOTE_AVATAR' => $lang['Link_remote_Avatar'], 'L_LINK_REMOTE_AVATAR_EXPLAIN' => $lang['Link_remote_Avatar_explain'], 'L_GRAVATAR' => $lang['Gravatar'], 'L_GRAVATAR_EXPLAIN' => $lang['Gravatar_explain'], 'L_DELETE_AVATAR' => $lang['Delete_Image'], 'L_CURRENT_IMAGE' => $lang['Current_Image'], 'L_SIGNATURE' => $lang['Signature'], 'L_SIGNATURE_EXPLAIN' => sprintf($lang['Signature_explain'], $config['max_sig_chars']), 'L_NOTIFY_ON_REPLY' => $lang['Always_notify'], 'L_NOTIFY_ON_REPLY_EXPLAIN' => $lang['Always_notify_explain'], 'L_NOTIFY_ON_PRIVMSG' => $lang['Notify_on_privmsg'], 'L_POPUP_ON_PRIVMSG' => $lang['Popup_on_privmsg'], 'L_POPUP_ON_PRIVMSG_EXPLAIN' => $lang['Popup_on_privmsg_explain'], 'L_PREFERENCES' => $lang['Preferences'], 'L_UPI2DB_SYSTEM' => $lang['upi2db_system'], 'L_UPI2DB_WHICH_SYSTEM' => $lang['upi2db_which_system'], 'L_UPI2DB_WHICH_SYSTEM_EXPLAIN' => $lang['upi2db_which_system_explain'], 'L_UPI2DB_NEW_WORD' => $lang['upi2db_new_word'], 'L_UPI2DB_NEW_WORD_EXPLAIN' => $lang['upi2db_new_word_explain'], 'L_UPI2DB_EDIT_WORD' => $lang['upi2db_edit_word'], 'L_UPI2DB_EDIT_WORD_EXPLAIN' => $lang['upi2db_edit_word_explain'], 'L_COOKIE_SYSTEM' => $lang['cookie_system'], 'L_UPI2DB_SYSTEM' => $lang['upi2db_system'], 'L_UPI2DB_UNREAD_COLOR' => $lang['upi2db_unread_color'], 'L_PUBLIC_VIEW_EMAIL' => $lang['Public_view_email'], 'L_MASS_EMAIL' => $lang['Admin_Emails'], 'L_PM_IN' => $lang['Allow_PM_IN'], 'L_PM_IN_EXPLAIN' => $lang['Allow_PM_IN_Explain'], 'L_ITEMS_REQUIRED' => $lang['Items_required'], 'L_REGISTRATION_INFO' => $lang['Registration_info'], 'L_PROFILE_INFO' => $lang['Profile_info'], 'L_PROFILE_INFO_NOTICE' => $lang['Profile_info_warn'], 'L_EMAIL_ADDRESS' => $lang['Email_address'], 'L_CONFIRM_EMAIL' => $lang['Email_confirm'], 'EMAIL_CONFIRM' => $email_confirm, 'L_CONFIRM_CODE_IMPAIRED' => sprintf($lang['CONFIRM_CODE_IMPAIRED'], '<a href="mailto:' . $config['board_email'] . '">', '</a>'), 'U_AJAX_VERIFY' => 'ajax_verify.' . PHP_EXT, 'VERIFY_UN_JS' => $verify_un_js, 'VERIFY_EMAIL_JS' => $verify_email_js, 'L_UN_SHORT' => $lang['Reg_Username_Short'], 'L_UN_LONG' => $lang['Reg_Username_Long'], 'L_UN_TAKEN' => $lang['Reg_Username_Taken'], 'L_UN_FREE' => $lang['Reg_Username_Free'], 'L_PWD_SHORT' => $lang['Reg_PWD_Short'], 'L_PWD_EASY' => $lang['Reg_PWD_Easy'], 'L_PWD_OK' => $lang['Reg_PWD_OK'], 'L_EMAIL_INVALID' => $lang['Reg_Email_Invalid'], 'L_EMAIL_OK' => $lang['Reg_Email_OK'], 'S_ALLOW_AVATAR_UPLOAD' => $config['allow_avatar_upload'], 'S_ALLOW_AVATAR_LOCAL' => $config['allow_avatar_local'], 'S_ALLOW_AVATAR_REMOTE' => $config['allow_avatar_remote'], 'S_ALLOW_AVATAR_GENERATOR' => $config['allow_avatar_generator'], 'S_ENABLE_GRAVATARS' => $config['enable_gravatars'], 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'S_FORM_ENCTYPE' => $form_enctype, 'S_PROFILE_ACTION' => append_sid(CMS_PAGE_PROFILE . '?cpl_mode=' . $cpl_mode . $social_connect_append))); // // This is another cheat using the block_var capability // of the templates to 'fake' an IF...ELSE...ENDIF solution // it works well :) // if ($mode != 'register') { if ($user->data['user_allowavatar'] && ($config['allow_avatar_upload'] || $config['allow_avatar_local'] || $config['allow_avatar_remote'] || $config['enable_gravatars'] || $config['allow_avatar_generator'])) { $template->assign_block_vars($cpl_avatar_control . 'switch_avatar_block', array()); if ($config['allow_avatar_upload'] && file_exists(@phpbb_realpath('./' . $config['avatar_path']))) { if ($form_enctype != '') { $template->assign_block_vars($cpl_avatar_control . 'switch_avatar_block.switch_avatar_local_upload', array()); } $template->assign_block_vars($cpl_avatar_control . 'switch_avatar_block.switch_avatar_remote_upload', array()); } if ($config['allow_avatar_remote']) {
$emailer->reset(); $message = $lang['PROFILE_UPDATED_INACTIVE']; $user->session_end(); } else { meta_refresh('index.php', 10); $message = $lang['PROFILE_UPDATED']; } $sql_args = DB()->build_array('UPDATE', $db_data); DB()->query("UPDATE " . BB_USERS . " SET {$sql_args} WHERE user_id = {$pr_data['user_id']} LIMIT 1"); if ($pr_data['user_id'] != $userdata['user_id']) { if ($pr_data['user_level'] == MOD && !empty($db_data['username'])) { $datastore->update('moderators'); } } cache_rm_user_sessions($pr_data['user_id']); if ($adm_edit) { bb_die($lang['PROFILE_USER'] . ' <b>' . profile_url($pr_data) . '</b> ' . $lang['GOOD_UPDATE']); } elseif (!$pr_data['user_active']) { bb_die($lang['PROFILE_UPDATED_INACTIVE']); } else { meta_refresh('index.php', 10); bb_die($lang['PROFILE_UPDATED']); } } else { bb_die($lang['NOTHING_HAS_CHANGED']); } } } $template->assign_vars($tp_data); $template->assign_vars(array('PAGE_TITLE' => $mode == 'editprofile' ? $lang['EDIT_PROFILE'] . ($adm_edit ? " :: {$pr_data['username']}" : '') : $lang['REGISTER'], 'SHOW_REG_AGREEMENT' => $mode == 'register' && !IS_ADMIN, 'ERROR_MESSAGE' => $errors ? join('<br />', array_unique($errors)) : '', 'MODE' => $mode, 'EDIT_PROFILE' => $mode == 'editprofile', 'ADM_EDIT' => $adm_edit, 'SHOW_PASS' => $adm_edit || $mode == 'register' && IS_ADMIN, 'CAPTCHA_HTML' => $need_captcha ? bb_captcha('get') : '', 'LANGUAGE_SELECT' => language_select($pr_data['user_lang'], 'user_lang'), 'TIMEZONE_SELECT' => tz_select($pr_data['user_timezone'], 'user_timezone'), 'USER_TIMEZONE' => $pr_data['user_timezone'], 'AVATAR_EXPLAIN' => sprintf($lang['AVATAR_EXPLAIN'], $bb_cfg['avatars']['max_width'], $bb_cfg['avatars']['max_height'], round($bb_cfg['avatars']['max_size'] / 1024)), 'AVATAR_DISALLOWED' => bf($pr_data['user_opt'], 'user_opt', 'dis_avatar'), 'AVATAR_DIS_EXPLAIN' => sprintf($lang['AVATAR_DISABLE'], $bb_cfg['terms_and_conditions_url']), 'AVATAR_IMG' => get_avatar($pr_data['user_id'], $pr_data['avatar_ext_id'], !bf($pr_data['user_opt'], 'user_opt', 'dis_avatar')), 'SIGNATURE_EXPLAIN' => sprintf($lang['SIGNATURE_EXPLAIN'], $bb_cfg['max_sig_chars']), 'SIG_DISALLOWED' => bf($pr_data['user_opt'], 'user_opt', 'dis_sig'), 'PR_USER_ID' => $pr_data['user_id'], 'U_RESET_AUTOLOGIN' => LOGIN_URL . "?logout=1&reset_autologin=1&sid={$userdata['session_id']}")); print_page('usercp_register.tpl');
function main($id, $mode) { global $config, $db, $user, $auth, $template, $phpbb_root_path, $phpEx; // if ($config['require_activation'] == USER_ACTIVATION_DISABLE) { trigger_error('UCP_REGISTER_DISABLE'); } include $phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx; $confirm_id = request_var('confirm_id', ''); $coppa = isset($_REQUEST['coppa']) ? !empty($_REQUEST['coppa']) ? 1 : 0 : false; $agreed = !empty($_POST['agreed']) ? 1 : 0; $submit = isset($_POST['submit']) ? true : false; $change_lang = request_var('change_lang', ''); if ($change_lang) { $submit = false; $lang = $change_lang; $user->lang_name = $lang = $change_lang; $user->lang_path = $phpbb_root_path . 'language/' . $lang . '/'; $user->lang = array(); $user->add_lang(array('common', 'ucp')); } $cp = new custom_profile(); $error = $data = $cp_data = $cp_error = array(); // if (!$agreed) { if ($coppa === false && $config['coppa_enable']) { $now = getdate(); $coppa_birthday = $user->format_date(mktime($now['hours'] + $user->data['user_dst'], $now['minutes'], $now['seconds'], $now['mon'], $now['mday'] - 1, $now['year'] - 13), $user->lang['DATE_FORMAT']); unset($now); $template->assign_vars(array('L_COPPA_NO' => sprintf($user->lang['UCP_COPPA_BEFORE'], $coppa_birthday), 'L_COPPA_YES' => sprintf($user->lang['UCP_COPPA_ON_AFTER'], $coppa_birthday), 'U_COPPA_NO' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=register&coppa=0'), 'U_COPPA_YES' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=register&coppa=1'), 'S_SHOW_COPPA' => true, 'S_REGISTER_ACTION' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=register'))); } else { $template->assign_vars(array('L_TERMS_OF_USE' => sprintf($user->lang['TERMS_OF_USE_CONTENT'], $config['sitename'], generate_board_url()), 'S_SHOW_COPPA' => false, 'S_REGISTRATION' => true, 'S_REGISTER_ACTION' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=register'))); } $this->tpl_name = 'ucp_agreement'; return; } $var_ary = array('username' => (string) '', 'password_confirm' => (string) '', 'new_password' => (string) '', 'cur_password' => (string) '', 'email' => (string) '', 'email_confirm' => (string) '', 'confirm_code' => (string) '', 'lang' => (string) $config['default_lang'], 'tz' => (double) $config['board_timezone']); // If we change the language inline, we do not want to display errors, but pre-fill already filled out values if ($change_lang) { foreach ($var_ary as $var => $default) { ${$var} = request_var($var, $default, true); } } // Check and initialize some variables if needed if ($submit) { foreach ($var_ary as $var => $default) { $data[$var] = request_var($var, $default, true); } $var_ary = array('username' => array(array('string', false, $config['min_name_chars'], $config['max_name_chars']), array('username')), 'password_confirm' => array('string', false, $config['min_pass_chars'], $config['max_pass_chars']), 'new_password' => array('string', false, $config['min_pass_chars'], $config['max_pass_chars']), 'email' => array(array('string', false, 6, 60), array('email')), 'email_confirm' => array('string', false, 6, 60), 'confirm_code' => array('string', !$config['enable_confirm'], 5, 8), 'tz' => array('num', false, -14, 14), 'lang' => array('match', false, '#^[a-z_]{2,}$#i')); $error = validate_data($data, $var_ary); extract($data); unset($data); // Replace "error" strings with their real, localised form $error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error); // validate custom profile fields $cp->submit_cp_field('register', $user->get_iso_lang_id(), $cp_data, $error); // Visual Confirmation handling $wrong_confirm = false; if ($config['enable_confirm']) { if (!$confirm_id) { $error[] = $user->lang['CONFIRM_CODE_WRONG']; $wrong_confirm = true; } else { $sql = 'SELECT code FROM ' . CONFIRM_TABLE . "\n\t\t\t\t\t\tWHERE confirm_id = '" . $db->sql_escape($confirm_id) . "'\n\t\t\t\t\t\t\tAND session_id = '" . $db->sql_escape($user->session_id) . "'\n\t\t\t\t\t\t\tAND confirm_type = " . CONFIRM_REG; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); if ($row) { if (strcasecmp($row['code'], $confirm_code) === 0) { $sql = 'DELETE FROM ' . CONFIRM_TABLE . "\n\t\t\t\t\t\t\t\tWHERE confirm_id = '" . $db->sql_escape($confirm_id) . "'\n\t\t\t\t\t\t\t\t\tAND session_id = '" . $db->sql_escape($user->session_id) . "'\n\t\t\t\t\t\t\t\t\tAND confirm_type = " . CONFIRM_REG; $db->sql_query($sql); } else { $error[] = $user->lang['CONFIRM_CODE_WRONG']; $wrong_confirm = true; } } else { $error[] = $user->lang['CONFIRM_CODE_WRONG']; $wrong_confirm = true; } } } if (!sizeof($error)) { if ($new_password != $password_confirm) { $error[] = $user->lang['NEW_PASSWORD_ERROR']; } if ($email != $email_confirm) { $error[] = $user->lang['NEW_EMAIL_ERROR']; } } if (!sizeof($error)) { $server_url = generate_board_url(); // Which group by default? $group_reg = $coppa ? 'REGISTERED_COPPA' : 'REGISTERED'; $group_inactive = $coppa ? 'INACTIVE_COPPA' : 'INACTIVE'; $group_name = $config['require_activation'] == USER_ACTIVATION_NONE ? $group_reg : $group_inactive; $sql = 'SELECT group_id FROM ' . GROUPS_TABLE . "\n\t\t\t\t\tWHERE group_name = '" . $db->sql_escape($group_name) . "'\n\t\t\t\t\t\tAND group_type = " . GROUP_SPECIAL; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); if (!$row) { trigger_error('NO_GROUP'); } $group_id = $row['group_id']; if (($coppa || $config['require_activation'] == USER_ACTIVATION_SELF || $config['require_activation'] == USER_ACTIVATION_ADMIN) && $config['email_enable']) { $user_actkey = gen_rand_string(10); $key_len = 54 - strlen($server_url); $key_len = $key_len < 6 ? 6 : $key_len; $user_actkey = substr($user_actkey, 0, $key_len); $user_type = USER_INACTIVE; } else { $user_type = USER_NORMAL; $user_actkey = ''; } $user_row = array('username' => $username, 'user_password' => md5($new_password), 'user_email' => $email, 'group_id' => (int) $group_id, 'user_timezone' => (double) $tz, 'user_lang' => $lang, 'user_type' => $user_type, 'user_actkey' => $user_actkey, 'user_ip' => $user->ip, 'user_regdate' => time()); // Register user... $user_id = user_add($user_row, $cp_data); // This should not happen, because the required variables are listed above... if ($user_id === false) { trigger_error($user->lang['NO_USER'], E_USER_ERROR); } if ($coppa && $config['email_enable']) { $message = $user->lang['ACCOUNT_COPPA']; $email_template = 'coppa_welcome_inactive'; } else { if ($config['require_activation'] == USER_ACTIVATION_SELF && $config['email_enable']) { $message = $user->lang['ACCOUNT_INACTIVE']; $email_template = 'user_welcome_inactive'; } else { if ($config['require_activation'] == USER_ACTIVATION_ADMIN && $config['email_enable']) { $message = $user->lang['ACCOUNT_INACTIVE_ADMIN']; $email_template = 'admin_welcome_inactive'; } else { $message = $user->lang['ACCOUNT_ADDED']; $email_template = 'user_welcome'; } } } if ($config['email_enable']) { include_once $phpbb_root_path . 'includes/functions_messenger.' . $phpEx; $messenger = new messenger(false); $messenger->template($email_template, $lang); $messenger->replyto($config['board_contact']); $messenger->to($email, $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('SITENAME' => $config['sitename'], 'WELCOME_MSG' => sprintf($user->lang['WELCOME_SUBJECT'], $config['sitename']), 'USERNAME' => html_entity_decode($username), 'PASSWORD' => html_entity_decode($password_confirm), 'EMAIL_SIG' => str_replace('<br />', "\n", "-- \n" . $config['board_email_sig']), 'U_ACTIVATE' => "{$server_url}/ucp.{$phpEx}?mode=activate&u={$user_id}&k={$user_actkey}")); if ($coppa) { $messenger->assign_vars(array('FAX_INFO' => $config['coppa_fax'], 'MAIL_INFO' => $config['coppa_mail'], 'EMAIL_ADDRESS' => $email, 'SITENAME' => $config['sitename'])); } $messenger->send(NOTIFY_EMAIL); if ($config['require_activation'] == USER_ACTIVATION_ADMIN) { // Grab an array of user_id's with a_user permissions ... these users can activate a user $admin_ary = $auth->acl_get_list(false, 'a_user', false); $sql = 'SELECT user_id, username, user_email, user_lang, user_jabber, user_notify_type FROM ' . USERS_TABLE . ' WHERE user_id IN (' . implode(', ', $admin_ary[0]['a_user']) . ')'; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $messenger->template('admin_activate', $row['user_lang']); $messenger->replyto($config['board_contact']); $messenger->to($row['user_email'], $row['username']); $messenger->im($row['user_jabber'], $row['username']); $messenger->assign_vars(array('USERNAME' => html_entity_decode($username), 'EMAIL_SIG' => str_replace('<br />', "\n", "-- \n" . $config['board_email_sig']), 'U_ACTIVATE' => "{$server_url}/ucp.{$phpEx}?mode=activate&u={$user_id}&k={$user_actkey}")); $messenger->send($row['user_notify_type']); } $db->sql_freeresult($result); } } if ($user_type == USER_NORMAL || !$config['email_enable']) { set_config('newest_user_id', $user_id, true); set_config('newest_username', $username, true); set_config('num_users', $config['num_users'] + 1, true); } unset($data); $message = $message . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid("{$phpbb_root_path}index.{$phpEx}") . '">', '</a>'); trigger_error($message); } } $s_hidden_fields = build_hidden_fields(array('agreed' => 'true', 'coppa' => $coppa, 'change_lang' => 0)); $confirm_image = ''; // Visual Confirmation - Show images if ($config['enable_confirm']) { if (!$change_lang) { $sql = 'SELECT session_id FROM ' . SESSIONS_TABLE; $result = $db->sql_query($sql); if ($row = $db->sql_fetchrow($result)) { $sql_in = array(); do { $sql_in[] = "'" . $db->sql_escape($row['session_id']) . "'"; } while ($row = $db->sql_fetchrow($result)); $sql = 'DELETE FROM ' . CONFIRM_TABLE . ' WHERE session_id NOT IN (' . implode(', ', $sql_in) . ') AND confirm_type = ' . CONFIRM_REG; $db->sql_query($sql); } $db->sql_freeresult($result); $sql = 'SELECT COUNT(session_id) AS attempts FROM ' . CONFIRM_TABLE . "\n\t\t\t\t\tWHERE session_id = '" . $db->sql_escape($user->session_id) . "'\n\t\t\t\t\t\tAND confirm_type = " . CONFIRM_REG; $result = $db->sql_query($sql); $attempts = (int) $db->sql_fetchfield('attempts'); $db->sql_freeresult($result); if ($config['max_reg_attempts'] && $attempts > $config['max_reg_attempts']) { trigger_error($user->lang['TOO_MANY_REGISTERS']); } $code = gen_rand_string(mt_rand(5, 8)); $confirm_id = md5(unique_id($user->ip)); $sql = 'INSERT INTO ' . CONFIRM_TABLE . ' ' . $db->sql_build_array('INSERT', array('confirm_id' => (string) $confirm_id, 'session_id' => (string) $user->session_id, 'confirm_type' => (int) CONFIRM_REG, 'code' => (string) $code)); $db->sql_query($sql); } $confirm_image = '<img src="' . append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=confirm&id=' . $confirm_id . '&type=' . CONFIRM_REG) . '" alt="" title="" />'; $s_hidden_fields .= '<input type="hidden" name="confirm_id" value="' . $confirm_id . '" />'; } // $l_reg_cond = ''; switch ($config['require_activation']) { case USER_ACTIVATION_SELF: $l_reg_cond = $user->lang['UCP_EMAIL_ACTIVATE']; break; case USER_ACTIVATION_ADMIN: $l_reg_cond = $user->lang['UCP_ADMIN_ACTIVATE']; break; } $user_char_ary = array('.*' => 'USERNAME_CHARS_ANY', '[\\w]+' => 'USERNAME_ALPHA_ONLY', '[\\w_\\+\\. \\-\\[\\]]+' => 'USERNAME_ALPHA_SPACERS'); $lang = isset($lang) ? $lang : $config['default_lang']; $tz = isset($tz) ? $tz : $config['board_timezone']; // $template->assign_vars(array('ERROR' => sizeof($error) ? implode('<br />', $error) : '', 'USERNAME' => isset($username) ? $username : '', 'PASSWORD' => isset($new_password) ? $new_password : '', 'PASSWORD_CONFIRM' => isset($password_confirm) ? $password_confirm : '', 'EMAIL' => isset($email) ? $email : '', 'EMAIL_CONFIRM' => isset($email_confirm) ? $email_confirm : '', 'CONFIRM_IMG' => $confirm_image, 'L_CONFIRM_EXPLAIN' => sprintf($user->lang['CONFIRM_EXPLAIN'], '<a href="mailto:' . htmlentities($config['board_contact']) . '">', '</a>'), 'L_ITEMS_REQUIRED' => $l_reg_cond, 'L_USERNAME_EXPLAIN' => sprintf($user->lang[$user_char_ary[str_replace('\\\\', '\\', $config['allow_name_chars'])] . '_EXPLAIN'], $config['min_name_chars'], $config['max_name_chars']), 'L_NEW_PASSWORD_EXPLAIN' => sprintf($user->lang['NEW_PASSWORD_EXPLAIN'], $config['min_pass_chars'], $config['max_pass_chars']), 'S_LANG_OPTIONS' => language_select($lang), 'S_TZ_OPTIONS' => tz_select($tz), 'S_CONFIRM_CODE' => $config['enable_confirm'] ? true : false, 'S_COPPA' => $coppa, 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'S_UCP_ACTION' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=register'))); // $user->profile_fields = array(); // Generate profile fields -> Template Block Variable profile_fields $cp->generate_profile_fields('register', $user->get_iso_lang_id()); // $this->tpl_name = 'ucp_register'; $this->page_title = 'UCP_REGISTRATION'; }
} if (isset($HTTP_POST_VARS['submit'])) { $sql = "UPDATE " . CONFIG_TABLE . " SET\r\n\t\t\t\tconfig_value = '" . str_replace("\\'", "''", $new[$config_name]) . "'\r\n\t\t\t\tWHERE config_name = '{$config_name}'"; if (!$db->sql_query($sql)) { message_die(GENERAL_ERROR, "Failed to update general configuration for {$config_name}", "", __LINE__, __FILE__, $sql); } } } if (isset($HTTP_POST_VARS['submit'])) { $message = $lang['Config_updated'] . "<br /><br />" . sprintf($lang['Click_return_config'], "<a href=\"" . append_sid("admin_board.{$phpEx}") . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_admin_index'], "<a href=\"" . append_sid("index.{$phpEx}?pane=right") . "\">", "</a>"); message_die(GENERAL_MESSAGE, $message); } } $style_select = style_select($new['default_style'], 'default_style', "../templates"); $lang_select = language_select($new['default_lang'], 'default_lang', "../language"); $timezone_select = tz_select($new['board_timezone'], 'board_timezone'); $disable_board_yes = $new['board_disable'] ? "checked=\"checked\"" : ""; $disable_board_no = !$new['board_disable'] ? "checked=\"checked\"" : ""; $cookie_secure_yes = $new['cookie_secure'] ? "checked=\"checked\"" : ""; $cookie_secure_no = !$new['cookie_secure'] ? "checked=\"checked\"" : ""; $html_tags = $new['allow_html_tags']; $override_user_style_yes = $new['override_user_style'] ? "checked=\"checked\"" : ""; $override_user_style_no = !$new['override_user_style'] ? "checked=\"checked\"" : ""; $html_yes = $new['allow_html'] ? "checked=\"checked\"" : ""; $html_no = !$new['allow_html'] ? "checked=\"checked\"" : ""; $bbcode_yes = $new['allow_bbcode'] ? "checked=\"checked\"" : ""; $bbcode_no = !$new['allow_bbcode'] ? "checked=\"checked\"" : ""; $activation_none = $new['require_activation'] == USER_ACTIVATION_NONE ? "checked=\"checked\"" : ""; $activation_user = $new['require_activation'] == USER_ACTIVATION_SELF ? "checked=\"checked\"" : ""; $activation_admin = $new['require_activation'] == USER_ACTIVATION_ADMIN ? "checked=\"checked\"" : ""; $confirm_yes = $new['enable_confirm'] ? 'checked="checked"' : '';
} } switch ($mode) { case 'config_mods': $template->assign_vars(array('S_CONFIG_ACTION' => 'admin_board.php?mode=config_mods', 'CONFIG_MODS' => true, 'MAGNET_LINKS_ENABLED' => $new['magnet_links_enabled'], 'GENDER' => $new['gender'], 'CALLSEED' => $new['callseed'], 'TOR_STATS' => $new['tor_stats'], 'SHOW_LATEST_NEWS' => $new['show_latest_news'], 'MAX_NEWS_TITLE' => $new['max_news_title'], 'LATEST_NEWS_COUNT' => $new['latest_news_count'], 'LATEST_NEWS_FORUM_ID' => $new['latest_news_forum_id'], 'SHOW_NETWORK_NEWS' => $new['show_network_news'], 'MAX_NET_TITLE' => $new['max_net_title'], 'NETWORK_NEWS_COUNT' => $new['network_news_count'], 'NETWORK_NEWS_FORUM_ID' => $new['network_news_forum_id'], 'WHOIS_INFO' => $new['whois_info'], 'SHOW_MOD_INDEX' => $new['show_mod_index'], 'BIRTHDAY_ENABLED' => $new['birthday_enabled'], 'BIRTHDAY_MAX_AGE' => $new['birthday_max_age'], 'BIRTHDAY_MIN_AGE' => $new['birthday_min_age'], 'BIRTHDAY_CHECK_DAY' => $new['birthday_check_day'], 'PREMOD' => $new['premod'], 'TOR_COMMENT' => $new['tor_comment'], 'NEW_TPLS' => $new['new_tpls'], 'SEED_BONUS_ENABLED' => $new['seed_bonus_enabled'], 'SEED_BONUS_TOR_SIZE' => $new['seed_bonus_tor_size'], 'SEED_BONUS_USER_REGDATE' => $new['seed_bonus_user_regdate'])); if ($new['seed_bonus_points'] && $new['seed_bonus_release']) { $seed_bonus = unserialize($new['seed_bonus_points']); $seed_release = unserialize($new['seed_bonus_release']); foreach ($seed_bonus as $i => $row) { if (!$row || !$seed_release[$i]) { continue; } $template->assign_block_vars('seed_bonus', array('RELEASE' => $seed_release[$i], 'POINTS' => $row)); } } if ($new['bonus_upload'] && $new['bonus_upload_price']) { $upload_row = unserialize($new['bonus_upload']); $price_row = unserialize($new['bonus_upload_price']); foreach ($upload_row as $i => $row) { if (!$row || !$price_row[$i]) { continue; } $template->assign_block_vars('bonus_upload', array('UP' => $row, 'PRICE' => $price_row[$i])); } } break; default: $template->assign_vars(array('S_CONFIG_ACTION' => 'admin_board.php?mode=config', 'CONFIG' => true, 'SITENAME' => htmlCHR($new['sitename']), 'CONFIG_SITE_DESCRIPTION' => htmlCHR($new['site_desc']), 'DISABLE_BOARD' => $new['board_disable'] ? true : false, 'ALLOW_AUTOLOGIN' => $new['allow_autologin'] ? true : false, 'AUTOLOGIN_TIME' => (int) $new['max_autologin_time'], 'MAX_POLL_OPTIONS' => $new['max_poll_options'], 'FLOOD_INTERVAL' => $new['flood_interval'], 'TOPICS_PER_PAGE' => $new['topics_per_page'], 'POSTS_PER_PAGE' => $new['posts_per_page'], 'HOT_TOPIC' => $new['hot_threshold'], 'DEFAULT_DATEFORMAT' => $new['default_dateformat'], 'LANG_SELECT' => language_select($new['default_lang'], 'default_lang'), 'TIMEZONE_SELECT' => tz_select($new['board_timezone'], 'board_timezone'), 'MAX_LOGIN_ATTEMPTS' => $new['max_login_attempts'], 'LOGIN_RESET_TIME' => $new['login_reset_time'], 'PRUNE_ENABLE' => $new['prune_enable'] ? true : false, 'ALLOW_BBCODE' => $new['allow_bbcode'] ? true : false, 'ALLOW_SMILIES' => $new['allow_smilies'] ? true : false, 'ALLOW_SIG' => $new['allow_sig'] ? true : false, 'SIG_SIZE' => $new['max_sig_chars'], 'ALLOW_NAMECHANGE' => $new['allow_namechange'] ? true : false, 'SMILIES_PATH' => $new['smilies_path'])); break; } print_page('admin_board.tpl', 'admin');
$custom_title_status_regdate = "checked=\"checked\""; break; case CUSTOM_TITLE_DISABLED: $custom_title_status_disabled = "checked=\"checked\""; break; case CUSTOM_TITLE_ENABLED: $custom_title_status_enabled = "checked=\"checked\""; break; } // // Let's do an overall check for settings/versions which would prevent // us from doing file uploads.... // $ini_val = phpversion() >= '4.0.0' ? 'ini_get' : 'get_cfg_var'; $form_enctype = !@$ini_val('file_uploads') || phpversion() == '4.0.4pl1' || !$board_config['allow_avatar_upload'] || phpversion() < '4.0.3' && @$ini_val('open_basedir') != '' ? '' : 'enctype="multipart/form-data"'; $template->assign_vars(array('USERNAME' => $username, 'EMAIL' => $email, 'USER_TYPE_SELECT' => user_type_select($user_type), 'YIM' => $yim, 'ICQ' => $icq, 'MSN' => $msn, 'AIM' => $aim, 'OCCUPATION' => $occupation, 'INTERESTS' => $interests, 'LOCATION' => $location, 'WEBSITE' => $website, 'SIGNATURE' => str_replace('<br />', "\n", $signature), 'CUSTOM_TITLE' => $custom_title, 'CUSTOM_TITLE_STATUS_REGDATE' => $custom_title_status_regdate, 'CUSTOM_TITLE_STATUS_DISABLED' => $custom_title_status_disabled, 'CUSTOM_TITLE_STATUS_ENABLED' => $custom_title_status_enabled, 'VIEW_EMAIL_YES' => $viewemail ? 'checked="checked"' : '', 'VIEW_EMAIL_NO' => !$viewemail ? 'checked="checked"' : '', 'HIDE_USER_YES' => !$allowviewonline ? 'checked="checked"' : '', 'HIDE_USER_NO' => $allowviewonline ? 'checked="checked"' : '', 'NOTIFY_PM_YES' => $notifypm ? 'checked="checked"' : '', 'NOTIFY_PM_NO' => !$notifypm ? 'checked="checked"' : '', 'POPUP_PM_YES' => $popuppm ? 'checked="checked"' : '', 'POPUP_PM_NO' => !$popuppm ? 'checked="checked"' : '', 'ALWAYS_ADD_SIGNATURE_YES' => $attachsig ? 'checked="checked"' : '', 'ALWAYS_ADD_SIGNATURE_NO' => !$attachsig ? 'checked="checked"' : '', 'NOTIFY_REPLY_YES' => $notifyreply ? 'checked="checked"' : '', 'NOTIFY_REPLY_NO' => !$notifyreply ? 'checked="checked"' : '', 'ALWAYS_ALLOW_BBCODE_YES' => $allowbbcode ? 'checked="checked"' : '', 'ALWAYS_ALLOW_BBCODE_NO' => !$allowbbcode ? 'checked="checked"' : '', 'ALWAYS_ALLOW_HTML_YES' => $allowhtml ? 'checked="checked"' : '', 'ALWAYS_ALLOW_HTML_NO' => !$allowhtml ? 'checked="checked"' : '', 'ALWAYS_ALLOW_SMILIES_YES' => $allowsmilies ? 'checked="checked"' : '', 'ALWAYS_ALLOW_SMILIES_NO' => !$allowsmilies ? 'checked="checked"' : '', 'AVATAR' => $avatar, 'LANGUAGE_SELECT' => language_select($user_lang), 'TIMEZONE_SELECT' => tz_select($user_timezone), 'STYLE_SELECT' => style_select($user_style, 'style'), 'DATE_FORMAT' => $user_dateformat, 'ALLOW_PM_YES' => $user_allowpm ? 'checked="checked"' : '', 'ALLOW_PM_NO' => !$user_allowpm ? 'checked="checked"' : '', 'ALLOW_AVATAR_YES' => $user_allowavatar ? 'checked="checked"' : '', 'ALLOW_AVATAR_NO' => !$user_allowavatar ? 'checked="checked"' : '', 'USER_ACTIVE_YES' => $user_status ? 'checked="checked"' : '', 'USER_ACTIVE_NO' => !$user_status ? 'checked="checked"' : '', 'BANCARD' => $user_ycard, 'RANK_SELECT_BOX' => $rank_select_box, 'L_USERNAME' => $lang['Username'], 'L_USER_TITLE' => $lang['User_admin'], 'L_USER_EXPLAIN' => $lang['User_admin_explain'], 'L_USER_TYPE' => $lang['User_Type'], 'L_USER_TYPE_EXPLAIN' => $lang['User_Type_explain'], 'L_NEW_PASSWORD' => $lang['New_password'], 'L_PASSWORD_IF_CHANGED' => $lang['password_if_changed'], 'L_CONFIRM_PASSWORD' => $lang['Confirm_password'], 'L_PASSWORD_CONFIRM_IF_CHANGED' => $lang['password_confirm_if_changed'], 'L_SUBMIT' => $lang['Submit'], 'L_RESET' => $lang['Reset'], 'L_ICQ_NUMBER' => $lang['ICQ'], 'L_MESSENGER' => $lang['MSNM'], 'L_YAHOO' => $lang['YIM'], 'L_WEBSITE' => $lang['Website'], 'L_AIM' => $lang['AIM'], 'L_LOCATION' => $lang['Location'], 'L_OCCUPATION' => $lang['Occupation'], 'L_BOARD_LANGUAGE' => $lang['Board_lang'], 'L_BOARD_STYLE' => $lang['Board_style'], 'L_TIMEZONE' => $lang['Timezone'], 'L_DATE_FORMAT' => $lang['Date_format'], 'L_DATE_FORMAT_EXPLAIN' => $lang['Date_format_explain'], 'L_YES' => $lang['Yes'], 'L_NO' => $lang['No'], 'L_INTERESTS' => $lang['Interests'], 'L_BANCARD' => $lang['ban_card'], 'L_BANCARD_EXPLAIN' => sprintf($lang['ban_card_explain'], $board_config['max_user_bancard']), 'L_CUSTOM_TITLE' => $lang['Custom_title'], 'L_CUSTOM_TITLE_STATUS' => $lang['Custom_title_status'], 'L_CUSTOM_TITLE_STATUS_REGDATE' => $lang['Custom_title_status_regdate'], 'L_CUSTOM_TITLE_STATUS_DISABLED' => $lang['Custom_title_status_disabled'], 'L_CUSTOM_TITLE_STATUS_ENABLED' => $lang['Custom_title_status_enabled'], 'L_ALWAYS_ALLOW_SMILIES' => $lang['Always_smile'], 'L_ALWAYS_ALLOW_BBCODE' => $lang['Always_bbcode'], 'L_ALWAYS_ALLOW_HTML' => $lang['Always_html'], 'L_HIDE_USER' => $lang['Hide_user'], 'L_ALWAYS_ADD_SIGNATURE' => $lang['Always_add_sig'], 'L_SPECIAL' => $lang['User_special'], 'L_SPECIAL_EXPLAIN' => $lang['User_special_explain'], 'L_USER_ACTIVE' => $lang['User_status'], 'L_ALLOW_PM' => $lang['User_allowpm'], 'L_ALLOW_AVATAR' => $lang['User_allowavatar'], 'L_AVATAR_PANEL' => $lang['Avatar_panel'], 'L_AVATAR_EXPLAIN' => $lang['Admin_avatar_explain'], 'L_DELETE_AVATAR' => $lang['Delete_Image'], 'L_CURRENT_IMAGE' => $lang['Current_Image'], 'L_UPLOAD_AVATAR_FILE' => $lang['Upload_Avatar_file'], 'L_UPLOAD_AVATAR_URL' => $lang['Upload_Avatar_URL'], 'L_AVATAR_GALLERY' => $lang['Select_from_gallery'], 'L_SHOW_GALLERY' => $lang['View_avatar_gallery'], 'L_LINK_REMOTE_AVATAR' => $lang['Link_remote_Avatar'], 'L_SIGNATURE' => $lang['Signature'], 'L_SIGNATURE_EXPLAIN' => sprintf($lang['Signature_explain'], $board_config['max_sig_chars']), 'L_NOTIFY_ON_PRIVMSG' => $lang['Notify_on_privmsg'], 'L_NOTIFY_ON_REPLY' => $lang['Always_notify'], 'L_POPUP_ON_PRIVMSG' => $lang['Popup_on_privmsg'], 'L_PREFERENCES' => $lang['Preferences'], 'L_PUBLIC_VIEW_EMAIL' => $lang['Public_view_email'], 'L_ITEMS_REQUIRED' => $lang['Items_required'], 'L_REGISTRATION_INFO' => $lang['Registration_info'], 'L_PROFILE_INFO' => $lang['Profile_info'], 'L_PROFILE_INFO_NOTICE' => $lang['Profile_info_warn'], 'L_EMAIL_ADDRESS' => $lang['Email_address'], 'S_FORM_ENCTYPE' => $form_enctype, 'HTML_STATUS' => $html_status, 'BBCODE_STATUS' => sprintf($bbcode_status, '<a href="../' . append_sid("faq.{$phpEx}?mode=bbcode") . '" target="_phpbbcode">', '</a>'), 'SMILIES_STATUS' => $smilies_status, 'L_DELETE_USER' => $lang['User_delete'], 'L_DELETE_USER_EXPLAIN' => $lang['User_delete_explain'], 'L_SELECT_RANK' => $lang['Rank_title'], 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'S_PROFILE_ACTION' => append_sid("admin_users.{$phpEx}"))); if (file_exists(@phpbb_realpath('./../' . $board_config['avatar_path'])) && $board_config['allow_avatar_upload'] == TRUE) { if ($form_enctype != '') { $template->assign_block_vars('avatar_local_upload', array()); } $template->assign_block_vars('avatar_remote_upload', array()); } if (file_exists(@phpbb_realpath('./../' . $board_config['avatar_gallery_path'])) && $board_config['allow_avatar_local'] == TRUE) { $template->assign_block_vars('avatar_local_gallery', array()); } if ($board_config['allow_avatar_remote'] == TRUE) { $template->assign_block_vars('avatar_remote_link', array()); } } $template->pparse('body'); } else {
${'user_' . $sort_option . '_sortby_dir_select'} = '<select name="user_' . $sort_option . '_sortby_dir">'; foreach ($sort_dir_text as $key => $value) { $selected = ${'user_' . $sort_option . '_sortby_dir'} == $key ? ' selected="selected"' : ''; ${'user_' . $sort_option . '_sortby_dir_select'} .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>'; } ${'user_' . $sort_option . '_sortby_dir_select'} .= '</select>'; } // TOPICS / POSTS - SORTING - END // Let's do an overall check for settings/versions which would prevent us from doing file uploads... $ini_val = phpversion() >= '4.0.0' ? 'ini_get' : 'get_cfg_var'; $form_enctype = !@$ini_val('file_uploads') || phpversion() == '4.0.4pl1' || !$config['allow_avatar_upload'] || phpversion() < '4.0.3' && @$ini_val('open_basedir') != '' ? '' : 'enctype="multipart/form-data"'; $user_sn_im_array = get_user_sn_im_array(); foreach ($user_sn_im_array as $k => $v) { $template->assign_var(strtoupper($v['form']), ${$v}['form']); } $template->assign_vars(array('USERNAME' => $username, 'EMAIL' => $email, 'USER_FIRST_NAME' => $user_first_name, 'USER_LAST_NAME' => $user_last_name, 'OCCUPATION' => $occupation, 'INTERESTS' => $interests, 'FLAG_SELECT' => $flag_select, 'FLAG_START' => $flag_start_image, 'PHONE' => $phone, 'SELFDES' => str_replace('<br />', "\n", $selfdes), 'L_FLAG' => $lang['Country_Flag'], 'L_PHONE' => $lang['UserPhone'], 'L_EXTRA_PROFILE_INFO' => $lang['Extra_profile_info'], 'L_EXTRA_PROFILE_INFO_EXPLAIN' => sprintf($lang['Extra_profile_info_explain'], $config['extra_max']), 'PROFILE_VIEW_POPUP_YES' => $profile_view_popup ? 'checked="checked"' : '', 'PROFILE_VIEW_POPUP_NO' => !$profile_view_popup ? 'checked="checked"' : '', 'L_PROFILE_VIEW_POPUP' => $lang['Profile_view_option'], 'NEXT_BIRTHDAY_GREETING' => $next_birthday_greeting, 'S_BIRTHDAY' => $s_birthday, 'GENDER' => $gender, 'GENDER_NO_SPECIFY_CHECKED' => $gender_no_specify_checked, 'GENDER_MALE_CHECKED' => $gender_male_checked, 'GENDER_FEMALE_CHECKED' => $gender_female_checked, 'LOCATION' => $location, 'WEBSITE' => $website, 'SIGNATURE' => str_replace('<br />', "\n", $signature), 'HIDE_USER_YES' => !$allowviewonline ? 'checked="checked"' : '', 'HIDE_USER_NO' => $allowviewonline ? 'checked="checked"' : '', 'VIEW_EMAIL_YES' => $viewemail ? 'checked="checked"' : '', 'VIEW_EMAIL_NO' => !$viewemail ? 'checked="checked"' : '', 'ALLOW_MASS_EMAIL_YES' => $allowmassemail ? 'checked="checked"' : '', 'ALLOW_MASS_EMAIL_NO' => !$allowmassemail ? 'checked="checked"' : '', 'ALLOW_PM_IN_YES' => $allowpmin ? 'checked="checked"' : '', 'ALLOW_PM_IN_NO' => !$allowpmin ? 'checked="checked"' : '', 'NOTIFY_PM_YES' => $notifypm ? 'checked="checked"' : '', 'NOTIFY_PM_NO' => !$notifypm ? 'checked="checked"' : '', 'POPUP_PM_YES' => $popup_pm ? 'checked="checked"' : '', 'POPUP_PM_NO' => !$popup_pm ? 'checked="checked"' : '', 'ALWAYS_ADD_SIGNATURE_YES' => $attachsig ? 'checked="checked"' : '', 'ALWAYS_ADD_SIGNATURE_NO' => !$attachsig ? 'checked="checked"' : '', 'ALWAYS_SET_BOOKMARK_YES' => $setbm ? 'checked="checked"' : '', 'ALWAYS_SET_BOOKMARK_NO' => !$setbm ? 'checked="checked"' : '', 'ALWAYS_SHOW_AVATARS_YES' => $user_showavatars ? 'checked="checked"' : '', 'ALWAYS_SHOW_AVATARS_NO' => !$user_showavatars ? 'checked="checked"' : '', 'ALWAYS_SHOW_SIGNATURES_YES' => $user_showsignatures ? 'checked="checked"' : '', 'ALWAYS_SHOW_SIGNATURES_NO' => !$user_showsignatures ? 'checked="checked"' : '', 'ALWAYS_SWEARY_WORDS_YES' => $user_allowswearywords ? 'checked="checked"' : '', 'ALWAYS_SWEARY_WORDS_NO' => !$user_allowswearywords ? 'checked="checked"' : '', 'NOTIFY_REPLY_YES' => $notifyreply ? 'checked="checked"' : '', 'NOTIFY_REPLY_NO' => !$notifyreply ? 'checked="checked"' : '', 'ALWAYS_ALLOW_BBCODE_YES' => $allowbbcode ? 'checked="checked"' : '', 'ALWAYS_ALLOW_BBCODE_NO' => !$allowbbcode ? 'checked="checked"' : '', 'ALWAYS_ALLOW_HTML_YES' => $allowhtml ? 'checked="checked"' : '', 'ALWAYS_ALLOW_HTML_NO' => !$allowhtml ? 'checked="checked"' : '', 'ALWAYS_ALLOW_SMILIES_YES' => $allowsmilies ? 'checked="checked"' : '', 'ALWAYS_ALLOW_SMILIES_NO' => !$allowsmilies ? 'checked="checked"' : '', 'POSTS_PER_PAGE' => !$user_posts_per_page ? $config['posts_per_page'] : $user_posts_per_page, 'TOPICS_PER_PAGE' => !$user_topics_per_page ? $config['topics_per_page'] : $user_topics_per_page, 'HOT_TOPIC' => !$user_hot_threshold ? $config['hot_threshold'] : $user_hot_threshold, 'USER_TOPIC_SHOW_DAYS_SELECT' => $user_topic_show_days_select, 'USER_TOPIC_SORTBY_TYPE_SELECT' => $user_topic_sortby_type_select, 'USER_TOPIC_SORTBY_DIR_SELECT' => $user_topic_sortby_dir_select, 'USER_POST_SHOW_DAYS_SELECT' => $user_post_show_days_select, 'USER_POST_SORTBY_TYPE_SELECT' => $user_post_sortby_type_select, 'USER_POST_SORTBY_DIR_SELECT' => $user_post_sortby_dir_select, 'AVATAR' => $avatar, 'GRAVATAR' => $user_avatar_type == USER_GRAVATAR ? $user->data['user_avatar'] : '', 'STYLE_SELECT' => style_select('style', $user_style), 'LANGUAGE_SELECT' => language_select('language', $user_lang), 'TIMEZONE_SELECT' => tz_select('timezone', $user_timezone), 'DATE_FORMAT' => date_select('dateformat', $user_dateformat), 'TIME_MODE' => $time_mode, 'TIME_MODE_MANUAL_CHECKED' => $time_mode_manual_checked, 'TIME_MODE_MANUAL_DST_CHECKED' => $time_mode_manual_dst_checked, 'TIME_MODE_SERVER_SWITCH_CHECKED' => $time_mode_server_switch_checked, 'TIME_MODE_FULL_SERVER_CHECKED' => $time_mode_full_server_checked, 'TIME_MODE_SERVER_PC_CHECKED' => $time_mode_server_pc_checked, 'TIME_MODE_FULL_PC_CHECKED' => $time_mode_full_pc_checked, 'DST_TIME_LAG' => $dst_time_lag, 'ALLOW_PM_YES' => $user_allowpm ? 'checked="checked"' : '', 'ALLOW_PM_NO' => !$user_allowpm ? 'checked="checked"' : '', 'ALLOW_AVATAR_YES' => $user_allowavatar ? 'checked="checked"' : '', 'ALLOW_AVATAR_NO' => !$user_allowavatar ? 'checked="checked"' : '', 'DISABLE_UPI2DB_YES' => $user_upi2db_disable ? 'checked="checked"' : '', 'DISABLE_UPI2DB_NO' => !$user_upi2db_disable ? 'checked="checked"' : '', 'USER_ACTIVE_YES' => $user_status ? 'checked="checked"' : '', 'USER_ACTIVE_NO' => !$user_status ? 'checked="checked"' : '', 'USER_MASK_YES' => $user_mask ? 'checked="checked"' : '', 'USER_MASK_NO' => !$user_mask ? 'checked="checked"' : '', 'BANCARD' => $user_ycard, 'POSTS' => $user_posts, 'RANK1_SELECT_BOX' => $rank1_select_box, 'RANK2_SELECT_BOX' => $rank2_select_box, 'RANK3_SELECT_BOX' => $rank3_select_box, 'RANK4_SELECT_BOX' => $rank4_select_box, 'RANK5_SELECT_BOX' => $rank5_select_box, 'USER_GROUP_ID' => $user_default_group_select, 'USER_COLOR' => str_replace('#', '', $user_color), 'USER_COLOR_STYLE' => $user_color != '' ? ' style="color:' . $user_color . ';font-weight:bold;"' : ' style="font-weight:bold;"', 'L_USERNAME' => $lang['Username'], 'L_USER_TITLE' => $lang['User_admin'], 'L_USER_EXPLAIN' => $lang['User_admin_explain'], 'L_NEW_PASSWORD' => $lang['New_password'], 'L_PASSWORD_IF_CHANGED' => $lang['password_if_changed'], 'L_CONFIRM_PASSWORD' => $lang['Confirm_password'], 'L_PASSWORD_CONFIRM_IF_CHANGED' => $lang['password_confirm_if_changed'], 'L_SUBMIT' => $lang['Submit'], 'L_RESET' => $lang['Reset'], 'L_ICQ_NUMBER' => $lang['ICQ'], 'L_MESSENGER' => $lang['MSNM'], 'L_YAHOO' => $lang['YIM'], 'L_SKYPE' => $lang['SKYPE'], 'L_WEBSITE' => $lang['Website'], 'L_AIM' => $lang['AIM'], 'L_LOCATION' => $lang['Location'], 'L_OCCUPATION' => $lang['Occupation'], 'L_BOARD_LANGUAGE' => $lang['Board_lang'], 'L_BOARD_STYLE' => $lang['Board_style'], 'L_TIMEZONE' => $lang['Timezone'], 'L_TIME_MODE' => $lang['time_mode'], 'L_TIME_MODE_TEXT' => $lang['time_mode_text'], 'L_TIME_MODE_MANUAL' => $lang['time_mode_manual'], 'L_TIME_MODE_DST' => $lang['time_mode_dst'], 'L_TIME_MODE_DST_OFF' => $l_time_mode_0, 'L_TIME_MODE_DST_ON' => $l_time_mode_1, 'L_TIME_MODE_DST_SERVER' => $l_time_mode_2, 'L_TIME_MODE_DST_TIME_LAG' => $lang['time_mode_dst_time_lag'], 'L_TIME_MODE_DST_MN' => $lang['time_mode_dst_mn'], 'L_TIME_MODE_TIMEZONE' => $lang['time_mode_timezone'], 'L_TIME_MODE_AUTO' => $lang['time_mode_auto'], 'L_TIME_MODE_FULL_SERVER' => $l_time_mode_3, 'L_TIME_MODE_SERVER_PC' => $l_time_mode_4, 'L_TIME_MODE_FULL_PC' => $l_time_mode_6, 'L_DATE_FORMAT' => $lang['Date_format'], 'L_DATE_FORMAT_EXPLAIN' => $lang['Date_format_explain'], 'L_YES' => $lang['Yes'], 'L_NO' => $lang['No'], 'L_INTERESTS' => $lang['Interests'], 'L_BIRTHDAY' => $lang['Birthday'], 'L_NEXT_BIRTHDAY_GREETING' => $lang['Next_birthday_greeting'], 'L_NEXT_BIRTHDAY_GREETING_EXPLAIN' => $lang['Next_birthday_greeting_explain'], 'L_GENDER' => $lang['Gender'], 'L_GENDER_MALE' => $lang['Male'], 'L_GENDER_FEMALE' => $lang['Female'], 'L_GENDER_NOT_SPECIFY' => $lang['No_gender_specify'], 'L_BANCARD' => $lang['ban_card'], 'L_BANCARD_EXPLAIN' => sprintf($lang['ban_card_explain'], $config['max_user_bancard']), 'L_HOT_THRESHOLD' => $lang['Hot_threshold'], 'L_POSTS_PER_PAGE' => $lang['Posts_per_page'], 'L_TOPICS_PER_PAGE' => $lang['Topics_per_page'], 'L_ALWAYS_ALLOW_SMILIES' => $lang['Always_smile'], 'L_ALWAYS_ALLOW_BBCODE' => $lang['Always_bbcode'], 'L_ALWAYS_ALLOW_HTML' => $lang['Always_html'], 'L_HIDE_USER' => $lang['Hide_user'], 'L_ALWAYS_ADD_SIGNATURE' => $lang['Always_add_sig'], 'L_ALWAYS_SET_BOOKMARK' => $lang['Always_set_bm'], 'L_SHOW_AVATARS' => $lang['Show_avatars'], 'L_SHOW_SIGNATURES' => $lang['Show_signatures'], 'L_ALWAYS_ALLOW_SWEARYWORDS' => $lang['Always_swear'], 'L_SPECIAL' => $lang['User_special'], 'L_SPECIAL_EXPLAIN' => $lang['User_special_explain'], 'L_USER_ACTIVE' => $lang['User_status'], 'L_ALLOW_PM' => $lang['User_allowpm'], 'L_ALLOW_AVATAR' => $lang['User_allowavatar'], 'L_DISABLE_UPI2DB' => $lang['user_disable_upi2db'], 'L_POSTCOUNT' => $lang['Modify_post_counts'], 'L_POSTCOUNT_EXPLAIN' => $lang['Post_count_explain'], 'L_AVATAR_PANEL' => $lang['Avatar_panel'], 'L_AVATAR_EXPLAIN' => $lang['Admin_avatar_explain'], 'L_DELETE_AVATAR' => $lang['Delete_Image'], 'L_CURRENT_IMAGE' => $lang['Current_Image'], 'L_UPLOAD_AVATAR_FILE' => $lang['Upload_Avatar_file'], 'L_UPLOAD_AVATAR_URL' => $lang['Upload_Avatar_URL'], 'L_AVATAR_GALLERY' => $lang['Select_from_gallery'], 'L_SHOW_GALLERY' => $lang['View_avatar_gallery'], 'L_LINK_REMOTE_AVATAR' => $lang['Link_remote_Avatar'], 'L_GRAVATAR' => $lang['Gravatar'], 'L_GRAVATAR_EXPLAIN' => $lang['Gravatar_explain'], 'L_SIGNATURE' => $lang['Signature'], 'L_SIGNATURE_EXPLAIN' => sprintf($lang['Signature_explain'], $config['max_sig_chars']), 'L_NOTIFY_ON_PRIVMSG' => $lang['Notify_on_privmsg'], 'L_NOTIFY_ON_REPLY' => $lang['Always_notify'], 'L_POPUP_ON_PRIVMSG' => $lang['Popup_on_privmsg'], 'L_PREFERENCES' => $lang['Preferences'], 'L_PUBLIC_VIEW_EMAIL' => $lang['Public_view_email'], 'L_MASS_EMAIL' => $lang['Admin_Emails'], 'L_PM_IN' => $lang['Allow_PM_IN'], 'L_PM_IN_EXPLAIN' => $lang['Allow_PM_IN_Explain'], 'L_ITEMS_REQUIRED' => $lang['Items_required'], 'L_REGISTRATION_INFO' => $lang['Registration_info'], 'L_PROFILE_INFO' => $lang['Profile_info'], 'L_PROFILE_INFO_NOTICE' => $lang['Profile_info_warn'], 'L_EMAIL_ADDRESS' => $lang['Email_address'], 'S_FORM_ENCTYPE' => $form_enctype, 'HTML_STATUS' => $html_status, 'BBCODE_STATUS' => sprintf($bbcode_status, '<a href="../' . append_sid('faq.' . PHP_EXT . '?mode=bbcode') . '" target="_blank">', '</a>'), 'SMILIES_STATUS' => $smilies_status, 'L_DELETE_USER' => $lang['User_delete'], 'L_DELETE_USER_EXPLAIN' => $lang['User_delete_explain'], 'L_SELECT_RANK1' => $lang['Rank1_title'], 'L_SELECT_RANK2' => $lang['Rank2_title'], 'L_SELECT_RANK3' => $lang['Rank3_title'], 'L_SELECT_RANK4' => $lang['Rank4_title'], 'L_SELECT_RANK5' => $lang['Rank5_title'], 'L_GROUP_DEFAULT' => $lang['Group_Default_Membership'], 'L_GROUP_DEFAULT_EXPLAIN' => $lang['Group_Default_Membership_Explain'], 'L_USER_COLOR' => $lang['User_Color'], 'L_USER_COLOR_EXPLAIN' => $lang['User_Color_Explain'], 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'S_PROFILE_ACTION' => append_sid('admin_users.' . PHP_EXT))); if (file_exists(@phpbb_realpath('./../' . $config['avatar_path'])) && $config['allow_avatar_upload'] == true) { if ($form_enctype != '') { $template->assign_block_vars('avatar_local_upload', array()); } $template->assign_block_vars('avatar_remote_upload', array()); } if (file_exists(@phpbb_realpath('./../' . $config['avatar_gallery_path'])) && $config['allow_avatar_local'] == true) { $template->assign_block_vars('avatar_local_gallery', array()); } if ($config['allow_avatar_remote'] == true) { $template->assign_block_vars('avatar_remote_link', array()); } if ($config['enable_gravatars']) { $template->assign_block_vars('switch_gravatar', array()); }