home *** CD-ROM | disk | FTP | other *** search
/ PC World 2005 April / PCWorld_2005-04_cd.bin / akce / web / unitednuke / unitednuke.exe / html / includes / usercp_register.php < prev    next >
PHP Script  |  2004-01-10  |  56KB  |  1,050 lines

  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.51 2003/06/11 10:05:15 psotfx Exp $
  10.  *
  11.  *
  12.  ***************************************************************************/
  13. /***************************************************************************
  14. * phpbb2 forums port version 2.0.5 (c) 2003 - Nuke Cops (http://nukecops.com)
  15. *
  16. * Ported by Nuke Cops to phpbb2 standalone 2.0.5 Test
  17. * and debugging completed by the Elite Nukers and site members.
  18. *
  19. * You run this package at your sole risk. Nuke Cops and affiliates cannot
  20. * be held liable if anything goes wrong. You are advised to test this
  21. * package on a development system. Backup everything before implementing
  22. * in a production environment. If something goes wrong, you can always
  23. * backout and restore your backups.
  24. *
  25. * Installing and running this also means you agree to the terms of the AUP
  26. * found at Nuke Cops.
  27. *
  28. * This is version 2.0.5 of the phpbb2 forum port for PHP-Nuke. Work is based
  29. * on Tom Nitzschner's forum port version 2.0.6. Tom's 2.0.6 port was based
  30. * on the phpbb2 standalone version 2.0.3. Our version 2.0.5 from Nuke Cops is
  31. * now reflecting phpbb2 standalone 2.0.5 that fixes some bugs and the
  32. * invalid_session error message.
  33. ***************************************************************************/
  34. /***************************************************************************
  35.  *   This file is part of the phpBB2 port to Nuke 6.0 (c) copyright 2002
  36.  *   by Tom Nitzschner (tom@toms-home.com)
  37.  *   http://bbtonuke.sourceforge.net (or http://www.toms-home.com)
  38.  *
  39.  *   As always, make a backup before messing with anything. All code
  40.  *   release by me is considered sample code only. It may be fully
  41.  *   functual, but you use it at your own risk, if you break it,
  42.  *   you get to fix it too. No waranty is given or implied.
  43.  *
  44.  *   Please post all questions/request about this port on http://bbtonuke.sourceforge.net first,
  45.  *   then on my site. All original header code and copyright messages will be maintained
  46.  *   to give credit where credit is due. If you modify this, the only requirement is
  47.  *   that you also maintain all original copyright messages. All my work is released
  48.  *   under the GNU GENERAL PUBLIC LICENSE. Please see the README for more information.
  49.  *
  50.  ***************************************************************************/
  51. /***************************************************************************
  52.  *
  53.  *   This program is free software; you can redistribute it and/or modify
  54.  *   it under the terms of the GNU General Public License as published by
  55.  *   the Free Software Foundation; either version 2 of the License, or
  56.  *   (at your option) any later version.
  57.  *
  58.  *
  59.  ***************************************************************************/
  60.  
  61. if ( !defined('IN_PHPBB') )
  62. {
  63.         die("Hacking attempt");
  64.         exit;
  65. }
  66.  
  67. $unhtml_specialchars_match = array('#>#', '#<#', '#"#', '#&#');
  68. $unhtml_specialchars_replace = array('>', '<', '"', '&');
  69.  
  70. // ---------------------------------------
  71. // Load agreement template since user has not yet
  72. // agreed to registration conditions/coppa
  73. //
  74. function show_coppa()
  75. {
  76.         global $userdata, $template, $lang, $phpbb_root_path, $phpEx;
  77.  
  78.         $template->set_filenames(array(
  79.                 'body' => 'agreement.tpl')
  80.         );
  81.  
  82.         $template->assign_vars(array(
  83.                 'REGISTRATION' => $lang['Registration'],
  84.                 'AGREEMENT' => $lang['Reg_agreement'],
  85.                 "AGREE_OVER_13" => $lang['Agree_over_13'],
  86.                 "AGREE_UNDER_13" => $lang['Agree_under_13'],
  87.                 'DO_NOT_AGREE' => $lang['Agree_not'],
  88.  
  89.                 "U_AGREE_OVER13" => append_sid("profile.$phpEx?mode=register&agreed=true"),
  90.                 "U_AGREE_UNDER13" => append_sid("profile.$phpEx?mode=register&agreed=true&coppa=true"))
  91.         );
  92.  
  93.         $template->pparse('body');
  94.  
  95. }
  96. //
  97. // ---------------------------------------
  98.  
  99. $error = FALSE;
  100. $page_title = ( $mode == 'editprofile' ) ? $lang['Edit_profile'] : $lang['Register'];
  101.  
  102. if ( $mode == 'register' && !isset($HTTP_POST_VARS['agreed']) && !isset($HTTP_GET_VARS['agreed']) )
  103. {
  104.         include("includes/page_header.php");
  105.  
  106.         show_coppa();
  107.  
  108.         include("includes/page_tail.php");
  109. }
  110.  
  111. $coppa = ( empty($HTTP_POST_VARS['coppa']) && empty($HTTP_GET_VARS['coppa']) ) ? 0 : TRUE;
  112.  
  113. //
  114. // Check and initialize some variables if needed
  115. //
  116. if (
  117.         isset($HTTP_POST_VARS['submit']) ||
  118.         isset($HTTP_POST_VARS['avatargallery']) ||
  119.         isset($HTTP_POST_VARS['submitavatar']) ||
  120.         isset($HTTP_POST_VARS['cancelavatar']) ||
  121.         $mode == 'register' )
  122. {
  123.         include('includes/functions_validate.'.$phpEx);
  124.         include('includes/bbcode.'.$phpEx);
  125.         include('includes/functions_post.'.$phpEx);
  126.  
  127.         if ( $mode == 'editprofile' )
  128.         {
  129.                 $user_id = intval($HTTP_POST_VARS['user_id']);
  130.                 $current_email = trim(htmlspecialchars($HTTP_POST_VARS['current_email']));
  131.         }
  132.  
  133.         $strip_var_list = array('username' => 'username', 'email' => 'email', 'icq' => 'icq', 'aim' => 'aim', 'msn' => 'msn', 'yim' => 'yim', 'website' => 'website', 'location' => 'location', 'occupation' => 'occupation', 'interests' => 'interests');
  134.  
  135.         // Strip all tags from data ... may p**s some people off, bah, strip_tags is
  136.         // doing the job but can still break HTML output ... have no choice, have
  137.         // to use htmlspecialchars ... be prepared to be moaned at.
  138.         while( list($var, $param) = @each($strip_var_list) )
  139.         {
  140.                 if ( !empty($HTTP_POST_VARS[$param]) )
  141.                 {
  142.                         $$var = trim(htmlspecialchars($HTTP_POST_VARS[$param]));
  143.                 }
  144.         }
  145.  
  146.         $trim_var_list = array('cur_password' => 'cur_password', 'new_password' => 'new_password', 'password_confirm' => 'password_confirm', 'signature' => 'signature');
  147.  
  148.         while( list($var, $param) = @each($trim_var_list) )
  149.         {
  150.                 if ( !empty($HTTP_POST_VARS[$param]) )
  151.                 {
  152.                         $$var = trim($HTTP_POST_VARS[$param]);
  153.                 }
  154.         }
  155.  
  156.         $signature = str_replace('<br />', "\n", $signature);
  157.  
  158.         // Run some validation on the optional fields. These are pass-by-ref, so they'll be changed to
  159.         // empty strings if they fail.
  160.         validate_optional_fields($icq, $aim, $msn, $yim, $website, $location, $occupation, $interests, $signature);
  161.  
  162.         $viewemail = ( isset($HTTP_POST_VARS['viewemail']) ) ? ( ($HTTP_POST_VARS['viewemail']) ? TRUE : 0 ) : 0;
  163.         $allowviewonline = ( isset($HTTP_POST_VARS['hideonline']) ) ? ( ($HTTP_POST_VARS['hideonline']) ? 0 : TRUE ) : TRUE;
  164.         $notifyreply = ( isset($HTTP_POST_VARS['notifyreply']) ) ? ( ($HTTP_POST_VARS['notifyreply']) ? TRUE : 0 ) : 0;
  165.         $notifypm = ( isset($HTTP_POST_VARS['notifypm']) ) ? ( ($HTTP_POST_VARS['notifypm']) ? TRUE : 0 ) : TRUE;
  166.         $popup_pm = ( isset($HTTP_POST_VARS['popup_pm']) ) ? ( ($HTTP_POST_VARS['popup_pm']) ? TRUE : 0 ) : TRUE;
  167.  
  168.         if ( $mode == 'register' )
  169.         {
  170.                 $attachsig = ( isset($HTTP_POST_VARS['attachsig']) ) ? ( ($HTTP_POST_VARS['attachsig']) ? TRUE : 0 ) : $board_config['allow_sig'];
  171.  
  172.                 $allowhtml = ( isset($HTTP_POST_VARS['allowhtml']) ) ? ( ($HTTP_POST_VARS['allowhtml']) ? TRUE : 0 ) : $board_config['allow_html'];
  173.                 $allowbbcode = ( isset($HTTP_POST_VARS['allowbbcode']) ) ? ( ($HTTP_POST_VARS['allowbbcode']) ? TRUE : 0 ) : $board_config['allow_bbcode'];
  174.                 $allowsmilies = ( isset($HTTP_POST_VARS['allowsmilies']) ) ? ( ($HTTP_POST_VARS['allowsmilies']) ? TRUE : 0 ) : $board_config['allow_smilies'];
  175.         }
  176.         else
  177.         {
  178.                 $attachsig = ( isset($HTTP_POST_VARS['attachsig']) ) ? ( ($HTTP_POST_VARS['attachsig']) ? TRUE : 0 ) : 0;
  179.  
  180.                 $allowhtml = ( isset($HTTP_POST_VARS['allowhtml']) ) ? ( ($HTTP_POST_VARS['allowhtml']) ? TRUE : 0 ) : $userdata['user_allowhtml'];
  181.                 $allowbbcode = ( isset($HTTP_POST_VARS['allowbbcode']) ) ? ( ($HTTP_POST_VARS['allowbbcode']) ? TRUE : 0 ) : $userdata['user_allowbbcode'];
  182.                 $allowsmilies = ( isset($HTTP_POST_VARS['allowsmilies']) ) ? ( ($HTTP_POST_VARS['allowsmilies']) ? TRUE : 0 ) : $userdata['user_allowsmile'];
  183.         }
  184.  
  185.         $user_style = ( isset($HTTP_POST_VARS['style']) ) ? intval($HTTP_POST_VARS['style']) : $board_config['default_style'];
  186.  
  187.         if ( !empty($HTTP_POST_VARS['language']) )
  188.         {
  189.                 if ( preg_match('/^[a-z_]+$/i', $HTTP_POST_VARS['language']) )
  190.                 {
  191.                         $user_lang = htmlspecialchars($HTTP_POST_VARS['language']);
  192.                 }
  193.                 else
  194.                 {
  195.                         $error = true;
  196.                         $error_msg = $lang['Fields_empty'];
  197.                 }
  198.         }
  199.         else
  200.         {
  201.                 $user_lang = $board_config['default_lang'];
  202.         }
  203.  
  204.         $user_timezone = ( isset($HTTP_POST_VARS['timezone']) ) ? doubleval($HTTP_POST_VARS['timezone']) : $board_config['board_timezone'];
  205.     $sql = "SELECT config_value
  206.         FROM " . CONFIG_TABLE . "
  207.         WHERE config_name = 'default_dateformat'";
  208.     if ( !($result = $db->sql_query($sql)) )
  209.     {
  210.         message_die(GENERAL_ERROR, 'Could not select default dateformat', '', __LINE__, __FILE__, $sql);
  211.     }
  212.     $row = $db->sql_fetchrow($result);
  213.     $board_config['default_dateformat'] = $row['config_value'];
  214.         $user_dateformat = ( !empty($HTTP_POST_VARS['dateformat']) ) ? trim(htmlspecialchars($HTTP_POST_VARS['dateformat'])) : $board_config['default_dateformat'];
  215.  
  216.         $user_avatar_local = ( isset($HTTP_POST_VARS['avatarselect']) && !empty($HTTP_POST_VARS['submitavatar']) && $board_config['allow_avatar_local'] ) ? $HTTP_POST_VARS['avatarselect'] : ( ( isset($HTTP_POST_VARS['avatarlocal'])  ) ? htmlspecialchars($HTTP_POST_VARS['avatarlocal']) : '' );
  217.  
  218.         $user_avatar_remoteurl = ( !empty($HTTP_POST_VARS['avatarremoteurl']) ) ? trim(htmlspecialchars($HTTP_POST_VARS['avatarremoteurl'])) : '';
  219.         $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'] : '' );
  220.         $user_avatar_name = ( !empty($HTTP_POST_FILES['avatar']['name']) ) ? $HTTP_POST_FILES['avatar']['name'] : '';
  221.         $user_avatar_size = ( !empty($HTTP_POST_FILES['avatar']['size']) ) ? $HTTP_POST_FILES['avatar']['size'] : 0;
  222.         $user_avatar_filetype = ( !empty($HTTP_POST_FILES['avatar']['type']) ) ? $HTTP_POST_FILES['avatar']['type'] : '';
  223.  
  224.         $user_avatar = ( empty($user_avatar_loc) && $mode == 'editprofile' ) ? $userdata['user_avatar'] : '';
  225.         $user_avatar_type = ( empty($user_avatar_loc) && $mode == 'editprofile' ) ? $userdata['user_avatar_type'] : '';
  226.  
  227.         if ( (isset($HTTP_POST_VARS['avatargallery']) || isset($HTTP_POST_VARS['submitavatar']) || isset($HTTP_POST_VARS['cancelavatar'])) && (!isset($HTTP_POST_VARS['submit'])) )
  228.         {
  229.                 $username = stripslashes($username);
  230.                 $email = stripslashes($email);
  231.                 $cur_password = htmlspecialchars(stripslashes($cur_password));
  232.                 $new_password = htmlspecialchars(stripslashes($new_password));
  233.                 $password_confirm = htmlspecialchars(stripslashes($password_confirm));
  234.  
  235.                 $icq = stripslashes($icq);
  236.                 $aim = stripslashes($aim);
  237.                 $msn = stripslashes($msn);
  238.                 $yim = stripslashes($yim);
  239.  
  240.                 $website = stripslashes($website);
  241.                 $location = stripslashes($location);
  242.                 $occupation = stripslashes($occupation);
  243.                 $interests = stripslashes($interests);
  244.                 $signature = stripslashes($signature);
  245.  
  246.                 $user_lang = stripslashes($user_lang);
  247.                 $user_dateformat = stripslashes($user_dateformat);
  248.  
  249.                 if ( !isset($HTTP_POST_VARS['cancelavatar']))
  250.                 {
  251.                         $user_avatar = $user_avatar_local;
  252.                         $user_avatar_type = USER_AVATAR_GALLERY;
  253.                 }
  254.         }
  255. }
  256.  
  257. //
  258. // Let's make sure the user isn't logged in while registering,
  259. // and ensure that they were trying to register a second time
  260. // (Prevents double registrations)
  261. //
  262. if ($mode == 'register' && ($userdata['session_logged_in'] || $username == $userdata['username']))
  263. {
  264.         message_die(GENERAL_MESSAGE, $lang['Username_taken'], '', __LINE__, __FILE__);
  265. }
  266.  
  267. //
  268. // Did the user submit? In this case build a query to update the users profile in the DB
  269. //
  270. if ( isset($HTTP_POST_VARS['submit']) )
  271. {
  272.         include("includes/usercp_avatar.php");
  273.  
  274.         $passwd_sql = '';
  275.         if ( $mode == 'editprofile' )
  276.         {
  277.                 if ( $user_id != $userdata['user_id'] )
  278.                 {
  279.                         $error = TRUE;
  280.                         $error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $lang['Wrong_Profile'];
  281.                 }
  282.         }
  283.         else if ( $mode == 'register' )
  284.         {
  285.                 if ( empty($username) || empty($new_password) || empty($password_confirm) || empty($email) )
  286.                 {
  287.                         $error = TRUE;
  288.                         $error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $lang['Fields_empty'];
  289.                 }
  290.         }
  291.  
  292.         $passwd_sql = '';
  293.         if ( !empty($new_password) && !empty($password_confirm) )
  294.         {
  295.                 if ( $new_password != $password_confirm )
  296.                 {
  297.                         $error = TRUE;
  298.                         $error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $lang['Password_mismatch'];
  299.                 }
  300.                 else if ( strlen($new_password) > 32 )
  301.                 {
  302.                         $error = TRUE;
  303.                         $error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $lang['Password_long'];
  304.                 }
  305.         else if ( strlen($new_password) < $minpass )
  306.                 {
  307.                         $error = TRUE;
  308.                         $error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $lang['Password_short'];
  309.                 }
  310.                 else
  311.                 {
  312.                         if ( $mode == 'editprofile' )
  313.                         {
  314.                                 $sql = "SELECT user_password
  315.                                         FROM " . USERS_TABLE . "
  316.                                         WHERE user_id = $user_id";
  317.                                 if ( !($result = $db->sql_query($sql)) )
  318.                                 {
  319.                                         message_die(GENERAL_ERROR, 'Could not obtain user_password information', '', __LINE__, __FILE__, $sql);
  320.                                 }
  321.  
  322.                                 $row = $db->sql_fetchrow($result);
  323.  
  324.                                 if ( $row['user_password'] != md5($cur_password) )
  325.                                 {
  326.                                         $error = TRUE;
  327.                                         $error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $lang['Current_password_mismatch'];
  328.                                 }
  329.                         }
  330.  
  331.                         if ( !$error )
  332.                         {
  333.                                 $new_password = md5($new_password);
  334.                                 $passwd_sql = "user_password = '$new_password', ";
  335.                         }
  336.                 }
  337.         }
  338.         else if ( ( empty($new_password) && !empty($password_confirm) ) || ( !empty($new_password) && empty($password_confirm) ) )
  339.         {
  340.                 $error = TRUE;
  341.                 $error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $lang['Password_mismatch'];
  342.         }
  343.  
  344.         //
  345.         // Do a ban check on this email address
  346.         //
  347.         if ( $email != $userdata['user_email'] || $mode == 'register' )
  348.         {
  349.                 $result = validate_email($email);
  350.                 if ( $result['error'] )
  351.                 {
  352.                         $email = $userdata['user_email'];
  353.  
  354.                         $error = TRUE;
  355.                         $error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $result['error_msg'];
  356.                 }
  357.  
  358.                 if ( $mode == 'editprofile' )
  359.                 {
  360.                         $sql = "SELECT user_password
  361.                                 FROM " . USERS_TABLE . "
  362.                                 WHERE user_id = $user_id";
  363.                         if ( !($result = $db->sql_query($sql)) )
  364.                         {
  365.                                 message_die(GENERAL_ERROR, 'Could not obtain user_password information', '', __LINE__, __FILE__, $sql);
  366.                         }
  367.  
  368.                         $row = $db->sql_fetchrow($result);
  369.  
  370.                         if ( $row['user_password'] != md5($cur_password) )
  371.                         {
  372.                                 $email = $userdata['user_email'];
  373.  
  374.                                 $error = TRUE;
  375.                                 $error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $lang['Current_password_mismatch'];
  376.                         }
  377.                 }
  378.         }
  379.  
  380.         $username_sql = '';
  381.         if ( $board_config['allow_namechange'] || $mode == 'register' )
  382.         {
  383.                 if ( empty($username) )
  384.                 {
  385.                         // Error is already triggered, since one field is empty.
  386.                         $error = TRUE;
  387.                 }
  388.                 else if ( $username != $userdata['username'] || $mode == 'register' )
  389.                 {
  390.                         if (strtolower($username) != strtolower($userdata['username']))
  391.                         {
  392.                                 $result = validate_username($username);
  393.                                 if ( $result['error'] )
  394.                                 {
  395.                                         $error = TRUE;
  396.                                         $error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $result['error_msg'];
  397.                                 }
  398.                         }
  399.  
  400.                         if (!$error)
  401.                         {
  402.                                 $username_sql = "username = '" . str_replace("\'", "''", $username) . "', ";
  403.                         }
  404.                 }
  405.         }
  406.  
  407.         if ( $signature != '' )
  408.         {
  409.                 if ( strlen($signature) > $board_config['max_sig_chars'] )
  410.                 {
  411.                         $error = TRUE;
  412.                         $error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $lang['Signature_too_long'];
  413.                 }
  414.  
  415.                 if ( $signature_bbcode_uid == '' )
  416.                 {
  417.                         $signature_bbcode_uid = ( $allowbbcode ) ? make_bbcode_uid() : '';
  418.                 }
  419.                 $signature = prepare_message($signature, $allowhtml, $allowbbcode, $allowsmilies, $signature_bbcode_uid);
  420.         }
  421.  
  422.         if ( $website != '' )
  423.         {
  424.                 rawurlencode($website);
  425.         }
  426.  
  427.         $avatar_sql = '';
  428.  
  429.         if ( isset($HTTP_POST_VARS['avatardel']) && $mode == 'editprofile' )
  430.         {
  431.                 $avatar_sql = user_avatar_delete($userdata['user_avatar_type'], $userdata['user_avatar']);
  432.         }
  433.  
  434.         if ( ( !empty($user_avatar_upload) || !empty($user_avatar_name) ) && $board_config['allow_avatar_upload'] )
  435.         {
  436.                 if ( !empty($user_avatar_upload) )
  437.                 {
  438.                         $avatar_mode = ( !empty($user_avatar_name) ) ? 'local' : 'remote';
  439.                         $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);
  440.                 }
  441.                 else if ( !empty($user_avatar_name) )
  442.                 {
  443.                         $l_avatar_size = sprintf($lang['Avatar_filesize'], round($board_config['avatar_filesize'] / 1024));
  444.  
  445.                         $error = true;
  446.                         $error_msg .= ( ( !empty($error_msg) ) ? '<br />' : '' ) . $l_avatar_size;
  447.                 }
  448.         }
  449.         else if ( $user_avatar_remoteurl != '' && $board_config['allow_avatar_remote'] )
  450.         {
  451.                 if ( @file_exists(@phpbb_realpath('./' . $board_config['avatar_path'] . '/' . $userdata['user_avatar'])) )
  452.                 {
  453.                         @unlink(@phpbb_realpath('./' . $board_config['avatar_path'] . '/' . $userdata['user_avatar']));
  454.                 }
  455.                 $avatar_sql = user_avatar_url($mode, $error, $error_msg, $user_avatar_remoteurl);
  456.         }
  457.         else if ( $user_avatar_local != '' && $board_config['allow_avatar_local'] )
  458.         {
  459.                 if ( @file_exists(@phpbb_realpath('./' . $board_config['avatar_path'] . '/' . $userdata['user_avatar'])) )
  460.                 {
  461.                         @unlink(@phpbb_realpath('./' . $board_config['avatar_path'] . '/' . $userdata['user_avatar']));
  462.                 }
  463.                 $avatar_sql = user_avatar_gallery($mode, $error, $error_msg, $user_avatar_local);
  464.         }
  465.  
  466.         if ( !$error )
  467.         {
  468.                 if ( $avatar_sql == '' )
  469.                 {
  470.                         $avatar_sql = ( $mode == 'editprofile' ) ? '' : "'', " . USER_AVATAR_NONE;
  471.                 }
  472.  
  473.                 if ( $mode == 'editprofile' )
  474.                 {
  475.                         if ( $email != $userdata['user_email'] && $board_config['require_activation'] != USER_ACTIVATION_NONE && $userdata['user_level'] != ADMIN )
  476.                         {
  477.                                 $user_active = 0;
  478.  
  479.                                 $user_actkey = gen_rand_string(true);
  480.                                 $key_len = 54 - ( strlen($server_url) );
  481.                                 $key_len = ( $key_len > 6 ) ? $key_len : 6;
  482.                                 $user_actkey = substr($user_actkey, 0, $key_len);
  483.  
  484.                                 if ( $userdata['session_logged_in'] )
  485.                                 {
  486.                                         session_end($userdata['sid'], $userdata['user_id']);
  487.                                 }
  488.                         }
  489.                         else
  490.                         {
  491.                                 $user_active = 1;
  492.                                 $user_actkey = '';
  493.                         }
  494.  
  495.                         $sql = "UPDATE " . USERS_TABLE . "
  496.                                 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 . "
  497.                                 WHERE user_id = $user_id";
  498.                         if ( !($result = $db->sql_query($sql)) )
  499.                         {
  500.                                 message_die(GENERAL_ERROR, 'Could not update users table', '', __LINE__, __FILE__, $sql);
  501.                         } else {
  502.                             // The database "Stuff" has been done, but the nuke theme is "cookie-based" until they relog-in
  503.                             // Lets re-set the cookie now huh ;)
  504.  
  505.                             getusrinfo($user);
  506.                                     docookie($userinfo[user_id],$userinfo[username],$userinfo[user_password],$userinfo[storynum],$userinfo[umode],$userinfo[uorder],$userinfo[thold],$userinfo[noscore],$userinfo[ublockon],$userinfo[theme],$userinfo[commentmax]);
  507.                         }
  508.  
  509.                         if ( !$user_active )
  510.                         {
  511.                                 //
  512.                                 // The users account has been deactivated, send them an email with a new activation key
  513.                                 //
  514.                                 include("includes/emailer.php");
  515.                                 $emailer = new emailer($board_config['smtp_delivery']);
  516.  
  517.                                 $emailer->from($board_config['board_email']);
  518.                                 $emailer->replyto($board_config['board_email']);
  519.  
  520.                                 $emailer->use_template('user_activate', stripslashes($user_lang));
  521.                                 $emailer->email_address($email);
  522.                                 $emailer->set_subject($lang['Reactivate']);
  523.  
  524.                                 $emailer->assign_vars(array(
  525.                                         'SITENAME' => $board_config['sitename'],
  526.                                         'USERNAME' => preg_replace($unhtml_specialchars_match, $unhtml_specialchars_replace, substr(str_replace("\'", "'", $username), 0, 25)),
  527.                                         'EMAIL_SIG' => (!empty($board_config['board_email_sig'])) ? str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']) : '',
  528.  
  529.                                         'U_ACTIVATE' => $server_url . '&mode=activate&' . POST_USERS_URL . '=' . $user_id . '&act_key=' . $user_actkey)
  530.                                 );
  531.                                 $emailer->send();
  532.                                 $emailer->reset();
  533.  
  534.                                 if (is_active("Forums")) {
  535.                                         $message = $lang['Profile_updated_inactive'] . '<br /><br />' . sprintf($lang['Click_return_index'],  '<a href="' . append_sid("index.$phpEx") . '">', '</a>');
  536.                                 } else {
  537.                                         $message = $lang['Profile_updated_inactive'] . '<br /><br />' . sprintf($lang['Click_return_index'],  '<a href="index.php">', '</a>');
  538.                                 }
  539.                         }
  540.                         else
  541.                         {
  542.                                 if (is_active("Forums")) {
  543.                                         $message = $lang['Profile_updated'] . '<br /><br />' . sprintf($lang['Click_return_index'],  '<a href="' . append_sid("index.$phpEx") . '">', '</a>');
  544.                                 } else {
  545.                                             $message = $lang['Profile_updated'] . '<br /><br />' . sprintf($lang['Click_return_index'],  '<a href="index.php">', '</a>');
  546.                                 }
  547.                         }
  548.  
  549. //                            $template->assign_vars(array(
  550. //                        "META" => '<meta http-equiv="refresh" content="5;url=' . append_sid("index.$phpEx") . '">')
  551. //                        );
  552.  
  553.                         message_die(GENERAL_MESSAGE, $message);
  554.                 }
  555.                 else
  556.                 {
  557.                         $sql = "SELECT MAX(user_id) AS total
  558.                                 FROM " . USERS_TABLE;
  559.                         if ( !($result = $db->sql_query($sql)) )
  560.                         {
  561.                                 message_die(GENERAL_ERROR, 'Could not obtain next user_id information', '', __LINE__, __FILE__, $sql);
  562.                         }
  563.  
  564.                         if ( !($row = $db->sql_fetchrow($result)) )
  565.                         {
  566.                                 message_die(GENERAL_ERROR, 'Could not obtain next user_id information', '', __LINE__, __FILE__, $sql);
  567.                         }
  568.                         $user_id = $row['total'] + 1;
  569.  
  570.                         //
  571.                         // Get current date
  572.                         //
  573.                         $reg_date = date("M d, Y");
  574.                         $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)
  575.                                 VALUES ($user_id, '" . str_replace("\'", "''", $username) . "', '" . $reg_date . "', '" . 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, 1, 1, ";
  576.                         if ( $board_config['require_activation'] == USER_ACTIVATION_SELF || $board_config['require_activation'] == USER_ACTIVATION_ADMIN || $coppa )
  577.                         {
  578.                                 $user_actkey = gen_rand_string(true);
  579.                                 $key_len = 54 - (strlen($server_url));
  580.                                 $key_len = ( $key_len > 6 ) ? $key_len : 6;
  581.                                 $user_actkey = substr($user_actkey, 0, $key_len);
  582.                                 $sql .= "0, '" . str_replace("\'", "''", $user_actkey) . "')";
  583.                         }
  584.                         else
  585.                         {
  586.                                 $sql .= "1, '')";
  587.                         }
  588.  
  589.                         if ( !($result = $db->sql_query($sql, BEGIN_TRANSACTION)) )
  590.                         {
  591.                                 message_die(GENERAL_ERROR, 'Could not insert data into users table', '', __LINE__, __FILE__, $sql);
  592.                         }
  593.  
  594.                         $sql = "INSERT INTO " . GROUPS_TABLE . " (group_name, group_description, group_single_user, group_moderator)
  595.                                 VALUES ('', 'Personal User', 1, 0)";
  596.                         if ( !($result = $db->sql_query($sql)) )
  597.                         {
  598.                                 message_die(GENERAL_ERROR, 'Could not insert data into groups table', '', __LINE__, __FILE__, $sql);
  599.                         }
  600.  
  601.                         $group_id = $db->sql_nextid();
  602.  
  603.                         $sql = "INSERT INTO " . USER_GROUP_TABLE . " (user_id, group_id, user_pending)
  604.                                 VALUES ($user_id, $group_id, 0)";
  605.                         if( !($result = $db->sql_query($sql, END_TRANSACTION)) )
  606.                         {
  607.                                 message_die(GENERAL_ERROR, 'Could not insert data into user_group table', '', __LINE__, __FILE__, $sql);
  608.                         }
  609.  
  610.                         if ( $coppa )
  611.                         {
  612.                                 $message = $lang['COPPA'];
  613.                                 $email_template = 'coppa_welcome_inactive';
  614.                         }
  615.                         else if ( $board_config['require_activation'] == USER_ACTIVATION_SELF )
  616.                         {
  617.                                 $message = $lang['Account_inactive'];
  618.                                 $email_template = 'user_welcome_inactive';
  619.                         }
  620.                         else if ( $board_config['require_activation'] == USER_ACTIVATION_ADMIN )
  621.                         {
  622.                                 $message = $lang['Account_inactive_admin'];
  623.                                 $email_template = 'admin_welcome_inactive';
  624.                         }
  625.                         else
  626.                         {
  627.                                 $message = $lang['Account_added'];
  628.                                 $email_template = 'user_welcome';
  629.                         }
  630.  
  631.                         include("includes/emailer.php");
  632.                         $emailer = new emailer($board_config['smtp_delivery']);
  633.  
  634.                         $emailer->from($board_config['board_email']);
  635.                         $emailer->replyto($board_config['board_email']);
  636.  
  637.                         $emailer->use_template($email_template, stripslashes($user_lang));
  638.                         $emailer->email_address($email);
  639.                         $emailer->set_subject(sprintf($lang['Welcome_subject'], $board_config['sitename']));
  640.  
  641.                         if( $coppa )
  642.                         {
  643.                                 $emailer->assign_vars(array(
  644.                                         'SITENAME' => $board_config['sitename'],
  645.                                         'WELCOME_MSG' => sprintf($lang['Welcome_subject'], $board_config['sitename']),
  646.                                         'USERNAME' => preg_replace($unhtml_specialchars_match, $unhtml_specialchars_replace, substr(str_replace("\'", "'", $username), 0, 25)),
  647.                                         'PASSWORD' => $password_confirm,
  648.                                         'EMAIL_SIG' => str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']),
  649.  
  650.                                         'FAX_INFO' => $board_config['coppa_fax'],
  651.                                         'MAIL_INFO' => $board_config['coppa_mail'],
  652.                                         'EMAIL_ADDRESS' => $email,
  653.                                         'ICQ' => $icq,
  654.                                         'AIM' => $aim,
  655.                                         'YIM' => $yim,
  656.                                         'MSN' => $msn,
  657.                                         'WEB_SITE' => $website,
  658.                                         'FROM' => $location,
  659.                                         'OCC' => $occupation,
  660.                                         'INTERESTS' => $interests,
  661.                                         'SITENAME' => $board_config['sitename']));
  662.                         }
  663.                         else
  664.                         {
  665.                                 $emailer->assign_vars(array(
  666.                                         'SITENAME' => $board_config['sitename'],
  667.                                         'WELCOME_MSG' => sprintf($lang['Welcome_subject'], $board_config['sitename']),
  668.                                         'USERNAME' => preg_replace($unhtml_specialchars_match, $unhtml_specialchars_replace, substr(str_replace("\'", "'", $username), 0, 25)),
  669.                                         'PASSWORD' => $password_confirm,
  670.                                         'EMAIL_SIG' => str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']),
  671.  
  672.                                         'U_ACTIVATE' => $server_url . '&mode=activate&' . POST_USERS_URL . '=' . $user_id . '&act_key=' . $user_actkey)
  673.                                 );
  674.                         }
  675.  
  676.                         $emailer->send();
  677.                         $emailer->reset();
  678.  
  679.                         if ( $board_config['require_activation'] == USER_ACTIVATION_ADMIN )
  680.                         {
  681.                                 $sql = "SELECT user_email, user_lang
  682.                                         FROM " . USERS_TABLE . "
  683.                                         WHERE user_level = " . ADMIN;
  684.  
  685.                                 if ( !($result = $db->sql_query($sql)) )
  686.                                 {
  687.                                         message_die(GENERAL_ERROR, 'Could not select Administrators', '', __LINE__, __FILE__, $sql);
  688.                                 }
  689.  
  690.                                 while ($row = $db->sql_fetchrow($result))
  691.                                 {
  692.                     $emailer->from($board_config['board_email']);
  693.                     $emailer->replyto($board_config['board_email']);
  694.                     
  695.                     $emailer->email_address(trim($row['user_email']));
  696.                     $emailer->use_template("admin_activate", $row['user_lang']);
  697.                                 $emailer->set_subject($lang['New_account_subject']);
  698.  
  699.                                 $emailer->assign_vars(array(
  700.                                         'USERNAME' => preg_replace($unhtml_specialchars_match, $unhtml_specialchars_replace, substr(str_replace("\'", "'", $username), 0, 25)),
  701.                                         'EMAIL_SIG' => str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']),
  702.  
  703.                                         'U_ACTIVATE' => $server_url . '&mode=activate&' . POST_USERS_URL . '=' . $user_id . '&act_key=' . $user_actkey)
  704.                                 );
  705.                                 $emailer->send();
  706.                                 $emailer->reset();
  707.                         }
  708.                 $db->sql_freeresult($result);
  709.             }
  710.                         $message = $message . '<br /><br />' . sprintf($lang['Click_return_index'],  '<a href="' . append_sid("index.$phpEx") . '">', '</a>');
  711.  
  712.                         message_die(GENERAL_MESSAGE, $message);
  713.                 } // if mode == register
  714.         }
  715. } // End of submit
  716.  
  717.  
  718. if ( $error )
  719. {
  720.         //
  721.         // If an error occured we need to stripslashes on returned data
  722.         //
  723.         $username = stripslashes($username);
  724.         $email = stripslashes($email);
  725.         $new_password = '';
  726.         $password_confirm = '';
  727.  
  728.         $icq = stripslashes($icq);
  729.         $aim = str_replace('+', ' ', stripslashes($aim));
  730.         $msn = stripslashes($msn);
  731.         $yim = stripslashes($yim);
  732.  
  733.         $website = stripslashes($website);
  734.         $location = stripslashes($location);
  735.         $occupation = stripslashes($occupation);
  736.         $interests = stripslashes($interests);
  737.         $signature = stripslashes($signature);
  738.         $signature = ($signature_bbcode_uid != '') ? preg_replace("/:(([a-z0-9]+:)?)$signature_bbcode_uid(=|\])/si", '\\3', $signature) : $signature;
  739.  
  740.         $user_lang = stripslashes($user_lang);
  741.         $user_dateformat = stripslashes($user_dateformat);
  742.  
  743. }
  744. else if ( $mode == 'editprofile' && !isset($HTTP_POST_VARS['avatargallery']) && !isset($HTTP_POST_VARS['submitavatar']) && !isset($HTTP_POST_VARS['cancelavatar']) )
  745. {
  746.         $user_id = $userdata['user_id'];
  747.         $username = $userdata['username'];
  748.         $email = $userdata['user_email'];
  749.         $new_password = '';
  750.         $password_confirm = '';
  751.  
  752.         $icq = $userdata['user_icq'];
  753.         $aim = str_replace('+', ' ', $userdata['user_aim']);
  754.         $msn = $userdata['user_msnm'];
  755.         $yim = $userdata['user_yim'];
  756.  
  757.         $website = $userdata['user_website'];
  758.         $userdata['user_from'] = str_replace(".gif", "", $userdata['user_from']);
  759.         $location = $userdata['user_from'];
  760.         $occupation = $userdata['user_occ'];
  761.         $interests = $userdata['user_interests'];
  762.         $signature_bbcode_uid = $userdata['user_sig_bbcode_uid'];
  763.         $signature = ($signature_bbcode_uid != '') ? preg_replace("/:(([a-z0-9]+:)?)$signature_bbcode_uid(=|\])/si", '\\3', $userdata['user_sig']) : $userdata['user_sig'];
  764.  
  765.         $viewemail = $userdata['user_viewemail'];
  766.         $notifypm = $userdata['user_notify_pm'];
  767.         $popup_pm = $userdata['user_popup_pm'];
  768.         $notifyreply = $userdata['user_notify'];
  769.         $attachsig = $userdata['user_attachsig'];
  770.         $allowhtml = $userdata['user_allowhtml'];
  771.         $allowbbcode = $userdata['user_allowbbcode'];
  772.         $allowsmilies = $userdata['user_allowsmile'];
  773.         $allowviewonline = $userdata['user_allow_viewonline'];
  774.  
  775.         $user_avatar = ( $userdata['user_allowavatar'] ) ? $userdata['user_avatar'] : '';
  776.         $user_avatar_type = ( $userdata['user_allowavatar'] ) ? $userdata['user_avatar_type'] : USER_AVATAR_NONE;
  777.  
  778.         $user_style = $userdata['user_style'];
  779.         $user_lang = $userdata['user_lang'];
  780.         $user_timezone = $userdata['user_timezone'];
  781.         $user_dateformat = $userdata['user_dateformat'];
  782. }
  783.  
  784. //
  785. // Default pages
  786. //
  787. include("includes/page_header.php");
  788.  
  789. make_jumpbox('viewforum.'.$phpEx);
  790.  
  791. if ( $mode == 'editprofile' )
  792. {
  793.         if ( $user_id != $userdata['user_id'] )
  794.         {
  795.                 $error = TRUE;
  796.                 $error_msg = $lang['Wrong_Profile'];
  797.         }
  798. }
  799.  
  800. if( isset($HTTP_POST_VARS['avatargallery']) && !$error )
  801. {
  802.         include("includes/usercp_avatar.php");
  803.  
  804.         $avatar_category = ( !empty($HTTP_POST_VARS['avatarcategory']) ) ? $HTTP_POST_VARS['avatarcategory'] : '';
  805.  
  806.         $template->set_filenames(array(
  807.                 'body' => 'profile_avatar_gallery.tpl')
  808.         );
  809.  
  810.         $allowviewonline = !$allowviewonline;
  811.  
  812.         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']);
  813. }
  814. else
  815. {
  816.         include("includes/functions_selects.php");
  817.  
  818.         if ( !isset($coppa) )
  819.         {
  820.                 $coppa = FALSE;
  821.         }
  822.  
  823.         if ( !isset($user_template) )
  824.         {
  825.                 $selected_template = $board_config['system_template'];
  826.         }
  827.  
  828.         $avatar_img = '';
  829.         if ( $user_avatar_type )
  830.         {
  831.                 switch( $user_avatar_type )
  832.                 {
  833.                         case USER_AVATAR_UPLOAD:
  834.                                 $avatar_img = ( $board_config['allow_avatar_upload'] ) ? '<img src="' . $board_config['avatar_path'] . '/' . $user_avatar . '" alt="" />' : '';
  835.                                 break;
  836.                         case USER_AVATAR_REMOTE:
  837.                                 $avatar_img = ( $board_config['allow_avatar_remote'] ) ? '<img src="' . $user_avatar . '" alt="" />' : '';
  838.                                 break;
  839.                         case USER_AVATAR_GALLERY:
  840.                                 $avatar_img = ( $board_config['allow_avatar_local'] ) ? '<img src="' . $board_config['avatar_gallery_path'] . '/' . $user_avatar . '" alt="" />' : '';
  841.                                 break;
  842.                 }
  843.         }
  844.  
  845.         $s_hidden_fields = '<input type="hidden" name="mode" value="' . $mode . '" /><input type="hidden" name="agreed" value="true" /><input type="hidden" name="coppa" value="' . $coppa . '" />';
  846.         if( $mode == 'editprofile' )
  847.         {
  848.                 $s_hidden_fields .= '<input type="hidden" name="user_id" value="' . $userdata['user_id'] . '" />';
  849.                 //
  850.                 // Send the users current email address. If they change it, and account activation is turned on
  851.                 // the user account will be disabled and the user will have to reactivate their account.
  852.                 //
  853.                 $s_hidden_fields .= '<input type="hidden" name="current_email" value="' . $userdata['user_email'] . '" />';
  854.         }
  855.  
  856.         if ( !empty($user_avatar_local) )
  857.         {
  858.                 $s_hidden_fields .= '<input type="hidden" name="avatarlocal" value="' . $user_avatar_local . '" />';
  859.         }
  860.  
  861.         $html_status =  ( $userdata['user_allowhtml'] && $board_config['allow_html'] ) ? $lang['HTML_is_ON'] : $lang['HTML_is_OFF'];
  862.         $bbcode_status = ( $userdata['user_allowbbcode'] && $board_config['allow_bbcode']  ) ? $lang['BBCode_is_ON'] : $lang['BBCode_is_OFF'];
  863.         $smilies_status = ( $userdata['user_allowsmile'] && $board_config['allow_smilies']  ) ? $lang['Smilies_are_ON'] : $lang['Smilies_are_OFF'];
  864.  
  865.         if ( $error )
  866.         {
  867.                 $template->set_filenames(array(
  868.                         'reg_header' => 'error_body.tpl')
  869.                 );
  870.                 $template->assign_vars(array(
  871.                         'ERROR_MESSAGE' => $error_msg)
  872.                 );
  873.                 $template->assign_var_from_handle('ERROR_BOX', 'reg_header');
  874.         }
  875.  
  876.         $template->set_filenames(array(
  877.                 'body' => 'profile_add_body.tpl')
  878.         );
  879.  
  880.         if ( $mode == 'editprofile' )
  881.         {
  882.                 $template->assign_block_vars('switch_edit_profile', array());
  883.         }
  884.  
  885.         if ( ($mode == 'register') || ($board_config['allow_namechange']) )
  886.         {
  887.                 $template->assign_block_vars('switch_namechange_allowed', array());
  888.         }
  889.         else
  890.         {
  891.                 $template->assign_block_vars('switch_namechange_disallowed', array());
  892.         }
  893.  
  894.         //
  895.         // Let's do an overall check for settings/versions which would prevent
  896.         // us from doing file uploads....
  897.         //
  898.         $ini_val = ( phpversion() >= '4.0.0' ) ? 'ini_get' : 'get_cfg_var';
  899.         $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"';
  900.  
  901.         $template->assign_vars(array(
  902.                 'USERNAME' => $username,
  903.                 'CUR_PASSWORD' => $cur_password,
  904.                 'NEW_PASSWORD' => $new_password,
  905.                 'PASSWORD_CONFIRM' => $password_confirm,
  906.                 'EMAIL' => $email,
  907.                 'YIM' => $yim,
  908.                 'ICQ' => $icq,
  909.                 'MSN' => $msn,
  910.                 'AIM' => $aim,
  911.                 'OCCUPATION' => $occupation,
  912.                 'INTERESTS' => $interests,
  913.                 'LOCATION' => $location,
  914.                 'WEBSITE' => $website,
  915.                 'SIGNATURE' => str_replace('<br />', "\n", $signature),
  916.                 'VIEW_EMAIL_YES' => ( $viewemail ) ? 'checked="checked"' : '',
  917.                 'VIEW_EMAIL_NO' => ( !$viewemail ) ? 'checked="checked"' : '',
  918.                 'HIDE_USER_YES' => ( !$allowviewonline ) ? 'checked="checked"' : '',
  919.                 'HIDE_USER_NO' => ( $allowviewonline ) ? 'checked="checked"' : '',
  920.                 'NOTIFY_PM_YES' => ( $notifypm ) ? 'checked="checked"' : '',
  921.                 'NOTIFY_PM_NO' => ( !$notifypm ) ? 'checked="checked"' : '',
  922.                 'POPUP_PM_YES' => ( $popup_pm ) ? 'checked="checked"' : '',
  923.                 'POPUP_PM_NO' => ( !$popup_pm ) ? 'checked="checked"' : '',
  924.                 'ALWAYS_ADD_SIGNATURE_YES' => ( $attachsig ) ? 'checked="checked"' : '',
  925.                 'ALWAYS_ADD_SIGNATURE_NO' => ( !$attachsig ) ? 'checked="checked"' : '',
  926.                 'NOTIFY_REPLY_YES' => ( $notifyreply ) ? 'checked="checked"' : '',
  927.                 'NOTIFY_REPLY_NO' => ( !$notifyreply ) ? 'checked="checked"' : '',
  928.                 'ALWAYS_ALLOW_BBCODE_YES' => ( $allowbbcode ) ? 'checked="checked"' : '',
  929.                 'ALWAYS_ALLOW_BBCODE_NO' => ( !$allowbbcode ) ? 'checked="checked"' : '',
  930.                 'ALWAYS_ALLOW_HTML_YES' => ( $allowhtml ) ? 'checked="checked"' : '',
  931.                 'ALWAYS_ALLOW_HTML_NO' => ( !$allowhtml ) ? 'checked="checked"' : '',
  932.                 'ALWAYS_ALLOW_SMILIES_YES' => ( $allowsmilies ) ? 'checked="checked"' : '',
  933.                 'ALWAYS_ALLOW_SMILIES_NO' => ( !$allowsmilies ) ? 'checked="checked"' : '',
  934.                 'ALLOW_AVATAR' => $board_config['allow_avatar_upload'],
  935.                 'AVATAR' => $avatar_img,
  936.                 'AVATAR_SIZE' => $board_config['avatar_filesize'],
  937.                 'LANGUAGE_SELECT' => language_select($user_lang, 'language'),
  938.                 'STYLE_SELECT' => style_select($user_style, 'style'),
  939.                 'TIMEZONE_SELECT' => tz_select($user_timezone, 'timezone'),
  940.                 'DATE_FORMAT' => $user_dateformat,
  941.                 'HTML_STATUS' => $html_status,
  942.                 'BBCODE_STATUS' => sprintf($bbcode_status, '<a href="' . append_sid("faq.$phpEx?mode=bbcode") . '" target="_phpbbcode">', '</a>'),
  943.                 'SMILIES_STATUS' => $smilies_status,
  944.  
  945.                 'L_CURRENT_PASSWORD' => $lang['Current_password'],
  946.                 'L_NEW_PASSWORD' => ( $mode == 'register' ) ? $lang['Password'] : $lang['New_password'],
  947.                 'L_CONFIRM_PASSWORD' => $lang['Confirm_password'],
  948.                 'L_CONFIRM_PASSWORD_EXPLAIN' => ( $mode == 'editprofile' ) ? $lang['Confirm_password_explain'] : '',
  949.                 'L_PASSWORD_IF_CHANGED' => ( $mode == 'editprofile' ) ? $lang['password_if_changed'] : '',
  950.                 'L_PASSWORD_CONFIRM_IF_CHANGED' => ( $mode == 'editprofile' ) ? $lang['password_confirm_if_changed'] : '',
  951.                 'L_SUBMIT' => $lang['Submit'],
  952.                 'L_RESET' => $lang['Reset'],
  953.                 'L_ICQ_NUMBER' => $lang['ICQ'],
  954.                 'L_MESSENGER' => $lang['MSNM'],
  955.                 'L_YAHOO' => $lang['YIM'],
  956.                 'L_WEBSITE' => $lang['Website'],
  957.                 'L_AIM' => $lang['AIM'],
  958.                 'L_LOCATION' => $lang['Location'],
  959.                 'L_OCCUPATION' => $lang['Occupation'],
  960.                 'L_BOARD_LANGUAGE' => $lang['Board_lang'],
  961.                 'L_BOARD_STYLE' => $lang['Board_style'],
  962.                 'L_TIMEZONE' => $lang['Timezone'],
  963.                 'L_DATE_FORMAT' => $lang['Date_format'],
  964.                 'L_DATE_FORMAT_EXPLAIN' => $lang['Date_format_explain'],
  965.                 'L_YES' => $lang['Yes'],
  966.                 'L_NO' => $lang['No'],
  967.                 'L_INTERESTS' => $lang['Interests'],
  968.                 'L_ALWAYS_ALLOW_SMILIES' => $lang['Always_smile'],
  969.                 'L_ALWAYS_ALLOW_BBCODE' => $lang['Always_bbcode'],
  970.                 'L_ALWAYS_ALLOW_HTML' => $lang['Always_html'],
  971.                 'L_HIDE_USER' => $lang['Hide_user'],
  972.                 'L_ALWAYS_ADD_SIGNATURE' => $lang['Always_add_sig'],
  973.  
  974.                 'L_AVATAR_PANEL' => $lang['Avatar_panel'],
  975.                 'L_AVATAR_EXPLAIN' => sprintf($lang['Avatar_explain'], $board_config['avatar_max_width'], $board_config['avatar_max_height'], (round($board_config['avatar_filesize'] / 1024))),
  976.                 'L_UPLOAD_AVATAR_FILE' => $lang['Upload_Avatar_file'],
  977.                 'L_UPLOAD_AVATAR_URL' => $lang['Upload_Avatar_URL'],
  978.                 'L_UPLOAD_AVATAR_URL_EXPLAIN' => $lang['Upload_Avatar_URL_explain'],
  979.                 'L_AVATAR_GALLERY' => $lang['Select_from_gallery'],
  980.                 'L_SHOW_GALLERY' => $lang['View_avatar_gallery'],
  981.                 'L_LINK_REMOTE_AVATAR' => $lang['Link_remote_Avatar'],
  982.                 'L_LINK_REMOTE_AVATAR_EXPLAIN' => $lang['Link_remote_Avatar_explain'],
  983.                 'L_DELETE_AVATAR' => $lang['Delete_Image'],
  984.                 'L_CURRENT_IMAGE' => $lang['Current_Image'],
  985.  
  986.                 'L_SIGNATURE' => $lang['Signature'],
  987.                 'L_SIGNATURE_EXPLAIN' => sprintf($lang['Signature_explain'], $board_config['max_sig_chars']),
  988.                 'L_NOTIFY_ON_REPLY' => $lang['Always_notify'],
  989.                 'L_NOTIFY_ON_REPLY_EXPLAIN' => $lang['Always_notify_explain'],
  990.                 'L_NOTIFY_ON_PRIVMSG' => $lang['Notify_on_privmsg'],
  991.                 'L_POPUP_ON_PRIVMSG' => $lang['Popup_on_privmsg'],
  992.                 'L_POPUP_ON_PRIVMSG_EXPLAIN' => $lang['Popup_on_privmsg_explain'],
  993.                 'L_PREFERENCES' => $lang['Preferences'],
  994.                 'L_PUBLIC_VIEW_EMAIL' => $lang['Public_view_email'],
  995.                 'L_ITEMS_REQUIRED' => $lang['Items_required'],
  996.                 'L_REGISTRATION_INFO' => $lang['Registration_info'],
  997.                 'L_PROFILE_INFO' => $lang['Profile_info'],
  998.                 'L_PROFILE_INFO_NOTICE' => $lang['Profile_info_warn'],
  999.                 'L_EMAIL_ADDRESS' => $lang['Email_address'],
  1000.  
  1001.                 'S_ALLOW_AVATAR_UPLOAD' => $board_config['allow_avatar_upload'],
  1002.                 'S_ALLOW_AVATAR_LOCAL' => $board_config['allow_avatar_local'],
  1003.                 'S_ALLOW_AVATAR_REMOTE' => $board_config['allow_avatar_remote'],
  1004.                 'S_HIDDEN_FIELDS' => $s_hidden_fields,
  1005.                 'S_FORM_ENCTYPE' => $form_enctype,
  1006.                 'S_PROFILE_ACTION' => append_sid("profile.$phpEx"))
  1007.         );
  1008.  
  1009.         //
  1010.         // This is another cheat using the block_var capability
  1011.         // of the templates to 'fake' an IF...ELSE...ENDIF solution
  1012.         // it works well :)
  1013.         //
  1014.         if ( $mode != 'register' )
  1015.         {
  1016.                 if ( $userdata['user_allowavatar'] && ( $board_config['allow_avatar_upload'] || $board_config['allow_avatar_local'] || $board_config['allow_avatar_remote'] ) )
  1017.                 {
  1018.                         $template->assign_block_vars('switch_avatar_block', array() );
  1019.  
  1020.                         if ( $board_config['allow_avatar_upload'] && file_exists(@phpbb_realpath('./' . $board_config['avatar_path'])) )
  1021.                         {
  1022.                                 if ( $form_enctype != '' )
  1023.                                 {
  1024.                                         $template->assign_block_vars('switch_avatar_block.switch_avatar_local_upload', array() );
  1025.                                 }
  1026.                                 $template->assign_block_vars('switch_avatar_block.switch_avatar_remote_upload', array() );
  1027.                         }
  1028.  
  1029.                         if ( $board_config['allow_avatar_remote'] )
  1030.                         {
  1031.                                 $template->assign_block_vars('switch_avatar_block.switch_avatar_remote_link', array() );
  1032.                         }
  1033.  
  1034.                         if ( $board_config['allow_avatar_local'] && file_exists(@phpbb_realpath('./' . $board_config['avatar_gallery_path'])) )
  1035.                         {
  1036.                                 $template->assign_block_vars('switch_avatar_block.switch_avatar_local_gallery', array() );
  1037.                         }
  1038.                 }
  1039.         }
  1040. }
  1041.  
  1042. function docookie($setuser_id, $setusername, $setuser_password, $setstorynum, $setumode, $setuorder, $setthold, $setnoscore, $setublockon, $settheme, $setcommentmax) {
  1043.     $info = base64_encode("$setuser_id:$setusername:$setuser_password:$setstorynum:$setumode:$setuorder:$setthold:$setnoscore:$setublockon:$settheme:$setcommentmax");
  1044.     setcookie("user","$info",time()+15552000);
  1045. }
  1046. $template->pparse('body');
  1047.  
  1048. include("includes/page_tail.php");
  1049.  
  1050. ?>