~azzar1/unity/add-show-desktop-key

443 by dcoles
Added Forum application along with unmodifed version of phpBB3 "Olympus" 3.0.0
1
<?php
2
/**
3
*
4
* @package ucp
5
* @version $Id: ucp_profile.php,v 1.127 2007/10/05 14:36:34 acydburn Exp $
6
* @copyright (c) 2005 phpBB Group
7
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
8
*
9
*/
10
11
/**
12
* @ignore
13
*/
14
if (!defined('IN_PHPBB'))
15
{
16
	exit;
17
}
18
19
/**
20
* ucp_profile
21
* Changing profile settings
22
*
23
* @todo what about pertaining user_sig_options?
24
* @package ucp
25
*/
26
class ucp_profile
27
{
28
	var $u_action;
29
30
	function main($id, $mode)
31
	{
32
		global $config, $db, $user, $auth, $template, $phpbb_root_path, $phpEx;
33
34
		$user->add_lang('posting');
35
36
		$preview	= (!empty($_POST['preview'])) ? true : false;
37
		$submit		= (!empty($_POST['submit'])) ? true : false;
38
		$delete		= (!empty($_POST['delete'])) ? true : false;
39
		$error = $data = array();
40
		$s_hidden_fields = '';
41
42
		switch ($mode)
43
		{
44
			case 'reg_details':
45
46
				$data = array(
47
					'username'			=> utf8_normalize_nfc(request_var('username', $user->data['username'], true)),
48
					'email'				=> strtolower(request_var('email', $user->data['user_email'])),
49
					'email_confirm'		=> strtolower(request_var('email_confirm', '')),
50
					'new_password'		=> request_var('new_password', '', true),
51
					'cur_password'		=> request_var('cur_password', '', true),
52
					'password_confirm'	=> request_var('password_confirm', '', true),
53
				);
54
55
				add_form_key('ucp_reg_details');
56
57
				if ($submit)
58
				{
59
					// Do not check cur_password, it is the old one.
60
					$check_ary = array(
61
						'new_password'		=> array(
62
							array('string', true, $config['min_pass_chars'], $config['max_pass_chars']),
63
							array('password')),
64
						'password_confirm'	=> array('string', true, $config['min_pass_chars'], $config['max_pass_chars']),
65
						'email'				=> array(
66
							array('string', false, 6, 60),
67
							array('email')),
68
						'email_confirm'		=> array('string', true, 6, 60),
69
					);
70
71
					if ($auth->acl_get('u_chgname') && $config['allow_namechange'])
72
					{
73
						$check_ary['username'] = array(
74
							array('string', false, $config['min_name_chars'], $config['max_name_chars']),
75
							array('username'),
76
						);
77
					}
78
79
					$error = validate_data($data, $check_ary);
80
81
					if ($auth->acl_get('u_chgpasswd') && $data['new_password'] && $data['password_confirm'] != $data['new_password'])
82
					{
83
						$error[] = 'NEW_PASSWORD_ERROR';
84
					}
85
86
					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']))
87
					{
88
						$error[] = 'CUR_PASSWORD_ERROR';
89
					}
90
91
					// Only check the new password against the previous password if there have been no errors
92
					if (!sizeof($error) && $auth->acl_get('u_chgpasswd') && $data['new_password'] && phpbb_check_hash($data['new_password'], $user->data['user_password']))
93
					{
94
						$error[] = 'SAME_PASSWORD_ERROR';
95
					}
96
97
					if ($auth->acl_get('u_chgemail') && $data['email'] != $user->data['user_email'] && $data['email_confirm'] != $data['email'])
98
					{
99
						$error[] = 'NEW_EMAIL_ERROR';
100
					}
101
102
					if (!check_form_key('ucp_reg_details'))
103
					{
104
						$error[] = 'FORM_INVALID';
105
					}
106
107
					if (!sizeof($error))
108
					{
109
						$sql_ary = array(
110
							'username'			=> ($auth->acl_get('u_chgname') && $config['allow_namechange']) ? $data['username'] : $user->data['username'],
111
							'username_clean'	=> ($auth->acl_get('u_chgname') && $config['allow_namechange']) ? utf8_clean_string($data['username']) : $user->data['username_clean'],
112
							'user_email'		=> ($auth->acl_get('u_chgemail')) ? $data['email'] : $user->data['user_email'],
113
							'user_email_hash'	=> ($auth->acl_get('u_chgemail')) ? crc32($data['email']) . strlen($data['email']) : $user->data['user_email_hash'],
114
							'user_password'		=> ($auth->acl_get('u_chgpasswd') && $data['new_password']) ? phpbb_hash($data['new_password']) : $user->data['user_password'],
115
							'user_passchg'		=> ($auth->acl_get('u_chgpasswd') && $data['new_password']) ? time() : 0,
116
						);
117
118
						if ($auth->acl_get('u_chgname') && $config['allow_namechange'] && $data['username'] != $user->data['username'])
119
						{
120
							add_log('user', $user->data['user_id'], 'LOG_USER_UPDATE_NAME', $user->data['username'], $data['username']);
121
						}
122
123
						if ($auth->acl_get('u_chgpasswd') && $data['new_password'] && !phpbb_check_hash($data['new_password'], $user->data['user_password']))
124
						{
125
							$user->reset_login_keys();
126
							add_log('user', $user->data['user_id'], 'LOG_USER_NEW_PASSWORD', $data['username']);
127
						}
128
129
						if ($auth->acl_get('u_chgemail') && $data['email'] != $user->data['user_email'])
130
						{
131
							add_log('user', $user->data['user_id'], 'LOG_USER_UPDATE_EMAIL', $data['username'], $user->data['user_email'], $data['email']);
132
						}
133
134
						$message = 'PROFILE_UPDATED';
135
136
						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))
137
						{
138
							$message = ($config['require_activation'] == USER_ACTIVATION_SELF) ? 'ACCOUNT_EMAIL_CHANGED' : 'ACCOUNT_EMAIL_CHANGED_ADMIN';
139
140
							include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
141
142
							$server_url = generate_board_url();
143
144
							$user_actkey = gen_rand_string(10);
145
							$key_len = 54 - (strlen($server_url));
146
							$key_len = ($key_len > 6) ? $key_len : 6;
147
							$user_actkey = substr($user_actkey, 0, $key_len);
148
149
							$messenger = new messenger(false);
150
151
							$template_file = ($config['require_activation'] == USER_ACTIVATION_ADMIN) ? 'user_activate_inactive' : 'user_activate';
152
							$messenger->template($template_file, $user->data['user_lang']);
153
154
							$messenger->to($data['email'], $data['username']);
155
156
							$messenger->headers('X-AntiAbuse: Board servername - ' . $config['server_name']);
157
							$messenger->headers('X-AntiAbuse: User_id - ' . $user->data['user_id']);
158
							$messenger->headers('X-AntiAbuse: Username - ' . $user->data['username']);
159
							$messenger->headers('X-AntiAbuse: User IP - ' . $user->ip);
160
161
							$messenger->assign_vars(array(
162
								'USERNAME'		=> htmlspecialchars_decode($data['username']),
163
								'U_ACTIVATE'	=> "$server_url/ucp.$phpEx?mode=activate&u={$user->data['user_id']}&k=$user_actkey")
164
							);
165
166
							$messenger->send(NOTIFY_EMAIL);
167
168
							if ($config['require_activation'] == USER_ACTIVATION_ADMIN)
169
							{
170
								// Grab an array of user_id's with a_user permissions ... these users can activate a user
171
								$admin_ary = $auth->acl_get_list(false, 'a_user', false);
172
								$admin_ary = (!empty($admin_ary[0]['a_user'])) ? $admin_ary[0]['a_user'] : array();
173
174
								// Also include founders
175
								$where_sql = ' WHERE user_type = ' . USER_FOUNDER;
176
177
								if (sizeof($admin_ary))
178
								{
179
									$where_sql .= ' OR ' . $db->sql_in_set('user_id', $admin_ary);
180
								}
181
182
								$sql = 'SELECT user_id, username, user_email, user_lang, user_jabber, user_notify_type
183
									FROM ' . USERS_TABLE . ' ' .
184
									$where_sql;
185
								$result = $db->sql_query($sql);
186
187
								while ($row = $db->sql_fetchrow($result))
188
								{
189
									$messenger->template('admin_activate', $row['user_lang']);
190
									$messenger->to($row['user_email'], $row['username']);
191
									$messenger->im($row['user_jabber'], $row['username']);
192
193
									$messenger->assign_vars(array(
194
										'USERNAME'			=> htmlspecialchars_decode($data['username']),
195
										'U_USER_DETAILS'	=> "$server_url/memberlist.$phpEx?mode=viewprofile&u={$user->data['user_id']}",
196
										'U_ACTIVATE'		=> "$server_url/ucp.$phpEx?mode=activate&u={$user->data['user_id']}&k=$user_actkey")
197
									);
198
199
									$messenger->send($row['user_notify_type']);
200
								}
201
								$db->sql_freeresult($result);
202
							}
203
204
							user_active_flip('deactivate', $user->data['user_id'], INACTIVE_PROFILE);
205
206
							// Because we want the profile to be reactivated we set user_newpasswd to empty (else the reactivation will fail)
207
							$sql_ary['user_actkey'] = $user_actkey;
208
							$sql_ary['user_newpasswd'] = '';
209
						}
210
211
						if (sizeof($sql_ary))
212
						{
213
							$sql = 'UPDATE ' . USERS_TABLE . '
214
								SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
215
								WHERE user_id = ' . $user->data['user_id'];
216
							$db->sql_query($sql);
217
						}
218
219
						// Need to update config, forum, topic, posting, messages, etc.
220
						if ($data['username'] != $user->data['username'] && $auth->acl_get('u_chgname') && $config['allow_namechange'])
221
						{
222
							user_update_name($user->data['username'], $data['username']);
223
						}
224
225
						// Now, we can remove the user completely (kill the session) - NOT BEFORE!!!
226
						if (!empty($sql_ary['user_actkey']))
227
						{
228
							meta_refresh(5, append_sid($phpbb_root_path . 'index.' . $phpEx));
229
							$message = $user->lang[$message] . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid($phpbb_root_path . 'index.' . $phpEx) . '">', '</a>');
230
231
							// Because the user gets deactivated we log him out too, killing his session
232
							$user->session_kill();
233
						}
234
						else
235
						{
236
							meta_refresh(3, $this->u_action);
237
							$message = $user->lang[$message] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
238
						}
239
240
						trigger_error($message);
241
					}
242
243
					// Replace "error" strings with their real, localised form
244
					$error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error);
