phpBBHacks.com - phpBB 2.0.3 to 2.0.4 Code Changes
Talk martial arts at KarateForums.com
StatsForums Home   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in
FAQFAQ   SearchSearch   MemberlistMemberlist   TutorialsTutorials   ContactContact Us
Add Us:     MySpace     Facebook     StumbleUpon
Username:    Password:
Remember Me?    
phpBB 2.0.3 to 2.0.4 Code Changes
Goto page 1, 2, 3, 4, 5, 6, 7, 8  Next
BlinkList
del.icio.us
Furl
linkaGoGo
reddit
Simpy
Mister Wong
Yahoo! My Web

Post new topic   Reply to topic    phpBBHacks.com Support Forums Forum Index -> phpBB 2: Fixes and Code Changes
 See a User Guidelines violation? Please contact us.
Author Message

Acyd Burn
Consultant

Joined: 19 Apr 2002
Posts: 650
Location: Germany (Oldb)

PostPosted: January 26th 2003, 5:11 pm    Post subject: phpBB 2.0.3 to 2.0.4 Code Changes Reply with quote

Text Version.

These are the changes from phpBB 2.0.3 to phpBB 2.0.4. This might be very helpful if you want to update your Board and have installed a bunch of hacks. Then it's normally easier to apply the code changes than to install all hacks again.

This tutorial is big, really big. If you can avoid a change and if you are able to replace a file directly, do it.

I have placed every file into one single post.

When you find a 'AFTER, ADD'-Statement, the code has to be added after the last line quoted in the 'FIND'-Statement.

When you find a 'BEFORE, ADD'-Statement, the code has to be added before the first line quoted in the 'FIND'-Statement.

When you find a 'REPLACE WITH'-Statement, the code quoted in the 'FIND'-Statement has to be replaced completely with the quoted code in the 'REPLACE WITH'-Statement.

When you find a 'DELETE'-Statement, the code has to be deleted.

After you have finished this tutorial, you have to upload the update_to_204.php file to the install folder, run it and then delete it from your webspace.

Ok, lets start:


Last edited by Acyd Burn on February 25th 2003, 12:55 pm; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website

Acyd Burn
Consultant

Joined: 19 Apr 2002
Posts: 650
Location: Germany (Oldb)

PostPosted: January 26th 2003, 5:14 pm    Post subject: privmsg.php Reply with quote

  • admin/admin_board.php



  1. FIND - Line 50
    Code:


          
          $new[$config_name] = ( isset($HTTP_POST_VARS[$config_name]) ) ? $HTTP_POST_VARS[$config_name] : $default_config[$config_name];



    AFTER, ADD
    Code:


          if ($config_name == 'cookie_name')
          {
             $cookie_name = str_replace('.', '_', $new['cookie_name']);
          }




  2. FIND - Line 76
    Code:


    $lang_select = language_select($new['default_lang'], 'default_lang', "../language");


    REPLACE WITH
    Code:


    $lang_select = language_select($new['default_lang'], 'default_lang', "language");


Back to top
View user's profile Send private message Visit poster's website

Acyd Burn
Consultant

Joined: 19 Apr 2002
Posts: 650
Location: Germany (Oldb)

