Blame Extras/phpBB/3.0.4/includes/ucp/ucp_profile.php

4c79b5
4c79b5
/**
4c79b5
*
4c79b5
* @package ucp
4c79b5
* @version $Id: ucp_profile.php 8990 2008-10-09 15:41:19Z acydburn $
4c79b5
* @copyright (c) 2005 phpBB Group
4c79b5
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
4c79b5
*
4c79b5
*/
4c79b5
4c79b5
/**
4c79b5
* @ignore
4c79b5
*/
4c79b5
if (!defined('IN_PHPBB'))
4c79b5
{
4c79b5
	exit;
4c79b5
}
4c79b5
4c79b5
/**
4c79b5
* ucp_profile
4c79b5
* Changing profile settings
4c79b5
*
4c79b5
* @todo what about pertaining user_sig_options?
4c79b5
* @package ucp
4c79b5
*/
4c79b5
class ucp_profile
4c79b5
{
4c79b5
	var $u_action;
4c79b5
4c79b5
	function main($id, $mode)
4c79b5
	{
4c79b5
		global $config, $db, $user, $auth, $template, $phpbb_root_path, $phpEx;
4c79b5
4c79b5
		$user->add_lang('posting');
4c79b5
4c79b5
		$preview	= (!empty($_POST['preview'])) ? true : false;
4c79b5
		$submit		= (!empty($_POST['submit'])) ? true : false;
4c79b5
		$delete		= (!empty($_POST['delete'])) ? true : false;
4c79b5
		$error = $data = array();
4c79b5
		$s_hidden_fields = '';
4c79b5
4c79b5
		switch ($mode)
4c79b5
		{
4c79b5
			case 'reg_details':
4c79b5
4c79b5
				$data = array(
4c79b5
					'username'			=> utf8_normalize_nfc(request_var('username', $user->data['username'], true)),
4c79b5
					'email'				=> strtolower(request_var('email', $user->data['user_email'])),
4c79b5
					'email_confirm'		=> strtolower(request_var('email_confirm', '')),
4c79b5
					'new_password'		=> request_var('new_password', '', true),
4c79b5
					'cur_password'		=> request_var('cur_password', '', true),
4c79b5
					'password_confirm'	=> request_var('password_confirm', '', true),
4c79b5
				);
4c79b5
4c79b5
				add_form_key('ucp_reg_details');
4c79b5
4c79b5
				if ($submit)
4c79b5
				{
4c79b5
					// Do not check cur_password, it is the old one.
4c79b5
					$check_ary = array(
4c79b5
						'new_password'		=> array(
4c79b5
							array('string', true, $config['min_pass_chars'], $config['max_pass_chars']),
4c79b5
							array('password')),
4c79b5
						'password_confirm'	=> array('string', true, $config['min_pass_chars'], $config['max_pass_chars']),
4c79b5
						'email'				=> array(
4c79b5
							array('string', false, 6, 60),
4c79b5
							array('email')),
4c79b5
						'email_confirm'		=> array('string', true, 6, 60),
4c79b5
					);
4c79b5
4c79b5
					if ($auth->acl_get('u_chgname') && $config['allow_namechange'])
4c79b5
					{
4c79b5
						$check_ary['username'] = array(
4c79b5
							array('string', false, $config['min_name_chars'], $config['max_name_chars']),
4c79b5
							array('username'),
4c79b5
						);
4c79b5
					}
4c79b5
4c79b5
					$error = validate_data($data, $check_ary);
4c79b5
4c79b5
					if ($auth->acl_get('u_chgpasswd') && $data['new_password'] && $data['password_confirm'] != $data['new_password'])
4c79b5
					{
4c79b5
						$error[] = 'NEW_PASSWORD_ERROR';
4c79b5
					}
4c79b5
4c79b5
					if (($data['new_password'] || ($auth->acl_get('u_chgemail') && $data['email'] != $user->data['user_email']) || ($data['username'] != $user->data['username'] && $auth->acl_get('u_chgname') && $config['allow_namechange'])) && !phpbb_check_hash($data['cur_password'], $user->data['user_password']))
4c79b5
					{
4c79b5
						$error[] = 'CUR_PASSWORD_ERROR';
4c79b5
					}
4c79b5
4c79b5
					// Only check the new password against the previous password if there have been no errors
4c79b5
					if (!sizeof($error) && $auth->acl_get('u_chgpasswd') && $data['new_password'] && phpbb_check_hash($data['new_password'], $user->data['user_password']))
4c79b5
					{
4c79b5
						$error[] = 'SAME_PASSWORD_ERROR';
4c79b5
					}
4c79b5
4c79b5
					if ($auth->acl_get('u_chgemail') && $data['email'] != $user->data['user_email'] && $data['email_confirm'] != $data['email'])
4c79b5
					{
4c79b5
						$error[] = 'NEW_EMAIL_ERROR';
4c79b5
					}
4c79b5
4c79b5
					if (!check_form_key('ucp_reg_details'))
4c79b5
					{
4c79b5
						$error[] = 'FORM_INVALID';
4c79b5
					}
4c79b5
4c79b5
					if (!sizeof($error))
4c79b5
					{
4c79b5
						$sql_ary = array(
4c79b5
							'username'			=> ($auth->acl_get('u_chgname') && $config['allow_namechange']) ? $data['username'] : $user->data['username'],
4c79b5
							'username_clean'	=> ($auth->acl_get('u_chgname') && $config['allow_namechange']) ? utf8_clean_string($data['username']) : $user->data['username_clean'],
4c79b5
							'user_email'		=> ($auth->acl_get('u_chgemail')) ? $data['email'] : $user->data['user_email'],
4c79b5
							'user_email_hash'	=> ($auth->acl_get('u_chgemail')) ? crc32($data['email']) . strlen($data['email']) : $user->data['user_email_hash'],
4c79b5
							'user_password'		=> ($auth->acl_get('u_chgpasswd') && $data['new_password']) ? phpbb_hash($data['new_password']) : $user->data['user_password'],
4c79b5
							'user_passchg'		=> ($auth->acl_get('u_chgpasswd') && $data['new_password']) ? time() : 0,
4c79b5
						);
4c79b5
4c79b5
						if ($auth->acl_get('u_chgname') && $config['allow_namechange'] && $data['username'] != $user->data['username'])
4c79b5
						{
4c79b5
							add_log('user', $user->data['user_id'], 'LOG_USER_UPDATE_NAME', $user->data['username'], $data['username']);
4c79b5
						}
4c79b5
4c79b5
						if ($auth->acl_get('u_chgpasswd') && $data['new_password'] && !phpbb_check_hash($data['new_password'], $user->data['user_password']))
4c79b5
						{
4c79b5
							$user->reset_login_keys();
4c79b5
							add_log('user', $user->data['user_id'], 'LOG_USER_NEW_PASSWORD', $data['username']);
4c79b5
						}
4c79b5
4c79b5
						if ($auth->acl_get('u_chgemail') && $data['email'] != $user->data['user_email'])
4c79b5
						{
4c79b5
							add_log('user', $user->data['user_id'], 'LOG_USER_UPDATE_EMAIL', $data['username'], $user->data['user_email'], $data['email']);
4c79b5
						}
4c79b5
4c79b5
						$message = 'PROFILE_UPDATED';
4c79b5
4c79b5
						if ($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))
4c79b5
						{
4c79b5
							$message = ($config['require_activation'] == USER_ACTIVATION_SELF) ? 'ACCOUNT_EMAIL_CHANGED' : 'ACCOUNT_EMAIL_CHANGED_ADMIN';
4c79b5
4c79b5
							include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
4c79b5
4c79b5
							$server_url = generate_board_url();
4c79b5
4c79b5
							$user_actkey = gen_rand_string(10);
4c79b5
							$key_len = 54 - (strlen($server_url));
4c79b5
							$key_len = ($key_len > 6) ? $key_len : 6;
4c79b5
							$user_actkey = substr($user_actkey, 0, $key_len);
4c79b5
4c79b5
							$messenger = new messenger(false);
4c79b5
4c79b5
							$template_file = ($config['require_activation'] == USER_ACTIVATION_ADMIN) ? 'user_activate_inactive' : 'user_activate';
4c79b5
							$messenger->template($template_file, $user->data['user_lang']);
4c79b5
4c79b5
							$messenger->to($data['email'], $data['username']);
4c79b5
4c79b5
							$messenger->headers('X-AntiAbuse: Board servername - ' . $config['server_name']);
4c79b5
							$messenger->headers('X-AntiAbuse: User_id - ' . $user->data['user_id']);
4c79b5
							$messenger->headers('X-AntiAbuse: Username - ' . $user->data['username']);
4c79b5
							$messenger->headers('X-AntiAbuse: User IP - ' . $user->ip);
4c79b5
4c79b5
							$messenger->assign_vars(array(
4c79b5
								'USERNAME'		=> htmlspecialchars_decode($data['username']),
4c79b5
								'U_ACTIVATE'	=> "$server_url/ucp.$phpEx?mode=activate&u={$user->data['user_id']}&k=$user_actkey")
4c79b5
							);
4c79b5
4c79b5
							$messenger->send(NOTIFY_EMAIL);
4c79b5
4c79b5
							if ($config['require_activation'] == USER_ACTIVATION_ADMIN)
4c79b5
							{
4c79b5
								// Grab an array of user_id's with a_user permissions ... these users can activate a user
4c79b5
								$admin_ary = $auth->acl_get_list(false, 'a_user', false);
4c79b5
								$admin_ary = (!empty($admin_ary[0]['a_user'])) ? $admin_ary[0]['a_user'] : array();
4c79b5
4c79b5
								// Also include founders
4c79b5
								$where_sql = ' WHERE user_type = ' . USER_FOUNDER;
4c79b5
4c79b5
								if (sizeof($admin_ary))
4c79b5
								{
4c79b5
									$where_sql .= ' OR ' . $db->sql_in_set('user_id', $admin_ary);
4c79b5
								}
4c79b5
4c79b5
								$sql = 'SELECT user_id, username, user_email, user_lang, user_jabber, user_notify_type
4c79b5
									FROM ' . USERS_TABLE . ' ' .
4c79b5
									$where_sql;
4c79b5
								$result = $db->sql_query($sql);
4c79b5
4c79b5
								while ($row = $db->sql_fetchrow($result))
4c79b5
								{
4c79b5
									$messenger->template('admin_activate', $row['user_lang']);
4c79b5
									$messenger->to($row['user_email'], $row['username']);
4c79b5
									$messenger->im($row['user_jabber'], $row['username']);
4c79b5
4c79b5
									$messenger->assign_vars(array(
4c79b5
										'USERNAME'			=> htmlspecialchars_decode($data['username']),
4c79b5
										'U_USER_DETAILS'	=> "$server_url/memberlist.$phpEx?mode=viewprofile&u={$user->data['user_id']}",
4c79b5
										'U_ACTIVATE'		=> "$server_url/ucp.$phpEx?mode=activate&u={$user->data['user_id']}&k=$user_actkey")
4c79b5
									);
4c79b5
4c79b5
									$messenger->send($row['user_notify_type']);
4c79b5
								}
4c79b5
								$db->sql_freeresult($result);
4c79b5
							}
4c79b5
4c79b5
							user_active_flip('deactivate', $user->data['user_id'], INACTIVE_PROFILE);
4c79b5
4c79b5
							// Because we want the profile to be reactivated we set user_newpasswd to empty (else the reactivation will fail)
4c79b5
							$sql_ary['user_actkey'] = $user_actkey;
4c79b5
							$sql_ary['user_newpasswd'] = '';
4c79b5
						}
4c79b5
4c79b5
						if (sizeof($sql_ary))
4c79b5
						{
4c79b5
							$sql = 'UPDATE ' . USERS_TABLE . '
4c79b5
								SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
4c79b5
								WHERE user_id = ' . $user->data['user_id'];
4c79b5
							$db->sql_query($sql);
4c79b5
						}
4c79b5
4c79b5
						// Need to update config, forum, topic, posting, messages, etc.
4c79b5
						if ($data['username'] != $user->data['username'] && $auth->acl_get('u_chgname') && $config['allow_namechange'])
4c79b5
						{
4c79b5
							user_update_name($user->data['username'], $data['username']);
4c79b5
						}
4c79b5
4c79b5
						// Now, we can remove the user completely (kill the session) - NOT BEFORE!!!
4c79b5
						if (!empty($sql_ary['user_actkey']))
4c79b5
						{
4c79b5
							meta_refresh(5, append_sid($phpbb_root_path . 'index.' . $phpEx));
4c79b5
							$message = $user->lang[$message] . '

' . sprintf($user->lang['RETURN_INDEX'], '', '');
4c79b5
4c79b5
							// Because the user gets deactivated we log him out too, killing his session
4c79b5
							$user->session_kill();
4c79b5
						}
4c79b5
						else
4c79b5
						{
4c79b5
							meta_refresh(3, $this->u_action);
4c79b5
							$message = $user->lang[$message] . '

' . sprintf($user->lang['RETURN_UCP'], '', '');
4c79b5
						}
4c79b5
4c79b5
						trigger_error($message);
4c79b5
					}
4c79b5
4c79b5
					// Replace "error" strings with their real, localised form
4c79b5
					$error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error);
4c79b5
				}
4c79b5
4c79b5
				$template->assign_vars(array(
4c79b5
					'ERROR'				=> (sizeof($error)) ? implode('
', $error) : '',
4c79b5
4c79b5
					'USERNAME'			=> $data['username'],
4c79b5
					'EMAIL'				=> $data['email'],
4c79b5
					'PASSWORD_CONFIRM'	=> $data['password_confirm'],
4c79b5
					'NEW_PASSWORD'		=> $data['new_password'],
4c79b5
					'CUR_PASSWORD'		=> '',
4c79b5
4c79b5
					'L_USERNAME_EXPLAIN'		=> sprintf($user->lang[$config['allow_name_chars'] . '_EXPLAIN'], $config['min_name_chars'], $config['max_name_chars']),
4c79b5
					'L_CHANGE_PASSWORD_EXPLAIN'	=> sprintf($user->lang[$config['pass_complex'] . '_EXPLAIN'], $config['min_pass_chars'], $config['max_pass_chars']),
4c79b5
4c79b5
					'S_FORCE_PASSWORD'	=> ($auth->acl_get('u_chgpasswd') && $config['chg_passforce'] && $user->data['user_passchg'] < time() - ($config['chg_passforce'] * 86400)) ? true : false,
4c79b5
					'S_CHANGE_USERNAME' => ($config['allow_namechange'] && $auth->acl_get('u_chgname')) ? true : false,
4c79b5
					'S_CHANGE_EMAIL'	=> ($auth->acl_get('u_chgemail')) ? true : false,
4c79b5
					'S_CHANGE_PASSWORD'	=> ($auth->acl_get('u_chgpasswd')) ? true : false)
4c79b5
				);
4c79b5
			break;
4c79b5
4c79b5
			case 'profile_info':
4c79b5
4c79b5
				include($phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx);
4c79b5
4c79b5
				$cp = new custom_profile();
4c79b5
4c79b5
				$cp_data = $cp_error = array();
4c79b5
4c79b5
				$data = array(
4c79b5
					'icq'			=> request_var('icq', $user->data['user_icq']),
4c79b5
					'aim'			=> request_var('aim', $user->data['user_aim']),
4c79b5
					'msn'			=> request_var('msn', $user->data['user_msnm']),
4c79b5
					'yim'			=> request_var('yim', $user->data['user_yim']),
4c79b5
					'jabber'		=> utf8_normalize_nfc(request_var('jabber', $user->data['user_jabber'], true)),
4c79b5
					'website'		=> request_var('website', $user->data['user_website']),
4c79b5
					'location'		=> utf8_normalize_nfc(request_var('location', $user->data['user_from'], true)),
4c79b5
					'occupation'	=> utf8_normalize_nfc(request_var('occupation', $user->data['user_occ'], true)),
4c79b5
					'interests'		=> utf8_normalize_nfc(request_var('interests', $user->data['user_interests'], true)),
4c79b5
				);
4c79b5
4c79b5
				if ($config['allow_birthdays'])
4c79b5
				{
4c79b5
					$data['bday_day'] = $data['bday_month'] = $data['bday_year'] = 0;
4c79b5
4c79b5
					if ($user->data['user_birthday'])
4c79b5
					{
4c79b5
						list($data['bday_day'], $data['bday_month'], $data['bday_year']) = explode('-', $user->data['user_birthday']);
4c79b5
					}
4c79b5
4c79b5
					$data['bday_day'] = request_var('bday_day', $data['bday_day']);
4c79b5
					$data['bday_month'] = request_var('bday_month', $data['bday_month']);
4c79b5
					$data['bday_year'] = request_var('bday_year', $data['bday_year']);
4c79b5
					$data['user_birthday'] = sprintf('%2d-%2d-%4d', $data['bday_day'], $data['bday_month'], $data['bday_year']);
4c79b5
				}
4c79b5
4c79b5
				add_form_key('ucp_profile_info');
4c79b5
4c79b5
				if ($submit)
4c79b5
				{
4c79b5
					$validate_array = array(
4c79b5
						'icq'			=> array(
4c79b5
							array('string', true, 3, 15),
4c79b5
							array('match', true, '#^[0-9]+$#i')),
4c79b5
						'aim'			=> array('string', true, 3, 255),
4c79b5
						'msn'			=> array('string', true, 5, 255),
4c79b5
						'jabber'		=> array(
4c79b5
							array('string', true, 5, 255),
4c79b5
							array('jabber')),
4c79b5
						'yim'			=> array('string', true, 5, 255),
4c79b5
						'website'		=> array(
4c79b5
							array('string', true, 12, 255),
4c79b5
							array('match', true, '#^http[s]?://(.*?\.)*?[a-z0-9\-]+\.[a-z]{2,4}#i')),
4c79b5
						'location'		=> array('string', true, 2, 100),
4c79b5
						'occupation'	=> array('string', true, 2, 500),
4c79b5
						'interests'		=> array('string', true, 2, 500),
4c79b5
					);
4c79b5
4c79b5
					if ($config['allow_birthdays'])
4c79b5
					{
4c79b5
						$validate_array = array_merge($validate_array, array(
4c79b5
							'bday_day'		=> array('num', true, 1, 31),
4c79b5
							'bday_month'	=> array('num', true, 1, 12),
4c79b5
							'bday_year'		=> array('num', true, 1901, gmdate('Y', time()) + 50),
4c79b5
							'user_birthday' => array('date', true),
4c79b5
						));
4c79b5
					}
4c79b5
4c79b5
					$error = validate_data($data, $validate_array);
4c79b5
4c79b5
					// validate custom profile fields
4c79b5
					$cp->submit_cp_field('profile', $user->get_iso_lang_id(), $cp_data, $cp_error);
4c79b5
4c79b5
					if (sizeof($cp_error))
4c79b5
					{
4c79b5
						$error = array_merge($error, $cp_error);
4c79b5
					}
4c79b5
4c79b5
					if (!check_form_key('ucp_profile_info'))
4c79b5
					{
4c79b5
						$error[] = 'FORM_INVALID';
4c79b5
					}
4c79b5
4c79b5
					if (!sizeof($error))
4c79b5
					{
4c79b5
						$data['notify'] = $user->data['user_notify_type'];
4c79b5
4c79b5
						if (!$config['jab_enable'] || !$data['jabber'] || !@extension_loaded('xml'))
4c79b5
						{
4c79b5
							// User has not filled in a jabber address (Or one of the modules is disabled or jabber is disabled)
4c79b5
							// Disable notify by Jabber now for this user.
4c79b5
							$data['notify'] = NOTIFY_BOTH;
4c79b5
						}
4c79b5
4c79b5
						$sql_ary = array(
4c79b5
							'user_icq'		=> $data['icq'],
4c79b5
							'user_aim'		=> $data['aim'],
4c79b5
							'user_msnm'		=> $data['msn'],
4c79b5
							'user_yim'		=> $data['yim'],
4c79b5
							'user_jabber'	=> $data['jabber'],
4c79b5
							'user_website'	=> $data['website'],
4c79b5
							'user_from'		=> $data['location'],
4c79b5
							'user_occ'		=> $data['occupation'],
4c79b5
							'user_interests'=> $data['interests'],
4c79b5
							'user_notify_type'	=> $data['notify'],
4c79b5
						);
4c79b5
4c79b5
						if ($config['allow_birthdays'])
4c79b5
						{
4c79b5
							$sql_ary['user_birthday'] = $data['user_birthday'];
4c79b5
						}
4c79b5
4c79b5
						$sql = 'UPDATE ' . USERS_TABLE . '
4c79b5
							SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
4c79b5
							WHERE user_id = ' . $user->data['user_id'];
4c79b5
						$db->sql_query($sql);
4c79b5
4c79b5
						// Update Custom Fields
4c79b5
						if (sizeof($cp_data))
4c79b5
						{
4c79b5
							$sql = 'UPDATE ' . PROFILE_FIELDS_DATA_TABLE . '
4c79b5
								SET ' . $db->sql_build_array('UPDATE', $cp_data) . '
4c79b5
								WHERE user_id = ' . $user->data['user_id'];
4c79b5
							$db->sql_query($sql);
4c79b5
4c79b5
							if (!$db->sql_affectedrows())
4c79b5
							{
4c79b5
								$cp_data['user_id'] = (int) $user->data['user_id'];
4c79b5
4c79b5
								$db->sql_return_on_error(true);
4c79b5
4c79b5
								$sql = 'INSERT INTO ' . PROFILE_FIELDS_DATA_TABLE . ' ' . $db->sql_build_array('INSERT', $cp_data);
4c79b5
								$db->sql_query($sql);
4c79b5
4c79b5
								$db->sql_return_on_error(false);
4c79b5
							}
4c79b5
						}
4c79b5
4c79b5
						meta_refresh(3, $this->u_action);
4c79b5
						$message = $user->lang['PROFILE_UPDATED'] . '

' . sprintf($user->lang['RETURN_UCP'], '', '');
4c79b5
						trigger_error($message);
4c79b5
					}
4c79b5
4c79b5
					// Replace "error" strings with their real, localised form
4c79b5
					$error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error);
4c79b5
				}
4c79b5
4c79b5
				if ($config['allow_birthdays'])
4c79b5
				{
4c79b5
					$s_birthday_day_options = '<option value="0"' . ((!$data['bday_day']) ? ' selected="selected"' : '') . '>--</option>';
4c79b5
					for ($i = 1; $i < 32; $i++)
4c79b5
					{
4c79b5
						$selected = ($i == $data['bday_day']) ? ' selected="selected"' : '';
4c79b5
						$s_birthday_day_options .= "<option value=\"$i\"$selected>$i</option>";
4c79b5
					}
4c79b5
4c79b5
					$s_birthday_month_options = '<option value="0"' . ((!$data['bday_month']) ? ' selected="selected"' : '') . '>--</option>';
4c79b5
					for ($i = 1; $i < 13; $i++)
4c79b5
					{
4c79b5
						$selected = ($i == $data['bday_month']) ? ' selected="selected"' : '';
4c79b5
						$s_birthday_month_options .= "<option value=\"$i\"$selected>$i</option>";
4c79b5
					}
4c79b5
					$s_birthday_year_options = '';
4c79b5
4c79b5
					$now = getdate();
4c79b5
					$s_birthday_year_options = '<option value="0"' . ((!$data['bday_year']) ? ' selected="selected"' : '') . '>--</option>';
4c79b5
					for ($i = $now['year'] - 100; $i <= $now['year']; $i++)
4c79b5
					{
4c79b5
						$selected = ($i == $data['bday_year']) ? ' selected="selected"' : '';
4c79b5
						$s_birthday_year_options .= "<option value=\"$i\"$selected>$i</option>";
4c79b5
					}
4c79b5
					unset($now);
4c79b5
4c79b5
					$template->assign_vars(array(
4c79b5
						'S_BIRTHDAY_DAY_OPTIONS'	=> $s_birthday_day_options,
4c79b5
						'S_BIRTHDAY_MONTH_OPTIONS'	=> $s_birthday_month_options,
4c79b5
						'S_BIRTHDAY_YEAR_OPTIONS'	=> $s_birthday_year_options,
4c79b5
						'S_BIRTHDAYS_ENABLED'		=> true,
4c79b5
					));
4c79b5
				}
4c79b5
4c79b5
				$template->assign_vars(array(
4c79b5
					'ERROR'		=> (sizeof($error)) ? implode('
', $error) : '',
4c79b5
4c79b5
					'ICQ'		=> $data['icq'],
4c79b5
					'YIM'		=> $data['yim'],
4c79b5
					'AIM'		=> $data['aim'],
4c79b5
					'MSN'		=> $data['msn'],
4c79b5
					'JABBER'	=> $data['jabber'],
4c79b5
					'WEBSITE'	=> $data['website'],
4c79b5
					'LOCATION'	=> $data['location'],
4c79b5
					'OCCUPATION'=> $data['occupation'],
4c79b5
					'INTERESTS'	=> $data['interests'],
4c79b5
				));
4c79b5
4c79b5
				// Get additional profile fields and assign them to the template block var 'profile_fields'
4c79b5
				$user->get_profile_fields($user->data['user_id']);
4c79b5
4c79b5
				$cp->generate_profile_fields('profile', $user->get_iso_lang_id());
4c79b5
4c79b5
			break;
4c79b5
4c79b5
			case 'signature':
4c79b5
4c79b5
				if (!$auth->acl_get('u_sig'))
4c79b5
				{
4c79b5
					trigger_error('NO_AUTH_SIGNATURE');
4c79b5
				}
4c79b5
4c79b5
				include($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
4c79b5
				include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
4c79b5
4c79b5
				$enable_bbcode	= ($config['allow_sig_bbcode']) ? ((request_var('disable_bbcode', !$user->optionget('bbcode'))) ? false : true) : false;
4c79b5
				$enable_smilies	= ($config['allow_sig_smilies']) ? ((request_var('disable_smilies', !$user->optionget('smilies'))) ? false : true) : false;
4c79b5
				$enable_urls	= ($config['allow_sig_links']) ? ((request_var('disable_magic_url', false)) ? false : true) : false;
4c79b5
4c79b5
				$signature		= utf8_normalize_nfc(request_var('signature', (string) $user->data['user_sig'], true));
4c79b5
4c79b5
				add_form_key('ucp_sig');
4c79b5
4c79b5
				if ($submit || $preview)
4c79b5
				{
4c79b5
					include($phpbb_root_path . 'includes/message_parser.' . $phpEx);
4c79b5
4c79b5
					if (!sizeof($error))
4c79b5
					{
4c79b5
						$message_parser = new parse_message($signature);
4c79b5
4c79b5
						// Allowing Quote BBCode
4c79b5
						$message_parser->parse($enable_bbcode, $enable_urls, $enable_smilies, $config['allow_sig_img'], $config['allow_sig_flash'], true, $config['allow_sig_links'], true, 'sig');
4c79b5
4c79b5
						if (sizeof($message_parser->warn_msg))
4c79b5
						{
4c79b5
							$error[] = implode('
', $message_parser->warn_msg);
4c79b5
						}
4c79b5
4c79b5
						if (!check_form_key('ucp_sig'))
4c79b5
						{
4c79b5
							$error[] = 'FORM_INVALID';
4c79b5
						}
4c79b5
4c79b5
						if (!sizeof($error) && $submit)
4c79b5
						{
4c79b5
							$sql_ary = array(
4c79b5
								'user_sig'					=> (string) $message_parser->message,
4c79b5
								'user_sig_bbcode_uid'		=> (string) $message_parser->bbcode_uid,
4c79b5
								'user_sig_bbcode_bitfield'	=> $message_parser->bbcode_bitfield
4c79b5
							);
4c79b5
4c79b5
							$sql = 'UPDATE ' . USERS_TABLE . '
4c79b5
								SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
4c79b5
								WHERE user_id = ' . $user->data['user_id'];
4c79b5
							$db->sql_query($sql);
4c79b5
4c79b5
							$message = $user->lang['PROFILE_UPDATED'] . '

' . sprintf($user->lang['RETURN_UCP'], '', '');
4c79b5
							trigger_error($message);
4c79b5
						}
4c79b5
					}
4c79b5
4c79b5
					// Replace "error" strings with their real, localised form
4c79b5
					$error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error);
4c79b5
				}
4c79b5
4c79b5
				$signature_preview = '';
4c79b5
				if ($preview)
4c79b5
				{
4c79b5
					// Now parse it for displaying
4c79b5
					$signature_preview = $message_parser->format_display($enable_bbcode, $enable_urls, $enable_smilies, false);
4c79b5
					unset($message_parser);
4c79b5
				}
4c79b5
4c79b5
				decode_message($signature, $user->data['user_sig_bbcode_uid']);
4c79b5
4c79b5
				$template->assign_vars(array(
4c79b5
					'ERROR'				=> (sizeof($error)) ? implode('
', $error) : '',
4c79b5
					'SIGNATURE'			=> $signature,
4c79b5
					'SIGNATURE_PREVIEW'	=> $signature_preview,
4c79b5
4c79b5
					'S_BBCODE_CHECKED' 		=> (!$enable_bbcode) ? ' checked="checked"' : '',
4c79b5
					'S_SMILIES_CHECKED' 	=> (!$enable_smilies) ? ' checked="checked"' : '',
4c79b5
					'S_MAGIC_URL_CHECKED' 	=> (!$enable_urls) ? ' checked="checked"' : '',
4c79b5
4c79b5
					'BBCODE_STATUS'			=> ($config['allow_sig_bbcode']) ? sprintf($user->lang['BBCODE_IS_ON'], '', '') : sprintf($user->lang['BBCODE_IS_OFF'], '', ''),
4c79b5
					'SMILIES_STATUS'		=> ($config['allow_sig_smilies']) ? $user->lang['SMILIES_ARE_ON'] : $user->lang['SMILIES_ARE_OFF'],
4c79b5
					'IMG_STATUS'			=> ($config['allow_sig_img']) ? $user->lang['IMAGES_ARE_ON'] : $user->lang['IMAGES_ARE_OFF'],
4c79b5
					'FLASH_STATUS'			=> ($config['allow_sig_flash']) ? $user->lang['FLASH_IS_ON'] : $user->lang['FLASH_IS_OFF'],
4c79b5
					'URL_STATUS'			=> ($config['allow_sig_links']) ? $user->lang['URL_IS_ON'] : $user->lang['URL_IS_OFF'],
4c79b5
4c79b5
					'L_SIGNATURE_EXPLAIN'	=> sprintf($user->lang['SIGNATURE_EXPLAIN'], $config['max_sig_chars']),
4c79b5
4c79b5
					'S_BBCODE_ALLOWED'		=> $config['allow_sig_bbcode'],
4c79b5
					'S_SMILIES_ALLOWED'		=> $config['allow_sig_smilies'],
4c79b5
					'S_BBCODE_IMG'			=> ($config['allow_sig_img']) ? true : false,
4c79b5
					'S_BBCODE_FLASH'		=> ($config['allow_sig_flash']) ? true : false,
4c79b5
					'S_LINKS_ALLOWED'		=> ($config['allow_sig_links']) ? true : false)
4c79b5
				);
4c79b5
4c79b5
				// Build custom bbcodes array
4c79b5
				display_custom_bbcodes();
4c79b5
4c79b5
			break;
4c79b5
4c79b5
			case 'avatar':
4c79b5
4c79b5
				include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
4c79b5
4c79b5
				$display_gallery = request_var('display_gallery', '0');
4c79b5
				$avatar_select = basename(request_var('avatar_select', ''));
4c79b5
				$category = basename(request_var('category', ''));
4c79b5
4c79b5
				$can_upload = ($config['allow_avatar_upload'] && file_exists($phpbb_root_path . $config['avatar_path']) && @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;
4c79b5
4c79b5
				add_form_key('ucp_avatar');
4c79b5
4c79b5
				if ($submit)
4c79b5
				{
4c79b5
					if (check_form_key('ucp_avatar'))
4c79b5
					{
4c79b5
						if (avatar_process_user($error))
4c79b5
						{
4c79b5
							meta_refresh(3, $this->u_action);
4c79b5
							$message = $user->lang['PROFILE_UPDATED'] . '

' . sprintf($user->lang['RETURN_UCP'], '', '');
4c79b5
							trigger_error($message);
4c79b5
						}
4c79b5
					}
4c79b5
					else
4c79b5
					{
4c79b5
						$error[] = 'FORM_INVALID';
4c79b5
					}
4c79b5
					// Replace "error" strings with their real, localised form
4c79b5
					$error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error);
4c79b5
				}
4c79b5
4c79b5
				$template->assign_vars(array(
4c79b5
					'ERROR'			=> (sizeof($error)) ? implode('
', $error) : '',
4c79b5
					'AVATAR'		=> get_user_avatar($user->data['user_avatar'], $user->data['user_avatar_type'], $user->data['user_avatar_width'], $user->data['user_avatar_height']),
4c79b5
					'AVATAR_SIZE'	=> $config['avatar_filesize'],
4c79b5
4c79b5
					'U_GALLERY'		=> append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=profile&mode=avatar&display_gallery=1'),
4c79b5
4c79b5
					'S_FORM_ENCTYPE'	=> ($can_upload) ? ' enctype="multipart/form-data"' : '',
4c79b5
4c79b5
					'L_AVATAR_EXPLAIN'	=> sprintf($user->lang['AVATAR_EXPLAIN'], $config['avatar_max_width'], $config['avatar_max_height'], $config['avatar_filesize'] / 1024),
4c79b5
				));
4c79b5
4c79b5
				if ($display_gallery && $auth->acl_get('u_chgavatar') && $config['allow_avatar_local'])
4c79b5
				{
4c79b5
					avatar_gallery($category, $avatar_select, 4);
4c79b5
				}
4c79b5
				else
4c79b5
				{
4c79b5
					$avatars_enabled = ($can_upload || ($auth->acl_get('u_chgavatar') && ($config['allow_avatar_local'] || $config['allow_avatar_remote']))) ? true : false;
4c79b5
4c79b5
					$template->assign_vars(array(
4c79b5
						'AVATAR_WIDTH'	=> request_var('width', $user->data['user_avatar_width']),
4c79b5
						'AVATAR_HEIGHT'	=> request_var('height', $user->data['user_avatar_height']),
4c79b5
4c79b5
						'S_AVATARS_ENABLED'		=> $avatars_enabled,
4c79b5
						'S_UPLOAD_AVATAR_FILE'	=> $can_upload,
4c79b5
						'S_UPLOAD_AVATAR_URL'	=> $can_upload,
4c79b5
						'S_LINK_AVATAR'			=> ($auth->acl_get('u_chgavatar') && $config['allow_avatar_remote']) ? true : false,
4c79b5
						'S_DISPLAY_GALLERY'		=> ($auth->acl_get('u_chgavatar') && $config['allow_avatar_local']) ? true : false)
4c79b5
					);
4c79b5
				}
4c79b5
4c79b5
			break;
4c79b5
		}
4c79b5
4c79b5
		$template->assign_vars(array(
4c79b5
			'L_TITLE'	=> $user->lang['UCP_PROFILE_' . strtoupper($mode)],
4c79b5
4c79b5
			'S_HIDDEN_FIELDS'	=> $s_hidden_fields,
4c79b5
			'S_UCP_ACTION'		=> $this->u_action)
4c79b5
		);
4c79b5
4c79b5
		// Set desired template
4c79b5
		$this->tpl_name = 'ucp_profile_' . $mode;
4c79b5
		$this->page_title = 'UCP_PROFILE_' . strtoupper($mode);
4c79b5
	}
4c79b5
}
4c79b5
4c79b5
?>