phpBB 2.0.17 to 2.0.18 Code Changes

These are the code changes introduced between phpBB 2.0.17 and phpBB 2.0.18. If you have installed many hacks on a forum, but wish to update it, these may help you. It is often easier to apply code changes such as these instead of replacing and rehacking your current files.

These code changes use the following instruction labels:
filename - The name of a file to be edited. Equivalent to an OPEN action in a hack or modification.
FIND - This indicates lines of code you should locate. Changes will be made in reference to this code.
REPLACE WITH - This code should completely replace the code in the preceding FIND instruction.
AFTER, ADD - The code in this instruction should be added on a new line after the last line of code in the preceding FIND instruction.
BEFORE, ADD - The code in this instruction should be added on a new line before the first line of code in the preceding FIND instruction.
FIND AND DELETE - Locate the code in this instruction as with a FIND statement, and then delete the code.

Once you have completed the code changes, create an install/ directory in your forum's root directory, and upload the update_to_latest.php file that comes in any phpBB 2.0.18 download to the install/ directory. Run update_to_latest.php by opening it via your web browser, just as you would a normal forum page. Afterward, delete the file and the install/ directory so that your forum is accessible again. This step updates your database to the current version and is very important. Failing to follow these instructions will cause errors to appear on your forum.

Now, onward to the file changes!

common.php
FIND
Code:
// The following code (unsetting globals) was contributed by Matt Kavanagh

// PHP5 with register_long_arrays off?
if (!isset($HTTP_POST_VARS) && isset($_POST))
REPLACE WITH
Code:
// The following code (unsetting globals)
// Thanks to Matt Kavanagh and Stefan Esser for providing feedback as well as patch files

// PHP5 with register_long_arrays off?
if (@phpversion() >= '5.0.0' && (!@ini_get('register_long_arrays') || @ini_get('register_long_arrays') == '0' || strtolower(@ini_get('register_long_arrays')) == 'off'))
FIND
Code:
if (@phpversion() < '4.0.0')
{
   // PHP3 path; in PHP3, globals are _always_ registered
   
   // We 'flip' the array of variables to test like this so that
   // we can validate later with isset($test[$var]) (no in_array())
   $test = array('HTTP_GET_VARS' => NULL, 'HTTP_POST_VARS' => NULL, 'HTTP_COOKIE_VARS' => NULL, 'HTTP_SERVER_VARS' => NULL, 'HTTP_ENV_VARS' => NULL, 'HTTP_POST_FILES' => NULL, 'phpEx' => NULL, 'phpbb_root_path' => NULL);

   // Loop through each input array
   @reset($test);
   while (list($input,) = @each($test))
   {
      while (list($var,) = @each($$input))
      {
         // Validate the variable to be unset
         if (!isset($test[$var]) && $var != 'test' && $var != 'input')
         {
            unset($$var);
         }
      }
   }
}
else if (@ini_get('register_globals') == '1' || strtolower(@ini_get('register_globals')) == 'on')
REPLACE WITH
Code:
// Protect against GLOBALS tricks
if (isset($HTTP_POST_VARS['GLOBALS']) || isset($HTTP_POST_FILES['GLOBALS']) || isset($HTTP_GET_VARS['GLOBALS']) || isset($HTTP_COOKIE_VARS['GLOBALS']))
{
   die("Hacking attempt");
}

// Protect against HTTP_SESSION_VARS tricks
if (isset($HTTP_SESSION_VARS) && !is_array($HTTP_SESSION_VARS))
{
   die("Hacking attempt");
}

if (@ini_get('register_globals') == '1' || strtolower(@ini_get('register_globals')) == 'on')
FIND
Code:
   if (!isset($HTTP_SESSION_VARS))
REPLACE WITH
Code:
   if (!isset($HTTP_SESSION_VARS) || !is_array($HTTP_SESSION_VARS))
The line before unset($input); contains two spaces. The objective here is to delete these. FIND
Code:
 
   unset($input);
REPLACE WITH
Code:

   unset($input);
FIND
Code:
   header("Location: install/install.$phpEx");
REPLACE WITH
Code:
   header('Location: ' . $phpbb_root_path . 'install/install.' . $phpEx);
FIND
Code:
include($phpbb_root_path . 'includes/db.'.$phpEx);
AFTER, ADD
Code:

// We do not need this any longer, unset for safety purposes
unset($dbpasswd);
groupcp.php
FIND
Code:
   $temp_url = append_sid("search.$phpEx?search_author=" . urlencode($username) . "&amp;showresults=posts");
   $search_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_search'] . '" alt="' . $lang['Search_user_posts'] . '" title="' . $lang['Search_user_posts'] . '" border="0" /></a>';
   $search = '<a href="' . $temp_url . '">' . $lang['Search_user_posts'] . '</a>';
REPLACE WITH
Code:
   $temp_url = append_sid("search.$phpEx?search_author=" . urlencode($row['username']) . "&amp;showresults=posts");
   $search_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_search'] . '" alt="' . sprintf($lang['Search_user_posts'], $row['username']) . '" title="' . sprintf($lang['Search_user_posts'], $row['username']) . '" border="0" /></a>';
   $search = '<a href="' . $temp_url . '">' . sprintf($lang['Search_user_posts'], $row['username']) . '</a>';
FIND
Code:
      //
      // Load and process templates
      //
AFTER, ADD
Code:
      $page_title = $lang['Group_Control_Panel'];
