Blame Identity/Webenv/phpBB/3.0.4/includes/ucp/ucp_profile.php

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

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

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

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

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

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