245
				}
246
247
				$template->assign_vars(array(
248
					'ERROR'				=> (sizeof($error)) ? implode('<br />', $error) : '',
249
250
					'USERNAME'			=> $data['username'],
251
					'EMAIL'				=> $data['email'],
252
					'PASSWORD_CONFIRM'	=> $data['password_confirm'],
253
					'NEW_PASSWORD'		=> $data['new_password'],
254
					'CUR_PASSWORD'		=> '',
255
256
					'L_USERNAME_EXPLAIN'		=> sprintf($user->lang[$config['allow_name_chars'] . '_EXPLAIN'], $config['min_name_chars'], $config['max_name_chars']),
257
					'L_CHANGE_PASSWORD_EXPLAIN'	=> sprintf($user->lang[$config['pass_complex'] . '_EXPLAIN'], $config['min_pass_chars'], $config['max_pass_chars']),
258
259
					'S_FORCE_PASSWORD'	=> ($auth->acl_get('u_chgpasswd') && $config['chg_passforce'] && $user->data['user_passchg'] < time() - ($config['chg_passforce'] * 86400)) ? true : false,
260
					'S_CHANGE_USERNAME' => ($config['allow_namechange'] && $auth->acl_get('u_chgname')) ? true : false,
261
					'S_CHANGE_EMAIL'	=> ($auth->acl_get('u_chgemail')) ? true : false,
262
					'S_CHANGE_PASSWORD'	=> ($auth->acl_get('u_chgpasswd')) ? true : false)
263
				);