PostPosted: January 26th 2003, 5:17 pm    Post subject: Reply with quote

  • admin/admin_db_utilities.php



  1. FIND - Line 37
    Code:


       if(@phpversion() >= '4.0.0')
       {   
          $file_uploads = @ini_get('file_uploads');
       }
       else
       {
          $file_uploads = @get_cfg_var('file_uploads');
       }

       if( ($file_uploads != 0 || empty($file_uploads)) && (strtolower($file_uploads) != 'off') && (@phpversion() != '4.0.4pl1') )


    REPLACE WITH
    Code:



       $file_uploads = (@phpversion() >= '4.0.0') ? @ini_get('file_uploads') : @get_cfg_var('file_uploads');

       if( (empty($file_uploads) || $file_uploads != 0) && (strtolower($file_uploads) != 'off') && (@phpversion() != '4.0.4pl1') )



  2. FIND - Line 569
    Code:


       //
       // Grab the data from the table.
       //
       $result = $db->sql_query("SELECT * FROM $table");

       if (!$result)
       {
          message_die(GENERAL_ERROR, "Failed in get_table_content (select *)", "", __LINE__, __FILE__, "SELECT * FROM $table");
       }

       if($db->sql_numrows($result) > 0)
       {
          $schema_insert = "\n#\n# Table Data for $table\n#\n";
       }
       else
       {
          $schema_insert = "";
       }

       $handler($schema_insert);

       //
       // Loop through the resulting rows and build the sql statement.
       //

       while ($row = $db->sql_fetchrow($result))
       {
          $table_list = '(';
          $num_fields = $db->sql_numfields($result);
          //
          // Grab the list of field names.
          //
          for ($j = 0; $j < $num_fields; $j++)
          {
             $table_list .= $db->sql_fieldname($j, $result) . ', ';
          }
          //
          // Get rid of the last comma
          //
          $table_list = ereg_replace(', $', '', $table_list);
          $table_list .= ')';
          //
          // Start building the SQL statement.
          //
          $schema_insert = "INSERT INTO $table $table_list VALUES(";
          //
          // Loop through the rows and fill in data for each column
          //
          for ($j = 0; $j < $num_fields; $j++)
          {
             if(!isset($row[$j]))


    REPLACE WITH
    Code:



       // Grab the data from the table.
       if (!($result = $db->sql_query("SELECT * FROM $table")))
       {
          message_die(GENERAL_ERROR, "Failed in get_table_content (select *)", "", __LINE__, __FILE__, "SELECT * FROM $table");
       }

       // Loop through the resulting rows and build the sql statement.
       if ($row = $db->sql_fetchrow($result))
       {
          $handler("\n#\n# Table Data for $table\n#\n");
          $field_names = array();

          // Grab the list of field names.
          $num_fields = $db->sql_numfields($result);
          $table_list = '(';
          for ($j = 0; $j < $num_fields; $j++)
          {
             $field_names[$j] = $db->sql_fieldname($j, $result);
             $table_list .= (($j > 0) ? ', ' : '') . $field_names[$j];
             
          }
          $table_list .= ')';

          do
          {
             // Start building the SQL statement.
             $schema_insert = "INSERT INTO $table $table_list VALUES(";

             // Loop through the rows and fill in data for each column
             for ($j = 0; $j < $num_fields; $j++)
             {
                $schema_insert .= ($j > 0) ? ', ' : '';

                if(!isset($row[$field_names[$j]]))



  3. FIND - Line 611
    Code:


                $schema_insert .= ' NULL,';
             }
             elseif ($row[$j] != '')
             {
                $schema_insert .= ' \'' . addslashes($row[$j]) . '\',';
             }
             else
             {
                $schema_insert .= '\'\',';
             }
          }
          //
          // Get rid of the the last comma.
          //
          $schema_insert = ereg_replace(',$', '', $schema_insert);
          $schema_insert .= ');';
          //
          // Go ahead and send the insert statement to the handler function.
          //
          $handler(trim($schema_insert));

       }


    REPLACE WITH
    Code:


                   $schema_insert .= 'NULL';
                }
                elseif ($row[$field_names[$j]] != '')
                {
                   $schema_insert .= '\'' . addslashes($row[$field_names[$j]]) . '\'';
                }
                else
                {
                   $schema_insert .= '\'\'';
                }
             }

             $schema_insert .= ');';

             // Go ahead and send the insert statement to the handler function.
             $handler(trim($schema_insert));

          }
          while ($row = $db->sql_fetchrow($result));
       }




  4. FIND - Line 660
    Code:


             if( SQL_LAYER == 'oracle' || SQL_LAYER == 'odbc' || SQL_LAYER == 'mssql' )
             {
                switch(SQL_LAYER)
                {
                   case 'oracle':
                      $db_type = "Oracle";
                      break;
                   case 'odbc':
                      $db_type = "ODBC";
                      break;
                   case 'mssql':
                      $db_type = "MSSQL";
                      break;
                }



    REPLACE WITH
    Code:


             $error = false;
             switch(SQL_LAYER)
             {
                case 'oracle':
                   $error = true;
                   break;
                case 'db2':
                   $error = true;
                   break;
                case 'msaccess':
                   $error = true;
                   break;
                case 'mssql':
                case 'mssql-odbc':
                   $error = true;
                   break;
             }

             if ($error)
             {



  5. FIND - Line 693
    Code:


                $template->pparse("body");

                break;
             }


    REPLACE WITH
    Code:


                $template->pparse("body");

                include('./page_footer_admin.'.$phpEx);
             }



  6. FIND - Line 763
    Code:


                   "META" => "<meta http-equiv=\"refresh\" content=\"2;url=admin_db_utilities.$phpEx?perform=backup&additional_tables=" . quotemeta($additional_tables) . "&backup_type=$backup_type&drop=1&backupstart=1&gzipcompress=$gzipcompress&startdownload=1\">",


    REPLACE WITH
    Code:


                   "META" => '<meta http-equiv="refresh" content="2;url=' . append_sid("admin_db_utilities.$phpEx?perform=backup&additional_tables=" . quotemeta($additional_tables) . "&backup_type=$backup_type&drop=1&backupstart=1&gzipcompress=$gzipcompress&startdownload=1") . '">',



  7. FIND - Line 819
    Code:


                if(SQL_LAYER != 'mysql4')
                {
                   $table_def_function = "get_table_def_" . SQL_LAYER;
                   $table_content_function = "get_table_content_" . SQL_LAYER;
                }
                else
                {
                   $table_def_function = "get_table_def_mysql";
                   $table_content_function = "get_table_content_mysql";


    REPLACE WITH
    Code:



                switch (SQL_LAYER)
                {
                   case 'postgresql':
                      $table_def_function = "get_table_def_postgresql";
                      $table_content_function = "get_table_content_postgresql";
                      break;

                   case 'mysql':
                   case 'mysql4':
                      $table_def_function = "get_table_def_mysql";
                      $table_content_function = "get_table_content_mysql";
                      break;



  8. FIND - Line 906
    Code:


                if( file_exists($backup_file_tmpname) )


    REPLACE WITH
    Code:


                if( file_exists(phpbb_realpath($backup_file_tmpname)) )


Back to top
View user's profile Send private message Visit poster's website

Acyd Burn
Consultant

Joined: 19 Apr 2002
Posts: 650
Location: Germany (Oldb)

PostPosted: January 26th 2003, 5:18 pm    Post subject: Reply with quote

  • admin/admin_disallow.php



  1. FIND - Line 44
    Code:


       $disallowed_user = ( isset($HTTP_POST_VARS['disallowed_user']) ) ? $HTTP_POST_VARS['disallowed_user'] : $HTTP_GET_VARS['disallowed_user'];



    REPLACE WITH
    Code:


       $disallowed_user = ( isset($HTTP_POST_VARS['disallowed_user']) ) ? trim($HTTP_POST_VARS['disallowed_user']) : trim($HTTP_GET_VARS['disallowed_user']);

       if ($disallowed_user == '')
       {
          message_die(MESSAGE, $lang['Fields_empty']);
       }


Back to top
View user's profile Send private message Visit poster's website

Acyd Burn
Consultant

Joined: 19 Apr 2002
Posts: 650
Location: Germany (Oldb)

PostPosted: January 26th 2003, 5:19 pm    Post subject: Reply with quote

  • admin/admin_forum_prune.php



  1. FIND - Line 171
    Code:


          $prune_data .= '<input type="text" name="prunedays" size="4"> ' . $lang['Days'];

          $hidden_input = '<input type="hidden" name="' . POST_FORUM_URL . '" value="' . $forum_id . '">';


    REPLACE WITH
    Code:


          $prune_data .= '<input class="post" type="text" name="prunedays" size="4"> ' . $lang['Days'];

          $hidden_input = '<input type="hidden" name="' . POST_FORUM_URL . '" value="' . $forum_id . '" />';


Back to top
View user's profile Send private message Visit poster's website

Acyd Burn
Consultant

Joined: 19 Apr 2002
Posts: 650
Location: Germany (Oldb)

PostPosted: January 26th 2003, 5:19 pm    Post subject: Reply with quote

  • admin/admin_forums.php



  1. FIND - Line 46
    Code:


       "auth_sticky" => AUTH_REG,


    REPLACE WITH
    Code:


       "auth_sticky" => AUTH_MOD,



  2. FIND - Line 304
    Code:


             $catlist = get_list('category', $cat_id, TRUE);

             $forumstatus == ( FORUM_LOCKED ) ? $forumlocked = "selected=\"selected\"" : $forumunlocked = "selected=\"selected\"";


    AFTER, ADD
    Code:


             
             // These two options ($lang['Status_unlocked'] and $lang['Status_locked']) seem to be missing from
             // the language files.
             $lang['Status_unlocked'] = isset($lang['Status_unlocked']) ? $lang['Status_unlocked'] : 'Unlocked';
             $lang['Status_locked'] = isset($lang['Status_locked']) ? $lang['Status_locked'] : 'Locked';
             



  3. FIND - Line 612
    Code:


                include($phpbb_root_path . "includes/prune.$phpEx");
                prune($from_id, 0); // Delete everything from forum


    REPLACE WITH
    Code:


                // Delete polls in this forum
                $sql = "SELECT v.vote_id
                   FROM " . VOTE_DESC_TABLE . " v, " . TOPICS_TABLE . " t
                   WHERE t.forum_id = $from_id
                      AND v.topic_id = t.topic_id";
                if (!($result = $db->sql_query($sql)))
                {
                   message_die(GENERAL_ERROR, "Couldn't obtain list of vote ids", "", __LINE__, __FILE__, $sql);
                }

                if ($row = $db->sql_fetchrow($result))
                {
                   $vote_ids = '';
                   do
                   {
                      $vote_ids = (($vote_ids != '') ? ', ' : '') . $row['vote_id'];
                   }
                   while ($row = $db->sql_fetchrow($result));

                   $sql = "DELETE FROM " . VOTE_DESC_TABLE . "
                      WHERE vote_id IN ($vote_ids)";
                   $db->sql_query($sql);

                   $sql = "DELETE FROM " . VOTE_RESULTS_TABLE . "
                      WHERE vote_id IN ($vote_ids)";
                   $db->sql_query($sql);

                   $sql = "DELETE FROM " . VOTE_USERS_TABLE . "
                      WHERE vote_id IN ($vote_ids)";
                   $db->sql_query($sql);
                }
                $db->sql_freeresult($result);
                
                include($phpbb_root_path . "includes/prune.$phpEx");
                prune($from_id, 0, true); // Delete everything from forum



  4. FIND - Line 679
    Code:


                sync('forum', $to_id);
             }



    AFTER, ADD
    Code:


             // Alter Mod level if appropriate - 2.0.4
             $sql = "SELECT ug.user_id
                FROM " . AUTH_ACCESS_TABLE . " a, " . USER_GROUP_TABLE . " ug
                WHERE a.forum_id <> $from_id
                   AND a.auth_mod = 1
                   AND ug.group_id = a.group_id";
             if( !$result = $db->sql_query($sql) )
             {
                message_die(GENERAL_ERROR, "Couldn't obtain moderator list", "", __LINE__, __FILE__, $sql);
             }

             if ($row = $db->sql_fetchrow($result))
             {
                $user_ids = '';
                do
                {
                   $user_ids .= (($user_ids != '') ? ', ' : '' ) . $row['user_id'];
                }
                while ($row = $db->sql_fetchrow($result));

                $sql = "SELECT ug.user_id
                   FROM " . AUTH_ACCESS_TABLE . " a, " . USER_GROUP_TABLE . " ug
                   WHERE a.forum_id = $from_id
                      AND a.auth_mod = 1
                      AND ug.group_id = a.group_id
                      AND ug.user_id NOT IN ($user_ids)";
                if( !$result2 = $db->sql_query($sql) )
                {
                   message_die(GENERAL_ERROR, "Couldn't obtain moderator list", "", __LINE__, __FILE__, $sql);
                }
                   
                if ($row = $db->sql_fetchrow($result2))
                {
                   $user_ids = '';
                   do
                   {
                      $user_ids .= (($user_ids != '') ? ', ' : '' ) . $row['user_id'];
                   }
                   while ($row = $db->sql_fetchrow($result2));

                   $sql = "UPDATE " . USERS_TABLE . "
                      SET user_level = " . USER . "
                      WHERE user_id IN ($user_ids)
                         AND user_level <> " . ADMIN;
                   $db->sql_query($sql);
                }
                $db->sql_freeresult($result);

             }
             $db->sql_freeresult($result2);



Back to top
View user's profile Send private message Visit poster's website

Acyd Burn
Consultant

Joined: 19 Apr 2002
Posts: 650
Location: Germany (Oldb)

PostPosted: January 26th 2003, 5:20 pm    Post subject: Reply with quote

  • admin/admin_ranks.php



  1. FIND - Line 164
    Code:


             }
          }

          if( $rank_id )
          {


    REPLACE WITH
    Code:


             }
          }

          if( $rank_id )
          {
             if (!$special_rank)
             {
                $sql = "UPDATE " . USERS_TABLE . "
                   SET user_rank = 0
                   WHERE user_rank = $rank_id";

                if( !$result = $db->sql_query($sql) )
                {
                   message_die(GENERAL_ERROR, $lang['No_update_ranks'], "", __LINE__, __FILE__, $sql);
                }
             }


Back to top
View user's profile Send private message Visit poster's website

Acyd Burn
Consultant

Joined: 19 Apr 2002
Posts: 650
Location: Germany (Oldb)

PostPosted: January 26th 2003, 5:21 pm    Post subject: Reply with quote

  • admin/admin_smilies.php



  1. FIND - Line 75
    Code:


       if( !@is_dir($phpbb_root_path . $board_config['smilies_path'] . '/' . $file) )


    REPLACE WITH
    Code:


       if( !@is_dir(phpbb_realpath($phpbb_root_path . $board_config['smilies_path'] . '/' . $file)) )



  2. FIND - Line 242
    Code:


             message_die(GENERAL_ERROR, "Couldn't delete smiley", "", __LINE__, __FILE__, $sql);


    REPLACE WITH
    Code:


             message_die(GENERAL_ERROR, "Could not get smiley list", "", __LINE__, __FILE__, $sql);



  3. FIND - Line 402
    Code:


             $smile_code = ( isset($HTTP_POST_VARS['smile_code']) ) ? $HTTP_POST_VARS['smile_code'] : $HTTP_GET_VARS['smile_code'];
             $smile_url = ( isset($HTTP_POST_VARS['smile_url']) ) ? $HTTP_POST_VARS['smile_url'] : $HTTP_GET_VARS['smile_url'];
             $smile_emotion = ( isset($HTTP_POST_VARS['smile_emotion']) ) ? $HTTP_POST_VARS['smile_emotion'] : $HTTP_GET_VARS['smile_emotion'];
             $smile_id = ( isset($HTTP_POST_VARS['smile_id']) ) ? intval($HTTP_POST_VARS['smile_id']) : intval($HTTP_GET_VARS['smile_id']);


    REPLACE WITH
    Code:


             $smile_code = ( isset($HTTP_POST_VARS['smile_code']) ) ? trim($HTTP_POST_VARS['smile_code']) : trim($HTTP_GET_VARS['smile_code']);
             $smile_url = ( isset($HTTP_POST_VARS['smile_url']) ) ? trim($HTTP_POST_VARS['smile_url']) : trim($HTTP_GET_VARS['smile_url']);
             $smile_emotion = ( isset($HTTP_POST_VARS['smile_emotion']) ) ? trim($HTTP_POST_VARS['smile_emotion']) : trim($HTTP_GET_VARS['smile_emotion']);
             $smile_id = ( isset($HTTP_POST_VARS['smile_id']) ) ? intval($HTTP_POST_VARS['smile_id']) : intval($HTTP_GET_VARS['smile_id']);

             // If no code was entered complain ...
             if ($smile_code == '' || $smile_url == '')
             {
                message_die(MESSAGE, $lang['Fields_empty']);
             }




  4. FIND - Line 425
    Code:


             $result = $db->sql_query($sql);
             if( !$result )


    REPLACE WITH
    Code:


             if( !($result = $db->sql_query($sql)) )



  5. FIND - Line 448
    Code:


             $smile_url = ( isset($HTTP_POST_VARS['smile_url']) ) ? $HTTP_POST_VARS['smile_url'] : $HTTP_GET_VARS['smile_url'];
             $smile_emotion = ( isset($HTTP_POST_VARS['smile_emotion']) ) ? $HTTP_POST_VARS['smile_emotion'] : $HTTP_GET_VARS['smile_emotion'];



    AFTER, ADD
    Code:


             // If no code was entered complain ...
             if ($smile_code == '' || $smile_url == '')
             {
                message_die(MESSAGE, $lang['Fields_empty']);
             }



Back to top
View user's profile Send private message Visit poster's website

Acyd Burn
Consultant

Joined: 19 Apr 2002
Posts: 650
Location: Germany (Oldb)

PostPosted: January 26th 2003, 5:22 pm    Post subject: Reply with quote

  • admin/admin_styles.php



  1. FIND - Line 46
    Code:


    }

    if( $cancel )
    {
       $header_location = ( @preg_match('/Microsoft|WebSTAR|Xitami/', getenv('SERVER_SOFTWARE')) ) ? 'Refresh: 0; URL=' : 'Location: ';
       header($header_location  . append_sid("admin_styles.$phpEx"));
       exit;


    REPLACE WITH
    Code:


    }

    if ($cancel)
    {
       redirect('admin/' . append_sid("admin_styles.$phpEx", true));



  2. FIND - Line 135
    Code:


                   if( !is_file($phpbb_root_path . 'templates/' .$sub_dir) && !is_link($phpbb_root_path . 'templates/' .$sub_dir) && $sub_dir != "." && $sub_dir != ".." && $sub_dir != "CVS" )
                   {
                      if( @file_exists($phpbb_root_path. "templates/" . $sub_dir . "/theme_info.cfg") )


    REPLACE WITH
    Code:


                   if( !is_file(phpbb_realpath($phpbb_root_path . 'templates/' .$sub_dir)) && !is_link(phpbb_realpath($phpbb_root_path . 'templates/' .$sub_dir)) && $sub_dir != "." && $sub_dir != ".." && $sub_dir != "CVS" )
                   {
                      if( @file_exists(@phpbb_realpath($phpbb_root_path. "templates/" . $sub_dir . "/theme_info.cfg")) )



  3. FIND - Line 552
    Code:


                   if( !is_file($phpbb_root_path . 'templates/' . $file) && !is_link($phpbb_root_path . 'templates/' . $file) && $file != "." && $file != ".." && $file != "CVS" )


    REPLACE WITH
    Code:


                   if( !is_file(phpbb_realpath($phpbb_root_path . 'templates/' . $file)) && !is_link(phpbb_realpath($phpbb_root_path . 'templates/' . $file)) && $file != "." && $file != ".." && $file != "CVS" )



  4. FIND - Line 751
    Code:


                $download_form = '<form action="' . append_sid("admin_styles.$phpEx") . '" method="post"><input type="submit" name="submit" value="' . $lang['Download'] . '" />' . $s_hidden_fields;


    REPLACE WITH
    Code:


                $download_form = '<form action="' . append_sid("admin_styles.$phpEx") . '" method="post"><input class="mainoption" type="submit" name="submit" value="' . $lang['Download'] . '" />' . $s_hidden_fields;



  5. FIND - Line 793
    Code: