From c5ac073c9f48ce33960f66f5cc925bb452ae18b2 Mon Sep 17 00:00:00 2001
From: svncommit <devs@roundcube.net>
Date: Thu, 18 May 2006 11:46:50 -0400
Subject: [PATCH] renamed $mbox so that it will stop interfering with the $_SESSION when register_globals is turned on

---
 program/steps/mail/list.inc         |   10 +++++-----
 program/steps/mail/folders.inc      |    4 ++--
 program/steps/mail/check_recent.inc |    6 +++---
 program/steps/mail/func.inc         |   23 +++++++++++++----------
 program/steps/mail/getunread.inc    |    4 ++--
 program/steps/mail/mark.inc         |    5 ++---
 program/steps/mail/sendmail.inc     |    6 +++---
 7 files changed, 30 insertions(+), 28 deletions(-)

diff --git a/program/steps/mail/check_recent.inc b/program/steps/mail/check_recent.inc
index 0bde47e..8a563c4 100644
--- a/program/steps/mail/check_recent.inc
+++ b/program/steps/mail/check_recent.inc
@@ -20,14 +20,14 @@
 */
 
 $REMOTE_REQUEST = TRUE;
-$mbox = $IMAP->get_mailbox_name();
+$mbox_name = $IMAP->get_mailbox_name();
 
 if ($recent_count = $IMAP->messagecount(NULL, 'RECENT', TRUE))
   {
   $count = $IMAP->messagecount();
   $unread_count = $IMAP->messagecount(NULL, 'UNSEEN', TRUE);
     
-  $commands = sprintf("this.set_unread_count('%s', %d, true);\n", addslashes($mbox), $unread_count);
+  $commands = sprintf("this.set_unread_count('%s', %d, true);\n", addslashes($mbox_name), $unread_count);
   $commands .= sprintf("this.set_env('messagecount', %d);\n", $count);
   $commands .= sprintf("this.set_rowcount('%s');\n", rcmail_get_messagecount_text());
   $commands .= sprintf("this.set_quota('%s');\n", $IMAP->get_quota());
@@ -40,7 +40,7 @@
   $commands .= rcmail_js_message_list($a_headers, TRUE);
   }
 
-if (strtoupper($mbox)!='INBOX' && $IMAP->messagecount('INBOX', 'RECENT'))
+if (strtoupper($mbox_name)!='INBOX' && $IMAP->messagecount('INBOX', 'RECENT'))
   $commands = sprintf("this.set_unread_count('INBOX', %d);\n", $IMAP->messagecount('INBOX', 'UNSEEN'));
 
 
diff --git a/program/steps/mail/folders.inc b/program/steps/mail/folders.inc
index 5a22b7e..d614ac8 100644
--- a/program/steps/mail/folders.inc
+++ b/program/steps/mail/folders.inc
@@ -19,7 +19,7 @@
 */
 
 $REMOTE_REQUEST = TRUE;
-$mbox = $IMAP->get_mailbox_name();
+$mbox_name = $IMAP->get_mailbox_name();
 
 
 // send EXPUNGE command
@@ -49,7 +49,7 @@
     $commands .= "this.set_env('messagecount', 0);\n";
     $commands .= "this.set_env('pagecount', 0);\n";
     $commands .= sprintf("this.set_rowcount('%s');\n", rcmail_get_messagecount_text());
-    $commands .= sprintf("this.set_unread_count('%s', 0);\n", addslashes($mbox));
+    $commands .= sprintf("this.set_unread_count('%s', 0);\n", addslashes($mbox_name));
     }
   else
     $commands = "// purged: $success";
diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc
index 83c8bd8..1be690a 100644
--- a/program/steps/mail/func.inc
+++ b/program/steps/mail/func.inc
@@ -25,6 +25,10 @@
 
 $EMAIL_ADDRESS_PATTERN = '/([a-z0-9][a-z0-9\-\.\+\_]*@[a-z0-9]([a-z0-9\-][.]?)*[a-z0-9]\\.[a-z]{2,5})/i';
 
+if (empty($_SESSION['mbox'])){
+  $_SESSION['mbox'] = $IMAP->get_mailbox_name();
+}
+
 // set imap properties and session vars
 if (strlen($_GET['_mbox']))
   {
@@ -56,7 +60,6 @@
 
 // set current mailbox in client environment
 $OUTPUT->add_script(sprintf("%s.set_env('mailbox', '%s');", $JS_OBJECT_NAME, $IMAP->get_mailbox_name()));
-
 
 if ($CONFIG['trash_mbox'])
   $OUTPUT->add_script(sprintf("%s.set_env('trash_mailbox', '%s');", $JS_OBJECT_NAME, $CONFIG['trash_mbox']));
@@ -93,7 +96,7 @@
                     rcube_label($attrib['noselection']));
   
   // get mailbox list
-  $mbox = $IMAP->get_mailbox_name();
+  $mbox_name = $IMAP->get_mailbox_name();
   
   // for these mailboxes we have localized labels
   $special_mailboxes = array('inbox', 'sent', 'drafts', 'trash', 'junk');
@@ -116,9 +119,9 @@
 // var_dump($a_mailboxes);
 
   if ($type=='select')
-    $out .= rcmail_render_folder_tree_select($a_mailboxes, $special_mailboxes, $mbox, $attrib['maxlength']);
+    $out .= rcmail_render_folder_tree_select($a_mailboxes, $special_mailboxes, $mbox_name, $attrib['maxlength']);
    else
-    $out .= rcmail_render_folder_tree_html($a_mailboxes, $special_mailboxes, $mbox, $attrib['maxlength']);
+    $out .= rcmail_render_folder_tree_html($a_mailboxes, $special_mailboxes, $mbox_name, $attrib['maxlength']);
 
 // rcube_print_time($mboxlist_start, 'render_folder_tree()');
 
@@ -162,7 +165,7 @@
   
 
 // return html for a structured list <ul> for the mailbox tree
-function rcmail_render_folder_tree_html(&$arrFolders, &$special, &$mbox, $maxlength, $nestLevel=0)
+function rcmail_render_folder_tree_html(&$arrFolders, &$special, &$mbox_name, $maxlength, $nestLevel=0)
   {
   global $JS_OBJECT_NAME, $COMM_PATH, $IMAP, $CONFIG, $OUTPUT;
 
@@ -191,7 +194,7 @@
       }
 
     // add unread message count display
-    if ($unread_count = $IMAP->messagecount($folder['id'], 'RECENT', ($folder['id']==$mbox)))
+    if ($unread_count = $IMAP->messagecount($folder['id'], 'RECENT', ($folder['id']==$mbox_name)))
       $foldername .= sprintf(' (%d)', $unread_count);
 
     // make folder name safe for ids and class names
@@ -214,7 +217,7 @@
                     $class_name,
                     $zebra_class,
                     $unread_count ? ' unread' : '',
-                    $folder['id']==$mbox ? ' selected' : '',
+                    $folder['id']==$mbox_name ? ' selected' : '',
                     $COMM_PATH,
                     urlencode($folder['id']),
                     $JS_OBJECT_NAME,
@@ -225,7 +228,7 @@
                     rep_specialchars_output($foldername, 'html', 'all'));
 
     if (!empty($folder['folders']))
-      $out .= "\n<ul>\n" . rcmail_render_folder_tree_html($folder['folders'], $special, $mbox, $maxlength, $nestLevel+1) . "</ul>\n";
+      $out .= "\n<ul>\n" . rcmail_render_folder_tree_html($folder['folders'], $special, $mbox_name, $maxlength, $nestLevel+1) . "</ul>\n";
 
     $out .= "</li>\n";
     $idx++;
@@ -236,7 +239,7 @@
 
 
 // return html for a flat list <select> for the mailbox tree
-function rcmail_render_folder_tree_select(&$arrFolders, &$special, &$mbox, $maxlength, $nestLevel=0)
+function rcmail_render_folder_tree_select(&$arrFolders, &$special, &$mbox_name, $maxlength, $nestLevel=0)
   {
   global $IMAP, $OUTPUT;
 
@@ -262,7 +265,7 @@
                     rep_specialchars_output($foldername, 'html', 'all'));
 
     if (!empty($folder['folders']))
-      $out .= rcmail_render_folder_tree_select($folder['folders'], $special, $mbox, $maxlength, $nestLevel+1);
+      $out .= rcmail_render_folder_tree_select($folder['folders'], $special, $mbox_name, $maxlength, $nestLevel+1);
 
     $idx++;
     }