264
			break;
265
266
			case 'profile_info':
267
268
				include($phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx);
269
270
				$cp = new custom_profile();
271
272
				$cp_data = $cp_error = array();
273
274
				$data = array(
275
					'icq'			=> request_var('icq', $user->data['user_icq']),
276
					'aim'			=> request_var('aim', $user->data['user_aim']),
277
					'msn'			=> request_var('msn', $user->data['user_msnm']),
278
					'yim'			=> request_var('yim', $user->data['user_yim']),
279
					'jabber'		=> utf8_normalize_nfc(request_var('jabber', $user->data['user_jabber'], true)),
280
					'website'		=> request_var('website', $user->data['user_website']),
281
					'location'		=> utf8_normalize_nfc(request_var('location', $user->data['user_from'], true)),
282
					'occupation'	=> utf8_normalize_nfc(request_var('occupation', $user->data['user_occ'], true)),
283
					'interests'		=> utf8_normalize_nfc(request_var('interests', $user->data['user_interests'], true)),
284
				);
285
286
				if ($config['allow_birthdays'])
287
				{
288
					$data['bday_day'] = $data['bday_month'] = $data['bday_year'] = 0;
289
290
					if ($user->data['user_birthday'])
291
					{
292
						list($data['bday_day'], $data['bday_month'], $data['bday_year']) = explode('-', $user->data['user_birthday']);
293
					}
294
295
					$data['bday_day'] = request_var('bday_day', $data['bday_day']);
296
					$data['bday_month'] = request_var('bday_month', $data['bday_month']);
297
					$data['bday_year'] = request_var('bday_year', $data['bday_year']);
298
				}
