phpBB 2.0.15 to 2.0.16 Code Changes

These are the code changes introduced between phpBB 2.0.15 and phpBB 2.0.16. 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.

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.16 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.

Now, onward to the file changes!

admin/admin_ug_auth.php
FIND
Code:
   @reset($auth_user);
REPLACE WITH
Code:
//   @reset($auth_user);
admin/pagestart.php
Some users may have already made these changes, or possibly removed the affected lines from your files, due to problems in accessing the admin panel. FIND
Code:
   redirect(append_sid("login.$phpEx?redirect=admin/", true));
REPLACE WITH
Code:
   redirect(append_sid("login.$phpEx?redirect=admin/index.$phpEx", true));
FIND
Code:
   redirect(append_sid("login.$phpEx?redirect=admin/&admin=1", true));
REPLACE WITH
Code:
   redirect(append_sid("login.$phpEx?redirect=admin/index.$phpEx&admin=1", true));
includes/bbcode.php
FIND
Code:
   $patterns[] = "#\[url=([\w]+?://[^ \"\n\r\t<]*?)\]([^?].*?)\[/url\]#i";
   $replacements[] = $bbcode_tpl['url3'];

   // [url=www.phpbb.com]phpBB[/url] code.. (no xxxx:// prefix).
   $patterns[] = "#\[url=((www|ftp)\.[^ \"\n\r\t<]*?)\]([^?].*?)\[/url\]#i";
REPLACE WITH
Code:
   $patterns[] = "#\[url=([\w]+?://[^ \"\n\r\t<]*?)\]([^?\n\r\t].*?)\[/url\]#is";
   $replacements[] = $bbcode_tpl['url3'];

   // [url=www.phpbb.com]phpBB[/url] code.. (no xxxx:// prefix).
   $patterns[] = "#\[url=((www|ftp)\.[^ \"\n\r\t<]*?)\]([^?\n\r\t].*?)\[/url\]#is";
includes/usercp_avatar.php
FIND
Code:
   if ( $width <= $board_config['avatar_max_width'] && $height <= $board_config['avatar_max_height'] )
REPLACE WITH
Code:
   if ( $width > 0 && $height > 0 && $width <= $board_config['avatar_max_width'] && $height <= $board_config['avatar_max_height'] )
includes/usercp_register.php
FIND
Code:
      $avatar_sql = user_avatar_delete($userdata['user_avatar_type'], $userdata['user_avatar']);
   }

   if ( ( !empty($user_avatar_upload) || !empty($user_avatar_name) ) && $board_config['allow_avatar_upload'] )
REPLACE WITH
Code:
      $avatar_sql = user_avatar_delete($userdata['user_avatar_type'], $userdata['user_avatar']);
   }
   else
   if ( ( !empty($user_avatar_upload) || !empty($user_avatar_name) ) && $board_config['allow_avatar_upload'] )
modcp.php
FIND
Code:
         $new_forum_id = intval($HTTP_POST_VARS['new_forum']);
         $old_forum_id = $forum_id;
AFTER, ADD
Code:
         $sql = 'SELECT forum_id FROM ' . FORUMS_TABLE . '
            WHERE forum_id = ' . $new_forum_id;
         if ( !($result = $db->sql_query($sql)) )
         {
            message_die(GENERAL_ERROR, 'Could not select from forums table', '', __LINE__, __FILE__, $sql);
         }
         
         if (!$db->sql_fetchrow($result))
         {
            message_die(GENERAL_MESSAGE, 'New forum does not exist');
         }

         $db->sql_freeresult($result);
FIND
Code:
            $new_forum_id = intval($HTTP_POST_VARS['new_forum_id']);
            $topic_time = time();
AFTER, ADD
Code:
            $sql = 'SELECT forum_id FROM ' . FORUMS_TABLE . '
               WHERE forum_id = ' . $new_forum_id;
            if ( !($result = $db->sql_query($sql)) )
            {
               message_die(GENERAL_ERROR, 'Could not select from forums table', '', __LINE__, __FILE__, $sql);
            }
         
            if (!$db->sql_fetchrow($result))
            {
               message_die(GENERAL_MESSAGE, 'New forum does not exist');
            }

            $db->sql_freeresult($result);
viewtopic.php
FIND
Code:
      $message = str_replace('\"', '"', substr(@preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "@preg_replace('#\b(" . str_replace('\\', '\\\\', $highlight_match) . ")\b#i', '<span style=\"color:#" . $theme['fontcolor3'] . "\"><b>\\\\1</b></span>', '\\0')", '>' . $message . '<'), 1, -1));
REPLACE WITH
Code:
      $message = str_replace('\"', '"', substr(@preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "@preg_replace('#\b(" . str_replace('\\', '\\\\', addslashes($highlight_match)) . ")\b#i', '<span style=\"color:#" . $theme['fontcolor3'] . "\"><b>\\\\1</b></span>', '\\0')", '>' . $message . '<'), 1, -1));