phpBBHacks.com - phpBB 2.0.3 to 2.0.4 Code Changes - Page 5
Managing Online Forums, a manual for the community admin
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 Previous  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, 6:13 pm    Post subject: Reply with quote

  • posting.php



  1. FIND - Line 119
    Code:


       $header_location = ( @preg_match('/Microsoft|WebSTAR|Xitami/', getenv('SERVER_SOFTWARE')) ) ? 'Refresh: 0; URL=' : 'Location: ';
       header($header_location . append_sid($redirect, true) . $post_append);
       exit;


    REPLACE WITH
    Code:


       redirect(append_sid($redirect, true) . $post_append);
    }

    //
    // Compare sid ... if sids don't match
    // output message ... note that AOL'ers may
    // obtain this error until the session code
    // is modified to change the 6 to 4 in the IP
    // comparison checks ... or if a user takes
    // longer than session time to submit the form
    // both can be easily altered by the admin
    //
    if ( $submit || $refresh )
    {
       if (!isset($HTTP_POST_VARS['sid']) || $HTTP_POST_VARS['sid'] != $userdata['session_id'])
       {
          // I've not added this to the language set at this time ... re-releasing
          // every single language to include this for the once in a blue moon
          // time it will be output is just not worthwhile at present.
          message_die(GENERAL_MESSAGE, 'Invalid_session');
       }



  2. FIND - Line 210
    Code:


          $sql = "SELECT f.*, t.topic_status 


    REPLACE WITH
    Code:


          $sql = "SELECT f.*, t.topic_status, t.topic_title 



  3. FIND - Line 303
    Code:


             $post_data['edit_poll'] = false;


    REPLACE WITH
    Code:


             $post_data['edit_poll'] = ($post_data['first_post'] && $is_auth['auth_pollcreate']) ? true : false;



  4. FIND - Line 369
    Code:


       $header_location = ( @preg_match('/Microsoft|WebSTAR|Xitami/', getenv('SERVER_SOFTWARE')) ) ? 'Refresh: 0; URL=' : 'Location: ';
       header($header_location . append_sid("login.$phpEx?redirect=posting.$phpEx&" . $redirect, true));
       exit;


    REPLACE WITH
    Code:


       redirect(append_sid("login.$phpEx?redirect=posting.$phpEx&" . $redirect, true));



  5. FIND - Line 402
    Code:


    if ( $submit || $refresh )
    {
       $notify_user = ( !empty($HTTP_POST_VARS['notify']) ) ? TRUE : 0;
    }
    else
    {
       if ( $mode != 'newtopic' && $userdata['session_logged_in'] )


    REPLACE WITH
    Code:


    if ( ($submit || $refresh) && $is_auth['auth_read'])
    {
       $notify_user = ( !empty($HTTP_POST_VARS['notify']) ) ? TRUE : 0;
    }
    else
    {
       if ( $mode != 'newtopic' && $userdata['session_logged_in'] && $is_auth['auth_read'] )



  6. FIND - Line 423
    Code:


          $notify_user = ( $userdata['session_logged_in'] ) ? $userdata['user_notify'] : 0;


    REPLACE WITH
    Code:


          $notify_user = ( $userdata['session_logged_in'] && $is_auth['auth_read'] ) ? $userdata['user_notify'] : 0;



  7. FIND - Line 437
    Code:


       $s_hidden_fields = '<input type="hidden" name="' . POST_POST_URL . '" value="' . $post_id . '" />';


    REPLACE WITH
    Code:


       $s_hidden_fields = '<input type="hidden" name="sid" value="' . $userdata['session_id'] . '" /><input type="hidden" name="' . POST_POST_URL . '" value="' . $post_id . '" />';



  8. FIND AND REMOVE - Line 564
    Code:


                if ( $error_msg == '' )
                {
                   user_notification($mode, $post_data, $forum_id, $topic_id, $post_id, $notify_user);
                }



  9. FIND - Line 581
    Code:


             update_post_stats($mode, $post_data, $forum_id, $topic_id, $post_id, $user_id);
          }



    AFTER, ADD
    Code:


          if ($error_msg == '' && $mode != 'poll_delete')
          {
             user_notification($mode, $post_data, $post_info['topic_title'], $forum_id, $topic_id, $post_id, $notify_user);
          }




  10. FIND - Line 800
    Code:


             $quote_username = ( !empty($post_info['post_username']) ) ? $post_info['post_username'] : $post_info['username'];


    REPLACE WITH
    Code:


             // Use trim to get rid of spaces placed there by MS-SQL 2000
             $quote_username = ( trim($post_info['post_username']) != '' ) ? $post_info['post_username'] : $post_info['username'];



  11. FIND - Line 879
    Code:


    if ( $userdata['session_logged_in'] )


    REPLACE WITH
    Code:


    if ( $userdata['session_logged_in'] && $is_auth['auth_read'] )



  12. FIND - Line 929
    Code:


    $hidden_form_fields = '<input type="hidden" name="mode" value="' . $mode . '" />';


    REPLACE WITH
    Code:


    $hidden_form_fields = '<input type="hidden" name="sid" value="' . $userdata['session_id'] . '" /><input type="hidden" name="mode" value="' . $mode . '" />';



  13. FIND - Line 1062
    Code:


    if( ( $mode == 'newtopic' || ( $mode == 'editpost' && $post_data['first_post'] ) ) && $is_auth['auth_pollcreate'] )


    REPLACE WITH
    Code:


    if( ( $mode == 'newtopic' || ( $mode == 'editpost' && $post_data['edit_poll']) ) && $is_auth['auth_pollcreate'] )



  14. FIND - Line 1104
    Code:


    if( $mode == 'reply' )


    REPLACE WITH
    Code:


    if( $mode == 'reply' && $is_auth['auth_read'] )


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, 6:15 pm    Post subject: Reply with quote

  • privmsg.php



  1. FIND - Line 72
    Code:


       $folder = 'inbox';
    }



    AFTER, ADD
    Code:


    // session id check
    if (!empty($HTTP_POST_VARS['sid']) || !empty($HTTP_GET_VARS['sid']))
    {
       $sid = (!empty($HTTP_POST_VARS['sid'])) ? $HTTP_POST_VARS['sid'] : $HTTP_GET_VARS['sid'];
    }
    else
    {
       $sid = '';
    }




  2. FIND - Line 96
    Code:


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


    REPLACE WITH
    Code:


       redirect(append_sid("privmsg.$phpEx?folder=$folder", true));



  3. FIND - Line 164
    Code:


          $l_new_message .= '<br /><br />' . sprintf($lang['Click_view_privmsg'], '<a href="' . append_sid("privmsg.".$phpEx."?folder=inbox") . '" onClick="jump_to_inbox();return false;" target="_new">', '</a>');


    REPLACE WITH
    Code:


          $l_new_message .= '<br /><br />' . sprintf($lang['Click_view_privmsg'], '<a href="' . append_sid("privmsg.".$phpEx."?folder=inbox") . '" onclick="jump_to_inbox();return false;" target="_new">', '</a>');



  4. FIND - Line 194
    Code:


          $header_location = ( @preg_match('/Microsoft|WebSTAR|Xitami/', getenv('SERVER_SOFTWARE')) ) ? 'Refresh: 0; URL=' : 'Location: ';
          header($header_location . append_sid("login.$phpEx?redirect=privmsg.$phpEx&folder=$folder&mode=$mode&" . POST_POST_URL . "=$privmsgs_id", true));
          exit;


    REPLACE WITH
    Code:


          redirect(append_sid("login.$phpEx?redirect=privmsg.$phpEx&folder=$folder&mode=$mode&" . POST_POST_URL . "=$privmsgs_id", true));



  5. FIND - Line 254
    Code:


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


    REPLACE WITH
    Code:


          redirect(append_sid("privmsg.$phpEx?folder=$folder", true));



  6. FIND - Line 263
    Code:


       if ( ( $privmsg['privmsgs_type'] == PRIVMSGS_NEW_MAIL || $privmsg['privmsgs_type'] == PRIVMSGS_UNREAD_MAIL ) && $folder == 'inbox' )
       {
          $sql = "UPDATE " . PRIVMSGS_TABLE . "
             SET privmsgs_type = " . PRIVMSGS_READ_MAIL . "
             WHERE privmsgs_id = " . $privmsg['privmsgs_id'];
          if ( !$db->sql_query($sql) )
          {
             message_die(GENERAL_ERROR, 'Could not update private message read status', '', __LINE__, __FILE__, $sql);
          }

          $sql = "UPDATE " . USERS_TABLE . "
             SET user_unread_privmsg = user_unread_privmsg - 1
             WHERE user_id = " . $userdata['user_id'];
          if ( !$db->sql_query($sql) )
          {
             message_die(GENERAL_ERROR, 'Could not update private message read status for user', '', __LINE__, __FILE__, $sql);
          }

          //
          // Check to see if the poster has a 'full' sent box
          //


    REPLACE WITH
    Code:


       if (($privmsg['privmsgs_type'] == PRIVMSGS_NEW_MAIL || $privmsg['privmsgs_type'] == PRIVMSGS_UNREAD_MAIL) && $folder == 'inbox')
       {
          // Update appropriate counter
          switch ($privmsg['privmsgs_type'])
          {
             case PRIVMSGS_NEW_MAIL:
                $sql = "user_new_privmsg = user_new_privmsg - 1";
                break;
             case PRIVMSGS_UNREAD_MAIL:
                $sql = "user_unread_privmsg = user_unread_privmsg - 1";
                break;
          }

          $sql = "UPDATE " . USERS_TABLE . "
             SET $sql
             WHERE user_id = " . $userdata['user_id'];
          if ( !$db->sql_query($sql) )
          {
             message_die(GENERAL_ERROR, 'Could not update private message read status for user', '', __LINE__, __FILE__, $sql);
          }

          $sql = "UPDATE " . PRIVMSGS_TABLE . "
             SET privmsgs_type = " . PRIVMSGS_READ_MAIL . "
             WHERE privmsgs_id = " . $privmsg['privmsgs_id'];
          if ( !$db->sql_query($sql) )
          {
             message_die(GENERAL_ERROR, 'Could not update private message read status', '', __LINE__, __FILE__, $sql);
          }

          // Check to see if the poster has a 'full' sent box



  7. FIND - Line 308
    Code:


                $sql = "DELETE $sql_priority FROM " . PRIVMSGS_TABLE . "
                   WHERE privmsgs_type = " . PRIVMSGS_SENT_MAIL . "
                      AND privmsgs_date = " . $sent_info['oldest_post_time'] . "
                      AND privmsgs_from_userid = " . $privmsg['privmsgs_from_userid'];
                if ( !$db->sql_query($sql) )
                {
                   message_die(GENERAL_ERROR, 'Could not delete oldest privmsgs', '', __LINE__, __FILE__, $sql);


    REPLACE WITH
    Code:


                $sql = "SELECT privmsgs_id FROM " . PRIVMSGS_TABLE . "
                   WHERE privmsgs_type = " . PRIVMSGS_SENT_MAIL . "
                      AND privmsgs_date = " . $sent_info['oldest_post_time'] . "
                      AND privmsgs_from_userid = " . $privmsg['privmsgs_from_userid'];
                if ( !$result = $db->sql_query($sql) )
                {
                   message_die(GENERAL_ERROR, 'Could not find oldest privmsgs', '', __LINE__, __FILE__, $sql);
                }
                $old_privmsgs_id = $db->sql_fetchrow($result);
                $old_privmsgs_id = $old_privmsgs_id['privmsgs_id'];
             
                $sql = "DELETE $sql_priority FROM " . PRIVMSGS_TABLE . "
                   WHERE privmsgs_id = $old_privmsgs_id";
                if ( !$db->sql_query($sql) )
                {
                   message_die(GENERAL_ERROR, 'Could not delete oldest privmsgs (sent)', '', __LINE__, __FILE__, $sql);
                }

                $sql = "DELETE $sql_priority FROM " . PRIVMSGS_TEXT_TABLE . "
                   WHERE privmsgs_text_id = $old_privmsgs_id";
                if ( !$db->sql_query($sql) )
                {
                   message_die(GENERAL_ERROR, 'Could not delete oldest privmsgs text (sent)', '', __LINE__, __FILE__, $sql);



  8. FIND - Line 367
    Code:


          'post_img' => '<a href="' . $post_urls['post'] . '"><img src="' . $images['pm_postmsg'] . '" alt="' . $lang['Post_new_pm'] . '" border="0"></a>',
          'post' => '<a href="' . $post_urls['post'] . '">' . $lang['Post_new_pm'] . '</a>',
          'reply_img' => '<a href="' . $post_urls['reply'] . '"><img src="' . $images['pm_replymsg'] . '" alt="' . $lang['Post_reply_pm'] . '" border="0"></a>',
          'reply' => '<a href="' . $post_urls['reply'] . '">' . $lang['Post_reply_pm'] . '</a>',
          'quote_img' => '<a href="' . $post_urls['quote'] . '"><img src="' . $images['pm_quotemsg'] . '" alt="' . $lang['Post_quote_pm'] . '" border="0"></a>',
          'quote' => '<a href="' . $post_urls['quote'] . '">' . $lang['Post_quote_pm'] . '</a>',
          'edit_img' => '<a href="' . $post_urls['edit'] . '"><img src="' . $images['pm_editmsg'] . '" alt="' . $lang['Edit_pm'] . '" border="0"></a>',
          'edit' => '<a href="' . $post_urls['edit'] . '">' . $lang['Edit_pm'] . '</a>'


    REPLACE WITH
    Code:


          'post_img' => '<a href="' . $post_urls['post'] . '"><img src="' . $images['pm_postmsg'] . '" alt="' . $lang['Post_new_pm'] . '" border="0" /></a>',
          'post' => '<a href="' . $post_urls['post'] . '">' . $lang['Post_new_pm'] . '</a>',
          'reply_img' => '<a href="' . $post_urls['reply'] . '"><img src="' . $images['pm_replymsg'] . '" alt="' . $lang['Post_reply_pm'] . '" border="0" /></a>',
          'reply' => '<a href="' . $post_urls['reply'] . '">' . $lang['Post_reply_pm'] . '</a>',
          'quote_img' => '<a href="' . $post_urls['quote'] . '"><img src="' . $images['pm_quotemsg'] . '" alt="' . $lang['Post_quote_pm'] . '" border="0" /></a>',
          'quote' => '<a href="' . $post_urls['quote'] . '">' . $lang['Post_quote_pm'] . '</a>',
          'edit_img' => '<a href="' . $post_urls['edit'] . '"><img src="' . $images['pm_editmsg'] . '" alt="' . $lang['Edit_pm'] . '" border="0" /></a>',
          'edit' => '<a href="' . $post_urls['edit'] . '" />' . $lang['Edit_pm'] . '</a>'



  9. FIND - Line 440
    Code:


       $s_hidden_fields = '<input type="hidden" name="mark[]" value="' . $privmsgs_id . '" />';


    REPLACE WITH
    Code:


       $s_hidden_fields = '<input type="hidden" name="sid" value="' . $userdata['session_id'] . '" /><input type="hidden" name="mark[]" value="' . $privmsgs_id . '" />';



  10. FIND - Line 540
    Code:


       $temp_url = append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=$poster_id");


    REPLACE WITH
    Code:


       $temp_url = append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=$user_id_from");



  11. FIND - Line 664
    Code:


          $header_location = ( @preg_match('/Microsoft|WebSTAR|Xitami/', getenv('SERVER_SOFTWARE')) ) ? 'Refresh: 0; URL=' : 'Location: ';
          header($header_location . append_sid("login.$phpEx?redirect=privmsg.$phpEx&folder=inbox", true));
          exit;
       }


    REPLACE WITH
    Code:


          redirect(append_sid("login.$phpEx?redirect=privmsg.$phpEx&folder=inbox", true));
       }

       // session id check
       if ($sid == '' || $sid != $userdata['session_id'])
       {
          message_die(GENERAL_ERROR, 'Invalid_session');
       }




  12. FIND - Line 681
    Code:


          $s_hidden_fields = '<input type="hidden" name="mode" value="' . $mode . '" />';
          $s_hidden_fields .= ( isset($HTTP_POST_VARS['delete']) ) ? '<input type="hidden" name="delete" value="true" />' : '<input type="hidden" name="deleteall" value="true" />';

          for($i = 0; $i < count($mark_list); $i++)
          {
             $s_hidden_fields .= '<input type="hidden" name="mark[]" value="' . $mark_list[$i] . '" />';


    REPLACE WITH
    Code:


          $s_hidden_fields = '<input type="hidden" name="sid" value="' . $userdata['session_id'] . '" /><input type="hidden" name="mode" value="' . $mode . '" />';
          $s_hidden_fields .= ( isset($HTTP_POST_VARS['delete']) ) ? '<input type="hidden" name="delete" value="true" />' : '<input type="hidden" name="deleteall" value="true" />';

          for($i = 0; $i < count($mark_list); $i++)
          {
             $s_hidden_fields .= '<input type="hidden" name="mark[]" value="' . intval($mark_list[$i]) . '" />';



  13. FIND - Line 758
    Code:


             $delete_sql_id = implode(', ', $mark_list);

             //
             // Need to decrement the new message counter of recipient
             // problem is this doesn't affect the unread counter even
             // though it may be the one that needs changing ... hhmmm
             //
             if ( $folder == 'outbox' )
             {
                $sql = "SELECT privmsgs_to_userid
                   FROM " . PRIVMSGS_TABLE . "
                   WHERE privmsgs_id IN ($delete_sql_id)
                      AND privmsgs_from_userid = " . $userdata['user_id'] . "
                      AND privmsgs_type = " . PRIVMSGS_NEW_MAIL;
                if ( !($result = $db->sql_query($sql)) )
                {
                   message_die(GENERAL_ERROR, 'Could not obtain user id list for outbox messages', '', __LINE__, __FILE__, $sql);
                }

                $update_pm_sql = '';
                while( $row = $db->sql_fetchrow($result) )
                {
                   $update_pm_sql .= ( ( $update_pm_sql != '' ) ? ', ' : '' ) . $row['privmsgs_to_userid'];
                }

                if ( $update_pm_sql != '' )
                {
                   $sql = "UPDATE " . USERS_TABLE . " 
                      SET user_new_privmsg = user_new_privmsg - 1
                      WHERE user_id IN ($update_pm_sql)";
                   if ( !$db->sql_query($sql) )
                   {
                      message_die(GENERAL_ERROR, 'Could not update users new msg counters', '', __LINE__, __FILE__, $sql);
                   }
                }

                $sql = "SELECT privmsgs_to_userid
                   FROM " . PRIVMSGS_TABLE . "
                   WHERE privmsgs_id IN ($delete_sql_id)
                      AND privmsgs_from_userid = " . $userdata['user_id'] . "
                      AND privmsgs_type = " . PRIVMSGS_UNREAD_MAIL;
                if ( !($result = $db->sql_query($sql)) )
                {
                   message_die(GENERAL_ERROR, 'Could not obtain user id list for outbox messages', '', __LINE__, __FILE__, $sql);
                }

                $update_pm_sql = '';
                while( $row = $db->sql_fetchrow($result) )
                {
                   $update_pm_sql .= ( ( $update_pm_sql != '' ) ? ', ' : '' ) . $row['privmsgs_to_userid'];
                }

                if ( $update_pm_sql != '' )
                {
                   $sql = "UPDATE " . USERS_TABLE . " 
                      SET user_unread_privmsg = user_unread_privmsg - 1
                      WHERE user_id IN ($update_pm_sql)";
                   if ( !$db->sql_query($sql) )
                   {
                      message_die(GENERAL_ERROR, 'Could not update users new msg counters', '', __LINE__, __FILE__, $sql);
                   }
                }
             }



    REPLACE WITH
    Code:


             $delete_sql_id = '';
             for ($i = 0; $i < sizeof($mark_list); $i++)
             {
                $delete_sql_id .= (($delete_sql_id != '') ? ', ' : '') . intval($mark_list[$i]);
             }

             if ($folder == 'inbox' || $folder == 'outbox')
             {
                switch ($folder)
                {
                   case 'inbox':
                      $sql = "privmsgs_to_userid = " . $userdata['user_id'];
                      break;
                   case 'outbox':
                      $sql = "privmsgs_from_userid = " . $userdata['user_id'];
                      break;
                }

                // Get information relevant to new or unread mail
                // so we can adjust users counters appropriately
                $sql = "SELECT privmsgs_to_userid, privmsgs_type
                   FROM " . PRIVMSGS_TABLE . "
                   WHERE privmsgs_id IN ($delete_sql_id)
                      AND $sql 
                      AND privmsgs_type IN (" . PRIVMSGS_NEW_MAIL . ", " . PRIVMSGS_UNREAD_MAIL . ")";
                if ( !($result = $db->sql_query($sql)) )
                {
                   message_die(GENERAL_ERROR, 'Could not obtain user id list for outbox messages', '', __LINE__, __FILE__, $sql);
                }

                if ( $row = $db->sql_fetchrow($result))
                {
                   $update_users = $update_list = array();
                
                   do
                   {
                      switch ($row['privmsgs_type'])
                      {
                         case PRIVMSGS_NEW_MAIL:
                            $update_users['new'][$row['privmsgs_to_userid']]++;
                            break;

                         case PRIVMSGS_UNREAD_MAIL:
                            $update_users['unread'][$row['privmsgs_to_userid']]++;
                            break;
                      }
                   }
                   while ($row = $db->sql_fetchrow($result));

                   if (sizeof($update_users))
                   {
                      while (list($type, $users) = each($update_users))
                      {
                         while (list($user_id, $dec) = each($users))
                         {
                            $update_list[$type][$dec][] = $user_id;
                         }
                      }
                      unset($update_users);

                      while (list($type, $dec_ary) = each($update_list))
                      {
                         switch ($type)
                         {
                            case 'new':
                               $type = "user_new_privmsg";
                               break;

                            case 'unread':
                               $type = "user_unread_privmsg";
                               break;
                         }

                         while (list($dec, $user_ary) = each($dec_ary))
                         {
                            $user_ids = implode(', ', $user_ary);

                            $sql = "UPDATE " . USERS_TABLE . "
                               SET $type = $type - $dec
                               WHERE user_id IN ($user_ids)";
                            if ( !$db->sql_query($sql) )
                            {
                               message_die(GENERAL_ERROR, 'Could not update user pm counters', '', __LINE__, __FILE__, $sql);
                            }
                         }
                      }
                      unset($update_list);
                   }
                }
                $db->sql_freeresult($result);
             }

             // Delete the messages



  14. FIND - Line 897
    Code:


          $header_location = ( @preg_match('/Microsoft|WebSTAR|Xitami/', getenv('SERVER_SOFTWARE')) ) ? 'Refresh: 0; URL=' : 'Location: ';
          header($header_location . append_sid("login.$phpEx?redirect=privmsg.$phpEx&folder=inbox", true));
          exit;
       }

       //
       // See if recipient is at their savebox limit
       //


    REPLACE WITH
    Code:


          redirect(append_sid("login.$phpEx?redirect=privmsg.$phpEx&folder=inbox", true));
       }

       // session id check
       if ($sid == '' || $sid != $userdata['session_id'])
       {
          message_die(GENERAL_ERROR, 'Invalid_session');
       }
       
       if (sizeof($mark_list))
       {
          // See if recipient is at their savebox limit



  15. FIND - Line 926
    Code:


             $sql = "DELETE $sql_priority FROM " . PRIVMSGS_TABLE . "
                WHERE ( ( privmsgs_to_userid = " . $userdata['user_id'] . "
                         AND privmsgs_type = " . PRIVMSGS_SAVED_IN_MAIL . " )
                      OR ( privmsgs_from_userid = " . $userdata['user_id'] . "
                         AND privmsgs_type = " . PRIVMSGS_SAVED_OUT_MAIL . ") )
                   AND privmsgs_date = " . $saved_info['oldest_post_time'];
             if ( !$db->sql_query($sql) )
             {
                message_die(GENERAL_ERROR, 'Could not delete oldest privmsgs', '', __LINE__, __FILE__, $sql);
             }
          }
       }

       //
       // Process request
       //
       $saved_sql = "UPDATE " . PRIVMSGS_TABLE;

       switch( $folder )


    REPLACE WITH
    Code:


                $sql = "SELECT privmsgs_id FROM " . PRIVMSGS_TABLE . "
                   WHERE ( ( privmsgs_to_userid = " . $userdata['user_id'] . "
                            AND privmsgs_type = " . PRIVMSGS_SAVED_IN_MAIL . " )
                         OR ( privmsgs_from_userid = " . $userdata['user_id'] . "
                            AND privmsgs_type = " . PRIVMSGS_SAVED_OUT_MAIL . ") )
                      AND privmsgs_date = " . $saved_info['oldest_post_time'];
                if ( !$result = $db->sql_query($sql) )
                {
                   message_die(GENERAL_ERROR, 'Could not find oldest privmsgs (save)', '', __LINE__, __FILE__, $sql);
                }
                $old_privmsgs_id = $db->sql_fetchrow($result);
                $old_privmsgs_id = $old_privmsgs_id['privmsgs_id'];
             
                $sql = "DELETE $sql_priority FROM " . PRIVMSGS_TABLE . "
                   WHERE privmsgs_id = $old_privmsgs_id";
                if ( !$db->sql_query($sql) )
                {
                   message_die(GENERAL_ERROR, 'Could not delete oldest privmsgs (save)', '', __LINE__, __FILE__, $sql);
                }

                $sql = "DELETE $sql_priority FROM " . PRIVMSGS_TEXT_TABLE . "
                   WHERE privmsgs_text_id = $old_privmsgs_id";
                if ( !$db->sql_query($sql) )
                {
                   message_die(GENERAL_ERROR, 'Could not delete oldest privmsgs text (save)', '', __LINE__, __FILE__, $sql);
                }
             }
          }
       
          $saved_sql_id = '';
          for ($i = 0; $i < sizeof($mark_list); $i++)
          {
             $saved_sql_id .= (($saved_sql_id != '') ? ', ' : '') . intval($mark_list[$i]);
          }

          // Process request
          $saved_sql = "UPDATE " . PRIVMSGS_TABLE;

          // Decrement read/new counters if appropriate
          if ($folder == 'inbox' || $folder == 'outbox')
          {
             switch ($folder)
             {
                case 'inbox':
                   $sql = "privmsgs_to_userid = " . $userdata['user_id'];
                   break;
                case 'outbox':
                   $sql = "privmsgs_from_userid = " . $userdata['user_id'];
                   break;
             }

             // Get information relevant to new or unread mail
             // so we can adjust users counters appropriately
             $sql = "SELECT privmsgs_to_userid, privmsgs_type
                FROM " . PRIVMSGS_TABLE . "
                WHERE privmsgs_id IN ($saved_sql_id)
                   AND $sql 
                   AND privmsgs_type IN (" . PRIVMSGS_NEW_MAIL . ", " . PRIVMSGS_UNREAD_MAIL . ")";
             if ( !($result = $db->sql_query($sql)) )
             {
                message_die(GENERAL_ERROR, 'Could not obtain user id list for outbox messages', '', __LINE__, __FILE__, $sql);
             }

             if ( $row = $db->sql_fetchrow($result))
             {
                $update_users = $update_list = array();
             
                do
                {
                   switch ($row['privmsgs_type'])
                   {
                      case PRIVMSGS_NEW_MAIL:
                         $update_users['new'][$row['privmsgs_to_userid']]++;
                         break;

                      case PRIVMSGS_UNREAD_MAIL:
                         $update_users['unread'][$row['privmsgs_to_userid']]++;
                         break;
                   }
                }
                while ($row = $db->sql_fetchrow($result));

                if (sizeof($update_users))
                {
                   while (list($type, $users) = each($update_users))
                   {
                      while (list($user_id, $dec) = each($users))
                      {
                         $update_list[$type][$dec][] = $user_id;
                      }
                   }
                   unset($update_users);

                   while (list($type, $dec_ary) = each($update_list))
                   {
                      switch ($type)
                      {
                         case 'new':
                            $type = "user_new_privmsg";
                            break;

                         case 'unread':
                            $type = "user_unread_privmsg";
                            break;
                      }

                      while (list($dec, $user_ary) = each($dec_ary))
                      {
                         $user_ids = implode(', ', $user_ary);

                         $sql = "UPDATE " . USERS_TABLE . "
                            SET $type = $type - $dec
                            WHERE user_id IN ($user_ids)";
                         if ( !$db->sql_query($sql) )
                         {
                            message_die(GENERAL_ERROR, 'Could not update user pm counters', '', __LINE__, __FILE__, $sql);
                         }
                      }
                   }
                   unset($update_list);
                }
             }
             $db->sql_freeresult($result);
          }

          switch ($folder)



  16. FIND - Line 1075
    Code:


       if ( count($mark_list) )
       {
          $saved_sql_id = '';
          for($i = 0; $i < count($mark_list); $i++)
          {
             $saved_sql_id .= ( ( $saved_sql_id != '' ) ? ', ' : '' ) . $mark_list[$i];
          }