299
300
				add_form_key('ucp_profile_info');
301
302
				if ($submit)
303
				{
304
					$validate_array = array(
305
						'icq'			=> array(
306
							array('string', true, 3, 15),
307
							array('match', true, '#^[0-9]+$#i')),
308
						'aim'			=> array('string', true, 3, 255),
309
						'msn'			=> array('string', true, 5, 255),
310
						'jabber'		=> array(
311
							array('string', true, 5, 255),
312
							array('jabber')),
313
						'yim'			=> array('string', true, 5, 255),
314
						'website'		=> array(
315
							array('string', true, 12, 255),
316
							array('match', true, '#^http[s]?://(.*?\.)*?[a-z0-9\-]+\.[a-z]{2,4}#i')),
317
						'location'		=> array('string', true, 2, 255),
318
						'occupation'	=> array('string', true, 2, 500),
319
						'interests'		=> array('string', true, 2, 500),
320
					);
321
322
					if ($config['allow_birthdays'])
323
					{
324
						$validate_array = array_merge($validate_array, array(
325
							'bday_day'		=> array('num', true, 1, 31),
326
							'bday_month'	=> array('num', true, 1, 12),
327
							'bday_year'		=> array('num', true, 1901, gmdate('Y', time()) + 50),
328
						));
329
					}
330
331
					$error = validate_data($data, $validate_array);
332
333
					// validate custom profile fields
334
					$cp->submit_cp_field('profile', $user->get_iso_lang_id(), $cp_data, $cp_error);
335
336
					if (sizeof($cp_error))
337
					{
338
						$error = array_merge($error, $cp_error);
339
					}
340
341
					if (!check_form_key('ucp_profile_info'))
342
					{
343
						$error[] = 'FORM_INVALID';
344
					}
345
346
					if (!sizeof($error))
347
					{
348
						$sql_ary = array(
349
							'user_icq'		=> $data['icq'],
350
							'user_aim'		=> $data['aim'],
351
							'user_msnm'		=> $data['msn'],
352
							'user_yim'		=> $data['yim'],
353
							'user_jabber'	=> $data['jabber'],
354
							'user_website'	=> $data['website'],
355
							'user_from'		=> $data['location'],
356
							'user_occ'		=> $data['occupation'],
357
							'user_interests'=> $data['interests'],
358
						);
359
360
						if ($config['allow_birthdays'])
361
						{
362
							$sql_ary['user_birthday'] = sprintf('%2d-%2d-%4d', $data['bday_day'], $data['bday_month'], $data['bday_year']);
363
						}
364
365
						$sql = 'UPDATE ' . USERS_TABLE . '
366
							SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
367
							WHERE user_id = ' . $user->data['user_id'];
368
						$db->sql_query($sql);
369
370
						// Update Custom Fields
371
						if (sizeof($cp_data))
372
						{
373
							$sql = 'UPDATE ' . PROFILE_FIELDS_DATA_TABLE . '
374
								SET ' . $db->sql_build_array('UPDATE', $cp_data) . '
375
								WHERE user_id = ' . $user->data['user_id'];
376
							$db->sql_query($sql);
377
378
							if (!$db->sql_affectedrows())
379
							{
380
								$cp_data['user_id'] = (int) $user->data['user_id'];
381
382
								$db->sql_return_on_error(true);
383
384
								$sql = 'INSERT INTO ' . PROFILE_FIELDS_DATA_TABLE . ' ' . $db->sql_build_array('INSERT', $cp_data);
385
								$db->sql_query($sql);
386
387
								$db->sql_return_on_error(false);
388
							}
389
						}
390
391
						meta_refresh(3, $this->u_action);
392
						$message = $user->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
393
						trigger_error($message);
394
					}
395
396
					// Replace "error" strings with their real, localised form
397
					$error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error);
398
				}
399
400
				if ($config['allow_birthdays'])
401
				{
402
					$s_birthday_day_options = '<option value="0"' . ((!$data['bday_day']) ? ' selected="selected"' : '') . '>--</option>';
403
					for ($i = 1; $i < 32; $i++)
404
					{
405
						$selected = ($i == $data['bday_day']) ? ' selected="selected"' : '';
406
						$s_birthday_day_options .= "<option value=\"$i\"$selected>$i</option>";
407
					}
408
409
					$s_birthday_month_options = '<option value="0"' . ((!$data['bday_month']) ? ' selected="selected"' : '') . '>--</option>';
410
					for ($i = 1; $i < 13; $i++)
411
					{
412
						$selected = ($i == $data['bday_month']) ? ' selected="selected"' : '';
413
						$s_birthday_month_options .= "<option value=\"$i\"$selected>$i</option>";
414
					}
415
					$s_birthday_year_options = '';
416
417
					$now = getdate();
418
					$s_birthday_year_options = '<option value="0"' . ((!$data['bday_year']) ? ' selected="selected"' : '') . '>--</option>';
419
					for ($i = $now['year'] - 100; $i < $now['year']; $i++)
420
					{
421
						$selected = ($i == $data['bday_year']) ? ' selected="selected"' : '';
422
						$s_birthday_year_options .= "<option value=\"$i\"$selected>$i</option>";
423
					}
424
					unset($now);
425
426
					$template->assign_vars(array(
427
						'S_BIRTHDAY_DAY_OPTIONS'	=> $s_birthday_day_options,
428
						'S_BIRTHDAY_MONTH_OPTIONS'	=> $s_birthday_month_options,
429
						'S_BIRTHDAY_YEAR_OPTIONS'	=> $s_birthday_year_options,
430
						'S_BIRTHDAYS_ENABLED'		=> true,
431
					));
432
				}
433
434
				$template->assign_vars(array(
435
					'ERROR'		=> (sizeof($error)) ? implode('<br />', $error) : '',
436
437
					'ICQ'		=> $data['icq'],
438
					'YIM'		=> $data['yim'],
439
					'AIM'		=> $data['aim'],
440
					'MSN'		=> $data['msn'],
441
					'JABBER'	=> $data['jabber'],
442
					'WEBSITE'	=> $data['website'],
443
					'LOCATION'	=> $data['location'],
444
					'OCCUPATION'=> $data['occupation'],
445
					'INTERESTS'	=> $data['interests'],
446
				));
447
448
				// Get additional profile fields and assign them to the template block var 'profile_fields'
449
				$user->get_profile_fields($user->data['user_id']);
450
451
				$cp->generate_profile_fields('profile', $user->get_iso_lang_id());
452
453
			break;
454
455
			case 'signature':
456
457
				if (!$auth->acl_get('u_sig'))
