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_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')) ? 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(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 | $data['user_birthday'] = sprintf('%2d-%2d-%4d', $data['bday_day'], $data['bday_month'], $data['bday_year']);
|
---|
299 | }
|
---|
300 |
|
---|
301 | add_form_key('ucp_profile_info');
|
---|
302 |
|
---|
303 | if ($submit)
|
---|
304 | {
|
---|
305 | $validate_array = array(
|
---|
306 | 'icq' => array(
|
---|
307 | array('string', true, 3, 15),
|
---|
308 | array('match', true, '#^[0-9]+$#i')),
|
---|
309 | 'aim' => array('string', true, 3, 255),
|
---|
310 | 'msn' => array('string', true, 5, 255),
|
---|
311 | 'jabber' => array(
|
---|
312 | array('string', true, 5, 255),
|
---|
313 | array('jabber')),
|
---|
314 | 'yim' => array('string', true, 5, 255),
|
---|
315 | 'website' => array(
|
---|
316 | array('string', true, 12, 255),
|
---|
317 | array('match', true, '#^http[s]?://(.*?\.)*?[a-z0-9\-]+\.[a-z]{2,4}#i')),
|
---|
318 | 'location' => array('string', true, 2, 100),
|
---|
319 | 'occupation' => array('string', true, 2, 500),
|
---|
320 | 'interests' => array('string', true, 2, 500),
|
---|
321 | );
|
---|
322 |
|
---|
323 | if ($config['allow_birthdays'])
|
---|
324 | {
|
---|
325 | $validate_array = array_merge($validate_array, array(
|
---|
326 | 'bday_day' => array('num', true, 1, 31),
|
---|
327 | 'bday_month' => array('num', true, 1, 12),
|
---|
328 | 'bday_year' => array('num', true, 1901, gmdate('Y', time()) + 50),
|
---|
329 | 'user_birthday' => array('date', true),
|
---|
330 | ));
|
---|
331 | }
|
---|
332 |
|
---|
333 | $error = validate_data($data, $validate_array);
|
---|
334 |
|
---|
335 | // validate custom profile fields
|
---|
336 | $cp->submit_cp_field('profile', $user->get_iso_lang_id(), $cp_data, $cp_error);
|
---|
337 |
|
---|
338 | if (sizeof($cp_error))
|
---|
339 | {
|
---|
340 | $error = array_merge($error, $cp_error);
|
---|
341 | }
|
---|
342 |
|
---|
343 | if (!check_form_key('ucp_profile_info'))
|
---|
344 | {
|
---|
345 | $error[] = 'FORM_INVALID';
|
---|
346 | }
|
---|
347 |
|
---|
348 | if (!sizeof($error))
|
---|
349 | {
|
---|
350 | $data['notify'] = $user->data['user_notify_type'];
|
---|
351 |
|
---|
352 | if ($data['notify'] == NOTIFY_IM && (!$config['jab_enable'] || !$data['jabber'] || !@extension_loaded('xml')))
|
---|
353 | {
|
---|
354 | // User has not filled in a jabber address (Or one of the modules is disabled or jabber is disabled)
|
---|
355 | // Disable notify by Jabber now for this user.
|
---|
356 | $data['notify'] = NOTIFY_EMAIL;
|
---|
357 | }
|
---|
358 |
|
---|
359 | $sql_ary = array(
|
---|
360 | 'user_icq' => $data['icq'],
|
---|
361 | 'user_aim' => $data['aim'],
|
---|
362 | 'user_msnm' => $data['msn'],
|
---|
363 | 'user_yim' => $data['yim'],
|
---|
364 | 'user_jabber' => $data['jabber'],
|
---|
365 | 'user_website' => $data['website'],
|
---|
366 | 'user_from' => $data['location'],
|
---|
367 | 'user_occ' => $data['occupation'],
|
---|
368 | 'user_interests'=> $data['interests'],
|
---|
369 | 'user_notify_type' => $data['notify'],
|
---|
370 | );
|
---|
371 |
|
---|
372 | if ($config['allow_birthdays'])
|
---|
373 | {
|
---|
374 | $sql_ary['user_birthday'] = $data['user_birthday'];
|
---|
375 | }
|
---|
376 |
|
---|
377 | $sql = 'UPDATE ' . USERS_TABLE . '
|
---|
378 | SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
|
---|
379 | WHERE user_id = ' . $user->data['user_id'];
|
---|
380 | $db->sql_query($sql);
|
---|
381 |
|
---|
382 | // Update Custom Fields
|
---|
383 | $cp->update_profile_field_data($user->data['user_id'], $cp_data);
|
---|
384 |
|
---|
385 | meta_refresh(3, $this->u_action);
|
---|
386 | $message = $user->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
|
---|
387 | trigger_error($message);
|
---|
388 | }
|
---|
389 |
|
---|
390 | // Replace "error" strings with their real, localised form
|
---|
391 | $error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error);
|
---|
392 | }
|
---|
393 |
|
---|
394 | if ($config['allow_birthdays'])
|
---|
395 | {
|
---|
396 | $s_birthday_day_options = '<option value="0"' . ((!$data['bday_day']) ? ' selected="selected"' : '') . '>--</option>';
|
---|
397 | for ($i = 1; $i < 32; $i++)
|
---|
398 | {
|
---|
399 | $selected = ($i == $data['bday_day']) ? ' selected="selected"' : '';
|
---|
400 | $s_birthday_day_options .= "<option value=\"$i\"$selected>$i</option>";
|
---|
401 | }
|
---|
402 |
|
---|
403 | $s_birthday_month_options = '<option value="0"' . ((!$data['bday_month']) ? ' selected="selected"' : '') . '>--</option>';
|
---|
404 | for ($i = 1; $i < 13; $i++)
|
---|
405 | {
|
---|
406 | $selected = ($i == $data['bday_month']) ? ' selected="selected"' : '';
|
---|
407 | $s_birthday_month_options .= "<option value=\"$i\"$selected>$i</option>";
|
---|
408 | }
|
---|
409 | $s_birthday_year_options = '';
|
---|
410 |
|
---|
411 | $now = getdate();
|
---|
412 | $s_birthday_year_options = '<option value="0"' . ((!$data['bday_year']) ? ' selected="selected"' : '') . '>--</option>';
|
---|
413 | for ($i = $now['year'] - 100; $i <= $now['year']; $i++)
|
---|
414 | {
|
---|
415 | $selected = ($i == $data['bday_year']) ? ' selected="selected"' : '';
|
---|
416 | $s_birthday_year_options .= "<option value=\"$i\"$selected>$i</option>";
|
---|
417 | }
|
---|
418 | unset($now);
|
---|
419 |
|
---|
420 | $template->assign_vars(array(
|
---|
421 | 'S_BIRTHDAY_DAY_OPTIONS' => $s_birthday_day_options,
|
---|
422 | 'S_BIRTHDAY_MONTH_OPTIONS' => $s_birthday_month_options,
|
---|
423 | 'S_BIRTHDAY_YEAR_OPTIONS' => $s_birthday_year_options,
|
---|
424 | 'S_BIRTHDAYS_ENABLED' => true,
|
---|
425 | ));
|
---|
426 | }
|
---|
427 |
|
---|
428 | $template->assign_vars(array(
|
---|
429 | 'ERROR' => (sizeof($error)) ? implode('<br />', $error) : '',
|
---|
430 |
|
---|
431 | 'ICQ' => $data['icq'],
|
---|
432 | 'YIM' => $data['yim'],
|
---|
433 | 'AIM' => $data['aim'],
|
---|
434 | 'MSN' => $data['msn'],
|
---|
435 | 'JABBER' => $data['jabber'],
|
---|
436 | 'WEBSITE' => $data['website'],
|
---|
437 | 'LOCATION' => $data['location'],
|
---|
438 | 'OCCUPATION'=> $data['occupation'],
|
---|
439 | 'INTERESTS' => $data['interests'],
|
---|
440 | ));
|
---|
441 |
|
---|
442 | // Get additional profile fields and assign them to the template block var 'profile_fields'
|
---|
443 | $user->get_profile_fields($user->data['user_id']);
|
---|
444 |
|
---|
445 | $cp->generate_profile_fields('profile', $user->get_iso_lang_id());
|
---|
446 |
|
---|
447 | break;
|
---|
448 |
|
---|
449 | case 'signature':
|
---|
450 |
|
---|
451 | if (!$auth->acl_get('u_sig'))
|
---|
452 | {
|
---|
453 | trigger_error('NO_AUTH_SIGNATURE');
|
---|
454 | }
|
---|
455 |
|
---|
456 | include($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
|
---|
457 | include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
|
---|
458 |
|
---|
459 | $enable_bbcode = ($config['allow_sig_bbcode']) ? (bool) $user->optionget('sig_bbcode') : false;
|
---|
460 | $enable_smilies = ($config['allow_sig_smilies']) ? (bool) $user->optionget('sig_smilies') : false;
|
---|
461 | $enable_urls = ($config['allow_sig_links']) ? (bool) $user->optionget('sig_links') : false;
|
---|
462 |
|
---|
463 | $signature = utf8_normalize_nfc(request_var('signature', (string) $user->data['user_sig'], true));
|
---|
464 |
|
---|
465 | add_form_key('ucp_sig');
|
---|
466 |
|
---|
467 | if ($submit || $preview)
|
---|
468 | {
|
---|
469 | include($phpbb_root_path . 'includes/message_parser.' . $phpEx);
|
---|
470 |
|
---|
471 | $enable_bbcode = ($config['allow_sig_bbcode']) ? ((request_var('disable_bbcode', false)) ? false : true) : false;
|
---|
472 | $enable_smilies = ($config['allow_sig_smilies']) ? ((request_var('disable_smilies', false)) ? false : true) : false;
|
---|
473 | $enable_urls = ($config['allow_sig_links']) ? ((request_var('disable_magic_url', false)) ? false : true) : false;
|
---|
474 |
|
---|
475 | if (!sizeof($error))
|
---|
476 | {
|
---|
477 | $message_parser = new parse_message($signature);
|
---|
478 |
|
---|
479 | // Allowing Quote BBCode
|
---|
480 | $message_parser->parse($enable_bbcode, $enable_urls, $enable_smilies, $config['allow_sig_img'], $config['allow_sig_flash'], true, $config['allow_sig_links'], true, 'sig');
|
---|
481 |
|
---|
482 | if (sizeof($message_parser->warn_msg))
|
---|
483 | {
|
---|
484 | $error[] = implode('<br />', $message_parser->warn_msg);
|
---|
485 | }
|
---|
486 |
|
---|
487 | if (!check_form_key('ucp_sig'))
|
---|
488 | {
|
---|
489 | $error[] = 'FORM_INVALID';
|
---|
490 | }
|
---|
491 |
|
---|
492 | if (!sizeof($error) && $submit)
|
---|
493 | {
|
---|
494 | $user->optionset('sig_bbcode', $enable_bbcode);
|
---|
495 | $user->optionset('sig_smilies', $enable_smilies);
|
---|
496 | $user->optionset('sig_links', $enable_urls);
|
---|
497 |
|
---|
498 | $sql_ary = array(
|
---|
499 | 'user_sig' => (string) $message_parser->message,
|
---|
500 | 'user_options' => $user->data['user_options'],
|
---|
501 | 'user_sig_bbcode_uid' => (string) $message_parser->bbcode_uid,
|
---|
502 | 'user_sig_bbcode_bitfield' => $message_parser->bbcode_bitfield
|
---|
503 | );
|
---|
504 |
|
---|
505 | $sql = 'UPDATE ' . USERS_TABLE . '
|
---|
506 | SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
|
---|
507 | WHERE user_id = ' . $user->data['user_id'];
|
---|
508 | $db->sql_query($sql);
|
---|
509 |
|
---|
510 | $message = $user->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
|
---|
511 | trigger_error($message);
|
---|
512 | }
|
---|
513 | }
|
---|
514 |
|
---|
515 | // Replace "error" strings with their real, localised form
|
---|
516 | $error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error);
|
---|
517 | }
|
---|
518 |
|
---|
519 | $signature_preview = '';
|
---|
520 | if ($preview)
|
---|
521 | {
|
---|
522 | // Now parse it for displaying
|
---|
523 | $signature_preview = $message_parser->format_display($enable_bbcode, $enable_urls, $enable_smilies, false);
|
---|
524 | unset($message_parser);
|
---|
525 | }
|
---|
526 |
|
---|
527 | decode_message($signature, $user->data['user_sig_bbcode_uid']);
|
---|
528 |
|
---|
529 | $template->assign_vars(array(
|
---|
530 | 'ERROR' => (sizeof($error)) ? implode('<br />', $error) : '',
|
---|
531 | 'SIGNATURE' => $signature,
|
---|
532 | 'SIGNATURE_PREVIEW' => $signature_preview,
|
---|
533 |
|
---|
534 | 'S_BBCODE_CHECKED' => (!$enable_bbcode) ? ' checked="checked"' : '',
|
---|
535 | 'S_SMILIES_CHECKED' => (!$enable_smilies) ? ' checked="checked"' : '',
|
---|
536 | 'S_MAGIC_URL_CHECKED' => (!$enable_urls) ? ' checked="checked"' : '',
|
---|
537 |
|
---|
538 | '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>'),
|
---|
539 | 'SMILIES_STATUS' => ($config['allow_sig_smilies']) ? $user->lang['SMILIES_ARE_ON'] : $user->lang['SMILIES_ARE_OFF'],
|
---|
540 | 'IMG_STATUS' => ($config['allow_sig_img']) ? $user->lang['IMAGES_ARE_ON'] : $user->lang['IMAGES_ARE_OFF'],
|
---|
541 | 'FLASH_STATUS' => ($config['allow_sig_flash']) ? $user->lang['FLASH_IS_ON'] : $user->lang['FLASH_IS_OFF'],
|
---|
542 | 'URL_STATUS' => ($config['allow_sig_links']) ? $user->lang['URL_IS_ON'] : $user->lang['URL_IS_OFF'],
|
---|
543 | 'MAX_FONT_SIZE' => (int) $config['max_sig_font_size'],
|
---|
544 |
|
---|
545 | 'L_SIGNATURE_EXPLAIN' => sprintf($user->lang['SIGNATURE_EXPLAIN'], $config['max_sig_chars']),
|
---|
546 |
|
---|
547 | 'S_BBCODE_ALLOWED' => $config['allow_sig_bbcode'],
|
---|
548 | 'S_SMILIES_ALLOWED' => $config['allow_sig_smilies'],
|
---|
549 | 'S_BBCODE_IMG' => ($config['allow_sig_img']) ? true : false,
|
---|
550 | 'S_BBCODE_FLASH' => ($config['allow_sig_flash']) ? true : false,
|
---|
551 | 'S_LINKS_ALLOWED' => ($config['allow_sig_links']) ? true : false)
|
---|
552 | );
|
---|
553 |
|
---|
554 | // Build custom bbcodes array
|
---|
555 | display_custom_bbcodes();
|
---|
556 |
|
---|
557 | break;
|
---|
558 |
|
---|
559 | case 'avatar':
|
---|
560 |
|
---|
561 | include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
|
---|
562 |
|
---|
563 | $display_gallery = request_var('display_gallery', '0');
|
---|
564 | $avatar_select = basename(request_var('avatar_select', ''));
|
---|
565 | $category = basename(request_var('category', ''));
|
---|
566 |
|
---|
567 | $can_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;
|
---|
568 |
|
---|
569 | add_form_key('ucp_avatar');
|
---|
570 |
|
---|
571 | if ($submit)
|
---|
572 | {
|
---|
573 | if (check_form_key('ucp_avatar'))
|
---|
574 | {
|
---|
575 | if (avatar_process_user($error))
|
---|
576 | {
|
---|
577 | meta_refresh(3, $this->u_action);
|
---|
578 | $message = $user->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
|
---|
579 | trigger_error($message);
|
---|
580 | }
|
---|
581 | }
|
---|
582 | else
|
---|
583 | {
|
---|
584 | $error[] = 'FORM_INVALID';
|
---|
585 | }
|
---|
586 | // Replace "error" strings with their real, localised form
|
---|
587 | $error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error);
|
---|
588 | }
|
---|
589 |
|
---|
590 | if (!$config['allow_avatar'] && $user->data['user_avatar_type'])
|
---|
591 | {
|
---|
592 | $error[] = $user->lang['AVATAR_NOT_ALLOWED'];
|
---|
593 | }
|
---|
594 | else if ((($user->data['user_avatar_type'] == AVATAR_UPLOAD) && !$config['allow_avatar_upload']) ||
|
---|
595 | (($user->data['user_avatar_type'] == AVATAR_REMOTE) && !$config['allow_avatar_remote']) ||
|
---|
596 | (($user->data['user_avatar_type'] == AVATAR_GALLERY) && !$config['allow_avatar_local']))
|
---|
597 | {
|
---|
598 | $error[] = $user->lang['AVATAR_TYPE_NOT_ALLOWED'];
|
---|
599 | }
|
---|
600 |
|
---|
601 | $template->assign_vars(array(
|
---|
602 | 'ERROR' => (sizeof($error)) ? implode('<br />', $error) : '',
|
---|
603 | '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),
|
---|
604 | 'AVATAR_SIZE' => $config['avatar_filesize'],
|
---|
605 |
|
---|
606 | 'U_GALLERY' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=profile&mode=avatar&display_gallery=1'),
|
---|
607 |
|
---|
608 | 'S_FORM_ENCTYPE' => ($can_upload && ($config['allow_avatar_upload'] || $config['allow_avatar_remote_upload'])) ? ' enctype="multipart/form-data"' : '',
|
---|
609 |
|
---|
610 | 'L_AVATAR_EXPLAIN' => sprintf($user->lang['AVATAR_EXPLAIN'], $config['avatar_max_width'], $config['avatar_max_height'], $config['avatar_filesize'] / 1024),
|
---|
611 | ));
|
---|
612 |
|
---|
613 | if ($config['allow_avatar'] && $display_gallery && $auth->acl_get('u_chgavatar') && $config['allow_avatar_local'])
|
---|
614 | {
|
---|
615 | avatar_gallery($category, $avatar_select, 4);
|
---|
616 | }
|
---|
617 | else if ($config['allow_avatar'])
|
---|
618 | {
|
---|
619 | $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;
|
---|
620 |
|
---|
621 | $template->assign_vars(array(
|
---|
622 | 'AVATAR_WIDTH' => request_var('width', $user->data['user_avatar_width']),
|
---|
623 | 'AVATAR_HEIGHT' => request_var('height', $user->data['user_avatar_height']),
|
---|
624 |
|
---|
625 | 'S_AVATARS_ENABLED' => $avatars_enabled,
|
---|
626 | 'S_UPLOAD_AVATAR_FILE' => ($can_upload && $config['allow_avatar_upload']) ? true : false,
|
---|
627 | 'S_UPLOAD_AVATAR_URL' => ($can_upload && $config['allow_avatar_remote_upload']) ? true : false,
|
---|
628 | 'S_LINK_AVATAR' => ($auth->acl_get('u_chgavatar') && $config['allow_avatar_remote']) ? true : false,
|
---|
629 | 'S_DISPLAY_GALLERY' => ($auth->acl_get('u_chgavatar') && $config['allow_avatar_local']) ? true : false)
|
---|
630 | );
|
---|
631 | }
|
---|
632 |
|
---|
633 | break;
|
---|
634 | }
|
---|
635 |
|
---|
636 | $template->assign_vars(array(
|
---|
637 | 'L_TITLE' => $user->lang['UCP_PROFILE_' . strtoupper($mode)],
|
---|
638 |
|
---|
639 | 'S_HIDDEN_FIELDS' => $s_hidden_fields,
|
---|
640 | 'S_UCP_ACTION' => $this->u_action)
|
---|
641 | );
|
---|
642 |
|
---|
643 | // Set desired template
|
---|
644 | $this->tpl_name = 'ucp_profile_' . $mode;
|
---|
645 | $this->page_title = 'UCP_PROFILE_' . strtoupper($mode);
|
---|
646 | }
|
---|
647 | }
|
---|
648 |
|
---|
649 | ?>
|
---|