index.php
FIND
Code:
   if ( $userdata['session_logged_in'] )
   {
      $sql = "SELECT t.forum_id, t.topic_id, p.post_time
REPLACE WITH
Code:
   if ($userdata['session_logged_in'])
   {
      // 60 days limit
      if ($userdata['user_lastvisit'] < (time() - 5184000))
      {
         $userdata['user_lastvisit'] = time() - 5184000;
      }

      $sql = "SELECT t.forum_id, t.topic_id, p.post_time
login.php
FIND
Code:
   else if( ( isset($HTTP_GET_VARS['logout']) || isset($HTTP_POST_VARS['logout']) ) && $userdata['session_logged_in'] )
   {
AFTER, ADD
Code:
      // session id check
      if ($sid == '' || $sid != $userdata['session_id'])
      {
         message_die(GENERAL_ERROR, 'Invalid_session');
      }
FIND
Code:
      if( isset($HTTP_POST_VARS['redirect']) || isset($HTTP_GET_VARS['redirect']) )
      {
         $forward_to = $HTTP_SERVER_VARS['QUERY_STRING'];
BEFORE, ADD
Code:
      $forward_page = '';
FIND AND DELETE
Code:
               $forward_page = '';
FIND AND DELETE
Code:
      else
      {
         $forward_page = '';
      }
FIND
Code:
      make_jumpbox('viewforum.'.$phpEx, $forum_id);
REPLACE WITH
Code:
      make_jumpbox('viewforum.'.$phpEx);
memberlist.php
FIND
Code:
$mode_types = array('joindate', 'username', 'location', 'posts', 'email', 'website', 'topten');
REPLACE WITH
Code:
$mode_types = array('joined', 'username', 'location', 'posts', 'email', 'website', 'topten');
modcp.php
FIND
Code:
         message_die(MESSAGE, sprintf($lang['Sorry_auth_delete'], $is_auth['auth_delete_type']));
REPLACE WITH
Code:
         message_die(GENERAL_MESSAGE, sprintf($lang['Sorry_auth_delete'], $is_auth['auth_delete_type']));
FIND
Code:
               'U_SEARCHPOSTS' => append_sid("search.$phpEx?search_author=" . urlencode($username) . "&amp;showresults=topics"))
REPLACE WITH
Code:
               'U_SEARCHPOSTS' => append_sid("search.$phpEx?search_author=" . (($id == ANONYMOUS) ? 'Anonymous' : urlencode($username)) . "&amp;showresults=topics"))
posting.php
FIND
Code:
$refresh = $preview || $poll_add || $poll_edit || $poll_delete;
AFTER, ADD
Code:
$orig_word = $replacement_word = array();
FIND
Code:
$topic_type = ( !empty($HTTP_POST_VARS['topictype']) ) ? intval($HTTP_POST_VARS['topictype']) : POST_NORMAL;
AFTER, ADD
Code:
$topic_type = ( in_array($topic_type, array(POST_NORMAL, POST_STICKY, POST_ANNOUNCE)) ) ? $topic_type : POST_NORMAL;
FIND
Code:
      $sql = "SELECT f.*, t.topic_status, t.topic_title 
REPLACE WITH
Code:
      $sql = "SELECT f.*, t.topic_status, t.topic_title, t.topic_type 
FIND
Code:
      $select_sql = ( !$submit ) ? ", t.topic_title, p.enable_bbcode, p.enable_html, p.enable_smilies, p.enable_sig, p.post_username, pt.post_subject, pt.post_text, pt.bbcode_uid, u.username, u.user_id, u.user_sig" : '';
REPLACE WITH
Code:
      $select_sql = (!$submit) ? ', t.topic_title, p.enable_bbcode, p.enable_html, p.enable_smilies, p.enable_sig, p.post_username, pt.post_subject, pt.post_text, pt.bbcode_uid, u.username, u.user_id, u.user_sig, u.user_sig_bbcode_uid' : '';
FIND
Code:
      {
         $topic_id = $post_info['topic_id'];
      }
AFTER, ADD
Code:
      if ( $mode == 'newtopic' )
      {
         $post_data['topic_type'] = POST_NORMAL;
      }
FIND
Code:
      $post_data['has_poll'] = false;
      $post_data['edit_poll'] = false;
   }
AFTER, ADD
Code:
   if ( $mode == 'poll_delete' && !isset($poll_id) )
   {
      message_die(GENERAL_MESSAGE, $lang['No_such_post']);
   }
FIND
Code:
      $user_sig = ( $post_info['user_sig'] != '' && $board_config['allow_sig'] ) ? $post_info['user_sig'] : '';
AFTER, ADD
Code:
      $userdata['user_sig_bbcode_uid'] = $post_info['user_sig_bbcode_uid'];
privmsg.php
FIND
Code:
         if ( $sent_info['sent_items'] >= $board_config['max_sentbox_privmsgs'] )
REPLACE WITH
Code:
         if ($board_config['max_sentbox_privmsgs'] && $sent_info['sent_items'] >= $board_config['max_sentbox_privmsgs'])
FIND
Code:
   $search_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_search'] . '" alt="' . $lang['Search_user_posts'] . '" title="' . $lang['Search_user_posts'] . '" border="0" /></a>';
   $search = '<a href="' . $temp_url . '">' . $lang['Search_user_posts'] . '</a>';
REPLACE WITH
Code:
   $search_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_search'] . '" alt="' . sprintf($lang['Search_user_posts'], $username_from) . '" title="' . sprintf($lang['Search_user_posts'], $username_from) . '" border="0" /></a>';
   $search = '<a href="' . $temp_url . '">' . sprintf($lang['Search_user_posts'], $username_from) . '</a>';
FIND
Code:
         if ( $saved_info['savebox_items'] >= $board_config['max_savebox_privmsgs'] )
REPLACE WITH
Code:
         if ($board_config['max_savebox_privmsgs'] && $saved_info['savebox_items'] >= $board_config['max_savebox_privmsgs'] )
FIND
Code:
   if ( $submit )
   {
      if ( !empty($HTTP_POST_VARS['username']) )
BEFORE, ADD
Code:
   if ($submit && $mode == 'edit')
   {
      $sql = 'SELECT privmsgs_from_userid
         FROM ' . PRIVMSGS_TABLE . '
         WHERE privmsgs_id = ' . (int) $privmsg_id . '
            AND privmsgs_from_userid = ' . $userdata['user_id'];

      if (!($result = $db->sql_query($sql)))
      {
         message_die(GENERAL_ERROR, "Could not obtain message details", "", __LINE__, __FILE__, $sql);
      }

      if (!($row = $db->sql_fetchrow($result)))
      {
         message_die(GENERAL_MESSAGE, $lang['No_such_post']);
      }
      $db->sql_freeresult($result);

      unset($row);
   }
FIND
Code:
         $to_userdata = $db->sql_fetchrow($result);
REPLACE WITH
Code:
         if (!($to_userdata = $db->sql_fetchrow($result)))
         {
            $error = TRUE;
            $error_msg = $lang['No_such_user'];
         }
FIND
Code:
            if ( $inbox_info['inbox_items'] >= $board_config['max_inbox_privmsgs'] )
REPLACE WITH
Code:
            if ($board_config['max_inbox_privmsgs'] && $inbox_info['inbox_items'] >= $board_config['max_inbox_privmsgs'])
FIND
Code:
               'USERNAME' => $to_username,
REPLACE WITH
Code:
               'USERNAME' => stripslashes($to_username),
FIND
Code:

      if ( $mode == 'edit' )
      {
         $sql = "SELECT pm.*, pmt.privmsgs_bbcode_uid, pmt.privmsgs_text, u.username, u.user_id, u.user_sig
REPLACE WITH
Code:
      else if ( $mode == 'edit' )
      {
         $sql = "SELECT pm.*, pmt.privmsgs_bbcode_uid, pmt.privmsgs_text, u.username, u.user_id, u.user_sig
FIND
Code:
         $privmsg_subject = $privmsg_message = '';
REPLACE WITH
Code:
         $privmsg_subject = $privmsg_message = $to_username = '';
FIND AND DELETE
Code:
      'S_NAMES_SELECT' => $user_names_select,
search.php
FIND
Code:
         $split_search = ( !strstr($multibyte_charset, $lang['ENCODING']) ) ?  split_words(clean_words('search', stripslashes($search_keywords), $stopword_array, $synonym_array), 'search') : split(' ', $search_keywords);   
REPLACE WITH
Code:
         $stripped_keywords = stripslashes($search_keywords);
         $split_search = ( !strstr($multibyte_charset, $lang['ENCODING']) ) ?  split_words(clean_words('search', $stripped_keywords, $stopword_array, $synonym_array), 'search') : split(' ', $search_keywords);   
         unset($stripped_keywords);
FIND
Code:
   ORDER BY c.cat_id, f.forum_order";
REPLACE WITH
Code:
   ORDER BY c.cat_order, f.forum_order";
viewtopic.php
FIND
Code:
if ( !isset($topic_id) && !isset($post_id) )
REPLACE WITH
Code:
if (!$topic_id && !$post_id)
FIND
Code:
         WHERE
            t2.topic_id = $topic_id
            AND t.forum_id = t2.forum_id
AFTER, ADD
Code:
            AND t.topic_moved_id = 0
FIND
Code:
$join_sql_table = ( empty($post_id) ) ? '' : ", " . POSTS_TABLE . " p, " . POSTS_TABLE . " p2 ";
$join_sql = ( empty($post_id) ) ? "t.topic_id = $topic_id" : "p.post_id = $post_id AND t.topic_id = p.topic_id AND p2.topic_id = p.topic_id AND p2.post_id <= $post_id";
$count_sql = ( empty($post_id) ) ? '' : ", COUNT(p2.post_id) AS prev_posts";

$order_sql = ( empty($post_id) ) ? '' : "GROUP BY p.post_id, t.topic_id, t.topic_title, t.topic_status, t.topic_replies, t.topic_time, t.topic_type, t.topic_vote, t.topic_last_post_id, f.forum_name, f.forum_status, f.forum_id, f.auth_view, f.auth_read, f.auth_post, f.auth_reply, f.auth_edit, f.auth_delete, f.auth_sticky, f.auth_announce, f.auth_pollcreate, f.auth_vote, f.auth_attachments ORDER BY p.post_id ASC";
REPLACE WITH
Code:
$join_sql_table = (!$post_id) ? '' : ", " . POSTS_TABLE . " p, " . POSTS_TABLE . " p2 ";
$join_sql = (!$post_id) ? "t.topic_id = $topic_id" : "p.post_id = $post_id AND t.topic_id = p.topic_id AND p2.topic_id = p.topic_id AND p2.post_id <= $post_id";
$count_sql = (!$post_id) ? '' : ", COUNT(p2.post_id) AS prev_posts";

$order_sql = (!$post_id) ? '' : "GROUP BY p.post_id, t.topic_id, t.topic_title, t.topic_status, t.topic_replies, t.topic_time, t.topic_type, t.topic_vote, t.topic_last_post_id, f.forum_name, f.forum_status, f.forum_id, f.auth_view, f.auth_read, f.auth_post, f.auth_reply, f.auth_edit, f.auth_delete, f.auth_sticky, f.auth_announce, f.auth_pollcreate, f.auth_vote, f.auth_attachments ORDER BY p.post_id ASC";
FIND
Code:
      $redirect = ( isset($post_id) ) ? POST_POST_URL . "=$post_id" : POST_TOPIC_URL . "=$topic_id";
      $redirect .= ( isset($start) ) ? "&start=$start" : '';
REPLACE WITH
Code:
      $redirect = ($post_id) ? POST_POST_URL . "=$post_id" : POST_TOPIC_URL . "=$topic_id";
      $redirect .= ($start) ? "&start=$start" : '';
FIND
Code:
if ( !empty($post_id) )
REPLACE WITH
Code:
if ($post_id)
FIND
Code:
         $highlight_match .= (($highlight_match != '') ? '|' : '') . str_replace('*', '\w*', phpbb_preg_quote($words[$i], '#'));
REPLACE WITH
Code:
         $highlight_match .= (($highlight_match != '') ? '|' : '') . str_replace('*', '\w*', preg_quote($words[$i], '#'));
FIND
Code:
   $search_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_search'] . '" alt="' . $lang['Search_user_posts'] . '" title="' . sprintf($lang['Search_user_posts'], $postrow[$i]['username']) . '" border="0" /></a>';
REPLACE WITH
Code:
   $search_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_search'] . '" alt="' . sprintf($lang['Search_user_posts'], $postrow[$i]['username']) . '" title="' . sprintf($lang['Search_user_posts'], $postrow[$i]['username']) . '" border="0" /></a>';
FIND
Code:
   if ( $board_config['allow_bbcode'] )
   {
      if ( $user_sig != '' && $user_sig_bbcode_uid != '' )
      {
         $user_sig = ( $board_config['allow_bbcode'] ) ? bbencode_second_pass($user_sig, $user_sig_bbcode_uid) : preg_replace('/\:[0-9a-z\:]+\]/si', ']', $user_sig);
      }

      if ( $bbcode_uid != '' )
      {
         $message = ( $board_config['allow_bbcode'] ) ? bbencode_second_pass($message, $bbcode_uid) : preg_replace('/\:[0-9a-z\:]+\]/si', ']', $message);
      }
REPLACE WITH
Code:
   if ($user_sig != '' && $user_sig_bbcode_uid != '')
   {
      $user_sig = ($board_config['allow_bbcode']) ? bbencode_second_pass($user_sig, $user_sig_bbcode_uid) : preg_replace("/\:$user_sig_bbcode_uid/si", '', $user_sig);
   }

   if ($bbcode_uid != '')
   {
      $message = ($board_config['allow_bbcode']) ? bbencode_second_pass($message, $bbcode_uid) : preg_replace("/\:$bbcode_uid/si", '', $message);
admin/admin_board.php
FIND
Code:
$confirm_yes = ($new['enable_confirm']) ? 'checked="checked"' : '';
$confirm_no = (!$new['enable_confirm']) ? 'checked="checked"' : '';
AFTER, ADD
Code:
$allow_autologin_yes = ($new['allow_autologin']) ? 'checked="checked"' : '';
$allow_autologin_no = (!$new['allow_autologin']) ? 'checked="checked"' : '';
FIND
Code:
   "L_ADMIN" => $lang['Acc_Admin'],
   "L_VISUAL_CONFIRM" => $lang['Visual_confirm'],
   "L_VISUAL_CONFIRM_EXPLAIN" => $lang['Visual_confirm_explain'],
AFTER, ADD
Code:
   "L_ALLOW_AUTOLOGIN" => $lang['Allow_autologin'],
   "L_ALLOW_AUTOLOGIN_EXPLAIN" => $lang['Allow_autologin_explain'],
   "L_AUTOLOGIN_TIME" => $lang['Autologin_time'],
   "L_AUTOLOGIN_TIME_EXPLAIN" => $lang['Autologin_time_explain'],
FIND
Code:
   "CONFIRM_DISABLE" => $confirm_no,
   "ACTIVATION_NONE_CHECKED" => $activation_none,
REPLACE WITH
Code:
   'ALLOW_AUTOLOGIN_YES' => $allow_autologin_yes,
   'ALLOW_AUTOLOGIN_NO' => $allow_autologin_no,
   'AUTOLOGIN_TIME' => (int) $new['max_autologin_time'],
admin/admin_disallow.php
FIND
Code:
      message_die(MESSAGE, $lang['Fields_empty']);
REPLACE WITH
Code:
      message_die(GENERAL_MESSAGE, $lang['Fields_empty']);
admin/admin_smilies.php
FIND
Code:
         $smile_url = ( isset($HTTP_POST_VARS['smile_url']) ) ? trim($HTTP_POST_VARS['smile_url']) : trim($HTTP_GET_VARS['smile_url']);
AFTER, ADD
Code:
         $smile_url = phpbb_ltrim(basename($smile_url), "'");
FIND
Code:
            message_die(MESSAGE, $lang['Fields_empty']);
REPLACE WITH
Code:
            message_die(GENERAL_MESSAGE, $lang['Fields_empty']);
FIND
Code:
         $smile_url = ( isset($HTTP_POST_VARS['smile_url']) ) ? $HTTP_POST_VARS['smile_url'] : $HTTP_GET_VARS['smile_url'];
AFTER, ADD
Code:
         $smile_url = phpbb_ltrim(basename($smile_url), "'");
FIND
Code:
            message_die(MESSAGE, $lang['Fields_empty']);
REPLACE WITH
Code:
            message_die(GENERAL_MESSAGE, $lang['Fields_empty']);
admin/admin_styles.php
FIND
Code:
            "L_STYLESHEET" => $lang['Stylesheet'],
AFTER, ADD
Code:
            "L_STYLESHEET_EXPLAIN" => $lang['Stylesheet_explain'],
admin/admin_ug_auth.php
FIND
Code:
         $sql = "SELECT *
            FROM " . FORUMS_TABLE . " f
            ORDER BY forum_order";
REPLACE WITH
Code:
         $sql = 'SELECT f.*
            FROM ' . FORUMS_TABLE . ' f, ' . CATEGORIES_TABLE . ' c
            WHERE f.cat_id = c.cat_id
            ORDER BY c.cat_order, f.forum_order';
FIND
Code:
   if( count($name) )
   {
      $t_usergroup_list = $t_pending_list = '';
      for($i = 0; $i < count($ug_info); $i++)
REPLACE WITH
Code:
   $t_usergroup_list = $t_pending_list = '';
   if( count($name) )
   {
      for($i = 0; $i < count($ug_info); $i++)
FIND
Code:
   else
   {
      $t_usergroup_list = $lang['None'];
   }

   $s_column_span = 2; // Two columns always present
REPLACE WITH
Code:

   $t_usergroup_list = ($t_usergroup_list == '') ? $lang['None'] : $t_usergroup_list;
   $t_pending_list = ($t_pending_list == '') ? $lang['None'] : $t_pending_list;

   $s_column_span = 2; // Two columns always present
admin/admin_user_ban.php
FIND
Code:
         if (preg_match('#^(([a-z0-9&.-_+])|(\*))+@[a-z0-9\-]+\.([a-z0-9\-]+\.)*?[a-z]+$#is', trim($email_list_temp[$i])))
REPLACE WITH
Code:
         if (preg_match('/^(([a-z0-9&\'\.\-_\+])|(\*))+@(([a-z0-9\-])|(\*))+\.([a-z0-9\-]+\.)*?[a-z]+$/is', trim($email_list_temp[$i])))
admin/admin_users.php
FIND
Code:
      if( $HTTP_POST_VARS['deleteuser'] )
REPLACE WITH
Code:
      if( $HTTP_POST_VARS['deleteuser'] && ( $userdata['user_id'] != $user_id ) )
FIND
Code:
      $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'] )  ) ? $HTTP_POST_VARS['avatarlocal'] : '' );
AFTER, ADD
Code:
      $user_avatar_category = ( isset($HTTP_POST_VARS['avatarcatname']) && $board_config['allow_avatar_local'] ) ? htmlspecialchars($HTTP_POST_VARS['avatarcatname']) : '' ;
FIND
Code:
            $user_avatar = $user_avatar_local;
REPLACE WITH
Code:
            $user_avatar = $user_avatar_category . '/' . $user_avatar_local;
FIND
Code:
         $avatar_sql = ", user_avatar = '" . str_replace("\'", "''", $user_avatar_local) . "', user_avatar_type = " . USER_AVATAR_GALLERY;
REPLACE WITH
Code:
         $avatar_sql = ", user_avatar = '" . str_replace("\'", "''", phpbb_ltrim(basename($user_avatar_category), "'") . '/' . phpbb_ltrim(basename($user_avatar_local), "'")) . "', user_avatar_type = " . USER_AVATAR_GALLERY;
FIND
Code:
                     $avatar_images[$file][$avatar_row_count][$avatar_col_count] = $file . "/" . $sub_file;
REPLACE WITH
Code:
                     $avatar_images[$file][$avatar_row_count][$avatar_col_count] = $sub_file;
FIND
Code:
                  "AVATAR_IMAGE" => "../" . $board_config['avatar_gallery_path'] . "/" . $avatar_images[$category][$i][$j])
REPLACE WITH
Code:
                  "AVATAR_IMAGE" => "../" . $board_config['avatar_gallery_path'] . '/' . $category . '/' . $avatar_images[$category][$i][$j])
FIND
Code:
         $s_hidden_fields = '<input type="hidden" name="mode" value="edit" /><input type="hidden" name="agreed" value="true" /><input type="hidden" name="coppa" value="' . $coppa . '" />';
REPLACE WITH
Code:
         $s_hidden_fields = '<input type="hidden" name="mode" value="edit" /><input type="hidden" name="agreed" value="true" /><input type="hidden" name="coppa" value="' . $coppa . '" /><input type="hidden" name="avatarcatname" value="' . $category . '" />';
FIND
Code:
         $s_hidden_fields .= '<input type="hidden" name="avatarlocal" value="' . $user_avatar_local . '" />';
REPLACE WITH
Code:
         $s_hidden_fields .= '<input type="hidden" name="avatarlocal" value="' . $user_avatar_local . '" /><input type="hidden" name="avatarcatname" value="' . $user_avatar_category . '" />';
admin/index.php
FIND
Code:
   if ($fsock = @fsockopen('www.phpbb.com', 80, $errno, $errstr))
REPLACE WITH
Code:
   if ($fsock = @fsockopen('www.phpbb.com', 80, $errno, $errstr, 10))
FIND
Code:
         $version_info .= '<br />' . sprintf($lang['Latest_version_info'], $latest_version) . sprintf($lang['Current_version_info'], '2' . $board_config['version']) . '</p>';
REPLACE WITH
Code:
         $version_info .= '<br />' . sprintf($lang['Latest_version_info'], $latest_version) . ' ' . sprintf($lang['Current_version_info'], '2' . $board_config['version']) . '</p>';
admin/page_footer_admin.php
FIND
Code:
//
// Show the overall footer.
//
BEFORE, ADD
Code:
global $do_gzip_compress;
FIND
Code:
   'TRANSLATION_INFO' => $lang['TRANSLATION_INFO'])
REPLACE WITH
Code:
   'TRANSLATION_INFO' => (isset($lang['TRANSLATION_INFO'])) ? $lang['TRANSLATION_INFO'] : ((isset($lang['TRANSLATION'])) ? $lang['TRANSLATION'] : ''))
db/mysql.php
FIND
Code:
                  $result = $this->rowset[$query_id][$field];
REPLACE WITH
Code:
                  $result = $this->rowset[$query_id][0][$field];
db/mysql4.php
FIND
Code:
                  $result = $this->rowset[$query_id][$field];
REPLACE WITH
Code:
                  $result = $this->rowset[$query_id][0][$field];
includes/bbcode.php
FIND
Code:
            bbcode_array_push($stack, $match);
REPLACE WITH
Code:
            array_push($stack, $match);
FIND
Code:
                  $match = bbcode_array_pop($stack);
REPLACE WITH
Code:
                  $match = array_pop($stack);
FIND
Code:
                     $match = bbcode_array_pop($stack);
REPLACE WITH
Code:
                     $match = array_pop($stack);
FIND
Code:
 * This function does exactly what the PHP4 function array_push() does
 * however, to keep phpBB compatable with PHP 3 we had to come up with our own
 * method of doing it.
AFTER, ADD
Code:
 * This function was deprecated in phpBB 2.0.18
FIND
Code:
 * This function does exactly what the PHP4 function array_pop() does
 * however, to keep phpBB compatable with PHP 3 we had to come up with our own
 * method of doing it.
REPLACE WITH
Code:
 * This function was deprecated in phpBB 2.0.18
FIND
Code:
         $orig[] = "/(?<=.\W|\W.|^\W)" . phpbb_preg_quote($smilies[$i]['code'], "/") . "(?=.\W|\W.|\W$)/";
REPLACE WITH
Code:
         $orig[] = "/(?<=.\W|\W.|^\W)" . preg_quote($smilies[$i]['code'], "/") . "(?=.\W|\W.|\W$)/";
includes/constants.php
FIND
Code:
define('SESSIONS_TABLE', $table_prefix.'sessions');
AFTER, ADD
Code:
define('SESSIONS_KEYS_TABLE', $table_prefix.'sessions_keys');
includes/db.php
The objective here is to replace spaces at the beginning of the line with a tab. FIND
Code:
   message_die(CRITICAL_ERROR, "Could not connect to the database");
REPLACE WITH
Code:
   message_die(CRITICAL_ERROR, "Could not connect to the database");
includes/emailer.php
FIND
Code:
         $drop_header .= '[\r\n]*?' . phpbb_preg_quote($match[1], '#');
REPLACE WITH
Code:
         $drop_header .= '[\r\n]*?' . preg_quote($match[1], '#');
FIND
Code:
         $drop_header .= '[\r\n]*?' . phpbb_preg_quote($match[1], '#');
REPLACE WITH
Code:
         $drop_header .= '[\r\n]*?' . preg_quote($match[1], '#');
FIND
Code:
      $str = preg_replace('#' . phpbb_preg_quote($spacer, '#') . '$#', '', $str);
REPLACE WITH
Code:
      $str = preg_replace('#' . preg_quote($spacer, '#') . '$#', '', $str);
includes/functions.php
The objective here is to remove a tab at the end of the line. FIND
Code:
   $username = phpbb_rtrim($username, "\\");   
REPLACE WITH
Code:
   $username = phpbb_rtrim($username, "\\");
FIND
Code:
   return $username;
}
AFTER, ADD
Code:
/**
* This function is a wrapper for ltrim, as charlist is only supported in php >= 4.1.0
* Added in phpBB 2.0.18
*/
function phpbb_ltrim($str, $charlist = false)
{
   if ($charlist === false)
   {
      return ltrim($str);
   }
   
   $php_version = explode('.', PHP_VERSION);

   // php version < 4.1.0
   if ((int) $php_version[0] < 4 || ((int) $php_version[0] == 4 && (int) $php_version[1] < 1))
   {
      while ($str{0} == $charlist)
      {
         $str = substr($str, 1);
      }
   }
   else
   {
      $str = ltrim($str, $charlist);
   }

   return $str;
}
FIND
Code:
         $orig_word[] = '#\b(' . str_replace('\*', '\w*?', phpbb_preg_quote($row['word'], '#')) . ')\b#i';
REPLACE WITH
Code:
         $orig_word[] = '#\b(' . str_replace('\*', '\w*?', preg_quote($row['word'], '#')) . ')\b#i';
includes/functions_admin.php
FIND
Code:
   $sql = "SELECT forum_id, forum_name
      FROM " . FORUMS_TABLE . "
      ORDER BY cat_id, forum_order";
REPLACE WITH
Code:
   $sql = 'SELECT f.forum_id, f.forum_name
      FROM ' . CATEGORIES_TABLE . ' c, ' . FORUMS_TABLE . ' f
      WHERE f.cat_id = c.cat_id
      ORDER BY c.cat_order, f.forum_order';
FIND
Code:
            $sql = ( $row['total_posts'] ) ? "UPDATE " . TOPICS_TABLE . " SET topic_replies = " . ( $row['total_posts'] - 1 ) . ", topic_first_post_id = " . $row['first_post'] . ", topic_last_post_id = " . $row['last_post'] . " WHERE topic_id = $id" : "DELETE FROM " . TOPICS_TABLE . " WHERE topic_id = $id";
            if ( !$db->sql_query($sql) )
            {
               message_die(GENERAL_ERROR, 'Could not update topic', '', __LINE__, __FILE__, $sql);
REPLACE WITH
Code:
            if ($row['total_posts'])
            {
               // Correct the details of this topic
               $sql = 'UPDATE ' . TOPICS_TABLE . '
                  SET topic_replies = ' . ($row['total_posts'] - 1) . ', topic_first_post_id = ' . $row['first_post'] . ', topic_last_post_id = ' . $row['last_post'] . "
                  WHERE topic_id = $id";

               if (!$db->sql_query($sql))
               {
                  message_die(GENERAL_ERROR, 'Could not update topic', '', __LINE__, __FILE__, $sql);
               }
            }
            else
            {
               // There are no replies to this topic
               // Check if it is a move stub
               $sql = 'SELECT topic_moved_id
                  FROM ' . TOPICS_TABLE . "
                  WHERE topic_id = $id";

               if (!($result = $db->sql_query($sql)))
               {
                  message_die(GENERAL_ERROR, 'Could not get topic ID', '', __LINE__, __FILE__, $sql);
               }

               if ($row = $db->sql_fetchrow($result))
               {
                  if (!$row['topic_moved_id'])
                  {
                     $sql = 'DELETE FROM ' . TOPICS_TABLE . " WHERE topic_id = $id";
         
                     if (!$db->sql_query($sql))
                     {
                        message_die(GENERAL_ERROR, 'Could not remove topic', '', __LINE__, __FILE__, $sql);
                     }
                  }
               }

               $db->sql_freeresult($result);
includes/functions_post.php
FIND
Code:
function submit_post($mode, &$post_data, &$message, &$meta, &$forum_id, &$topic_id, &$post_id, &$poll_id, &$topic_type, &$bbcode_on, &$html_on, &$smilies_on, &$attach_sig, &$bbcode_uid, &$post_username, &$post_subject, &$post_message, &$poll_title, &$poll_options, &$poll_length)
REPLACE WITH
Code:
function submit_post($mode, &$post_data, &$message, &$meta, &$forum_id, &$topic_id, &$post_id, &$poll_id, &$topic_type, &$bbcode_on, &$html_on, &$smilies_on, &$attach_sig, &$bbcode_uid, $post_username, $post_subject, $post_message, $poll_title, &$poll_options, &$poll_length)
FIND
Code:
   if ($mode == 'delete')
   {
      $delete_sql = (!$post_data['first_post'] && !$post_data['last_post']) ? " AND user_id = " . $userdata['user_id'] : '';
      $sql = "DELETE FROM " . TOPICS_WATCH_TABLE . " WHERE topic_id = $topic_id" . $delete_sql;
      if (!$db->sql_query($sql))
      {
         message_die(GENERAL_ERROR, 'Could not change topic notify data', '', __LINE__, __FILE__, $sql);
      }
   }
   else
REPLACE WITH
Code:
   if ($mode != 'delete')
FIND
Code:
      $page_title = $lang['Emoticons'] . " - $topic_title";
REPLACE WITH
Code:
      $page_title = $lang['Emoticons'];
includes/functions_search.php
FIND
Code:
function split_words(&$entry, $mode = 'post')
REPLACE WITH
Code:
function split_words($entry, $mode = 'post')
includes/functions_validate.php
FIND
Code:
   $username = phpbb_clean_username($username);
   
   $sql = "SELECT username
      FROM " . USERS_TABLE . "
      WHERE LOWER(username) = '" . strtolower($username) . "'";
   if ($result = $db->sql_query($sql))
   {
      if ($row = $db->sql_fetchrow($result))
REPLACE WITH
Code:
   $username = phpbb_clean_username($username);

   $sql = "SELECT username
      FROM " . USERS_TABLE . "
      WHERE LOWER(username) = '" . strtolower($username) . "'";
   if ($result = $db->sql_query($sql))
   {
      while ($row = $db->sql_fetchrow($result))
FIND
Code:
            if (preg_match("#\b(" . str_replace("\*", ".*?", phpbb_preg_quote($row['disallow_username'], '#')) . ")\b#i", $username))
REPLACE WITH
Code:
            if (preg_match("#\b(" . str_replace("\*", ".*?", preg_quote($row['disallow_username'], '#')) . ")\b#i", $username))
FIND
Code:
            if (preg_match("#\b(" . str_replace("\*", ".*?", phpbb_preg_quote($row['word'], '#')) . ")\b#i", $username))
REPLACE WITH
Code:
            if (preg_match("#\b(" . str_replace("\*", ".*?", preg_quote($row['word'], '#')) . ")\b#i", $username))
includes/page_header.php
FIND
Code:
   $template->assign_block_vars('switch_user_logged_out', array());
AFTER, ADD
Code:
   //
   // Allow autologin?
   //
   if (!isset($board_config['allow_autologin']) || $board_config['allow_autologin'] )
   {
      $template->assign_block_vars('switch_allow_autologin', array());
      $template->assign_block_vars('switch_user_logged_out.switch_allow_autologin', array());
   }
includes/page_tail.php
FIND
Code:
//
// Show the overall footer.
//
BEFORE, ADD
Code:
global $do_gzip_compress;
FIND
Code:
   'TRANSLATION_INFO' => ( isset($lang['TRANSLATION_INFO']) ) ? $lang['TRANSLATION_INFO'] : '',
REPLACE WITH
Code:
   'TRANSLATION_INFO' => (isset($lang['TRANSLATION_INFO'])) ? $lang['TRANSLATION_INFO'] : ((isset($lang['TRANSLATION'])) ? $lang['TRANSLATION'] : ''),
includes/sessions.php
FIND AND DELETE
Code:
   $expiry_time = $current_time - $board_config['session_length'];
FIND
Code:
   // Try and pull the last time stored in a cookie, if it exists
   //
   $sql = "SELECT *
      FROM " . USERS_TABLE . "
      WHERE user_id = $user_id";
   if ( !($result = $db->sql_query($sql)) )
   {
      message_die(CRITICAL_ERROR, 'Could not obtain lastvisit data from user table', '', __LINE__, __FILE__, $sql);
   }

   $userdata = $db->sql_fetchrow($result);

   if ( $user_id != ANONYMOUS )
   {
      $auto_login_key = $userdata['user_password'];

      if ( $auto_create )
      {
         if ( isset($sessiondata['autologinid']) && $userdata['user_active'] )
         {
            // We have to login automagically
            if( $sessiondata['autologinid'] === $auto_login_key )
            {
               // autologinid matches password
               $login = 1;
               $enable_autologin = 1;
            }
            else
            {
               // No match; don't login, set as anonymous user
               $login = 0;
               $enable_autologin = 0;
               $user_id = $userdata['user_id'] = ANONYMOUS;
            
               $sql = 'SELECT * FROM ' . USERS_TABLE . ' WHERE user_id = ' . ANONYMOUS;
               $result = $db->sql_query($sql);
               $userdata = $db->sql_fetchrow($result);
               $db->sql_freeresult($result);
            }
         }
         else
         {
            // Autologin is not set. Don't login, set as anonymous user
            $login = 0;
            $enable_autologin = 0;
            $user_id = $userdata['user_id'] = ANONYMOUS;

            $sql = 'SELECT * FROM ' . USERS_TABLE . ' WHERE user_id = ' . ANONYMOUS;
            $result = $db->sql_query($sql);
            $userdata = $db->sql_fetchrow($result);
            $db->sql_freeresult($result);
         }
      }
      else
      {
         $login = 1;
      }
   }
   else
   {
      $login = 0;
      $enable_autologin = 0;
REPLACE WITH
Code:
   // Are auto-logins allowed?
   // If allow_autologin is not set or is true then they are
   // (same behaviour as old 2.0.x session code)
   //
   if (isset($board_config['allow_autologin']) && !$board_config['allow_autologin'])
   {
      $enable_autologin = $sessiondata['autologinid'] = false;
   }

   //
   // First off attempt to join with the autologin value if we have one
   // If not, just use the user_id value
   //
   $userdata = array();

   if ($user_id != ANONYMOUS)
   {
      if (isset($sessiondata['autologinid']) && (string) $sessiondata['autologinid'] != '' && $user_id)
      {
         $sql = 'SELECT u.*
            FROM ' . USERS_TABLE . ' u, ' . SESSIONS_KEYS_TABLE . ' k
            WHERE u.user_id = ' . (int) $user_id . "
               AND u.user_active = 1
               AND k.user_id = u.user_id
               AND k.key_id = '" . md5($sessiondata['autologinid']) . "'";
         if (!($result = $db->sql_query($sql)))
         {
            message_die(CRITICAL_ERROR, 'Error doing DB query userdata row fetch', '', __LINE__, __FILE__, $sql);
         }

         $userdata = $db->sql_fetchrow($result);
         $db->sql_freeresult($result);
      
         $enable_autologin = $login = 1;
      }
      else if (!$auto_create)
      {
         $sessiondata['autologinid'] = '';
         $sessiondata['userid'] = $user_id;

         $sql = 'SELECT *
            FROM ' . USERS_TABLE . '
            WHERE user_id = ' . (int) $user_id . '
               AND user_active = 1';
         if (!($result = $db->sql_query($sql)))
         {
            message_die(CRITICAL_ERROR, 'Error doing DB query userdata row fetch', '', __LINE__, __FILE__, $sql);
         }

         $userdata = $db->sql_fetchrow($result);
         $db->sql_freeresult($result);

         $login = 1;
      }
   }

   //
   // At this point either $userdata should be populated or
   // one of the below is true
   // * Key didn't match one in the DB
   // * User does not exist
   // * User is inactive
   //
   if (!sizeof($userdata) || !is_array($userdata) || !$userdata)
   {
      $sessiondata['autologinid'] = '';
      $sessiondata['userid'] = $user_id = ANONYMOUS;
      $enable_autologin = $login = 0;

      $sql = 'SELECT *
         FROM ' . USERS_TABLE . '
         WHERE user_id = ' . (int) $user_id;
      if (!($result = $db->sql_query($sql)))
      {
         message_die(CRITICAL_ERROR, 'Error doing DB query userdata row fetch', '', __LINE__, __FILE__, $sql);
      }

      $userdata = $db->sql_fetchrow($result);
      $db->sql_freeresult($result);
FIND
Code:
   {// ( $userdata['user_session_time'] > $expiry_time && $auto_create ) ? $userdata['user_lastvisit'] : (
REPLACE WITH
Code:
   {
FIND
Code:
      $sessiondata['autologinid'] = (!$admin) ? (( $enable_autologin && $sessionmethod == SESSION_METHOD_COOKIE ) ? $auto_login_key : '') : $sessiondata['autologinid'];
REPLACE WITH
Code:
      //
      // Regenerate the auto-login key
      //
      if ($enable_autologin)
      {
         list($sec, $usec) = explode(' ', microtime());
         mt_srand(hexdec(substr($session_id, 0, 8)) + (float) $sec + ((float) $usec * 1000000));
         $auto_login_key = uniqid(mt_rand(), true);
         
         if (isset($sessiondata['autologinid']) && (string) $sessiondata['autologinid'] != '')
         {
            $sql = 'UPDATE ' . SESSIONS_KEYS_TABLE . "
               SET last_ip = '$user_ip', key_id = '" . md5($auto_login_key) . "', last_login = $current_time
               WHERE key_id = '" . md5($sessiondata['autologinid']) . "'";
         }
         else
         {
            $sql = 'INSERT INTO ' . SESSIONS_KEYS_TABLE . "(key_id, user_id, last_ip, last_login)
               VALUES ('" . md5($auto_login_key) . "', $user_id, '$user_ip', $current_time)";
         }

         if ( !$db->sql_query($sql) )
         {
            message_die(CRITICAL_ERROR, 'Error updating session key', '', __LINE__, __FILE__, $sql);
         }
         
         $sessiondata['autologinid'] = $auto_login_key;
         unset($auto_login_key);
      }
      else
      {
         $sessiondata['autologinid'] = '';
      }

//      $sessiondata['autologinid'] = (!$admin) ? (( $enable_autologin && $sessionmethod == SESSION_METHOD_COOKIE ) ? $auto_login_key : '') : $sessiondata['autologinid'];
FIND
Code:
   $userdata['session_admin'] = $admin;
AFTER, ADD
Code:
   $userdata['session_key'] = $sessiondata['autologinid'];
FIND
Code:
               //
               // Delete expired sessions
               //
               $expiry_time = $current_time - $board_config['session_length'];

               $sql = "DELETE FROM " . SESSIONS_TABLE . "
                  WHERE session_time < $expiry_time
                     AND session_id <> '$session_id'";
               if ( !$db->sql_query($sql) )
               {
                  message_die(CRITICAL_ERROR, 'Error clearing sessions table', '', __LINE__, __FILE__, $sql);
               }
REPLACE WITH
Code:
               session_clean($userdata['session_id']);
FIND
Code:
//
// session_end closes out a session
// deleting the corresponding entry
// in the sessions table
//
function session_end($session_id, $user_id)
{
   global $db, $lang, $board_config;
REPLACE WITH
Code:
/**
* Terminates the specified session
* It will delete the entry in the sessions table for this session,
* remove the corresponding auto-login key and reset the cookies
*/
function session_end($session_id, $user_id)
{
   global $db, $lang, $board_config, $userdata;
FIND AND DELETE
Code:
   //
   // Pull cookiedata or grab the URI propagated sid
   //
   if ( isset($HTTP_COOKIE_VARS[$cookiename . '_sid']) )
   {
      $session_id = isset( $HTTP_COOKIE_VARS[$cookiename . '_sid'] ) ? $HTTP_COOKIE_VARS[$cookiename . '_sid'] : '';
      $sessionmethod = SESSION_METHOD_COOKIE;
   }
   else
   {
      $session_id = ( isset($HTTP_GET_VARS['sid']) ) ? $HTTP_GET_VARS['sid'] : '';
      $sessionmethod = SESSION_METHOD_GET;
   }
FIND
Code:
   $sql = "DELETE FROM " . SESSIONS_TABLE . "
REPLACE WITH
Code:
   $sql = 'DELETE FROM ' . SESSIONS_TABLE . "
FIND
Code:
      message_die(CRITICAL_ERROR, 'Error removing user session', '', __LINE__, __FILE__, $sql);
   }
AFTER, ADD
Code:
   //
   // Remove this auto-login entry (if applicable)
   //
   if ( isset($userdata['session_key']) && $userdata['session_key'] != '' )
   {
      $autologin_key = md5($userdata['session_key']);
      $sql = 'DELETE FROM ' . SESSIONS_KEYS_TABLE . '
         WHERE user_id = ' . (int) $user_id . "
            AND key_id = '$autologin_key'";
      if ( !$db->sql_query($sql) )
      {
         message_die(CRITICAL_ERROR, 'Error removing auto-login key', '', __LINE__, __FILE__, $sql);
      }
   }

   //
   // We expect that message_die will be called after this function,
   // but just in case it isn't, reset $userdata to the details for a guest
   //
   $sql = 'SELECT *
      FROM ' . USERS_TABLE . '
      WHERE user_id = ' . ANONYMOUS;
   if ( !($result = $db->sql_query($sql)) )
   {
      message_die(CRITICAL_ERROR, 'Error obtaining user details', '', __LINE__, __FILE__, $sql);
   }
   if ( !($userdata = $db->sql_fetchrow($result)) )
   {
      message_die(CRITICAL_ERROR, 'Error obtaining user details', '', __LINE__, __FILE__, $sql);
   }
   $db->sql_freeresult($result);
FIND
Code:
   setcookie($cookiename . '_data', '', $current_time - 31536000, $cookiepath, $cookiedomain, $cookiesecure);
   setcookie($cookiename . '_sid', '', $current_time - 31536000, $cookiepath, $cookiedomain, $cookiesecure);

   return true;
}
AFTER, ADD
Code:
/**
* Removes expired sessions and auto-login keys from the database
*/
function session_clean($session_id)
{
   global $board_config, $db;

   //
   // Delete expired sessions
   //
   $sql = 'DELETE FROM ' . SESSIONS_TABLE . '
      WHERE session_time < ' . (time() - (int) $board_config['session_length']) . "
         AND session_id <> '$session_id'";
   if ( !$db->sql_query($sql) )
   {
      message_die(CRITICAL_ERROR, 'Error clearing sessions table', '', __LINE__, __FILE__, $sql);
   }

   //
   // Delete expired auto-login keys
   // If max_autologin_time is not set then keys will never be deleted
   // (same behaviour as old 2.0.x session code)
   //
   if (!empty($board_config['max_autologin_time']) && $board_config['max_autologin_time'] > 0)
   {
      $sql = 'DELETE FROM ' . SESSIONS_KEYS_TABLE . '
         WHERE last_login < ' . (time() - (86400 * (int) $board_config['max_autologin_time']));
      $db->sql_query($sql);
   }

   return true;
}
FIND
Code:
      $url .= ( ( strpos($url, '?') != false ) ?  ( ( $non_html_amp ) ? '&' : '&amp;' ) : '?' ) . $SID;
REPLACE WITH
Code:
      $url .= ( ( strpos($url, '?') !== false ) ?  ( ( $non_html_amp ) ? '&' : '&amp;' ) : '?' ) . $SID;
includes/smtp.php
FIND
Code:
function server_parse($socket, $response, $line = __LINE__)
{
   while (substr($server_response, 3, 1) != ' ')
REPLACE WITH
Code:
function server_parse($socket, $response, $line = __LINE__)
{
   $server_response = '';
   while (substr($server_response, 3, 1) != ' ')
includes/usercp_activate.php
FIND
Code:
      if (intval($board_config['require_activation']) == USER_ACTIVATION_ADMIN && $userdata['user_level'] != ADMIN)
      {
         message_die(GENERAL_MESSAGE, $lang['Not_Authorised']);
REPLACE WITH
Code:
      if (intval($board_config['require_activation']) == USER_ACTIVATION_ADMIN && $row['user_newpasswd'] == '')
      {
         if (!$userdata['session_logged_in'])
         {
            redirect(append_sid('login.' . $phpEx . '?redirect=profile.' . $phpEx . '&mode=activate&' . POST_USERS_URL . '=' . $row['user_id'] . '&act_key=' . trim($HTTP_GET_VARS['act_key'])));
         }
         else if ($userdata['user_level'] != ADMIN)
         {
            message_die(GENERAL_MESSAGE, $lang['Not_Authorised']);
         }
includes/usercp_avatar.php
FIND
Code:
function user_avatar_gallery($mode, &$error, &$error_msg, $avatar_filename)
{
   global $board_config;

   $avatar_filename = str_replace(array('../', '..\\', './', '.\\'), '', $avatar_filename);
   if ($avatar_filename{0} == '/' || $avatar_filename{0} == "\\")
   {
      return '';
   }

   if ( file_exists(@phpbb_realpath($board_config['avatar_gallery_path'] . '/' . $avatar_filename)) && ($mode == 'editprofile') )
   {
      $return = ", user_avatar = '" . str_replace("\'", "''", $avatar_filename) . "', user_avatar_type = " . USER_AVATAR_GALLERY;
REPLACE WITH
Code:
function user_avatar_gallery($mode, &$error, &$error_msg, $avatar_filename, $avatar_category)
{
   global $board_config;

   $avatar_filename = phpbb_ltrim(basename($avatar_filename), "'");
   $avatar_category = phpbb_ltrim(basename($avatar_category), "'");
   
   if(!preg_match('/(\.gif$|\.png$|\.jpg|\.jpeg)$/is', $avatar_filename))
   {
      return '';
   }

   if ($avatar_filename == "" || $avatar_category == "")
   {
      return '';
   }

   if ( file_exists(@phpbb_realpath($board_config['avatar_gallery_path'] . '/' . $avatar_category . '/' . $avatar_filename)) && ($mode == 'editprofile') )
   {
      $return = ", user_avatar = '" . str_replace("\'", "''", $avatar_category . '/' . $avatar_filename) . "', user_avatar_type = " . USER_AVATAR_GALLERY;
FIND
Code:
   if ( $avatar_mode == 'remote' && preg_match('/^(http:\/\/)?([\w\-\.]+)\:?([0-9]*)\/(.*)$/', $avatar_filename, $url_ary) )
BEFORE, ADD
Code:
   $width = $height = 0;
   $type = '';
FIND
Code:
         list($width, $height) = @getimagesize($tmp_filename);
REPLACE WITH
Code:
         list($width, $height, $type) = @getimagesize($tmp_filename);
FIND
Code:
      list($width, $height) = @getimagesize($avatar_filename);
REPLACE WITH
Code:
      list($width, $height, $type) = @getimagesize($avatar_filename);
FIND
Code:
   if ( $width > 0 && $height > 0 && $width <= $board_config['avatar_max_width'] && $height <= $board_config['avatar_max_height'] )
BEFORE, ADD
Code:
   switch ($type)
   {
      // GIF
      case 1:
         if ($imgtype != '.gif')
         {
            @unlink($tmp_filename);
            message_die(GENERAL_ERROR, 'Unable to upload file', '', __LINE__, __FILE__);
         }
      break;

      // JPG, JPC, JP2, JPX, JB2
      case 2:
      case 9:
      case 10:
      case 11:
      case 12:
         if ($imgtype != '.jpg' && $imgtype != '.jpeg')
         {
            @unlink($tmp_filename);
            message_die(GENERAL_ERROR, 'Unable to upload file', '', __LINE__, __FILE__);
         }
      break;

      // PNG
      case 3:
         if ($imgtype != '.png')
         {
            @unlink($tmp_filename);
            message_die(GENERAL_ERROR, 'Unable to upload file', '', __LINE__, __FILE__);
         }
      break;

      default:
         @unlink($tmp_filename);
         message_die(GENERAL_ERROR, 'Unable to upload file', '', __LINE__, __FILE__);
   }
FIND
Code:
         if ( file_exists(@phpbb_realpath('./' . $board_config['avatar_path'] . '/' . $current_avatar)) )
         {
            @unlink('./' . $board_config['avatar_path'] . '/' . $current_avatar);
         }
REPLACE WITH
Code:
         user_avatar_delete($current_type, $current_avatar);
FIND
Code:
               $avatar_images[$file][$avatar_row_count][$avatar_col_count] = $file . '/' . $sub_file;
REPLACE WITH
Code:
               $avatar_images[$file][$avatar_row_count][$avatar_col_count] = $sub_file;
FIND
Code:
            "AVATAR_IMAGE" => $board_config['avatar_gallery_path'] . '/' . $avatar_images[$category][$i][$j],
REPLACE WITH
Code:
            "AVATAR_IMAGE" => $board_config['avatar_gallery_path'] . '/' . $category . '/' . $avatar_images[$category][$i][$j],
FIND
Code:
   $s_hidden_vars = '<input type="hidden" name="sid" value="' . $session_id . '" /><input type="hidden" name="agreed" value="true" />';
REPLACE WITH
Code:
   $s_hidden_vars = '<input type="hidden" name="sid" value="' . $session_id . '" /><input type="hidden" name="agreed" value="true" /><input type="hidden" name="avatarcatname" value="' . $category . '" />';
includes/usercp_register.php
FIND
Code:
$error = FALSE;
AFTER, ADD
Code:
$error_msg = '';
FIND
Code:
      $attachsig = ( isset($HTTP_POST_VARS['attachsig']) ) ? ( ($HTTP_POST_VARS['attachsig']) ? TRUE : 0 ) : 0;
REPLACE WITH
Code:
      $attachsig = ( isset($HTTP_POST_VARS['attachsig']) ) ? ( ($HTTP_POST_VARS['attachsig']) ? TRUE : 0 ) : $userdata['user_attachsig'];
FIND
Code:
   $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']) : '' );
AFTER, ADD
Code:
   $user_avatar_category = ( isset($HTTP_POST_VARS['avatarcatname']) && $board_config['allow_avatar_local'] ) ? htmlspecialchars($HTTP_POST_VARS['avatarcatname']) : '' ;
FIND
Code:
   $user_avatar = ( empty($user_avatar_loc) && $mode == 'editprofile' ) ? $userdata['user_avatar'] : '';
   $user_avatar_type = ( empty($user_avatar_loc) && $mode == 'editprofile' ) ? $userdata['user_avatar_type'] : '';
REPLACE WITH
Code:
   $user_avatar = ( empty($user_avatar_local) && $mode == 'editprofile' ) ? $userdata['user_avatar'] : '';
   $user_avatar_type = ( empty($user_avatar_local) && $mode == 'editprofile' ) ? $userdata['user_avatar_type'] : '';
FIND
Code:
      $signature = stripslashes($signature);
REPLACE WITH
Code:
      $signature = htmlspecialchars(stripslashes($signature));
FIND
Code:
         $user_avatar = $user_avatar_local;
REPLACE WITH
Code:
         $user_avatar = $user_avatar_category . '/' . $user_avatar_local;
FIND
Code:
      if ( $signature_bbcode_uid == '' )
REPLACE WITH
Code:
      if ( !isset($signature_bbcode_uid) || $signature_bbcode_uid == '' )
FIND
Code:
      if ( @file_exists(@phpbb_realpath('./' . $board_config['avatar_path'] . '/' . $userdata['user_avatar'])) )
      {
         @unlink(@phpbb_realpath('./' . $board_config['avatar_path'] . '/' . $userdata['user_avatar']));
      }
REPLACE WITH
Code:
      user_avatar_delete($userdata['user_avatar_type'], $userdata['user_avatar']);
FIND
Code:
      if ( @file_exists(@phpbb_realpath('./' . $board_config['avatar_path'] . '/' . $userdata['user_avatar'])) )
      {
         @unlink(@phpbb_realpath('./' . $board_config['avatar_path'] . '/' . $userdata['user_avatar']));
      }
      $avatar_sql = user_avatar_gallery($mode, $error, $error_msg, $user_avatar_local);
REPLACE WITH
Code:
      user_avatar_delete($userdata['user_avatar_type'], $userdata['user_avatar']);
      $avatar_sql = user_avatar_gallery($mode, $error, $error_msg, $user_avatar_local, $user_avatar_category);
FIND
Code:
            $emailer->from($board_config['board_email']);
            $emailer->replyto($board_config['board_email']);

            $emailer->use_template('user_activate', stripslashes($user_lang));
            $emailer->email_address($email);
            $emailer->set_subject($lang['Reactivate']);

            $emailer->assign_vars(array(
               'SITENAME' => $board_config['sitename'],
               'USERNAME' => preg_replace($unhtml_specialchars_match, $unhtml_specialchars_replace, substr(str_replace("\'", "'", $username), 0, 25)),
               'EMAIL_SIG' => (!empty($board_config['board_email_sig'])) ? str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']) : '',

               'U_ACTIVATE' => $server_url . '?mode=activate&' . POST_USERS_URL . '=' . $user_id . '&act_key=' . $user_actkey)
            );
            $emailer->send();
            $emailer->reset();
REPLACE WITH
Code:
             if ( $board_config['require_activation'] != USER_ACTIVATION_ADMIN )
             {
                $emailer->from($board_config['board_email']);
                $emailer->replyto($board_config['board_email']);
 
                $emailer->use_template('user_activate', stripslashes($user_lang));
                $emailer->email_address($email);
                $emailer->set_subject($lang['Reactivate']);
 
                $emailer->assign_vars(array(
                   'SITENAME' => $board_config['sitename'],
                   'USERNAME' => preg_replace($unhtml_specialchars_match, $unhtml_specialchars_replace, substr(str_replace("\'", "'", $username), 0, 25)),
                   'EMAIL_SIG' => (!empty($board_config['board_email_sig'])) ? str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']) : '',
 
                   'U_ACTIVATE' => $server_url . '?mode=activate&' . POST_USERS_URL . '=' . $user_id . '&act_key=' . $user_actkey)
                );
                $emailer->send();
                $emailer->reset();
             }
             else if ( $board_config['require_activation'] == USER_ACTIVATION_ADMIN )
             {
                $sql = 'SELECT user_email, user_lang
                   FROM ' . USERS_TABLE . '
                   WHERE user_level = ' . ADMIN;
                
                if ( !($result = $db->sql_query($sql)) )
                {
                   message_die(GENERAL_ERROR, 'Could not select Administrators', '', __LINE__, __FILE__, $sql);
                }
                
                while ($row = $db->sql_fetchrow($result))
                {
                   $emailer->from($board_config['board_email']);
                   $emailer->replyto($board_config['board_email']);
                   
                   $emailer->email_address(trim($row['user_email']));
                   $emailer->use_template("admin_activate", $row['user_lang']);
                   $emailer->set_subject($lang['Reactivate']);
 
                   $emailer->assign_vars(array(
                      'USERNAME' => preg_replace($unhtml_specialchars_match, $unhtml_specialchars_replace, substr(str_replace("\'", "'", $username), 0, 25)),
                      'EMAIL_SIG' => str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']),
 
                      'U_ACTIVATE' => $server_url . '?mode=activate&' . POST_USERS_URL . '=' . $user_id . '&act_key=' . $user_actkey)
                   );
                   $emailer->send();
                   $emailer->reset();
                }
                $db->sql_freeresult($result);
             }
FIND
Code:
   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']);
REPLACE WITH
Code:
   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']);
FIND
Code:
   if ( !isset($user_template) )
   {
      $selected_template = $board_config['system_template'];
REPLACE WITH
Code:
   if ( !isset($user_style) )
   {
      $user_style = $board_config['default_style'];
FIND
Code:
      $s_hidden_fields .= '<input type="hidden" name="avatarlocal" value="' . $user_avatar_local . '" />';
REPLACE WITH
Code:
      $s_hidden_fields .= '<input type="hidden" name="avatarlocal" value="' . $user_avatar_local . '" /><input type="hidden" name="avatarcatname" value="' . $user_avatar_category . '" />';
includes/usercp_sendpasswd.php
FIND
Code:
         $key_len = ( $str_len > 6 ) ? $key_len : 6;
REPLACE WITH
Code:
         $key_len = ($key_len > 6) ? $key_len : 6;
includes/usercp_viewprofile.php
FIND
Code:
$search_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_search'] . '" alt="' . $lang['Search_user_posts'] . '" title="' . sprintf($lang['Search_user_posts'], $profiledata['username']) . '" border="0" /></a>';
REPLACE WITH
Code:
$search_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_search'] . '" alt="' . sprintf($lang['Search_user_posts'], $profiledata['username']) . '" title="' . sprintf($lang['Search_user_posts'], $profiledata['username']) . '" border="0" /></a>';
language/lang_english/email/topic_notify.tpl
FIND
Code:
>Hello {USERNAME},
REPLACE WITH
Code:
Hello,
language/lang_english/lang_admin.php
FIND
Code:
$lang['Visual_confirm'] = 'Enable Visual Confirmation';
$lang['Visual_confirm_explain'] = 'Requires users enter a code defined by an image when registering.';
AFTER, ADD
Code:
// Autologin Keys - added 2.0.18
$lang['Allow_autologin'] = 'Allow automatic logins';
$lang['Allow_autologin_explain'] = 'Determines whether users are allowed to select to be automatically logged in when visiting the forum';
$lang['Autologin_time'] = 'Automatic login key expiry';
$lang['Autologin_time_explain'] = 'How long a autologin key is valid for in days if the user does not visit the board. Set to zero to disable expiry.';