458
				{
459
					trigger_error('NO_AUTH_SIGNATURE');
460
				}
461
				
462
				include($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
463
				include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
464
465
				$enable_bbcode	= ($config['allow_sig_bbcode']) ? ((request_var('disable_bbcode', !$user->optionget('bbcode'))) ? false : true) : false;
466
				$enable_smilies	= ($config['allow_sig_smilies']) ? ((request_var('disable_smilies', !$user->optionget('smilies'))) ? false : true) : false;
467
				$enable_urls	= ($config['allow_sig_links']) ? ((request_var('disable_magic_url', false)) ? false : true) : false;
468
469
				$signature		= utf8_normalize_nfc(request_var('signature', (string) $user->data['user_sig'], true));
470
471
				add_form_key('ucp_sig');
472
473
				if ($submit || $preview)
474
				{
475
					include($phpbb_root_path . 'includes/message_parser.' . $phpEx);
476
477
					if (!sizeof($error))
478
					{
479
						$message_parser = new parse_message($signature);
480
481
						// Allowing Quote BBCode
482
						$message_parser->parse($enable_bbcode, $enable_urls, $enable_smilies, $config['allow_sig_img'], $config['allow_sig_flash'], true, $config['allow_sig_links'], true, 'sig');
483
484
						if (sizeof($message_parser->warn_msg))
485
						{
486
							$error[] = implode('<br />', $message_parser->warn_msg);
487
						}
488
489
						if (!check_form_key('ucp_sig'))
490
						{
491
							$error[] = 'FORM_INVALID';
492
						}
493
494
						if (!sizeof($error) && $submit)
495
						{
496
							$sql_ary = array(
497
								'user_sig'					=> (string) $message_parser->message,
498
								'user_sig_bbcode_uid'		=> (string) $message_parser->bbcode_uid,
499
								'user_sig_bbcode_bitfield'	=> $message_parser->bbcode_bitfield
500
							);
501
502
							$sql = 'UPDATE ' . USERS_TABLE . '
503
								SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
504
								WHERE user_id = ' . $user->data['user_id'];
505
							$db->sql_query($sql);
506
507
							$message = $user->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
508
							trigger_error($message);
509
						}
510
					}
511
512
					// Replace "error" strings with their real, localised form
513
					$error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error);
514
				}
515
516
				$signature_preview = '';
517
				if ($preview)
518
				{
519
					// Now parse it for displaying
520
					$signature_preview = $message_parser->format_display($enable_bbcode, $enable_urls, $enable_smilies, false);
521
					unset($message_parser);
522
				}
523
524
				decode_message($signature, $user->data['user_sig_bbcode_uid']);
525
526
				$template->assign_vars(array(
527
					'ERROR'				=> (sizeof($error)) ? implode('<br />', $error) : '',
528
					'SIGNATURE'			=> $signature,
529
					'SIGNATURE_PREVIEW'	=> $signature_preview,
530
531
					'S_BBCODE_CHECKED' 		=> (!$enable_bbcode) ? ' checked="checked"' : '',
532
					'S_SMILIES_CHECKED' 	=> (!$enable_smilies) ? ' checked="checked"' : '',
533
					'S_MAGIC_URL_CHECKED' 	=> (!$enable_urls) ? ' checked="checked"' : '',
534
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>'),
536
					'SMILIES_STATUS'		=> ($config['allow_sig_smilies']) ? $user->lang['SMILIES_ARE_ON'] : $user->lang['SMILIES_ARE_OFF'],
537
					'IMG_STATUS'			=> ($config['allow_sig_img']) ? $user->lang['IMAGES_ARE_ON'] : $user->lang['IMAGES_ARE_OFF'],
538
					'FLASH_STATUS'			=> ($config['allow_sig_flash']) ? $user->lang['FLASH_IS_ON'] : $user->lang['FLASH_IS_OFF'],
539
					'URL_STATUS'			=> ($config['allow_sig_links']) ? $user->lang['URL_IS_ON'] : $user->lang['URL_IS_OFF'],
540
541
					'L_SIGNATURE_EXPLAIN'	=> sprintf($user->lang['SIGNATURE_EXPLAIN'], $config['max_sig_chars']),
542
543
					'S_BBCODE_ALLOWED'		=> $config['allow_sig_bbcode'],
544
					'S_SMILIES_ALLOWED'		=> $config['allow_sig_smilies'],
545
					'S_BBCODE_IMG'			=> ($config['allow_sig_img']) ? true : false,
546
					'S_BBCODE_FLASH'		=> ($config['allow_sig_flash']) ? true : false,
547
					'S_LINKS_ALLOWED'		=> ($config['allow_sig_links']) ? true : false)
548
				);
