]> git.vanrenterghem.biz Git - www.vanrenterghem.biz.git/blob - phpBB2_old/includes/usercp_register.php
Baseline
[www.vanrenterghem.biz.git] / phpBB2_old / includes / usercp_register.php
1 <?php
2 /***************************************************************************
3  *                            usercp_register.php
4  *                            -------------------
5  *   begin                : Saturday, Feb 13, 2001
6  *   copyright            : (C) 2001 The phpBB Group
7  *   email                : support@phpbb.com
8  *
9  *   $Id: usercp_register.php,v 1.20.2.58 2004/11/18 17:49:45 acydburn Exp $
10  *
11  *
12  ***************************************************************************/
14 /***************************************************************************
15  *
16  *   This program is free software; you can redistribute it and/or modify
17  *   it under the terms of the GNU General Public License as published by
18  *   the Free Software Foundation; either version 2 of the License, or
19  *   (at your option) any later version.
20  *
21  *
22  ***************************************************************************/
24 /*
26         This code has been modified from its original form by psoTFX @ phpbb.com
27         Changes introduce the back-ported phpBB 2.2 visual confirmation code. 
29         NOTE: Anyone using the modified code contained within this script MUST include
30         a relevant message such as this in usercp_register.php ... failure to do so 
31         will affect a breach of Section 2a of the GPL and our copyright
33         png visual confirmation system : (c) phpBB Group, 2003 : All Rights Reserved
35 */
37 if ( !defined('IN_PHPBB') )
38 {
39         die("Hacking attempt");
40         exit;
41 }
43 $unhtml_specialchars_match = array('#&gt;#', '#&lt;#', '#&quot;#', '#&amp;#');
44 $unhtml_specialchars_replace = array('>', '<', '"', '&');
46 // ---------------------------------------
47 // Load agreement template since user has not yet
48 // agreed to registration conditions/coppa
49 //
50 function show_coppa()
51 {
52         global $userdata, $template, $lang, $phpbb_root_path, $phpEx;
54         $template->set_filenames(array(
55                 'body' => 'agreement.tpl')
56         );
58         $template->assign_vars(array(
59                 'REGISTRATION' => $lang['Registration'],
60                 'AGREEMENT' => $lang['Reg_agreement'],
61                 "AGREE_OVER_13" => $lang['Agree_over_13'],
62                 "AGREE_UNDER_13" => $lang['Agree_under_13'],
63                 'DO_NOT_AGREE' => $lang['Agree_not'],
65                 "U_AGREE_OVER13" => append_sid("profile.$phpEx?mode=register&amp;agreed=true"),
66                 "U_AGREE_UNDER13" => append_sid("profile.$phpEx?mode=register&amp;agreed=true&amp;coppa=true"))
67         );
69         $template->pparse('body');
71 }
72 //
73 // ---------------------------------------
75 $error = FALSE;
76 $page_title = ( $mode == 'editprofile' ) ? $lang['Edit_profile'] : $lang['Register'];
78 if ( $mode == 'register' && !isset($HTTP_POST_VARS['agreed']) && !isset($HTTP_GET_VARS['agreed']) )
79 {
80         include($phpbb_root_path . 'includes/page_header.'.$phpEx);
82         show_coppa();
84         include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
85 }
87 $coppa = ( empty($HTTP_POST_VARS['coppa']) && empty($HTTP_GET_VARS['coppa']) ) ? 0 : TRUE;
89 //
90 // Check and initialize some variables if needed
91 //
92 if (
93         isset($HTTP_POST_VARS['submit']) ||
94         isset($HTTP_POST_VARS['avatargallery']) ||
95         isset($HTTP_POST_VARS['submitavatar']) ||
96         isset($HTTP_POST_VARS['cancelavatar']) ||
97         $mode == 'register' )
98 {
99         include($phpbb_root_path . 'includes/functions_validate.'.$phpEx);
100         include($phpbb_root_path . 'includes/bbcode.'.$phpEx);
101         include($phpbb_root_path . 'includes/functions_post.'.$phpEx);
103         if ( $mode == 'editprofile' )
104         {
105                 $user_id = intval($HTTP_POST_VARS['user_id']);
106                 $current_email = trim(htmlspecialchars($HTTP_POST_VARS['current_email']));
107         }
109         $strip_var_list = array('username' => 'username', 'email' => 'email', 'icq' => 'icq', 'aim' => 'aim', 'msn' => 'msn', 'yim' => 'yim', 'website' => 'website', 'location' => 'location', 'occupation' => 'occupation', 'interests' => 'interests');
110         $strip_var_list['confirm_code'] = 'confirm_code';
112         // Strip all tags from data ... may p**s some people off, bah, strip_tags is
113         // doing the job but can still break HTML output ... have no choice, have
114         // to use htmlspecialchars ... be prepared to be moaned at.
115         while( list($var, $param) = @each($strip_var_list) )
116         {
117                 if ( !empty($HTTP_POST_VARS[$param]) )
118                 {
119                         $$var = trim(htmlspecialchars($HTTP_POST_VARS[$param]));
120                 }
121         }
123         $trim_var_list = array('cur_password' => 'cur_password', 'new_password' => 'new_password', 'password_confirm' => 'password_confirm', 'signature' => 'signature');
125         while( list($var, $param) = @each($trim_var_list) )
126         {
127                 if ( !empty($HTTP_POST_VARS[$param]) )
128                 {
129                         $$var = trim($HTTP_POST_VARS[$param]);
130                 }
131         }
133         $signature = str_replace('<br />', "\n", $signature);
135         // Run some validation on the optional fields. These are pass-by-ref, so they'll be changed to
136         // empty strings if they fail.
137         validate_optional_fields($icq, $aim, $msn, $yim, $website, $location, $occupation, $interests, $signature);
139         $viewemail = ( isset($HTTP_POST_VARS['viewemail']) ) ? ( ($HTTP_POST_VARS['viewemail']) ? TRUE : 0 ) : 0;
140         $allowviewonline = ( isset($HTTP_POST_VARS['hideonline']) ) ? ( ($HTTP_POST_VARS['hideonline']) ? 0 : TRUE ) : TRUE;
141         $notifyreply = ( isset($HTTP_POST_VARS['notifyreply']) ) ? ( ($HTTP_POST_VARS['notifyreply']) ? TRUE : 0 ) : 0;
142         $notifypm = ( isset($HTTP_POST_VARS['notifypm']) ) ? ( ($HTTP_POST_VARS['notifypm']) ? TRUE : 0 ) : TRUE;
143         $popup_pm = ( isset($HTTP_POST_VARS['popup_pm']) ) ? ( ($HTTP_POST_VARS['popup_pm']) ? TRUE : 0 ) : TRUE;
145         if ( $mode == 'register' )
146         {
147                 $attachsig = ( isset($HTTP_POST_VARS['attachsig']) ) ? ( ($HTTP_POST_VARS['attachsig']) ? TRUE : 0 ) : $board_config['allow_sig'];
149                 $allowhtml = ( isset($HTTP_POST_VARS['allowhtml']) ) ? ( ($HTTP_POST_VARS['allowhtml']) ? TRUE : 0 ) : $board_config['allow_html'];
150                 $allowbbcode = ( isset($HTTP_POST_VARS['allowbbcode']) ) ? ( ($HTTP_POST_VARS['allowbbcode']) ? TRUE : 0 ) : $board_config['allow_bbcode'];
151                 $allowsmilies = ( isset($HTTP_POST_VARS['allowsmilies']) ) ? ( ($HTTP_POST_VARS['allowsmilies']) ? TRUE : 0 ) : $board_config['allow_smilies'];
152         }
153         else
154         {
155                 $attachsig = ( isset($HTTP_POST_VARS['attachsig']) ) ? ( ($HTTP_POST_VARS['attachsig']) ? TRUE : 0 ) : 0;
157                 $allowhtml = ( isset($HTTP_POST_VARS['allowhtml']) ) ? ( ($HTTP_POST_VARS['allowhtml']) ? TRUE : 0 ) : $userdata['user_allowhtml'];
158                 $allowbbcode = ( isset($HTTP_POST_VARS['allowbbcode']) ) ? ( ($HTTP_POST_VARS['allowbbcode']) ? TRUE : 0 ) : $userdata['user_allowbbcode'];
159                 $allowsmilies = ( isset($HTTP_POST_VARS['allowsmilies']) ) ? ( ($HTTP_POST_VARS['allowsmilies']) ? TRUE : 0 ) : $userdata['user_allowsmile'];
160         }
162         $user_style = ( isset($HTTP_POST_VARS['style']) ) ? intval($HTTP_POST_VARS['style']) : $board_config['default_style'];
164         if ( !empty($HTTP_POST_VARS['language']) )
165         {
166                 if ( preg_match('/^[a-z_]+$/i', $HTTP_POST_VARS['language']) )
167                 {
168                         $user_lang = htmlspecialchars($HTTP_POST_VARS['language']);
169                 }
170                 else
171                 {
172                         $error = true;
173                         $error_msg = $lang['Fields_empty'];
174                 }
175         }
176         else
177         {
178                 $user_lang = $board_config['default_lang'];
179         }
181         $user_timezone = ( isset($HTTP_POST_VARS['timezone']) ) ? doubleval($HTTP_POST_VARS['timezone']) : $board_config['board_timezone'];
183         $sql = "SELECT config_value
184                 FROM " . CONFIG_TABLE . "
185                 WHERE config_name = 'default_dateformat'";
186         if ( !($result = $db->sql_query($sql)) )
187         {
188                 message_die(GENERAL_ERROR, 'Could not select default dateformat', '', __LINE__, __FILE__, $sql);
189         }
190         $row = $db->sql_fetchrow($result);
191         $board_config['default_dateformat'] = $row['config_value'];
192         $user_dateformat = ( !empty($HTTP_POST_VARS['dateformat']) ) ? trim(htmlspecialchars($HTTP_POST_VARS['dateformat'])) : $board_config['default_dateformat'];
194         $user_avatar_local = ( isset($HTTP_POST_VARS['avatarselect']) && !empty($HTTP_POST_VARS['submitavatar']) && $board_config['allow_avatar_local'] ) ? htmlspecialchars($HTTP_POST_VARS['avatarselect']) : ( ( isset($HTTP_POST_VARS['avatarlocal'])  ) ? htmlspecialchars($HTTP_POST_VARS['avatarlocal']) : '' );
196         $user_avatar_remoteurl = ( !empty($HTTP_POST_VARS['avatarremoteurl']) ) ? trim(htmlspecialchars($HTTP_POST_VARS['avatarremoteurl'])) : '';
197         $user_avatar_upload = ( !empty($HTTP_POST_VARS['avatarurl']) ) ? trim($HTTP_POST_VARS['avatarurl']) : ( ( $HTTP_POST_FILES['avatar']['tmp_name'] != "none") ? $HTTP_POST_FILES['avatar']['tmp_name'] : '' );
198         $user_avatar_name = ( !empty($HTTP_POST_FILES['avatar']['name']) ) ? $HTTP_POST_FILES['avatar']['name'] : '';
199         $user_avatar_size = ( !empty($HTTP_POST_FILES['avatar']['size']) ) ? $HTTP_POST_FILES['avatar']['size'] : 0;
200         $user_avatar_filetype = ( !empty($HTTP_POST_FILES['avatar']['type']) ) ? $HTTP_POST_FILES['avatar']['type'] : '';
202         $user_avatar = ( empty($user_avatar_loc) && $mode == 'editprofile' ) ? $userdata['user_avatar'] : '';
203         $user_avatar_type = ( empty($user_avatar_loc) && $mode == 'editprofile' ) ? $userdata['user_avatar_type'] : '';
205         if ( (isset($HTTP_POST_VARS['avatargallery']) || isset($HTTP_POST_VARS['submitavatar']) || isset($HTTP_POST_VARS['cancelavatar'])) && (!isset($HTTP_POST_VARS['submit'])) )
206         {
207                 $username = stripslashes($username);
208                 $email = stripslashes($email);
209                 $cur_password = htmlspecialchars(stripslashes($cur_password));
210                 $new_password = htmlspecialchars(stripslashes($new_password));
211                 $password_confirm = htmlspecialchars(stripslashes($password_confirm));
213                 $icq = stripslashes($icq);
214                 $aim = stripslashes($aim);
215                 $msn = stripslashes($msn);
216                 $yim = stripslashes($yim);
218                 $website = stripslashes($website);
219                 $location = stripslashes($location);
220                 $occupation = stripslashes($occupation);
221                 $interests = stripslashes($interests);
222                 $signature = stripslashes($signature);
224                 $user_lang = stripslashes($user_lang);
225                 $user_dateformat = stripslashes($user_dateformat);
227                 if ( !isset($HTTP_POST_VARS['cancelavatar']))
228                 {
229                         $user_avatar = $user_avatar_local;
230                         $user_avatar_type = USER_AVATAR_GALLERY;
231                 }
232         }
235 //
236 // Let's make sure the user isn't logged in while registering,
237 // and ensure that they were trying to register a second time
238 // (Prevents double registrations)
239 //
240 if ($mode == 'register' && ($userdata['session_logged_in'] || $username == $userdata['username']))
242         message_die(GENERAL_MESSAGE, $lang['Username_taken'], '', __LINE__, __FILE__);
245 //
246 // Did the user submit? In this case build a query to update the users profile in the DB
247 //
248 if ( isset($HTTP_POST_VARS['submit']) )
250         include($phpbb_root_path . 'includes/usercp_avatar.'.$phpEx);
252         $passwd_sql = '';
253         if ( $mode == 'editprofile' )
254         {
255                 if ( $user_id != $userdata['user_id'] )
256                 {
257                         $error = TRUE;
258                         $error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $lang['Wrong_Profile'];
259                 }
260         }
261         else if ( $mode == 'register' )
262         {
263                 if ( empty($username) || empty($new_password) || empty($password_confirm) || empty($email) )
264                 {
265                         $error = TRUE;
266                         $error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $lang['Fields_empty'];
267                 }
268         }
270         if ($board_config['enable_confirm'] && $mode == 'register')
271         {
272                 if (empty($HTTP_POST_VARS['confirm_id']))
273                 {
274                         $error = TRUE;
275                         $error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $lang['Confirm_code_wrong'];
276                 }
277                 else
278                 {
279                         $confirm_id = htmlspecialchars($HTTP_POST_VARS['confirm_id']);
280                         if (!preg_match('/^[A-Za-z0-9]+$/', $confirm_id))
281                         {
282                                 $confirm_id = '';
283                         }
284                         
285                         $sql = 'SELECT code 
286                                 FROM ' . CONFIRM_TABLE . " 
287                                 WHERE confirm_id = '$confirm_id' 
288                                         AND session_id = '" . $userdata['session_id'] . "'";
289                         if (!($result = $db->sql_query($sql)))
290                         {
291                                 message_die(GENERAL_ERROR, 'Could not obtain confirmation code', __LINE__, __FILE__, $sql);
292                         }
294                         if ($row = $db->sql_fetchrow($result))
295                         {
296                                 if ($row['code'] != $confirm_code)
297                                 {
298                                         $error = TRUE;
299                                         $error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $lang['Confirm_code_wrong'];
300                                 }
301                                 else
302                                 {
303                                         $sql = 'DELETE FROM ' . CONFIRM_TABLE . " 
304                                                 WHERE confirm_id = '$confirm_id' 
305                                                         AND session_id = '" . $userdata['session_id'] . "'";
306                                         if (!$db->sql_query($sql))
307                                         {
308                                                 message_die(GENERAL_ERROR, 'Could not delete confirmation code', __LINE__, __FILE__, $sql);
309                                         }
310                                 }
311                         }
312                         else
313                         {               
314                                 $error = TRUE;
315                                 $error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $lang['Confirm_code_wrong'];
316                         }
317                         $db->sql_freeresult($result);
318                 }
319         }
321         $passwd_sql = '';
322         if ( !empty($new_password) && !empty($password_confirm) )
323         {
324                 if ( $new_password != $password_confirm )
325                 {
326                         $error = TRUE;
327                         $error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $lang['Password_mismatch'];
328                 }
329                 else if ( strlen($new_password) > 32 )
330                 {
331                         $error = TRUE;
332                         $error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $lang['Password_long'];
333                 }
334                 else
335                 {
336                         if ( $mode == 'editprofile' )
337                         {
338                                 $sql = "SELECT user_password
339                                         FROM " . USERS_TABLE . "
340                                         WHERE user_id = $user_id";
341                                 if ( !($result = $db->sql_query($sql)) )
342                                 {
343                                         message_die(GENERAL_ERROR, 'Could not obtain user_password information', '', __LINE__, __FILE__, $sql);
344                                 }
346                                 $row = $db->sql_fetchrow($result);
348                                 if ( $row['user_password'] != md5($cur_password) )
349                                 {
350                                         $error = TRUE;
351                                         $error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $lang['Current_password_mismatch'];
352                                 }
353                         }
355                         if ( !$error )
356                         {
357                                 $new_password = md5($new_password);
358                                 $passwd_sql = "user_password = '$new_password', ";
359                         }
360                 }
361         }
362         else if ( ( empty($new_password) && !empty($password_confirm) ) || ( !empty($new_password) && empty($password_confirm) ) )
363         {
364                 $error = TRUE;
365                 $error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $lang['Password_mismatch'];
366         }
368         //
369         // Do a ban check on this email address
370         //
371         if ( $email != $userdata['user_email'] || $mode == 'register' )
372         {
373                 $result = validate_email($email);
374                 if ( $result['error'] )
375                 {
376                         $email = $userdata['user_email'];
378                         $error = TRUE;
379                         $error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $result['error_msg'];
380                 }
382                 if ( $mode == 'editprofile' )
383                 {
384                         $sql = "SELECT user_password
385                                 FROM " . USERS_TABLE . "
386                                 WHERE user_id = $user_id";
387                         if ( !($result = $db->sql_query($sql)) )
388                         {
389                                 message_die(GENERAL_ERROR, 'Could not obtain user_password information', '', __LINE__, __FILE__, $sql);
390                         }
392                         $row = $db->sql_fetchrow($result);
394                         if ( $row['user_password'] != md5($cur_password) )
395                         {
396                                 $email = $userdata['user_email'];
398                                 $error = TRUE;
399                                 $error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $lang['Current_password_mismatch'];
400                         }
401                 }
402         }
404         $username_sql = '';
405         if ( $board_config['allow_namechange'] || $mode == 'register' )
406         {
407                 if ( empty($username) )
408                 {
409                         // Error is already triggered, since one field is empty.
410                         $error = TRUE;
411                 }
412                 else if ( $username != $userdata['username'] || $mode == 'register' )
413                 {
414                         if (strtolower($username) != strtolower($userdata['username']))
415                         {
416                                 $result = validate_username($username);
417                                 if ( $result['error'] )
418                                 {
419                                         $error = TRUE;
420                                         $error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $result['error_msg'];
421                                 }
422                         }
424                         if (!$error)
425                         {
426                                 $username_sql = "username = '" . str_replace("\'", "''", $username) . "', ";
427                         }
428                 }
429         }
431         if ( $signature != '' )
432         {
433                 if ( strlen($signature) > $board_config['max_sig_chars'] )
434                 {
435                         $error = TRUE;
436                         $error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $lang['Signature_too_long'];
437                 }
439                 if ( $signature_bbcode_uid == '' )
440                 {
441                         $signature_bbcode_uid = ( $allowbbcode ) ? make_bbcode_uid() : '';
442                 }
443                 $signature = prepare_message($signature, $allowhtml, $allowbbcode, $allowsmilies, $signature_bbcode_uid);
444         }
446         if ( $website != '' )
447         {
448                 rawurlencode($website);
449         }
451         $avatar_sql = '';
453         if ( isset($HTTP_POST_VARS['avatardel']) && $mode == 'editprofile' )
454         {
455                 $avatar_sql = user_avatar_delete($userdata['user_avatar_type'], $userdata['user_avatar']);
456         }
458         if ( ( !empty($user_avatar_upload) || !empty($user_avatar_name) ) && $board_config['allow_avatar_upload'] )
459         {
460                 if ( !empty($user_avatar_upload) )
461                 {
462                         $avatar_mode = ( !empty($user_avatar_name) ) ? 'local' : 'remote';
463                         $avatar_sql = user_avatar_upload($mode, $avatar_mode, $userdata['user_avatar'], $userdata['user_avatar_type'], $error, $error_msg, $user_avatar_upload, $user_avatar_name, $user_avatar_size, $user_avatar_filetype);
464                 }
465                 else if ( !empty($user_avatar_name) )
466                 {
467                         $l_avatar_size = sprintf($lang['Avatar_filesize'], round($board_config['avatar_filesize'] / 1024));
469                         $error = true;
470                         $error_msg .= ( ( !empty($error_msg) ) ? '<br />' : '' ) . $l_avatar_size;
471                 }
472         }
473         else if ( $user_avatar_remoteurl != '' && $board_config['allow_avatar_remote'] )
474         {
475                 if ( @file_exists(@phpbb_realpath('./' . $board_config['avatar_path'] . '/' . $userdata['user_avatar'])) )
476                 {
477                         @unlink(@phpbb_realpath('./' . $board_config['avatar_path'] . '/' . $userdata['user_avatar']));
478                 }
479                 $avatar_sql = user_avatar_url($mode, $error, $error_msg, $user_avatar_remoteurl);
480         }
481         else if ( $user_avatar_local != '' && $board_config['allow_avatar_local'] )
482         {
483                 if ( @file_exists(@phpbb_realpath('./' . $board_config['avatar_path'] . '/' . $userdata['user_avatar'])) )
484                 {
485                         @unlink(@phpbb_realpath('./' . $board_config['avatar_path'] . '/' . $userdata['user_avatar']));
486                 }
487                 $avatar_sql = user_avatar_gallery($mode, $error, $error_msg, $user_avatar_local);
488         }
490         if ( !$error )
491         {
492                 if ( $avatar_sql == '' )
493                 {
494                         $avatar_sql = ( $mode == 'editprofile' ) ? '' : "'', " . USER_AVATAR_NONE;
495                 }
497                 if ( $mode == 'editprofile' )
498                 {
499                         if ( $email != $userdata['user_email'] && $board_config['require_activation'] != USER_ACTIVATION_NONE && $userdata['user_level'] != ADMIN )
500                         {
501                                 $user_active = 0;
503                                 $user_actkey = gen_rand_string(true);
504                                 $key_len = 54 - ( strlen($server_url) );
505                                 $key_len = ( $key_len > 6 ) ? $key_len : 6;
506                                 $user_actkey = substr($user_actkey, 0, $key_len);
508                                 if ( $userdata['session_logged_in'] )
509                                 {
510                                         session_end($userdata['session_id'], $userdata['user_id']);
511                                 }
512                         }
513                         else
514                         {
515                                 $user_active = 1;
516                                 $user_actkey = '';
517                         }
519                         $sql = "UPDATE " . USERS_TABLE . "
520                                 SET " . $username_sql . $passwd_sql . "user_email = '" . str_replace("\'", "''", $email) ."', user_icq = '" . str_replace("\'", "''", $icq) . "', user_website = '" . str_replace("\'", "''", $website) . "', user_occ = '" . str_replace("\'", "''", $occupation) . "', user_from = '" . str_replace("\'", "''", $location) . "', user_interests = '" . str_replace("\'", "''", $interests) . "', user_sig = '" . str_replace("\'", "''", $signature) . "', user_sig_bbcode_uid = '$signature_bbcode_uid', user_viewemail = $viewemail, user_aim = '" . str_replace("\'", "''", str_replace(' ', '+', $aim)) . "', user_yim = '" . str_replace("\'", "''", $yim) . "', user_msnm = '" . str_replace("\'", "''", $msn) . "', user_attachsig = $attachsig, user_allowsmile = $allowsmilies, user_allowhtml = $allowhtml, user_allowbbcode = $allowbbcode, user_allow_viewonline = $allowviewonline, user_notify = $notifyreply, user_notify_pm = $notifypm, user_popup_pm = $popup_pm, user_timezone = $user_timezone, user_dateformat = '" . str_replace("\'", "''", $user_dateformat) . "', user_lang = '" . str_replace("\'", "''", $user_lang) . "', user_style = $user_style, user_active = $user_active, user_actkey = '" . str_replace("\'", "''", $user_actkey) . "'" . $avatar_sql . "
521                                 WHERE user_id = $user_id";
522                         if ( !($result = $db->sql_query($sql)) )
523                         {
524                                 message_die(GENERAL_ERROR, 'Could not update users table', '', __LINE__, __FILE__, $sql);
525                         }
527                         if ( !$user_active )
528                         {
529                                 //
530                                 // The users account has been deactivated, send them an email with a new activation key
531                                 //
532                                 include($phpbb_root_path . 'includes/emailer.'.$phpEx);
533                                 $emailer = new emailer($board_config['smtp_delivery']);
535                                 $emailer->from($board_config['board_email']);
536                                 $emailer->replyto($board_config['board_email']);
538                                 $emailer->use_template('user_activate', stripslashes($user_lang));
539                                 $emailer->email_address($email);
540                                 $emailer->set_subject($lang['Reactivate']);
542                                 $emailer->assign_vars(array(
543                                         'SITENAME' => $board_config['sitename'],
544                                         'USERNAME' => preg_replace($unhtml_specialchars_match, $unhtml_specialchars_replace, substr(str_replace("\'", "'", $username), 0, 25)),
545                                         'EMAIL_SIG' => (!empty($board_config['board_email_sig'])) ? str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']) : '',
547                                         'U_ACTIVATE' => $server_url . '?mode=activate&' . POST_USERS_URL . '=' . $user_id . '&act_key=' . $user_actkey)
548                                 );
549                                 $emailer->send();
550                                 $emailer->reset();
552                                 $message = $lang['Profile_updated_inactive'] . '<br /><br />' . sprintf($lang['Click_return_index'],  '<a href="' . append_sid("index.$phpEx") . '">', '</a>');
553                         }
554                         else
555                         {
556                                 $message = $lang['Profile_updated'] . '<br /><br />' . sprintf($lang['Click_return_index'],  '<a href="' . append_sid("index.$phpEx") . '">', '</a>');
557                         }
559                         $template->assign_vars(array(
560                                 "META" => '<meta http-equiv="refresh" content="5;url=' . append_sid("index.$phpEx") . '">')
561                         );
563                         message_die(GENERAL_MESSAGE, $message);
564                 }
565                 else
566                 {
567                         $sql = "SELECT MAX(user_id) AS total
568                                 FROM " . USERS_TABLE;
569                         if ( !($result = $db->sql_query($sql)) )
570                         {
571                                 message_die(GENERAL_ERROR, 'Could not obtain next user_id information', '', __LINE__, __FILE__, $sql);
572                         }
574                         if ( !($row = $db->sql_fetchrow($result)) )
575                         {
576                                 message_die(GENERAL_ERROR, 'Could not obtain next user_id information', '', __LINE__, __FILE__, $sql);
577                         }
578                         $user_id = $row['total'] + 1;
580                         //
581                         // Get current date
582                         //
583                         $sql = "INSERT INTO " . USERS_TABLE . " (user_id, username, user_regdate, user_password, user_email, user_icq, user_website, user_occ, user_from, user_interests, user_sig, user_sig_bbcode_uid, user_avatar, user_avatar_type, user_viewemail, user_aim, user_yim, user_msnm, user_attachsig, user_allowsmile, user_allowhtml, user_allowbbcode, user_allow_viewonline, user_notify, user_notify_pm, user_popup_pm, user_timezone, user_dateformat, user_lang, user_style, user_level, user_allow_pm, user_active, user_actkey)
584                                 VALUES ($user_id, '" . str_replace("\'", "''", $username) . "', " . time() . ", '" . str_replace("\'", "''", $new_password) . "', '" . str_replace("\'", "''", $email) . "', '" . str_replace("\'", "''", $icq) . "', '" . str_replace("\'", "''", $website) . "', '" . str_replace("\'", "''", $occupation) . "', '" . str_replace("\'", "''", $location) . "', '" . str_replace("\'", "''", $interests) . "', '" . str_replace("\'", "''", $signature) . "', '$signature_bbcode_uid', $avatar_sql, $viewemail, '" . str_replace("\'", "''", str_replace(' ', '+', $aim)) . "', '" . str_replace("\'", "''", $yim) . "', '" . str_replace("\'", "''", $msn) . "', $attachsig, $allowsmilies, $allowhtml, $allowbbcode, $allowviewonline, $notifyreply, $notifypm, $popup_pm, $user_timezone, '" . str_replace("\'", "''", $user_dateformat) . "', '" . str_replace("\'", "''", $user_lang) . "', $user_style, 0, 1, ";
585                         if ( $board_config['require_activation'] == USER_ACTIVATION_SELF || $board_config['require_activation'] == USER_ACTIVATION_ADMIN || $coppa )
586                         {
587                                 $user_actkey = gen_rand_string(true);
588                                 $key_len = 54 - (strlen($server_url));
589                                 $key_len = ( $key_len > 6 ) ? $key_len : 6;
590                                 $user_actkey = substr($user_actkey, 0, $key_len);
591                                 $sql .= "0, '" . str_replace("\'", "''", $user_actkey) . "')";
592                         }
593                         else
594                         {
595                                 $sql .= "1, '')";
596                         }
598                         if ( !($result = $db->sql_query($sql, BEGIN_TRANSACTION)) )
599                         {
600                                 message_die(GENERAL_ERROR, 'Could not insert data into users table', '', __LINE__, __FILE__, $sql);
601                         }
603                         $sql = "INSERT INTO " . GROUPS_TABLE . " (group_name, group_description, group_single_user, group_moderator)
604                                 VALUES ('', 'Personal User', 1, 0)";
605                         if ( !($result = $db->sql_query($sql)) )
606                         {
607                                 message_die(GENERAL_ERROR, 'Could not insert data into groups table', '', __LINE__, __FILE__, $sql);
608                         }
610                         $group_id = $db->sql_nextid();
612                         $sql = "INSERT INTO " . USER_GROUP_TABLE . " (user_id, group_id, user_pending)
613                                 VALUES ($user_id, $group_id, 0)";
614                         if( !($result = $db->sql_query($sql, END_TRANSACTION)) )
615                         {
616                                 message_die(GENERAL_ERROR, 'Could not insert data into user_group table', '', __LINE__, __FILE__, $sql);
617                         }
619                         if ( $coppa )
620                         {
621                                 $message = $lang['COPPA'];
622                                 $email_template = 'coppa_welcome_inactive';
623                         }
624                         else if ( $board_config['require_activation'] == USER_ACTIVATION_SELF )
625                         {
626                                 $message = $lang['Account_inactive'];
627                                 $email_template = 'user_welcome_inactive';
628                         }
629                         else if ( $board_config['require_activation'] == USER_ACTIVATION_ADMIN )
630                         {
631                                 $message = $lang['Account_inactive_admin'];
632                                 $email_template = 'admin_welcome_inactive';
633                         }
634                         else
635                         {
636                                 $message = $lang['Account_added'];
637                                 $email_template = 'user_welcome';
638                         }
640                         include($phpbb_root_path . 'includes/emailer.'.$phpEx);
641                         $emailer = new emailer($board_config['smtp_delivery']);
643                         $emailer->from($board_config['board_email']);
644                         $emailer->replyto($board_config['board_email']);
646                         $emailer->use_template($email_template, stripslashes($user_lang));
647                         $emailer->email_address($email);
648                         $emailer->set_subject(sprintf($lang['Welcome_subject'], $board_config['sitename']));
650                         if( $coppa )
651                         {
652                                 $emailer->assign_vars(array(
653                                         'SITENAME' => $board_config['sitename'],
654                                         'WELCOME_MSG' => sprintf($lang['Welcome_subject'], $board_config['sitename']),
655                                         'USERNAME' => preg_replace($unhtml_specialchars_match, $unhtml_specialchars_replace, substr(str_replace("\'", "'", $username), 0, 25)),
656                                         'PASSWORD' => $password_confirm,
657                                         'EMAIL_SIG' => str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']),
659                                         'FAX_INFO' => $board_config['coppa_fax'],
660                                         'MAIL_INFO' => $board_config['coppa_mail'],
661                                         'EMAIL_ADDRESS' => $email,
662                                         'ICQ' => $icq,
663                                         'AIM' => $aim,
664                                         'YIM' => $yim,
665                                         'MSN' => $msn,
666                                         'WEB_SITE' => $website,
667                                         'FROM' => $location,
668                                         'OCC' => $occupation,
669                                         'INTERESTS' => $interests,
670                                         'SITENAME' => $board_config['sitename']));
671                         }
672                         else
673                         {
674                                 $emailer->assign_vars(array(
675                                         'SITENAME' => $board_config['sitename'],
676                                         'WELCOME_MSG' => sprintf($lang['Welcome_subject'], $board_config['sitename']),
677                                         'USERNAME' => preg_replace($unhtml_specialchars_match, $unhtml_specialchars_replace, substr(str_replace("\'", "'", $username), 0, 25)),
678                                         'PASSWORD' => $password_confirm,
679                                         'EMAIL_SIG' => str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']),
681                                         'U_ACTIVATE' => $server_url . '?mode=activate&' . POST_USERS_URL . '=' . $user_id . '&act_key=' . $user_actkey)
682                                 );
683                         }
685                         $emailer->send();
686                         $emailer->reset();
688                         if ( $board_config['require_activation'] == USER_ACTIVATION_ADMIN )
689                         {
690                                 $sql = "SELECT user_email, user_lang 
691                                         FROM " . USERS_TABLE . "
692                                         WHERE user_level = " . ADMIN;
693                                 
694                                 if ( !($result = $db->sql_query($sql)) )
695                                 {
696                                         message_die(GENERAL_ERROR, 'Could not select Administrators', '', __LINE__, __FILE__, $sql);
697                                 }
698                                 
699                                 while ($row = $db->sql_fetchrow($result))
700                                 {
701                                         $emailer->from($board_config['board_email']);
702                                         $emailer->replyto($board_config['board_email']);
703                                         
704                                         $emailer->email_address(trim($row['user_email']));
705                                         $emailer->use_template("admin_activate", $row['user_lang']);
706                                         $emailer->set_subject($lang['New_account_subject']);
708                                         $emailer->assign_vars(array(
709                                                 'USERNAME' => preg_replace($unhtml_specialchars_match, $unhtml_specialchars_replace, substr(str_replace("\'", "'", $username), 0, 25)),
710                                                 'EMAIL_SIG' => str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']),
712                                                 'U_ACTIVATE' => $server_url . '?mode=activate&' . POST_USERS_URL . '=' . $user_id . '&act_key=' . $user_actkey)
713                                         );
714                                         $emailer->send();
715                                         $emailer->reset();
716                                 }
717                                 $db->sql_freeresult($result);
718                         }
720                         $message = $message . '<br /><br />' . sprintf($lang['Click_return_index'],  '<a href="' . append_sid("index.$phpEx") . '">', '</a>');
722                         message_die(GENERAL_MESSAGE, $message);
723                 } // if mode == register
724         }
725 } // End of submit
728 if ( $error )
730         //
731         // If an error occured we need to stripslashes on returned data
732         //
733         $username = stripslashes($username);
734         $email = stripslashes($email);
735         $new_password = '';
736         $password_confirm = '';
738         $icq = stripslashes($icq);
739         $aim = str_replace('+', ' ', stripslashes($aim));
740         $msn = stripslashes($msn);
741         $yim = stripslashes($yim);
743         $website = stripslashes($website);
744         $location = stripslashes($location);
745         $occupation = stripslashes($occupation);
746         $interests = stripslashes($interests);
747         $signature = stripslashes($signature);
748         $signature = ($signature_bbcode_uid != '') ? preg_replace("/:(([a-z0-9]+:)?)$signature_bbcode_uid(=|\])/si", '\\3', $signature) : $signature;
750         $user_lang = stripslashes($user_lang);
751         $user_dateformat = stripslashes($user_dateformat);
754 else if ( $mode == 'editprofile' && !isset($HTTP_POST_VARS['avatargallery']) && !isset($HTTP_POST_VARS['submitavatar']) && !isset($HTTP_POST_VARS['cancelavatar']) )
756         $user_id = $userdata['user_id'];
757         $username = $userdata['username'];
758         $email = $userdata['user_email'];
759         $new_password = '';
760         $password_confirm = '';
762         $icq = $userdata['user_icq'];
763         $aim = str_replace('+', ' ', $userdata['user_aim']);
764         $msn = $userdata['user_msnm'];
765         $yim = $userdata['user_yim'];
767         $website = $userdata['user_website'];
768         $location = $userdata['user_from'];
769         $occupation = $userdata['user_occ'];
770         $interests = $userdata['user_interests'];
771         $signature_bbcode_uid = $userdata['user_sig_bbcode_uid'];
772         $signature = ($signature_bbcode_uid != '') ? preg_replace("/:(([a-z0-9]+:)?)$signature_bbcode_uid(=|\])/si", '\\3', $userdata['user_sig']) : $userdata['user_sig'];
774         $viewemail = $userdata['user_viewemail'];
775         $notifypm = $userdata['user_notify_pm'];
776         $popup_pm = $userdata['user_popup_pm'];
777         $notifyreply = $userdata['user_notify'];
778         $attachsig = $userdata['user_attachsig'];
779         $allowhtml = $userdata['user_allowhtml'];
780         $allowbbcode = $userdata['user_allowbbcode'];
781         $allowsmilies = $userdata['user_allowsmile'];
782         $allowviewonline = $userdata['user_allow_viewonline'];
784         $user_avatar = ( $userdata['user_allowavatar'] ) ? $userdata['user_avatar'] : '';
785         $user_avatar_type = ( $userdata['user_allowavatar'] ) ? $userdata['user_avatar_type'] : USER_AVATAR_NONE;
787         $user_style = $userdata['user_style'];
788         $user_lang = $userdata['user_lang'];
789         $user_timezone = $userdata['user_timezone'];
790         $user_dateformat = $userdata['user_dateformat'];
793 //
794 // Default pages
795 //
796 include($phpbb_root_path . 'includes/page_header.'.$phpEx);
798 make_jumpbox('viewforum.'.$phpEx);
800 if ( $mode == 'editprofile' )
802         if ( $user_id != $userdata['user_id'] )
803         {
804                 $error = TRUE;
805                 $error_msg = $lang['Wrong_Profile'];
806         }
809 if( isset($HTTP_POST_VARS['avatargallery']) && !$error )
811         include($phpbb_root_path . 'includes/usercp_avatar.'.$phpEx);
813         $avatar_category = ( !empty($HTTP_POST_VARS['avatarcategory']) ) ? htmlspecialchars($HTTP_POST_VARS['avatarcategory']) : '';
815         $template->set_filenames(array(
816                 'body' => 'profile_avatar_gallery.tpl')
817         );
819         $allowviewonline = !$allowviewonline;
821         display_avatar_gallery($mode, $avatar_category, $user_id, $email, $current_email, $coppa, $username, $email, &$new_password, &$cur_password, $password_confirm, $icq, $aim, $msn, $yim, $website, $location, $occupation, $interests, $signature, $viewemail, $notifypm, $popup_pm, $notifyreply, $attachsig, $allowhtml, $allowbbcode, $allowsmilies, $allowviewonline, $user_style, $user_lang, $user_timezone, $user_dateformat, $userdata['session_id']);
823 else
825         include($phpbb_root_path . 'includes/functions_selects.'.$phpEx);
827         if ( !isset($coppa) )
828         {
829                 $coppa = FALSE;
830         }
832         if ( !isset($user_template) )
833         {
834                 $selected_template = $board_config['system_template'];
835         }
837         $avatar_img = '';
838         if ( $user_avatar_type )
839         {
840                 switch( $user_avatar_type )
841                 {
842                         case USER_AVATAR_UPLOAD:
843                                 $avatar_img = ( $board_config['allow_avatar_upload'] ) ? '<img src="' . $board_config['avatar_path'] . '/' . $user_avatar . '" alt="" />' : '';
844                                 break;
845                         case USER_AVATAR_REMOTE:
846                                 $avatar_img = ( $board_config['allow_avatar_remote'] ) ? '<img src="' . $user_avatar . '" alt="" />' : '';
847                                 break;
848                         case USER_AVATAR_GALLERY:
849                                 $avatar_img = ( $board_config['allow_avatar_local'] ) ? '<img src="' . $board_config['avatar_gallery_path'] . '/' . $user_avatar . '" alt="" />' : '';
850                                 break;
851                 }
852         }
854         $s_hidden_fields = '<input type="hidden" name="mode" value="' . $mode . '" /><input type="hidden" name="agreed" value="true" /><input type="hidden" name="coppa" value="' . $coppa . '" />';
855         if( $mode == 'editprofile' )
856         {
857                 $s_hidden_fields .= '<input type="hidden" name="user_id" value="' . $userdata['user_id'] . '" />';
858                 //
859                 // Send the users current email address. If they change it, and account activation is turned on
860                 // the user account will be disabled and the user will have to reactivate their account.
861                 //
862                 $s_hidden_fields .= '<input type="hidden" name="current_email" value="' . $userdata['user_email'] . '" />';
863         }
865         if ( !empty($user_avatar_local) )
866         {
867                 $s_hidden_fields .= '<input type="hidden" name="avatarlocal" value="' . $user_avatar_local . '" />';
868         }
870         $html_status =  ( $userdata['user_allowhtml'] && $board_config['allow_html'] ) ? $lang['HTML_is_ON'] : $lang['HTML_is_OFF'];
871         $bbcode_status = ( $userdata['user_allowbbcode'] && $board_config['allow_bbcode']  ) ? $lang['BBCode_is_ON'] : $lang['BBCode_is_OFF'];
872         $smilies_status = ( $userdata['user_allowsmile'] && $board_config['allow_smilies']  ) ? $lang['Smilies_are_ON'] : $lang['Smilies_are_OFF'];
874         if ( $error )
875         {
876                 $template->set_filenames(array(
877                         'reg_header' => 'error_body.tpl')
878                 );
879                 $template->assign_vars(array(
880                         'ERROR_MESSAGE' => $error_msg)
881                 );
882                 $template->assign_var_from_handle('ERROR_BOX', 'reg_header');
883         }
885         $template->set_filenames(array(
886                 'body' => 'profile_add_body.tpl')
887         );
889         if ( $mode == 'editprofile' )
890         {
891                 $template->assign_block_vars('switch_edit_profile', array());
892         }
894         if ( ($mode == 'register') || ($board_config['allow_namechange']) )
895         {
896                 $template->assign_block_vars('switch_namechange_allowed', array());
897         }
898         else
899         {
900                 $template->assign_block_vars('switch_namechange_disallowed', array());
901         }
904         // Visual Confirmation
905         $confirm_image = '';
906         if (!empty($board_config['enable_confirm']) && $mode == 'register')
907         {
908                 $sql = 'SELECT session_id 
909                         FROM ' . SESSIONS_TABLE; 
910                 if (!($result = $db->sql_query($sql)))
911                 {
912                         message_die(GENERAL_ERROR, 'Could not select session data', '', __LINE__, __FILE__, $sql);
913                 }
915                 if ($row = $db->sql_fetchrow($result))
916                 {
917                         $confirm_sql = '';
918                         do
919                         {
920                                 $confirm_sql .= (($confirm_sql != '') ? ', ' : '') . "'" . $row['session_id'] . "'";
921                         }
922                         while ($row = $db->sql_fetchrow($result));
923                 
924                         $sql = 'DELETE FROM ' .  CONFIRM_TABLE . " 
925                                 WHERE session_id NOT IN ($confirm_sql)";
926                         if (!$db->sql_query($sql))
927                         {
928                                 message_die(GENERAL_ERROR, 'Could not delete stale confirm data', '', __LINE__, __FILE__, $sql);
929                         }
930                 }
931                 $db->sql_freeresult($result);
933                 $sql = 'SELECT COUNT(session_id) AS attempts 
934                         FROM ' . CONFIRM_TABLE . " 
935                         WHERE session_id = '" . $userdata['session_id'] . "'";
936                 if (!($result = $db->sql_query($sql)))
937                 {
938                         message_die(GENERAL_ERROR, 'Could not obtain confirm code count', '', __LINE__, __FILE__, $sql);
939                 }
941                 if ($row = $db->sql_fetchrow($result))
942                 {
943                         if ($row['attempts'] > 3)
944                         {
945                                 message_die(GENERAL_MESSAGE, $lang['Too_many_registers']);
946                         }
947                 }
948                 $db->sql_freeresult($result);
949                 
950                 $confirm_chars = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',  'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',  'U', 'V', 'W', 'X', 'Y', 'Z', '1', '2', '3', '4', '5', '6', '7', '8', '9');
952                 list($usec, $sec) = explode(' ', microtime()); 
953                 mt_srand($sec * $usec); 
955                 $max_chars = count($confirm_chars) - 1;
956                 $code = '';
957                 for ($i = 0; $i < 6; $i++)
958                 {
959                         $code .= $confirm_chars[mt_rand(0, $max_chars)];
960                 }
962                 $confirm_id = md5(uniqid($user_ip));
964                 $sql = 'INSERT INTO ' . CONFIRM_TABLE . " (confirm_id, session_id, code) 
965                         VALUES ('$confirm_id', '". $userdata['session_id'] . "', '$code')";
966                 if (!$db->sql_query($sql))
967                 {
968                         message_die(GENERAL_ERROR, 'Could not insert new confirm code information', '', __LINE__, __FILE__, $sql);
969                 }
971                 unset($code);
972                 
973                 $confirm_image = (@extension_loaded('zlib')) ? '<img src="' . append_sid("profile.$phpEx?mode=confirm&amp;id=$confirm_id") . '" alt="" title="" />' : '<img src="' . append_sid("profile.$phpEx?mode=confirm&amp;id=$confirm_id&amp;c=1") . '" alt="" title="" /><img src="' . append_sid("profile.$phpEx?mode=confirm&amp;id=$confirm_id&amp;c=2") . '" alt="" title="" /><img src="' . append_sid("profile.$phpEx?mode=confirm&amp;id=$confirm_id&amp;c=3") . '" alt="" title="" /><img src="' . append_sid("profile.$phpEx?mode=confirm&amp;id=$confirm_id&amp;c=4") . '" alt="" title="" /><img src="' . append_sid("profile.$phpEx?mode=confirm&amp;id=$confirm_id&amp;c=5") . '" alt="" title="" /><img src="' . append_sid("profile.$phpEx?mode=confirm&amp;id=$confirm_id&amp;c=6") . '" alt="" title="" />';
974                 $s_hidden_fields .= '<input type="hidden" name="confirm_id" value="' . $confirm_id . '" />';
976                 $template->assign_block_vars('switch_confirm', array());
977         }
980         //
981         // Let's do an overall check for settings/versions which would prevent
982         // us from doing file uploads....
983         //
984         $ini_val = ( phpversion() >= '4.0.0' ) ? 'ini_get' : 'get_cfg_var';
985         $form_enctype = ( @$ini_val('file_uploads') == '0' || strtolower(@$ini_val('file_uploads') == 'off') || phpversion() == '4.0.4pl1' || !$board_config['allow_avatar_upload'] || ( phpversion() < '4.0.3' && @$ini_val('open_basedir') != '' ) ) ? '' : 'enctype="multipart/form-data"';
987         $template->assign_vars(array(
988                 'USERNAME' => $username,
989                 'CUR_PASSWORD' => $cur_password,
990                 'NEW_PASSWORD' => $new_password,
991                 'PASSWORD_CONFIRM' => $password_confirm,
992                 'EMAIL' => $email,
993                 'CONFIRM_IMG' => $confirm_image, 
994                 'YIM' => $yim,
995                 'ICQ' => $icq,
996                 'MSN' => $msn,
997                 'AIM' => $aim,
998                 'OCCUPATION' => $occupation,
999                 'INTERESTS' => $interests,
1000                 'LOCATION' => $location,
1001                 'WEBSITE' => $website,
1002                 'SIGNATURE' => str_replace('<br />', "\n", $signature),
1003                 'VIEW_EMAIL_YES' => ( $viewemail ) ? 'checked="checked"' : '',
1004                 'VIEW_EMAIL_NO' => ( !$viewemail ) ? 'checked="checked"' : '',
1005                 'HIDE_USER_YES' => ( !$allowviewonline ) ? 'checked="checked"' : '',
1006                 'HIDE_USER_NO' => ( $allowviewonline ) ? 'checked="checked"' : '',
1007                 'NOTIFY_PM_YES' => ( $notifypm ) ? 'checked="checked"' : '',
1008                 'NOTIFY_PM_NO' => ( !$notifypm ) ? 'checked="checked"' : '',
1009                 'POPUP_PM_YES' => ( $popup_pm ) ? 'checked="checked"' : '',
1010                 'POPUP_PM_NO' => ( !$popup_pm ) ? 'checked="checked"' : '',
1011                 'ALWAYS_ADD_SIGNATURE_YES' => ( $attachsig ) ? 'checked="checked"' : '',
1012                 'ALWAYS_ADD_SIGNATURE_NO' => ( !$attachsig ) ? 'checked="checked"' : '',
1013                 'NOTIFY_REPLY_YES' => ( $notifyreply ) ? 'checked="checked"' : '',
1014                 'NOTIFY_REPLY_NO' => ( !$notifyreply ) ? 'checked="checked"' : '',
1015                 'ALWAYS_ALLOW_BBCODE_YES' => ( $allowbbcode ) ? 'checked="checked"' : '',
1016                 'ALWAYS_ALLOW_BBCODE_NO' => ( !$allowbbcode ) ? 'checked="checked"' : '',
1017                 'ALWAYS_ALLOW_HTML_YES' => ( $allowhtml ) ? 'checked="checked"' : '',
1018                 'ALWAYS_ALLOW_HTML_NO' => ( !$allowhtml ) ? 'checked="checked"' : '',
1019                 'ALWAYS_ALLOW_SMILIES_YES' => ( $allowsmilies ) ? 'checked="checked"' : '',
1020                 'ALWAYS_ALLOW_SMILIES_NO' => ( !$allowsmilies ) ? 'checked="checked"' : '',
1021                 'ALLOW_AVATAR' => $board_config['allow_avatar_upload'],
1022                 'AVATAR' => $avatar_img,
1023                 'AVATAR_SIZE' => $board_config['avatar_filesize'],
1024                 'LANGUAGE_SELECT' => language_select($user_lang, 'language'),
1025                 'STYLE_SELECT' => style_select($user_style, 'style'),
1026                 'TIMEZONE_SELECT' => tz_select($user_timezone, 'timezone'),
1027                 'DATE_FORMAT' => $user_dateformat,
1028                 'HTML_STATUS' => $html_status,
1029                 'BBCODE_STATUS' => sprintf($bbcode_status, '<a href="' . append_sid("faq.$phpEx?mode=bbcode") . '" target="_phpbbcode">', '</a>'),
1030                 'SMILIES_STATUS' => $smilies_status,
1032                 'L_CURRENT_PASSWORD' => $lang['Current_password'],
1033                 'L_NEW_PASSWORD' => ( $mode == 'register' ) ? $lang['Password'] : $lang['New_password'],
1034                 'L_CONFIRM_PASSWORD' => $lang['Confirm_password'],
1035                 'L_CONFIRM_PASSWORD_EXPLAIN' => ( $mode == 'editprofile' ) ? $lang['Confirm_password_explain'] : '',
1036                 'L_PASSWORD_IF_CHANGED' => ( $mode == 'editprofile' ) ? $lang['password_if_changed'] : '',
1037                 'L_PASSWORD_CONFIRM_IF_CHANGED' => ( $mode == 'editprofile' ) ? $lang['password_confirm_if_changed'] : '',
1038                 'L_SUBMIT' => $lang['Submit'],
1039                 'L_RESET' => $lang['Reset'],
1040                 'L_ICQ_NUMBER' => $lang['ICQ'],
1041                 'L_MESSENGER' => $lang['MSNM'],
1042                 'L_YAHOO' => $lang['YIM'],
1043                 'L_WEBSITE' => $lang['Website'],
1044                 'L_AIM' => $lang['AIM'],
1045                 'L_LOCATION' => $lang['Location'],
1046                 'L_OCCUPATION' => $lang['Occupation'],
1047                 'L_BOARD_LANGUAGE' => $lang['Board_lang'],
1048                 'L_BOARD_STYLE' => $lang['Board_style'],
1049                 'L_TIMEZONE' => $lang['Timezone'],
1050                 'L_DATE_FORMAT' => $lang['Date_format'],
1051                 'L_DATE_FORMAT_EXPLAIN' => $lang['Date_format_explain'],
1052                 'L_YES' => $lang['Yes'],
1053                 'L_NO' => $lang['No'],
1054                 'L_INTERESTS' => $lang['Interests'],
1055                 'L_ALWAYS_ALLOW_SMILIES' => $lang['Always_smile'],
1056                 'L_ALWAYS_ALLOW_BBCODE' => $lang['Always_bbcode'],
1057                 'L_ALWAYS_ALLOW_HTML' => $lang['Always_html'],
1058                 'L_HIDE_USER' => $lang['Hide_user'],
1059                 'L_ALWAYS_ADD_SIGNATURE' => $lang['Always_add_sig'],
1061                 'L_AVATAR_PANEL' => $lang['Avatar_panel'],
1062                 'L_AVATAR_EXPLAIN' => sprintf($lang['Avatar_explain'], $board_config['avatar_max_width'], $board_config['avatar_max_height'], (round($board_config['avatar_filesize'] / 1024))),
1063                 'L_UPLOAD_AVATAR_FILE' => $lang['Upload_Avatar_file'],
1064                 'L_UPLOAD_AVATAR_URL' => $lang['Upload_Avatar_URL'],
1065                 'L_UPLOAD_AVATAR_URL_EXPLAIN' => $lang['Upload_Avatar_URL_explain'],
1066                 'L_AVATAR_GALLERY' => $lang['Select_from_gallery'],
1067                 'L_SHOW_GALLERY' => $lang['View_avatar_gallery'],
1068                 'L_LINK_REMOTE_AVATAR' => $lang['Link_remote_Avatar'],
1069                 'L_LINK_REMOTE_AVATAR_EXPLAIN' => $lang['Link_remote_Avatar_explain'],
1070                 'L_DELETE_AVATAR' => $lang['Delete_Image'],
1071                 'L_CURRENT_IMAGE' => $lang['Current_Image'],
1073                 'L_SIGNATURE' => $lang['Signature'],
1074                 'L_SIGNATURE_EXPLAIN' => sprintf($lang['Signature_explain'], $board_config['max_sig_chars']),
1075                 'L_NOTIFY_ON_REPLY' => $lang['Always_notify'],
1076                 'L_NOTIFY_ON_REPLY_EXPLAIN' => $lang['Always_notify_explain'],
1077                 'L_NOTIFY_ON_PRIVMSG' => $lang['Notify_on_privmsg'],
1078                 'L_POPUP_ON_PRIVMSG' => $lang['Popup_on_privmsg'],
1079                 'L_POPUP_ON_PRIVMSG_EXPLAIN' => $lang['Popup_on_privmsg_explain'],
1080                 'L_PREFERENCES' => $lang['Preferences'],
1081                 'L_PUBLIC_VIEW_EMAIL' => $lang['Public_view_email'],
1082                 'L_ITEMS_REQUIRED' => $lang['Items_required'],
1083                 'L_REGISTRATION_INFO' => $lang['Registration_info'],
1084                 'L_PROFILE_INFO' => $lang['Profile_info'],
1085                 'L_PROFILE_INFO_NOTICE' => $lang['Profile_info_warn'],
1086                 'L_EMAIL_ADDRESS' => $lang['Email_address'],
1088                 'L_CONFIRM_CODE_IMPAIRED'       => sprintf($lang['Confirm_code_impaired'], '<a href="mailto:' . $board_config['board_email'] . '">', '</a>'), 
1089                 'L_CONFIRM_CODE'                        => $lang['Confirm_code'], 
1090                 'L_CONFIRM_CODE_EXPLAIN'        => $lang['Confirm_code_explain'], 
1092                 'S_ALLOW_AVATAR_UPLOAD' => $board_config['allow_avatar_upload'],
1093                 'S_ALLOW_AVATAR_LOCAL' => $board_config['allow_avatar_local'],
1094                 'S_ALLOW_AVATAR_REMOTE' => $board_config['allow_avatar_remote'],
1095                 'S_HIDDEN_FIELDS' => $s_hidden_fields,
1096                 'S_FORM_ENCTYPE' => $form_enctype,
1097                 'S_PROFILE_ACTION' => append_sid("profile.$phpEx"))
1098         );
1100         //
1101         // This is another cheat using the block_var capability
1102         // of the templates to 'fake' an IF...ELSE...ENDIF solution
1103         // it works well :)
1104         //
1105         if ( $mode != 'register' )
1106         {
1107                 if ( $userdata['user_allowavatar'] && ( $board_config['allow_avatar_upload'] || $board_config['allow_avatar_local'] || $board_config['allow_avatar_remote'] ) )
1108                 {
1109                         $template->assign_block_vars('switch_avatar_block', array() );
1111                         if ( $board_config['allow_avatar_upload'] && file_exists(@phpbb_realpath('./' . $board_config['avatar_path'])) )
1112                         {
1113                                 if ( $form_enctype != '' )
1114                                 {
1115                                         $template->assign_block_vars('switch_avatar_block.switch_avatar_local_upload', array() );
1116                                 }
1117                                 $template->assign_block_vars('switch_avatar_block.switch_avatar_remote_upload', array() );
1118                         }
1120                         if ( $board_config['allow_avatar_remote'] )
1121                         {
1122                                 $template->assign_block_vars('switch_avatar_block.switch_avatar_remote_link', array() );
1123                         }
1125                         if ( $board_config['allow_avatar_local'] && file_exists(@phpbb_realpath('./' . $board_config['avatar_gallery_path'])) )
1126                         {
1127                                 $template->assign_block_vars('switch_avatar_block.switch_avatar_local_gallery', array() );
1128                         }
1129                 }
1130         }
1133 $template->pparse('body');
1135 include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
1137 ?>