diff --git a/program/steps/mail/getunread.inc b/program/steps/mail/getunread.inc
index d35dcf9..437e3aa 100644
--- a/program/steps/mail/getunread.inc
+++ b/program/steps/mail/getunread.inc
@@ -25,9 +25,9 @@
 
 if (!empty($a_folders))
   {
-  foreach ($a_folders as $mbox)
+  foreach ($a_folders as $mbox_row)
     {
-    $commands = sprintf("this.set_unread_count('%s', %d);\n", $mbox, $IMAP->messagecount($mbox, 'UNSEEN'));
+    $commands = sprintf("this.set_unread_count('%s', %d);\n", $mbox_row, $IMAP->messagecount($mbox_row, 'UNSEEN'));
     rcube_remote_response($commands, TRUE);
     }
   }
diff --git a/program/steps/mail/list.inc b/program/steps/mail/list.inc
index ba4169f..b3ea08b 100644
--- a/program/steps/mail/list.inc
+++ b/program/steps/mail/list.inc
@@ -46,16 +46,16 @@
 if (!empty($_GET['_search']) && isset($_SESSION['search'][$_GET['_search']]))
   {
   $a_msgs = split(',', $_SESSION['search'][$_GET['_search']]);
-  $a_headers = $IMAP->list_header_set($mbox, $a_msgs, NULL, $sort_col, $sort_order);
+  $a_headers = $IMAP->list_header_set($mbox_name, $a_msgs, NULL, $sort_col, $sort_order);
   $count = count($a_msgs);
   }
 else
   {
   if ($count = $IMAP->messagecount())
-    $a_headers = $IMAP->list_headers($mbox, NULL, $sort_col, $sort_order);
+    $a_headers = $IMAP->list_headers($mbox_name, NULL, $sort_col, $sort_order);
   }
 
-$unseen = $IMAP->messagecount($mbox, 'UNSEEN', !empty($_GET['_refresh']) ? TRUE : FALSE);
+$unseen = $IMAP->messagecount($mbox_name, 'UNSEEN', !empty($_GET['_refresh']) ? TRUE : FALSE);
 
 // update message count display
 $pages = ceil($count/$IMAP->page_size);
@@ -64,8 +64,8 @@
 $commands .= sprintf("this.set_rowcount('%s');\n", rcmail_get_messagecount_text($count));
 
 // update mailboxlist
-$mbox = $IMAP->get_mailbox_name();
-$commands .= sprintf("this.set_unread_count('%s', %d);\n", addslashes($mbox), $unseen);
+$mbox_name = $IMAP->get_mailbox_name();
+$commands .= sprintf("this.set_unread_count('%s', %d);\n", addslashes($mbox_name), $unseen);
 
 
 // add message rows
diff --git a/program/steps/mail/mark.inc b/program/steps/mail/mark.inc
index c12429d..e6e06f9 100644
--- a/program/steps/mail/mark.inc
+++ b/program/steps/mail/mark.inc
@@ -1,5 +1,4 @@
 <?php
-
 /*
  +-----------------------------------------------------------------------+
  | program/steps/mail/mark.inc                                           |
@@ -32,8 +31,8 @@
   $marked = $IMAP->set_flag($_GET['_uid'], $flag);
   if ($marked != -1)
     {
-    $mbox = $IMAP->get_mailbox_name();
-    $commands = sprintf("this.set_unread_count('%s', %d);\n", $mbox, $IMAP->messagecount($mbox, 'UNSEEN'));
+    $mbox_name = $IMAP->get_mailbox_name();
+    $commands = sprintf("this.set_unread_count('%s', %d);\n", $mbox_name, $IMAP->messagecount($mbox_name, 'UNSEEN'));
     rcube_remote_response($commands);
     }
   }
diff --git a/program/steps/mail/sendmail.inc b/program/steps/mail/sendmail.inc
index f8d3ada..65365ea 100644
--- a/program/steps/mail/sendmail.inc
+++ b/program/steps/mail/sendmail.inc
@@ -286,12 +286,12 @@
 
   // check if mailbox exists
   if (!in_array_nocase($CONFIG['sent_mbox'], $IMAP->list_mailboxes()))
-    $mbox = $IMAP->create_mailbox($CONFIG['sent_mbox'], TRUE);
+    $sent_folder = $IMAP->create_mailbox($CONFIG['sent_mbox'], TRUE);
   else
-    $mbox = TRUE;
+    $sent_folder = TRUE;
 
   // append message to sent box
-  if ($mbox)
+  if ($sent_folder)
     $saved = $IMAP->save_message($CONFIG['sent_mbox'], $header_str."\r\n".$msg_body);
 
   // raise error if saving failed

--
Gitblit v1.9.1