549
550
				// Build custom bbcodes array
551
				display_custom_bbcodes();
552
553
			break;
554
555
			case 'avatar':
556
557
				include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
558
559
				$display_gallery = request_var('display_gallery', '0');
560
				$avatar_select = basename(request_var('avatar_select', ''));
561
				$category = basename(request_var('category', ''));
562
563
				$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;
564
565
				add_form_key('ucp_avatar');
566
567
				if ($submit)
568
				{
569
					if (check_form_key('ucp_avatar'))
570
					{
571
						if (avatar_process_user($error))
572
						{
573
							meta_refresh(3, $this->u_action);
574
							$message = $user->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
575
							trigger_error($message);
576
						}
577
					}
578
					else
579
					{
580
						$error[] = 'FORM_INVALID';
581
					}
582
					// Replace "error" strings with their real, localised form
583
					$error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error);
584
				}
585
586
				$template->assign_vars(array(
587
					'ERROR'			=> (sizeof($error)) ? implode('<br />', $error) : '',
588
					'AVATAR'		=> get_user_avatar($user->data['user_avatar'], $user->data['user_avatar_type'], $user->data['user_avatar_width'], $user->data['user_avatar_height']),
589
					'AVATAR_SIZE'	=> $config['avatar_filesize'],
590
					
591
					'U_GALLERY'		=> append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=profile&amp;mode=avatar&amp;display_gallery=1'),
592
					
593
					'S_FORM_ENCTYPE'	=> ($can_upload) ? ' enctype="multipart/form-data"' : '',
594
595
					'L_AVATAR_EXPLAIN'	=> sprintf($user->lang['AVATAR_EXPLAIN'], $config['avatar_max_width'], $config['avatar_max_height'], round($config['avatar_filesize'] / 1024)),)
596
				);
597
598
				if ($display_gallery && $auth->acl_get('u_chgavatar') && $config['allow_avatar_local'])
599
				{
600
					avatar_gallery($category, $avatar_select, 4);
601
				}
602
				else
603
				{
604
					$avatars_enabled = ($can_upload || ($auth->acl_get('u_chgavatar') && ($config['allow_avatar_local'] || $config['allow_avatar_remote']))) ? true : false;
605
					
606
					$template->assign_vars(array(
607
						'AVATAR_WIDTH'	=> request_var('width', $user->data['user_avatar_width']),
608
						'AVATAR_HEIGHT'	=> request_var('height', $user->data['user_avatar_height']),
609
610
						'S_AVATARS_ENABLED'		=> $avatars_enabled,
611
						'S_UPLOAD_AVATAR_FILE'	=> $can_upload,
612
						'S_UPLOAD_AVATAR_URL'	=> $can_upload,
613
						'S_LINK_AVATAR'			=> ($auth->acl_get('u_chgavatar') && $config['allow_avatar_remote']) ? true : false,
614
						'S_DISPLAY_GALLERY'		=> ($auth->acl_get('u_chgavatar') && $config['allow_avatar_local']) ? true : false)
615
					);
616
				}
617
618
			break;
619
		}
620
621
		$template->assign_vars(array(
622
			'L_TITLE'	=> $user->lang['UCP_PROFILE_' . strtoupper($mode)],
623
624
			'S_HIDDEN_FIELDS'	=> $s_hidden_fields,
625
			'S_UCP_ACTION'		=> $this->u_action)
626
		);
627
628
		// Set desired template
629
		$this->tpl_name = 'ucp_profile_' . $mode;
630
		$this->page_title = 'UCP_PROFILE_' . strtoupper($mode);
631
	}
632
}
633
634
?>