1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/includes/ucp/ucp_profile.php Wed Mar 07 16:41:10 2012 +0400
1.3 @@ -0,0 +1,643 @@
1.4 +<?php
1.5 +/**
1.6 +*
1.7 +* @package ucp
1.8 +* @version $Id$
1.9 +* @copyright (c) 2005 phpBB Group
1.10 +* @license http://opensource.org/licenses/gpl-license.php GNU Public License
1.11 +*
1.12 +*/
1.13 +
1.14 +/**
1.15 +* @ignore
1.16 +*/
1.17 +if (!defined('IN_PHPBB'))
1.18 +{
1.19 + exit;
1.20 +}
1.21 +
1.22 +/**
1.23 +* ucp_profile
1.24 +* Changing profile settings
1.25 +*
1.26 +* @todo what about pertaining user_sig_options?
1.27 +* @package ucp
1.28 +*/
1.29 +class ucp_profile
1.30 +{
1.31 + var $u_action;
1.32 +
1.33 + function main($id, $mode)
1.34 + {
1.35 + global $config, $db, $user, $auth, $template, $phpbb_root_path, $phpEx;
1.36 +
1.37 + $user->add_lang('posting');
1.38 +
1.39 + $preview = (!empty($_POST['preview'])) ? true : false;
1.40 + $submit = (!empty($_POST['submit'])) ? true : false;
1.41 + $delete = (!empty($_POST['delete'])) ? true : false;
1.42 + $error = $data = array();
1.43 + $s_hidden_fields = '';
1.44 +
1.45 + switch ($mode)
1.46 + {
1.47 + case 'reg_details':
1.48 +
1.49 + $data = array(
1.50 + 'username' => utf8_normalize_nfc(request_var('username', $user->data['username'], true)),
1.51 + 'email' => strtolower(request_var('email', $user->data['user_email'])),
1.52 + 'email_confirm' => strtolower(request_var('email_confirm', '')),
1.53 + 'new_password' => request_var('new_password', '', true),
1.54 + 'cur_password' => request_var('cur_password', '', true),
1.55 + 'password_confirm' => request_var('password_confirm', '', true),
1.56 + );
1.57 +
1.58 + add_form_key('ucp_reg_details');
1.59 +
1.60 + if ($submit)
1.61 + {
1.62 + // Do not check cur_password, it is the old one.
1.63 + $check_ary = array(
1.64 + 'new_password' => array(
1.65 + array('string', true, $config['min_pass_chars'], $config['max_pass_chars']),
1.66 + array('password')),
1.67 + 'password_confirm' => array('string', true, $config['min_pass_chars'], $config['max_pass_chars']),
1.68 + 'email' => array(
1.69 + array('string', false, 6, 60),
1.70 + array('email')),
1.71 + 'email_confirm' => array('string', true, 6, 60),
1.72 + );
1.73 +
1.74 + if ($auth->acl_get('u_chgname') && $config['allow_namechange'])
1.75 + {
1.76 + $check_ary['username'] = array(
1.77 + array('string', false, $config['min_name_chars'], $config['max_name_chars']),
1.78 + array('username'),
1.79 + );
1.80 + }
1.81 +
1.82 + $error = validate_data($data, $check_ary);
1.83 +
1.84 + if ($auth->acl_get('u_chgemail') && $data['email'] != $user->data['user_email'] && $data['email_confirm'] != $data['email'])
1.85 + {
1.86 + $error[] = ($data['email_confirm']) ? 'NEW_EMAIL_ERROR' : 'NEW_EMAIL_CONFIRM_EMPTY';
1.87 + }
1.88 +
1.89 + if ($auth->acl_get('u_chgpasswd') && $data['new_password'] && $data['password_confirm'] != $data['new_password'])
1.90 + {
1.91 + $error[] = ($data['password_confirm']) ? 'NEW_PASSWORD_ERROR' : 'NEW_PASSWORD_CONFIRM_EMPTY';
1.92 + }
1.93 +
1.94 + // Only check the new password against the previous password if there have been no errors
1.95 + if (!sizeof($error) && $auth->acl_get('u_chgpasswd') && $data['new_password'] && phpbb_check_hash($data['new_password'], $user->data['user_password']))
1.96 + {
1.97 + $error[] = 'SAME_PASSWORD_ERROR';
1.98 + }
1.99 +
1.100 + if (!phpbb_check_hash($data['cur_password'], $user->data['user_password']))
1.101 + {
1.102 + $error[] = ($data['cur_password']) ? 'CUR_PASSWORD_ERROR' : 'CUR_PASSWORD_EMPTY';
1.103 + }
1.104 +
1.105 + if (!check_form_key('ucp_reg_details'))
1.106 + {
1.107 + $error[] = 'FORM_INVALID';
1.108 + }
1.109 +
1.110 + if (!sizeof($error))
1.111 + {
1.112 + $sql_ary = array(
1.113 + 'username' => ($auth->acl_get('u_chgname') && $config['allow_namechange']) ? $data['username'] : $user->data['username'],
1.114 + 'username_clean' => ($auth->acl_get('u_chgname') && $config['allow_namechange']) ? utf8_clean_string($data['username']) : $user->data['username_clean'],
1.115 + 'user_email' => ($auth->acl_get('u_chgemail')) ? $data['email'] : $user->data['user_email'],
1.116 + 'user_email_hash' => ($auth->acl_get('u_chgemail')) ? phpbb_email_hash($data['email']) : $user->data['user_email_hash'],
1.117 + 'user_password' => ($auth->acl_get('u_chgpasswd') && $data['new_password']) ? phpbb_hash($data['new_password']) : $user->data['user_password'],
1.118 + 'user_passchg' => ($auth->acl_get('u_chgpasswd') && $data['new_password']) ? time() : 0,
1.119 + );
1.120 +
1.121 + if ($auth->acl_get('u_chgname') && $config['allow_namechange'] && $data['username'] != $user->data['username'])
1.122 + {
1.123 + add_log('user', $user->data['user_id'], 'LOG_USER_UPDATE_NAME', $user->data['username'], $data['username']);
1.124 + }
1.125 +
1.126 + if ($auth->acl_get('u_chgpasswd') && $data['new_password'] && !phpbb_check_hash($data['new_password'], $user->data['user_password']))
1.127 + {
1.128 + $user->reset_login_keys();
1.129 + add_log('user', $user->data['user_id'], 'LOG_USER_NEW_PASSWORD', $data['username']);
1.130 + }
1.131 +
1.132 + if ($auth->acl_get('u_chgemail') && $data['email'] != $user->data['user_email'])
1.133 + {
1.134 + add_log('user', $user->data['user_id'], 'LOG_USER_UPDATE_EMAIL', $data['username'], $user->data['user_email'], $data['email']);
1.135 + }
1.136 +
1.137 + $message = 'PROFILE_UPDATED';
1.138 +
1.139 + if ($auth->acl_get('u_chgemail') && $config['email_enable'] && $data['email'] != $user->data['user_email'] && $user->data['user_type'] != USER_FOUNDER && ($config['require_activation'] == USER_ACTIVATION_SELF || $config['require_activation'] == USER_ACTIVATION_ADMIN))
1.140 + {
1.141 + $message = ($config['require_activation'] == USER_ACTIVATION_SELF) ? 'ACCOUNT_EMAIL_CHANGED' : 'ACCOUNT_EMAIL_CHANGED_ADMIN';
1.142 +
1.143 + include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
1.144 +
1.145 + $server_url = generate_board_url();
1.146 +
1.147 + $user_actkey = gen_rand_string(mt_rand(6, 10));
1.148 +
1.149 + $messenger = new messenger(false);
1.150 +
1.151 + $template_file = ($config['require_activation'] == USER_ACTIVATION_ADMIN) ? 'user_activate_inactive' : 'user_activate';
1.152 + $messenger->template($template_file, $user->data['user_lang']);
1.153 +
1.154 + $messenger->to($data['email'], $data['username']);
1.155 +
1.156 + $messenger->anti_abuse_headers($config, $user);
1.157 +
1.158 + $messenger->assign_vars(array(
1.159 + 'USERNAME' => htmlspecialchars_decode($data['username']),
1.160 + 'U_ACTIVATE' => "$server_url/ucp.$phpEx?mode=activate&u={$user->data['user_id']}&k=$user_actkey")
1.161 + );
1.162 +
1.163 + $messenger->send(NOTIFY_EMAIL);
1.164 +
1.165 + if ($config['require_activation'] == USER_ACTIVATION_ADMIN)
1.166 + {
1.167 + // Grab an array of user_id's with a_user permissions ... these users can activate a user
1.168 + $admin_ary = $auth->acl_get_list(false, 'a_user', false);
1.169 + $admin_ary = (!empty($admin_ary[0]['a_user'])) ? $admin_ary[0]['a_user'] : array();
1.170 +
1.171 + // Also include founders
1.172 + $where_sql = ' WHERE user_type = ' . USER_FOUNDER;
1.173 +
1.174 + if (sizeof($admin_ary))
1.175 + {
1.176 + $where_sql .= ' OR ' . $db->sql_in_set('user_id', $admin_ary);
1.177 + }
1.178 +
1.179 + $sql = 'SELECT user_id, username, user_email, user_lang, user_jabber, user_notify_type
1.180 + FROM ' . USERS_TABLE . ' ' .
1.181 + $where_sql;
1.182 + $result = $db->sql_query($sql);
1.183 +
1.184 + while ($row = $db->sql_fetchrow($result))
1.185 + {
1.186 + $messenger->template('admin_activate', $row['user_lang']);
1.187 + $messenger->to($row['user_email'], $row['username']);
1.188 + $messenger->im($row['user_jabber'], $row['username']);
1.189 +
1.190 + $messenger->assign_vars(array(
1.191 + 'USERNAME' => htmlspecialchars_decode($data['username']),
1.192 + 'U_USER_DETAILS' => "$server_url/memberlist.$phpEx?mode=viewprofile&u={$user->data['user_id']}",
1.193 + 'U_ACTIVATE' => "$server_url/ucp.$phpEx?mode=activate&u={$user->data['user_id']}&k=$user_actkey")
1.194 + );
1.195 +
1.196 + $messenger->send($row['user_notify_type']);
1.197 + }
1.198 + $db->sql_freeresult($result);
1.199 + }
1.200 +
1.201 + user_active_flip('deactivate', $user->data['user_id'], INACTIVE_PROFILE);
1.202 +
1.203 + // Because we want the profile to be reactivated we set user_newpasswd to empty (else the reactivation will fail)
1.204 + $sql_ary['user_actkey'] = $user_actkey;
1.205 + $sql_ary['user_newpasswd'] = '';
1.206 + }
1.207 +
1.208 + if (sizeof($sql_ary))
1.209 + {
1.210 + $sql = 'UPDATE ' . USERS_TABLE . '
1.211 + SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
1.212 + WHERE user_id = ' . $user->data['user_id'];
1.213 + $db->sql_query($sql);
1.214 + }
1.215 +
1.216 + // Need to update config, forum, topic, posting, messages, etc.
1.217 + if ($data['username'] != $user->data['username'] && $auth->acl_get('u_chgname') && $config['allow_namechange'])
1.218 + {
1.219 + user_update_name($user->data['username'], $data['username']);
1.220 + }
1.221 +
1.222 + // Now, we can remove the user completely (kill the session) - NOT BEFORE!!!
1.223 + if (!empty($sql_ary['user_actkey']))
1.224 + {
1.225 + meta_refresh(5, append_sid($phpbb_root_path . 'index.' . $phpEx));
1.226 + $message = $user->lang[$message] . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid($phpbb_root_path . 'index.' . $phpEx) . '">', '</a>');
1.227 +
1.228 + // Because the user gets deactivated we log him out too, killing his session
1.229 + $user->session_kill();
1.230 + }
1.231 + else
1.232 + {
1.233 + meta_refresh(3, $this->u_action);
1.234 + $message = $user->lang[$message] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
1.235 + }
1.236 +
1.237 + trigger_error($message);
1.238 + }
1.239 +
1.240 + // Replace "error" strings with their real, localised form
1.241 + $error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error);
1.242 + }
1.243 +
1.244 + $template->assign_vars(array(
1.245 + 'ERROR' => (sizeof($error)) ? implode('<br />', $error) : '',
1.246 +
1.247 + 'USERNAME' => $data['username'],
1.248 + 'EMAIL' => $data['email'],
1.249 + 'PASSWORD_CONFIRM' => $data['password_confirm'],
1.250 + 'NEW_PASSWORD' => $data['new_password'],
1.251 + 'CUR_PASSWORD' => '',
1.252 +
1.253 + 'L_USERNAME_EXPLAIN' => sprintf($user->lang[$config['allow_name_chars'] . '_EXPLAIN'], $config['min_name_chars'], $config['max_name_chars']),
1.254 + 'L_CHANGE_PASSWORD_EXPLAIN' => sprintf($user->lang[$config['pass_complex'] . '_EXPLAIN'], $config['min_pass_chars'], $config['max_pass_chars']),
1.255 +
1.256 + 'S_FORCE_PASSWORD' => ($auth->acl_get('u_chgpasswd') && $config['chg_passforce'] && $user->data['user_passchg'] < time() - ($config['chg_passforce'] * 86400)) ? true : false,
1.257 + 'S_CHANGE_USERNAME' => ($config['allow_namechange'] && $auth->acl_get('u_chgname')) ? true : false,
1.258 + 'S_CHANGE_EMAIL' => ($auth->acl_get('u_chgemail')) ? true : false,
1.259 + 'S_CHANGE_PASSWORD' => ($auth->acl_get('u_chgpasswd')) ? true : false)
1.260 + );
1.261 + break;
1.262 +
1.263 + case 'profile_info':
1.264 +
1.265 + include($phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx);
1.266 +
1.267 + $cp = new custom_profile();
1.268 +
1.269 + $cp_data = $cp_error = array();
1.270 +
1.271 + $data = array(
1.272 + 'icq' => request_var('icq', $user->data['user_icq']),
1.273 + 'aim' => request_var('aim', $user->data['user_aim']),
1.274 + 'msn' => request_var('msn', $user->data['user_msnm']),
1.275 + 'yim' => request_var('yim', $user->data['user_yim']),
1.276 + 'jabber' => utf8_normalize_nfc(request_var('jabber', $user->data['user_jabber'], true)),
1.277 + 'website' => request_var('website', $user->data['user_website']),
1.278 + 'location' => utf8_normalize_nfc(request_var('location', $user->data['user_from'], true)),
1.279 + 'occupation' => utf8_normalize_nfc(request_var('occupation', $user->data['user_occ'], true)),
1.280 + 'interests' => utf8_normalize_nfc(request_var('interests', $user->data['user_interests'], true)),
1.281 + );
1.282 +
1.283 + if ($config['allow_birthdays'])
1.284 + {
1.285 + $data['bday_day'] = $data['bday_month'] = $data['bday_year'] = 0;
1.286 +
1.287 + if ($user->data['user_birthday'])
1.288 + {
1.289 + list($data['bday_day'], $data['bday_month'], $data['bday_year']) = explode('-', $user->data['user_birthday']);
1.290 + }
1.291 +
1.292 + $data['bday_day'] = request_var('bday_day', $data['bday_day']);
1.293 + $data['bday_month'] = request_var('bday_month', $data['bday_month']);
1.294 + $data['bday_year'] = request_var('bday_year', $data['bday_year']);
1.295 + $data['user_birthday'] = sprintf('%2d-%2d-%4d', $data['bday_day'], $data['bday_month'], $data['bday_year']);
1.296 + }
1.297 +
1.298 + add_form_key('ucp_profile_info');
1.299 +
1.300 + if ($submit)
1.301 + {
1.302 + $validate_array = array(
1.303 + 'icq' => array(
1.304 + array('string', true, 3, 15),
1.305 + array('match', true, '#^[0-9]+$#i')),
1.306 + 'aim' => array('string', true, 3, 255),
1.307 + 'msn' => array('string', true, 5, 255),
1.308 + 'jabber' => array(
1.309 + array('string', true, 5, 255),
1.310 + array('jabber')),
1.311 + 'yim' => array('string', true, 5, 255),
1.312 + 'website' => array(
1.313 + array('string', true, 12, 255),
1.314 + array('match', true, '#^http[s]?://(.*?\.)*?[a-z0-9\-]+\.[a-z]{2,4}#i')),
1.315 + 'location' => array('string', true, 2, 100),
1.316 + 'occupation' => array('string', true, 2, 500),
1.317 + 'interests' => array('string', true, 2, 500),
1.318 + );
1.319 +
1.320 + if ($config['allow_birthdays'])
1.321 + {
1.322 + $validate_array = array_merge($validate_array, array(
1.323 + 'bday_day' => array('num', true, 1, 31),
1.324 + 'bday_month' => array('num', true, 1, 12),
1.325 + 'bday_year' => array('num', true, 1901, gmdate('Y', time()) + 50),
1.326 + 'user_birthday' => array('date', true),
1.327 + ));
1.328 + }
1.329 +
1.330 + $error = validate_data($data, $validate_array);
1.331 +
1.332 + // validate custom profile fields
1.333 + $cp->submit_cp_field('profile', $user->get_iso_lang_id(), $cp_data, $cp_error);
1.334 +
1.335 + if (sizeof($cp_error))
1.336 + {
1.337 + $error = array_merge($error, $cp_error);
1.338 + }
1.339 +
1.340 + if (!check_form_key('ucp_profile_info'))
1.341 + {
1.342 + $error[] = 'FORM_INVALID';
1.343 + }
1.344 +
1.345 + if (!sizeof($error))
1.346 + {
1.347 + $data['notify'] = $user->data['user_notify_type'];
1.348 +
1.349 + if ($data['notify'] == NOTIFY_IM && (!$config['jab_enable'] || !$data['jabber'] || !@extension_loaded('xml')))
1.350 + {
1.351 + // User has not filled in a jabber address (Or one of the modules is disabled or jabber is disabled)
1.352 + // Disable notify by Jabber now for this user.
1.353 + $data['notify'] = NOTIFY_EMAIL;
1.354 + }
1.355 +
1.356 + $sql_ary = array(
1.357 + 'user_icq' => $data['icq'],
1.358 + 'user_aim' => $data['aim'],
1.359 + 'user_msnm' => $data['msn'],
1.360 + 'user_yim' => $data['yim'],
1.361 + 'user_jabber' => $data['jabber'],
1.362 + 'user_website' => $data['website'],
1.363 + 'user_from' => $data['location'],
1.364 + 'user_occ' => $data['occupation'],
1.365 + 'user_interests'=> $data['interests'],
1.366 + 'user_notify_type' => $data['notify'],
1.367 + );
1.368 +
1.369 + if ($config['allow_birthdays'])
1.370 + {
1.371 + $sql_ary['user_birthday'] = $data['user_birthday'];
1.372 + }
1.373 +
1.374 + $sql = 'UPDATE ' . USERS_TABLE . '
1.375 + SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
1.376 + WHERE user_id = ' . $user->data['user_id'];
1.377 + $db->sql_query($sql);
1.378 +
1.379 + // Update Custom Fields
1.380 + $cp->update_profile_field_data($user->data['user_id'], $cp_data);
1.381 +
1.382 + meta_refresh(3, $this->u_action);
1.383 + $message = $user->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
1.384 + trigger_error($message);
1.385 + }
1.386 +
1.387 + // Replace "error" strings with their real, localised form
1.388 + $error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error);
1.389 + }
1.390 +
1.391 + if ($config['allow_birthdays'])
1.392 + {
1.393 + $s_birthday_day_options = '<option value="0"' . ((!$data['bday_day']) ? ' selected="selected"' : '') . '>--</option>';
1.394 + for ($i = 1; $i < 32; $i++)
1.395 + {
1.396 + $selected = ($i == $data['bday_day']) ? ' selected="selected"' : '';
1.397 + $s_birthday_day_options .= "<option value=\"$i\"$selected>$i</option>";
1.398 + }
1.399 +
1.400 + $s_birthday_month_options = '<option value="0"' . ((!$data['bday_month']) ? ' selected="selected"' : '') . '>--</option>';
1.401 + for ($i = 1; $i < 13; $i++)
1.402 + {
1.403 + $selected = ($i == $data['bday_month']) ? ' selected="selected"' : '';
1.404 + $s_birthday_month_options .= "<option value=\"$i\"$selected>$i</option>";
1.405 + }
1.406 + $s_birthday_year_options = '';
1.407 +
1.408 + $now = getdate();
1.409 + $s_birthday_year_options = '<option value="0"' . ((!$data['bday_year']) ? ' selected="selected"' : '') . '>--</option>';
1.410 + for ($i = $now['year'] - 100; $i <= $now['year']; $i++)
1.411 + {
1.412 + $selected = ($i == $data['bday_year']) ? ' selected="selected"' : '';
1.413 + $s_birthday_year_options .= "<option value=\"$i\"$selected>$i</option>";
1.414 + }
1.415 + unset($now);
1.416 +
1.417 + $template->assign_vars(array(
1.418 + 'S_BIRTHDAY_DAY_OPTIONS' => $s_birthday_day_options,
1.419 + 'S_BIRTHDAY_MONTH_OPTIONS' => $s_birthday_month_options,
1.420 + 'S_BIRTHDAY_YEAR_OPTIONS' => $s_birthday_year_options,
1.421 + 'S_BIRTHDAYS_ENABLED' => true,
1.422 + ));
1.423 + }
1.424 +
1.425 + $template->assign_vars(array(
1.426 + 'ERROR' => (sizeof($error)) ? implode('<br />', $error) : '',
1.427 +
1.428 + 'ICQ' => $data['icq'],
1.429 + 'YIM' => $data['yim'],
1.430 + 'AIM' => $data['aim'],
1.431 + 'MSN' => $data['msn'],
1.432 + 'JABBER' => $data['jabber'],
1.433 + 'WEBSITE' => $data['website'],
1.434 + 'LOCATION' => $data['location'],
1.435 + 'OCCUPATION'=> $data['occupation'],
1.436 + 'INTERESTS' => $data['interests'],
1.437 + ));
1.438 +
1.439 + // Get additional profile fields and assign them to the template block var 'profile_fields'
1.440 + $user->get_profile_fields($user->data['user_id']);
1.441 +
1.442 + $cp->generate_profile_fields('profile', $user->get_iso_lang_id());
1.443 +
1.444 + break;
1.445 +
1.446 + case 'signature':
1.447 +
1.448 + if (!$auth->acl_get('u_sig'))
1.449 + {
1.450 + trigger_error('NO_AUTH_SIGNATURE');
1.451 + }
1.452 +
1.453 + include($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
1.454 + include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
1.455 +
1.456 + $enable_bbcode = ($config['allow_sig_bbcode']) ? (bool) $user->optionget('sig_bbcode') : false;
1.457 + $enable_smilies = ($config['allow_sig_smilies']) ? (bool) $user->optionget('sig_smilies') : false;
1.458 + $enable_urls = ($config['allow_sig_links']) ? (bool) $user->optionget('sig_links') : false;
1.459 +
1.460 + $signature = utf8_normalize_nfc(request_var('signature', (string) $user->data['user_sig'], true));
1.461 +
1.462 + add_form_key('ucp_sig');
1.463 +
1.464 + if ($submit || $preview)
1.465 + {
1.466 + include($phpbb_root_path . 'includes/message_parser.' . $phpEx);
1.467 +
1.468 + $enable_bbcode = ($config['allow_sig_bbcode']) ? ((request_var('disable_bbcode', false)) ? false : true) : false;
1.469 + $enable_smilies = ($config['allow_sig_smilies']) ? ((request_var('disable_smilies', false)) ? false : true) : false;
1.470 + $enable_urls = ($config['allow_sig_links']) ? ((request_var('disable_magic_url', false)) ? false : true) : false;
1.471 +
1.472 + if (!sizeof($error))
1.473 + {
1.474 + $message_parser = new parse_message($signature);
1.475 +
1.476 + // Allowing Quote BBCode
1.477 + $message_parser->parse($enable_bbcode, $enable_urls, $enable_smilies, $config['allow_sig_img'], $config['allow_sig_flash'], true, $config['allow_sig_links'], true, 'sig');
1.478 +
1.479 + if (sizeof($message_parser->warn_msg))
1.480 + {
1.481 + $error[] = implode('<br />', $message_parser->warn_msg);
1.482 + }
1.483 +
1.484 + if (!check_form_key('ucp_sig'))
1.485 + {
1.486 + $error[] = 'FORM_INVALID';
1.487 + }
1.488 +
1.489 + if (!sizeof($error) && $submit)
1.490 + {
1.491 + $user->optionset('sig_bbcode', $enable_bbcode);
1.492 + $user->optionset('sig_smilies', $enable_smilies);
1.493 + $user->optionset('sig_links', $enable_urls);
1.494 +
1.495 + $sql_ary = array(
1.496 + 'user_sig' => (string) $message_parser->message,
1.497 + 'user_options' => $user->data['user_options'],
1.498 + 'user_sig_bbcode_uid' => (string) $message_parser->bbcode_uid,
1.499 + 'user_sig_bbcode_bitfield' => $message_parser->bbcode_bitfield
1.500 + );
1.501 +
1.502 + $sql = 'UPDATE ' . USERS_TABLE . '
1.503 + SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
1.504 + WHERE user_id = ' . $user->data['user_id'];
1.505 + $db->sql_query($sql);
1.506 +
1.507 + $message = $user->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
1.508 + trigger_error($message);
1.509 + }
1.510 + }
1.511 +
1.512 + // Replace "error" strings with their real, localised form
1.513 + $error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error);
1.514 + }
1.515 +
1.516 + $signature_preview = '';
1.517 + if ($preview)
1.518 + {
1.519 + // Now parse it for displaying
1.520 + $signature_preview = $message_parser->format_display($enable_bbcode, $enable_urls, $enable_smilies, false);
1.521 + unset($message_parser);
1.522 + }
1.523 +
1.524 + decode_message($signature, $user->data['user_sig_bbcode_uid']);
1.525 +
1.526 + $template->assign_vars(array(
1.527 + 'ERROR' => (sizeof($error)) ? implode('<br />', $error) : '',
1.528 + 'SIGNATURE' => $signature,
1.529 + 'SIGNATURE_PREVIEW' => $signature_preview,
1.530 +
1.531 + 'S_BBCODE_CHECKED' => (!$enable_bbcode) ? ' checked="checked"' : '',
1.532 + 'S_SMILIES_CHECKED' => (!$enable_smilies) ? ' checked="checked"' : '',
1.533 + 'S_MAGIC_URL_CHECKED' => (!$enable_urls) ? ' checked="checked"' : '',
1.534 +
1.535 + 'BBCODE_STATUS' => ($config['allow_sig_bbcode']) ? sprintf($user->lang['BBCODE_IS_ON'], '<a href="' . append_sid("{$phpbb_root_path}faq.$phpEx", 'mode=bbcode') . '">', '</a>') : sprintf($user->lang['BBCODE_IS_OFF'], '<a href="' . append_sid("{$phpbb_root_path}faq.$phpEx", 'mode=bbcode') . '">', '</a>'),
1.536 + 'SMILIES_STATUS' => ($config['allow_sig_smilies']) ? $user->lang['SMILIES_ARE_ON'] : $user->lang['SMILIES_ARE_OFF'],
1.537 + 'IMG_STATUS' => ($config['allow_sig_img']) ? $user->lang['IMAGES_ARE_ON'] : $user->lang['IMAGES_ARE_OFF'],
1.538 + 'FLASH_STATUS' => ($config['allow_sig_flash']) ? $user->lang['FLASH_IS_ON'] : $user->lang['FLASH_IS_OFF'],
1.539 + 'URL_STATUS' => ($config['allow_sig_links']) ? $user->lang['URL_IS_ON'] : $user->lang['URL_IS_OFF'],
1.540 + 'MAX_FONT_SIZE' => (int) $config['max_sig_font_size'],
1.541 +
1.542 + 'L_SIGNATURE_EXPLAIN' => sprintf($user->lang['SIGNATURE_EXPLAIN'], $config['max_sig_chars']),
1.543 +
1.544 + 'S_BBCODE_ALLOWED' => $config['allow_sig_bbcode'],
1.545 + 'S_SMILIES_ALLOWED' => $config['allow_sig_smilies'],
1.546 + 'S_BBCODE_IMG' => ($config['allow_sig_img']) ? true : false,
1.547 + 'S_BBCODE_FLASH' => ($config['allow_sig_flash']) ? true : false,
1.548 + 'S_LINKS_ALLOWED' => ($config['allow_sig_links']) ? true : false)
1.549 + );
1.550 +
1.551 + // Build custom bbcodes array
1.552 + display_custom_bbcodes();
1.553 +
1.554 + break;
1.555 +
1.556 + case 'avatar':
1.557 +
1.558 + include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
1.559 +
1.560 + $display_gallery = request_var('display_gallery', '0');
1.561 + $avatar_select = basename(request_var('avatar_select', ''));
1.562 + $category = basename(request_var('category', ''));
1.563 +
1.564 + $can_upload = (file_exists($phpbb_root_path . $config['avatar_path']) && phpbb_is_writable($phpbb_root_path . $config['avatar_path']) && $auth->acl_get('u_chgavatar') && (@ini_get('file_uploads') || strtolower(@ini_get('file_uploads')) == 'on')) ? true : false;
1.565 +
1.566 + add_form_key('ucp_avatar');
1.567 +
1.568 + if ($submit)
1.569 + {
1.570 + if (check_form_key('ucp_avatar'))
1.571 + {
1.572 + if (avatar_process_user($error, false, $can_upload))
1.573 + {
1.574 + meta_refresh(3, $this->u_action);
1.575 + $message = $user->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
1.576 + trigger_error($message);
1.577 + }
1.578 + }
1.579 + else
1.580 + {
1.581 + $error[] = 'FORM_INVALID';
1.582 + }
1.583 + // Replace "error" strings with their real, localised form
1.584 + $error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error);
1.585 + }
1.586 +
1.587 + if (!$config['allow_avatar'] && $user->data['user_avatar_type'])
1.588 + {
1.589 + $error[] = $user->lang['AVATAR_NOT_ALLOWED'];
1.590 + }
1.591 + else if ((($user->data['user_avatar_type'] == AVATAR_UPLOAD) && !$config['allow_avatar_upload']) ||
1.592 + (($user->data['user_avatar_type'] == AVATAR_REMOTE) && !$config['allow_avatar_remote']) ||
1.593 + (($user->data['user_avatar_type'] == AVATAR_GALLERY) && !$config['allow_avatar_local']))
1.594 + {
1.595 + $error[] = $user->lang['AVATAR_TYPE_NOT_ALLOWED'];
1.596 + }
1.597 +
1.598 + $template->assign_vars(array(
1.599 + 'ERROR' => (sizeof($error)) ? implode('<br />', $error) : '',
1.600 + 'AVATAR' => get_user_avatar($user->data['user_avatar'], $user->data['user_avatar_type'], $user->data['user_avatar_width'], $user->data['user_avatar_height'], 'USER_AVATAR', true),
1.601 + 'AVATAR_SIZE' => $config['avatar_filesize'],
1.602 +
1.603 + 'U_GALLERY' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=profile&mode=avatar&display_gallery=1'),
1.604 +
1.605 + 'S_FORM_ENCTYPE' => ($can_upload && ($config['allow_avatar_upload'] || $config['allow_avatar_remote_upload'])) ? ' enctype="multipart/form-data"' : '',
1.606 +
1.607 + 'L_AVATAR_EXPLAIN' => sprintf($user->lang['AVATAR_EXPLAIN'], $config['avatar_max_width'], $config['avatar_max_height'], $config['avatar_filesize'] / 1024),
1.608 + ));
1.609 +
1.610 + if ($config['allow_avatar'] && $display_gallery && $auth->acl_get('u_chgavatar') && $config['allow_avatar_local'])
1.611 + {
1.612 + avatar_gallery($category, $avatar_select, 4);
1.613 + }
1.614 + else if ($config['allow_avatar'])
1.615 + {
1.616 + $avatars_enabled = (($can_upload && ($config['allow_avatar_upload'] || $config['allow_avatar_remote_upload'])) || ($auth->acl_get('u_chgavatar') && ($config['allow_avatar_local'] || $config['allow_avatar_remote']))) ? true : false;
1.617 +
1.618 + $template->assign_vars(array(
1.619 + 'AVATAR_WIDTH' => request_var('width', $user->data['user_avatar_width']),
1.620 + 'AVATAR_HEIGHT' => request_var('height', $user->data['user_avatar_height']),
1.621 +
1.622 + 'S_AVATARS_ENABLED' => $avatars_enabled,
1.623 + 'S_UPLOAD_AVATAR_FILE' => ($can_upload && $config['allow_avatar_upload']) ? true : false,
1.624 + 'S_UPLOAD_AVATAR_URL' => ($can_upload && $config['allow_avatar_remote_upload']) ? true : false,
1.625 + 'S_LINK_AVATAR' => ($auth->acl_get('u_chgavatar') && $config['allow_avatar_remote']) ? true : false,
1.626 + 'S_DISPLAY_GALLERY' => ($auth->acl_get('u_chgavatar') && $config['allow_avatar_local']) ? true : false)
1.627 + );
1.628 + }
1.629 +
1.630 + break;
1.631 + }
1.632 +
1.633 + $template->assign_vars(array(
1.634 + 'L_TITLE' => $user->lang['UCP_PROFILE_' . strtoupper($mode)],
1.635 +
1.636 + 'S_HIDDEN_FIELDS' => $s_hidden_fields,
1.637 + 'S_UCP_ACTION' => $this->u_action)
1.638 + );
1.639 +
1.640 + // Set desired template
1.641 + $this->tpl_name = 'ucp_profile_' . $mode;
1.642 + $this->page_title = 'UCP_PROFILE_' . strtoupper($mode);
1.643 + }
1.644 +}
1.645 +
1.646 +?>
1.647 \ No newline at end of file