|
1 <?php |
|
2 /** |
|
3 * |
|
4 * @package ucp |
|
5 * @version $Id$ |
|
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_chgemail') && $data['email'] != $user->data['user_email'] && $data['email_confirm'] != $data['email']) |
|
82 { |
|
83 $error[] = ($data['email_confirm']) ? 'NEW_EMAIL_ERROR' : 'NEW_EMAIL_CONFIRM_EMPTY'; |
|
84 } |
|
85 |
|
86 if ($auth->acl_get('u_chgpasswd') && $data['new_password'] && $data['password_confirm'] != $data['new_password']) |
|
87 { |
|
88 $error[] = ($data['password_confirm']) ? 'NEW_PASSWORD_ERROR' : 'NEW_PASSWORD_CONFIRM_EMPTY'; |
|
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 (!phpbb_check_hash($data['cur_password'], $user->data['user_password'])) |
|
98 { |
|
99 $error[] = ($data['cur_password']) ? 'CUR_PASSWORD_ERROR' : 'CUR_PASSWORD_EMPTY'; |
|
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')) ? phpbb_email_hash($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 ($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)) |
|
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(mt_rand(6, 10)); |
|
145 |
|
146 $messenger = new messenger(false); |
|
147 |
|
148 $template_file = ($config['require_activation'] == USER_ACTIVATION_ADMIN) ? 'user_activate_inactive' : 'user_activate'; |
|
149 $messenger->template($template_file, $user->data['user_lang']); |
|
150 |
|
151 $messenger->to($data['email'], $data['username']); |
|
152 |
|
153 $messenger->anti_abuse_headers($config, $user); |
|
154 |
|
155 $messenger->assign_vars(array( |
|
156 'USERNAME' => htmlspecialchars_decode($data['username']), |
|
157 'U_ACTIVATE' => "$server_url/ucp.$phpEx?mode=activate&u={$user->data['user_id']}&k=$user_actkey") |
|
158 ); |
|
159 |
|
160 $messenger->send(NOTIFY_EMAIL); |
|
161 |
|
162 if ($config['require_activation'] == USER_ACTIVATION_ADMIN) |
|
163 { |
|
164 // Grab an array of user_id's with a_user permissions ... these users can activate a user |
|
165 $admin_ary = $auth->acl_get_list(false, 'a_user', false); |
|
166 $admin_ary = (!empty($admin_ary[0]['a_user'])) ? $admin_ary[0]['a_user'] : array(); |
|
167 |
|
168 // Also include founders |
|
169 $where_sql = ' WHERE user_type = ' . USER_FOUNDER; |
|
170 |
|
171 if (sizeof($admin_ary)) |
|
172 { |
|
173 $where_sql .= ' OR ' . $db->sql_in_set('user_id', $admin_ary); |
|
174 } |
|
175 |
|
176 $sql = 'SELECT user_id, username, user_email, user_lang, user_jabber, user_notify_type |
|
177 FROM ' . USERS_TABLE . ' ' . |
|
178 $where_sql; |
|
179 $result = $db->sql_query($sql); |
|
180 |
|
181 while ($row = $db->sql_fetchrow($result)) |
|
182 { |
|
183 $messenger->template('admin_activate', $row['user_lang']); |
|
184 $messenger->to($row['user_email'], $row['username']); |
|
185 $messenger->im($row['user_jabber'], $row['username']); |
|
186 |
|
187 $messenger->assign_vars(array( |
|
188 'USERNAME' => htmlspecialchars_decode($data['username']), |
|
189 'U_USER_DETAILS' => "$server_url/memberlist.$phpEx?mode=viewprofile&u={$user->data['user_id']}", |
|
190 'U_ACTIVATE' => "$server_url/ucp.$phpEx?mode=activate&u={$user->data['user_id']}&k=$user_actkey") |
|
191 ); |
|
192 |
|
193 $messenger->send($row['user_notify_type']); |
|
194 } |
|
195 $db->sql_freeresult($result); |
|
196 } |
|
197 |
|
198 user_active_flip('deactivate', $user->data['user_id'], INACTIVE_PROFILE); |
|
199 |
|
200 // Because we want the profile to be reactivated we set user_newpasswd to empty (else the reactivation will fail) |
|
201 $sql_ary['user_actkey'] = $user_actkey; |
|
202 $sql_ary['user_newpasswd'] = ''; |
|
203 } |
|
204 |
|
205 if (sizeof($sql_ary)) |
|
206 { |
|
207 $sql = 'UPDATE ' . USERS_TABLE . ' |
|
208 SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' |
|
209 WHERE user_id = ' . $user->data['user_id']; |
|
210 $db->sql_query($sql); |
|
211 } |
|
212 |
|
213 // Need to update config, forum, topic, posting, messages, etc. |
|
214 if ($data['username'] != $user->data['username'] && $auth->acl_get('u_chgname') && $config['allow_namechange']) |
|
215 { |
|
216 user_update_name($user->data['username'], $data['username']); |
|
217 } |
|
218 |
|
219 // Now, we can remove the user completely (kill the session) - NOT BEFORE!!! |
|
220 if (!empty($sql_ary['user_actkey'])) |
|
221 { |
|
222 meta_refresh(5, append_sid($phpbb_root_path . 'index.' . $phpEx)); |
|
223 $message = $user->lang[$message] . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid($phpbb_root_path . 'index.' . $phpEx) . '">', '</a>'); |
|
224 |
|
225 // Because the user gets deactivated we log him out too, killing his session |
|
226 $user->session_kill(); |
|
227 } |
|
228 else |
|
229 { |
|
230 meta_refresh(3, $this->u_action); |
|
231 $message = $user->lang[$message] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>'); |
|
232 } |
|
233 |
|
234 trigger_error($message); |
|
235 } |
|
236 |
|
237 // Replace "error" strings with their real, localised form |
|
238 $error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error); |
|
239 } |
|
240 |
|
241 $template->assign_vars(array( |
|
242 'ERROR' => (sizeof($error)) ? implode('<br />', $error) : '', |
|
243 |
|
244 'USERNAME' => $data['username'], |
|
245 'EMAIL' => $data['email'], |
|
246 'PASSWORD_CONFIRM' => $data['password_confirm'], |
|
247 'NEW_PASSWORD' => $data['new_password'], |
|
248 'CUR_PASSWORD' => '', |
|
249 |
|
250 'L_USERNAME_EXPLAIN' => sprintf($user->lang[$config['allow_name_chars'] . '_EXPLAIN'], $config['min_name_chars'], $config['max_name_chars']), |
|
251 'L_CHANGE_PASSWORD_EXPLAIN' => sprintf($user->lang[$config['pass_complex'] . '_EXPLAIN'], $config['min_pass_chars'], $config['max_pass_chars']), |
|
252 |
|
253 'S_FORCE_PASSWORD' => ($auth->acl_get('u_chgpasswd') && $config['chg_passforce'] && $user->data['user_passchg'] < time() - ($config['chg_passforce'] * 86400)) ? true : false, |
|
254 'S_CHANGE_USERNAME' => ($config['allow_namechange'] && $auth->acl_get('u_chgname')) ? true : false, |
|
255 'S_CHANGE_EMAIL' => ($auth->acl_get('u_chgemail')) ? true : false, |
|
256 'S_CHANGE_PASSWORD' => ($auth->acl_get('u_chgpasswd')) ? true : false) |
|
257 ); |
|
258 break; |
|
259 |
|
260 case 'profile_info': |
|
261 |
|
262 include($phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx); |
|
263 |
|
264 $cp = new custom_profile(); |
|
265 |
|
266 $cp_data = $cp_error = array(); |
|
267 |
|
268 $data = array( |
|
269 'icq' => request_var('icq', $user->data['user_icq']), |
|
270 'aim' => request_var('aim', $user->data['user_aim']), |
|
271 'msn' => request_var('msn', $user->data['user_msnm']), |
|
272 'yim' => request_var('yim', $user->data['user_yim']), |
|
273 'jabber' => utf8_normalize_nfc(request_var('jabber', $user->data['user_jabber'], true)), |
|
274 'website' => request_var('website', $user->data['user_website']), |
|
275 'location' => utf8_normalize_nfc(request_var('location', $user->data['user_from'], true)), |
|
276 'occupation' => utf8_normalize_nfc(request_var('occupation', $user->data['user_occ'], true)), |
|
277 'interests' => utf8_normalize_nfc(request_var('interests', $user->data['user_interests'], true)), |
|
278 ); |
|
279 |
|
280 if ($config['allow_birthdays']) |
|
281 { |
|
282 $data['bday_day'] = $data['bday_month'] = $data['bday_year'] = 0; |
|
283 |
|
284 if ($user->data['user_birthday']) |
|
285 { |
|
286 list($data['bday_day'], $data['bday_month'], $data['bday_year']) = explode('-', $user->data['user_birthday']); |
|
287 } |
|
288 |
|
289 $data['bday_day'] = request_var('bday_day', $data['bday_day']); |
|
290 $data['bday_month'] = request_var('bday_month', $data['bday_month']); |
|
291 $data['bday_year'] = request_var('bday_year', $data['bday_year']); |
|
292 $data['user_birthday'] = sprintf('%2d-%2d-%4d', $data['bday_day'], $data['bday_month'], $data['bday_year']); |
|
293 } |
|
294 |
|
295 add_form_key('ucp_profile_info'); |
|
296 |
|
297 if ($submit) |
|
298 { |
|
299 $validate_array = array( |
|
300 'icq' => array( |
|
301 array('string', true, 3, 15), |
|
302 array('match', true, '#^[0-9]+$#i')), |
|
303 'aim' => array('string', true, 3, 255), |
|
304 'msn' => array('string', true, 5, 255), |
|
305 'jabber' => array( |
|
306 array('string', true, 5, 255), |
|
307 array('jabber')), |
|
308 'yim' => array('string', true, 5, 255), |
|
309 'website' => array( |
|
310 array('string', true, 12, 255), |
|
311 array('match', true, '#^http[s]?://(.*?\.)*?[a-z0-9\-]+\.[a-z]{2,4}#i')), |
|
312 'location' => array('string', true, 2, 100), |
|
313 'occupation' => array('string', true, 2, 500), |
|
314 'interests' => array('string', true, 2, 500), |
|
315 ); |
|
316 |
|
317 if ($config['allow_birthdays']) |
|
318 { |
|
319 $validate_array = array_merge($validate_array, array( |
|
320 'bday_day' => array('num', true, 1, 31), |
|
321 'bday_month' => array('num', true, 1, 12), |
|
322 'bday_year' => array('num', true, 1901, gmdate('Y', time()) + 50), |
|
323 'user_birthday' => array('date', true), |
|
324 )); |
|
325 } |
|
326 |
|
327 $error = validate_data($data, $validate_array); |
|
328 |
|
329 // validate custom profile fields |
|
330 $cp->submit_cp_field('profile', $user->get_iso_lang_id(), $cp_data, $cp_error); |
|
331 |
|
332 if (sizeof($cp_error)) |
|
333 { |
|
334 $error = array_merge($error, $cp_error); |
|
335 } |
|
336 |
|
337 if (!check_form_key('ucp_profile_info')) |
|
338 { |
|
339 $error[] = 'FORM_INVALID'; |
|
340 } |
|
341 |
|
342 if (!sizeof($error)) |
|
343 { |
|
344 $data['notify'] = $user->data['user_notify_type']; |
|
345 |
|
346 if ($data['notify'] == NOTIFY_IM && (!$config['jab_enable'] || !$data['jabber'] || !@extension_loaded('xml'))) |
|
347 { |
|
348 // User has not filled in a jabber address (Or one of the modules is disabled or jabber is disabled) |
|
349 // Disable notify by Jabber now for this user. |
|
350 $data['notify'] = NOTIFY_EMAIL; |
|
351 } |
|
352 |
|
353 $sql_ary = array( |
|
354 'user_icq' => $data['icq'], |
|
355 'user_aim' => $data['aim'], |
|
356 'user_msnm' => $data['msn'], |
|
357 'user_yim' => $data['yim'], |
|
358 'user_jabber' => $data['jabber'], |
|
359 'user_website' => $data['website'], |
|
360 'user_from' => $data['location'], |
|
361 'user_occ' => $data['occupation'], |
|
362 'user_interests'=> $data['interests'], |
|
363 'user_notify_type' => $data['notify'], |
|
364 ); |
|
365 |
|
366 if ($config['allow_birthdays']) |
|
367 { |
|
368 $sql_ary['user_birthday'] = $data['user_birthday']; |
|
369 } |
|
370 |
|
371 $sql = 'UPDATE ' . USERS_TABLE . ' |
|
372 SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' |
|
373 WHERE user_id = ' . $user->data['user_id']; |
|
374 $db->sql_query($sql); |
|
375 |
|
376 // Update Custom Fields |
|
377 $cp->update_profile_field_data($user->data['user_id'], $cp_data); |
|
378 |
|
379 meta_refresh(3, $this->u_action); |
|
380 $message = $user->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>'); |
|
381 trigger_error($message); |
|
382 } |
|
383 |
|
384 // Replace "error" strings with their real, localised form |
|
385 $error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error); |
|
386 } |
|
387 |
|
388 if ($config['allow_birthdays']) |
|
389 { |
|
390 $s_birthday_day_options = '<option value="0"' . ((!$data['bday_day']) ? ' selected="selected"' : '') . '>--</option>'; |
|
391 for ($i = 1; $i < 32; $i++) |
|
392 { |
|
393 $selected = ($i == $data['bday_day']) ? ' selected="selected"' : ''; |
|
394 $s_birthday_day_options .= "<option value=\"$i\"$selected>$i</option>"; |
|
395 } |
|
396 |
|
397 $s_birthday_month_options = '<option value="0"' . ((!$data['bday_month']) ? ' selected="selected"' : '') . '>--</option>'; |
|
398 for ($i = 1; $i < 13; $i++) |
|
399 { |
|
400 $selected = ($i == $data['bday_month']) ? ' selected="selected"' : ''; |
|
401 $s_birthday_month_options .= "<option value=\"$i\"$selected>$i</option>"; |
|
402 } |
|
403 $s_birthday_year_options = ''; |
|
404 |
|
405 $now = getdate(); |
|
406 $s_birthday_year_options = '<option value="0"' . ((!$data['bday_year']) ? ' selected="selected"' : '') . '>--</option>'; |
|
407 for ($i = $now['year'] - 100; $i <= $now['year']; $i++) |
|
408 { |
|
409 $selected = ($i == $data['bday_year']) ? ' selected="selected"' : ''; |
|
410 $s_birthday_year_options .= "<option value=\"$i\"$selected>$i</option>"; |
|
411 } |
|
412 unset($now); |
|
413 |
|
414 $template->assign_vars(array( |
|
415 'S_BIRTHDAY_DAY_OPTIONS' => $s_birthday_day_options, |
|
416 'S_BIRTHDAY_MONTH_OPTIONS' => $s_birthday_month_options, |
|
417 'S_BIRTHDAY_YEAR_OPTIONS' => $s_birthday_year_options, |
|
418 'S_BIRTHDAYS_ENABLED' => true, |
|
419 )); |
|
420 } |
|
421 |
|
422 $template->assign_vars(array( |
|
423 'ERROR' => (sizeof($error)) ? implode('<br />', $error) : '', |
|
424 |
|
425 'ICQ' => $data['icq'], |
|
426 'YIM' => $data['yim'], |
|
427 'AIM' => $data['aim'], |
|
428 'MSN' => $data['msn'], |
|
429 'JABBER' => $data['jabber'], |
|
430 'WEBSITE' => $data['website'], |
|
431 'LOCATION' => $data['location'], |
|
432 'OCCUPATION'=> $data['occupation'], |
|
433 'INTERESTS' => $data['interests'], |
|
434 )); |
|
435 |
|
436 // Get additional profile fields and assign them to the template block var 'profile_fields' |
|
437 $user->get_profile_fields($user->data['user_id']); |
|
438 |
|
439 $cp->generate_profile_fields('profile', $user->get_iso_lang_id()); |
|
440 |
|
441 break; |
|
442 |
|
443 case 'signature': |
|
444 |
|
445 if (!$auth->acl_get('u_sig')) |
|
446 { |
|
447 trigger_error('NO_AUTH_SIGNATURE'); |
|
448 } |
|
449 |
|
450 include($phpbb_root_path . 'includes/functions_posting.' . $phpEx); |
|
451 include($phpbb_root_path . 'includes/functions_display.' . $phpEx); |
|
452 |
|
453 $enable_bbcode = ($config['allow_sig_bbcode']) ? (bool) $user->optionget('sig_bbcode') : false; |
|
454 $enable_smilies = ($config['allow_sig_smilies']) ? (bool) $user->optionget('sig_smilies') : false; |
|
455 $enable_urls = ($config['allow_sig_links']) ? (bool) $user->optionget('sig_links') : false; |
|
456 |
|
457 $signature = utf8_normalize_nfc(request_var('signature', (string) $user->data['user_sig'], true)); |
|
458 |
|
459 add_form_key('ucp_sig'); |
|
460 |
|
461 if ($submit || $preview) |
|
462 { |
|
463 include($phpbb_root_path . 'includes/message_parser.' . $phpEx); |
|
464 |
|
465 $enable_bbcode = ($config['allow_sig_bbcode']) ? ((request_var('disable_bbcode', false)) ? false : true) : false; |
|
466 $enable_smilies = ($config['allow_sig_smilies']) ? ((request_var('disable_smilies', false)) ? false : true) : false; |
|
467 $enable_urls = ($config['allow_sig_links']) ? ((request_var('disable_magic_url', false)) ? false : true) : false; |
|
468 |
|
469 if (!sizeof($error)) |
|
470 { |
|
471 $message_parser = new parse_message($signature); |
|
472 |
|
473 // Allowing Quote BBCode |
|
474 $message_parser->parse($enable_bbcode, $enable_urls, $enable_smilies, $config['allow_sig_img'], $config['allow_sig_flash'], true, $config['allow_sig_links'], true, 'sig'); |
|
475 |
|
476 if (sizeof($message_parser->warn_msg)) |
|
477 { |
|
478 $error[] = implode('<br />', $message_parser->warn_msg); |
|
479 } |
|
480 |
|
481 if (!check_form_key('ucp_sig')) |
|
482 { |
|
483 $error[] = 'FORM_INVALID'; |
|
484 } |
|
485 |
|
486 if (!sizeof($error) && $submit) |
|
487 { |
|
488 $user->optionset('sig_bbcode', $enable_bbcode); |
|
489 $user->optionset('sig_smilies', $enable_smilies); |
|
490 $user->optionset('sig_links', $enable_urls); |
|
491 |
|
492 $sql_ary = array( |
|
493 'user_sig' => (string) $message_parser->message, |
|
494 'user_options' => $user->data['user_options'], |
|
495 'user_sig_bbcode_uid' => (string) $message_parser->bbcode_uid, |
|
496 'user_sig_bbcode_bitfield' => $message_parser->bbcode_bitfield |
|
497 ); |
|
498 |
|
499 $sql = 'UPDATE ' . USERS_TABLE . ' |
|
500 SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' |
|
501 WHERE user_id = ' . $user->data['user_id']; |
|
502 $db->sql_query($sql); |
|
503 |
|
504 $message = $user->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>'); |
|
505 trigger_error($message); |
|
506 } |
|
507 } |
|
508 |
|
509 // Replace "error" strings with their real, localised form |
|
510 $error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error); |
|
511 } |
|
512 |
|
513 $signature_preview = ''; |
|
514 if ($preview) |
|
515 { |
|
516 // Now parse it for displaying |
|
517 $signature_preview = $message_parser->format_display($enable_bbcode, $enable_urls, $enable_smilies, false); |
|
518 unset($message_parser); |
|
519 } |
|
520 |
|
521 decode_message($signature, $user->data['user_sig_bbcode_uid']); |
|
522 |
|
523 $template->assign_vars(array( |
|
524 'ERROR' => (sizeof($error)) ? implode('<br />', $error) : '', |
|
525 'SIGNATURE' => $signature, |
|
526 'SIGNATURE_PREVIEW' => $signature_preview, |
|
527 |
|
528 'S_BBCODE_CHECKED' => (!$enable_bbcode) ? ' checked="checked"' : '', |
|
529 'S_SMILIES_CHECKED' => (!$enable_smilies) ? ' checked="checked"' : '', |
|
530 'S_MAGIC_URL_CHECKED' => (!$enable_urls) ? ' checked="checked"' : '', |
|
531 |
|
532 '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>'), |
|
533 'SMILIES_STATUS' => ($config['allow_sig_smilies']) ? $user->lang['SMILIES_ARE_ON'] : $user->lang['SMILIES_ARE_OFF'], |
|
534 'IMG_STATUS' => ($config['allow_sig_img']) ? $user->lang['IMAGES_ARE_ON'] : $user->lang['IMAGES_ARE_OFF'], |
|
535 'FLASH_STATUS' => ($config['allow_sig_flash']) ? $user->lang['FLASH_IS_ON'] : $user->lang['FLASH_IS_OFF'], |
|
536 'URL_STATUS' => ($config['allow_sig_links']) ? $user->lang['URL_IS_ON'] : $user->lang['URL_IS_OFF'], |
|
537 'MAX_FONT_SIZE' => (int) $config['max_sig_font_size'], |
|
538 |
|
539 'L_SIGNATURE_EXPLAIN' => sprintf($user->lang['SIGNATURE_EXPLAIN'], $config['max_sig_chars']), |
|
540 |
|
541 'S_BBCODE_ALLOWED' => $config['allow_sig_bbcode'], |
|
542 'S_SMILIES_ALLOWED' => $config['allow_sig_smilies'], |
|
543 'S_BBCODE_IMG' => ($config['allow_sig_img']) ? true : false, |
|
544 'S_BBCODE_FLASH' => ($config['allow_sig_flash']) ? true : false, |
|
545 'S_LINKS_ALLOWED' => ($config['allow_sig_links']) ? true : false) |
|
546 ); |
|
547 |
|
548 // Build custom bbcodes array |
|
549 display_custom_bbcodes(); |
|
550 |
|
551 break; |
|
552 |
|
553 case 'avatar': |
|
554 |
|
555 include($phpbb_root_path . 'includes/functions_display.' . $phpEx); |
|
556 |
|
557 $display_gallery = request_var('display_gallery', '0'); |
|
558 $avatar_select = basename(request_var('avatar_select', '')); |
|
559 $category = basename(request_var('category', '')); |
|
560 |
|
561 $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; |
|
562 |
|
563 add_form_key('ucp_avatar'); |
|
564 |
|
565 if ($submit) |
|
566 { |
|
567 if (check_form_key('ucp_avatar')) |
|
568 { |
|
569 if (avatar_process_user($error, false, $can_upload)) |
|
570 { |
|
571 meta_refresh(3, $this->u_action); |
|
572 $message = $user->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>'); |
|
573 trigger_error($message); |
|
574 } |
|
575 } |
|
576 else |
|
577 { |
|
578 $error[] = 'FORM_INVALID'; |
|
579 } |
|
580 // Replace "error" strings with their real, localised form |
|
581 $error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error); |
|
582 } |
|
583 |
|
584 if (!$config['allow_avatar'] && $user->data['user_avatar_type']) |
|
585 { |
|
586 $error[] = $user->lang['AVATAR_NOT_ALLOWED']; |
|
587 } |
|
588 else if ((($user->data['user_avatar_type'] == AVATAR_UPLOAD) && !$config['allow_avatar_upload']) || |
|
589 (($user->data['user_avatar_type'] == AVATAR_REMOTE) && !$config['allow_avatar_remote']) || |
|
590 (($user->data['user_avatar_type'] == AVATAR_GALLERY) && !$config['allow_avatar_local'])) |
|
591 { |
|
592 $error[] = $user->lang['AVATAR_TYPE_NOT_ALLOWED']; |
|
593 } |
|
594 |
|
595 $template->assign_vars(array( |
|
596 'ERROR' => (sizeof($error)) ? implode('<br />', $error) : '', |
|
597 '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), |
|
598 'AVATAR_SIZE' => $config['avatar_filesize'], |
|
599 |
|
600 'U_GALLERY' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=profile&mode=avatar&display_gallery=1'), |
|
601 |
|
602 'S_FORM_ENCTYPE' => ($can_upload && ($config['allow_avatar_upload'] || $config['allow_avatar_remote_upload'])) ? ' enctype="multipart/form-data"' : '', |
|
603 |
|
604 'L_AVATAR_EXPLAIN' => sprintf($user->lang['AVATAR_EXPLAIN'], $config['avatar_max_width'], $config['avatar_max_height'], $config['avatar_filesize'] / 1024), |
|
605 )); |
|
606 |
|
607 if ($config['allow_avatar'] && $display_gallery && $auth->acl_get('u_chgavatar') && $config['allow_avatar_local']) |
|
608 { |
|
609 avatar_gallery($category, $avatar_select, 4); |
|
610 } |
|
611 else if ($config['allow_avatar']) |
|
612 { |
|
613 $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; |
|
614 |
|
615 $template->assign_vars(array( |
|
616 'AVATAR_WIDTH' => request_var('width', $user->data['user_avatar_width']), |
|
617 'AVATAR_HEIGHT' => request_var('height', $user->data['user_avatar_height']), |
|
618 |
|
619 'S_AVATARS_ENABLED' => $avatars_enabled, |
|
620 'S_UPLOAD_AVATAR_FILE' => ($can_upload && $config['allow_avatar_upload']) ? true : false, |
|
621 'S_UPLOAD_AVATAR_URL' => ($can_upload && $config['allow_avatar_remote_upload']) ? true : false, |
|
622 'S_LINK_AVATAR' => ($auth->acl_get('u_chgavatar') && $config['allow_avatar_remote']) ? true : false, |
|
623 'S_DISPLAY_GALLERY' => ($auth->acl_get('u_chgavatar') && $config['allow_avatar_local']) ? true : false) |
|
624 ); |
|
625 } |
|
626 |
|
627 break; |
|
628 } |
|
629 |
|
630 $template->assign_vars(array( |
|
631 'L_TITLE' => $user->lang['UCP_PROFILE_' . strtoupper($mode)], |
|
632 |
|
633 'S_HIDDEN_FIELDS' => $s_hidden_fields, |
|
634 'S_UCP_ACTION' => $this->u_action) |
|
635 ); |
|
636 |
|
637 // Set desired template |
|
638 $this->tpl_name = 'ucp_profile_' . $mode; |
|
639 $this->page_title = 'UCP_PROFILE_' . strtoupper($mode); |
|
640 } |
|
641 } |
|
642 |
|
643 ?> |