cleanup of all code using delimiter
authorteepe <teepe@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Wed, 14 Nov 2001 01:02:37 +0000 (01:02 +0000)
committerteepe <teepe@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Wed, 14 Nov 2001 01:02:37 +0000 (01:02 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@1749 7612ce4b-ef26-0410-bec9-ea0150e637f0

functions/imap_mailbox.php
functions/tree.php
src/empty_trash.php
src/folders_create.php
src/folders_delete.php
src/folders_rename_do.php
src/folders_rename_getname.php
src/folders_subscribe.php
src/left_main.php
src/redirect.php
src/signout.php

index 420d8ca45a87fbdcfd2950c2360c99942c16c105..0721eae3d0a49bbfa9642f7016377c30f6d91d8a 100755 (executable)
@@ -62,9 +62,9 @@
     **  Creates a folder 
     ******************************************************************************/
    function sqimap_mailbox_create ($imap_stream, $mailbox, $type) {
+      global $delimiter;
       if (strtolower($type) == "noselect") {
-         $dm = sqimap_get_delimiter($imap_stream);
-         $mailbox = $mailbox.$dm;
+         $mailbox = $mailbox.$delimiter;
       }
       fputs ($imap_stream, sqimap_session_id() . " CREATE \"$mailbox\"\r\n");
       $read_ary = sqimap_read_data($imap_stream, sqimap_session_id(), true, $response, $message);
     **    unformatted-disp - unformatted without $folder_prefix
     **
     ******************************************************************************/
-   function sqimap_mailbox_parse ($line, $line_lsub, $dm) {
-      global $folder_prefix;
+   function sqimap_mailbox_parse ($line, $line_lsub) {
+      global $folder_prefix, $delimiter;
      
       // Process each folder line
       for ($g=0; $g < count($line); $g++) {
             $boxes[$g]["raw"] = "";
 
 
-         // Count number of delimiters ($dm) in folder name
+         // Count number of delimiters ($delimiter) in folder name
          $mailbox = trim($line_lsub[$g]);
-         $dm_count = countCharInString($mailbox, $dm);
-         if (substr($mailbox, -1) == $dm)
+         $dm_count = countCharInString($mailbox, $delimiter);
+         if (substr($mailbox, -1) == $delimiter)
             $dm_count--;  // If name ends in delimiter - decrement count by one
 
          // Format folder name, but only if it's a INBOX.* or have
          // a parent.
          $boxesbyname[$mailbox] = $g;
-         $parentfolder = readMailboxParent($mailbox, $dm);
+         $parentfolder = readMailboxParent($mailbox, $delimiter);
          if((strtolower(substr($mailbox, 0, 5)) == "inbox") ||
             (substr($mailbox, 0, strlen($folder_prefix)) == $folder_prefix) ||
             (isset($boxesbyname[$parentfolder]) && (strlen($parentfolder) > 0) ) ) {
-            $indent = $dm_count - (countCharInString($folder_prefix, $dm));
+            $indent = $dm_count - (countCharInString($folder_prefix, $delimiter));
             if ($indent > 0)
                 $boxes[$g]["formatted"]  = str_repeat("&nbsp;&nbsp;", $indent);
             else
                 $boxes[$g]["formatted"] = '';
-            $boxes[$g]["formatted"] .= readShortMailboxName($mailbox, $dm);
+            $boxes[$g]["formatted"] .= readShortMailboxName($mailbox, $delimiter);
          } else {
             $boxes[$g]["formatted"]  = $mailbox;
          }
             
          $boxes[$g]['unformatted-dm'] = $mailbox;
-         if (substr($mailbox, -1) == $dm)
+         if (substr($mailbox, -1) == $delimiter)
             $mailbox = substr($mailbox, 0, strlen($mailbox) - 1);
          $boxes[$g]['unformatted'] = $mailbox;
          if (substr($mailbox,0,strlen($folder_prefix))==$folder_prefix)
       global $data_dir, $username, $list_special_folders_first;
       global $folder_prefix, $trash_folder, $sent_folder, $draft_folder;
       global $move_to_trash, $move_to_sent, $save_as_draft;
+      global $delimiter;
 
       $inbox_in_list = false;
       $inbox_subscribed = false;
       require_once('../src/load_prefs.php');
       require_once('../functions/array.php');
 
-      $dm = sqimap_get_delimiter ($imap_stream);
-
       /** LSUB array **/
       fputs ($imap_stream, sqimap_session_id() . " LSUB \"$folder_prefix\" \"*\"\r\n");
       $lsub_ary = sqimap_read_data ($imap_stream, sqimap_session_id(), true, $response, $message);
       /** LIST array **/
       $sorted_list_ary = array();
       for ($i=0; $i < count($sorted_lsub_ary); $i++) {
-         if (substr($sorted_lsub_ary[$i], -1) == $dm)
+         if (substr($sorted_lsub_ary[$i], -1) == $delimiter)
             $mbx = substr($sorted_lsub_ary[$i], 0, strlen($sorted_lsub_ary[$i])-1);
          else
             $mbx = $sorted_lsub_ary[$i];
          $sorted_lsub_ary[] = find_mailbox_name($inbox_ary[0]);
       }
 
-      $boxes = sqimap_mailbox_parse ($sorted_list_ary, $sorted_lsub_ary, $dm);
+      $boxes = sqimap_mailbox_parse ($sorted_list_ary, $sorted_lsub_ary);
 
       /** Now, lets sort for special folders **/
       $boxesnew = Array();
          for ($i = 0 ; $i < count($boxes) ; $i++) {
             if ($move_to_trash &&
                    eregi('^' . quotemeta($trash_folder) . '(' .
-                     quotemeta($dm) . '.*)?$', $boxes[$i]['unformatted'])) {
+                     quotemeta($delimiter) . '.*)?$', $boxes[$i]['unformatted'])) {
                $boxesnew[] = $boxes[$i];
                $used[$i] = true;
             }
          for ($i = 0 ; $i < count($boxes) ; $i++) {
             if ($move_to_sent &&
                   eregi('^' . quotemeta($sent_folder) . '(' .
-                    quotemeta($dm) . '.*)?$', $boxes[$i]['unformatted'])) {
+                    quotemeta($delimiter) . '.*)?$', $boxes[$i]['unformatted'])) {
                $boxesnew[] = $boxes[$i];
                $used[$i] = true;
             }
          for ($i = 0 ; $i < count($boxes) ; $i++) {
             if ($save_as_draft &&
                   eregi('^' . quotemeta($draft_folder) . '(' .
-                    quotemeta($dm) . '.*)?$', $boxes[$i]['unformatted'])) {
+                    quotemeta($delimiter) . '.*)?$', $boxes[$i]['unformatted'])) {
                $boxesnew[] = $boxes[$i];
                $used[$i] = true;
             }
     ******************************************************************************/
    function sqimap_mailbox_list_all ($imap_stream) {
       global $list_special_folders_first, $folder_prefix;
-      
+      global $delimiter;
+
       if (!function_exists ("ary_sort"))
          include_once('../functions/array.php');
-      
-      $dm = sqimap_get_delimiter ($imap_stream);
 
       $ssid = sqimap_session_id();
       $lsid = strlen( $ssid ); 
             // Store the raw IMAP reply
             $boxes[$g]["raw"] = $read_ary[$i];
 
-            // Count number of delimiters ($dm) in folder name
+            // Count number of delimiters ($delimiter) in folder name
             $mailbox = find_mailbox_name($read_ary[$i]);
-            $dm_count = countCharInString($mailbox, $dm);
-            if (substr($mailbox, -1) == $dm)
+            $dm_count = countCharInString($mailbox, $delimiter);
+            if (substr($mailbox, -1) == $delimiter)
                $dm_count--;  // If name ends in delimiter - decrement count by one
             
             // Format folder name, but only if it's a INBOX.* or have
             // a parent.
             $boxesbyname[$mailbox] = $g;
-            $parentfolder = readMailboxParent($mailbox, $dm);
-            if((eregi('^inbox'.quotemeta($dm), $mailbox)) || 
+            $parentfolder = readMailboxParent($mailbox, $delimiter);
+            if((eregi('^inbox'.quotemeta($delimiter), $mailbox)) || 
                (ereg('^'.$folder_prefix, $mailbox)) ||
                ( isset($boxesbyname[$parentfolder]) && (strlen($parentfolder) > 0) ) ) {
                if ($dm_count)
                    $boxes[$g]["formatted"]  = str_repeat("&nbsp;&nbsp;", $dm_count);
                else
                    $boxes[$g]["formatted"] = '';
-               $boxes[$g]["formatted"] .= readShortMailboxName($mailbox, $dm);
+               $boxes[$g]["formatted"] .= readShortMailboxName($mailbox, $delimiter);
             } else {
                $boxes[$g]["formatted"]  = $mailbox;
             }
                
             $boxes[$g]["unformatted-dm"] = $mailbox;
-            if (substr($mailbox, -1) == $dm)
+            if (substr($mailbox, -1) == $delimiter)
                $mailbox = substr($mailbox, 0, strlen($mailbox) - 1);
             $boxes[$g]["unformatted"] = $mailbox;
             $boxes[$g]["unformatted-disp"] = ereg_replace('^' . $folder_prefix, '', $mailbox);
index f37c8422a7ee06dd3472177d9cf0b1b0bc9136f9..d218e29b71a76ec666da324fdbea82cae16727ec 100644 (file)
       }
    }
 
-   function walkTreeInPostOrderCreatingFoldersUnderTrash($index, $imap_stream, $tree, $dm, $topFolderName) {
-      global $trash_folder;
+   function walkTreeInPostOrderCreatingFoldersUnderTrash($index, $imap_stream, $tree, $topFolderName) {
+      global $trash_folder, $delimiter;
 
-      $position = strrpos($topFolderName, $dm) + 1;
+      $position = strrpos($topFolderName, $delimiter) + 1;
       $subFolderName = substr($tree[$index]['value'], $position);
 
       if ($tree[$index]['doIHaveChildren']) {
-         sqimap_mailbox_create($imap_stream, $trash_folder . $dm . $subFolderName, "");
+         sqimap_mailbox_create($imap_stream, $trash_folder . $delimiter . $subFolderName, "");
          sqimap_mailbox_select($imap_stream, $tree[$index]['value']);
         
          $messageCount = sqimap_get_num_messages($imap_stream, $tree[$index]['value']);
          if ($messageCount > 0)
-            sqimap_messages_copy($imap_stream, 1, $messageCount, $trash_folder . $dm . $subFolderName);
+            sqimap_messages_copy($imap_stream, 1, $messageCount, $trash_folder . $delimiter . $subFolderName);
          
          for ($j = 0;$j < count($tree[$index]['subNodes']); $j++)
-            walkTreeInPostOrderCreatingFoldersUnderTrash($tree[$index]['subNodes'][$j], $imap_stream, $tree, $dm, $topFolderName);
+            walkTreeInPostOrderCreatingFoldersUnderTrash($tree[$index]['subNodes'][$j], $imap_stream, $tree, $topFolderName);
       } else {
-         sqimap_mailbox_create($imap_stream, $trash_folder . $dm . $subFolderName, '');
+         sqimap_mailbox_create($imap_stream, $trash_folder . $delimiter . $subFolderName, '');
          sqimap_mailbox_select($imap_stream, $tree[$index]['value']);
          
          $messageCount = sqimap_get_num_messages($imap_stream, $tree[$index]['value']);
          if ($messageCount > 0)
-            sqimap_messages_copy($imap_stream, 1, $messageCount, $trash_folder . $dm . $subFolderName);
+            sqimap_messages_copy($imap_stream, 1, $messageCount, $trash_folder . $delimiter . $subFolderName);
       }
    }
 
          echo $tree[$index]['value'] . '<br>';
       }
    }
-?>
\ No newline at end of file
+?>
index 279af75eaac657ce58fdcb86035153e5f5b4f3ac..7bb94d38f25662f9151327250a152204c4fca928 100644 (file)
@@ -23,7 +23,7 @@
 
    $mailbox = $trash_folder;
    $boxes = sqimap_mailbox_list($imap_stream);
-   $dm = sqimap_get_delimiter($imap_stream);
+   global $delimiter;
    
    // According to RFC2060, a DELETE command should NOT remove inferiors (sub folders)
    //    so lets go through the list of subfolders and remove them before removing the
@@ -42,7 +42,7 @@
    //    on the end of the $mailbox string, and compare to that.
    $j = 0;
    for ($i = 0;$i < count($boxes);$i++) {
-      if (substr($boxes[$i]["unformatted"], 0, strlen($mailbox . $dm)) == ($mailbox . $dm)) {
+      if (substr($boxes[$i]["unformatted"], 0, strlen($mailbox . $delimiter)) == ($mailbox . $delimiter)) {
          addChildNodeToTree($boxes[$i]["unformatted"], $boxes[$i]["unformatted-dm"], $foldersTree);
       }
    }
@@ -54,4 +54,4 @@
    header ("Location: $location/left_main.php");
 
    sqimap_logout($imap_stream);
-?>
\ No newline at end of file
+?>
index 1f25070b0f76b45ed195910971633183f32d5fa1..97661a83ed4431da79bed7b0183c68d86be0894d 100644 (file)
    require_once('../functions/display_messages.php');
 
    $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
-   $dm = sqimap_get_delimiter($imapConnection);
+   global $delimiter;
 
    if (strpos($folder_name, "\"") || strpos($folder_name, "\\") ||
-       strpos($folder_name, "'") || strpos($folder_name, "$dm")) {
+       strpos($folder_name, "'") || strpos($folder_name, "$delimiter")) {
       echo "<html><body bgcolor=$color[4]>";
       plain_error_message(_("Illegal folder name.  Please select a different name.")."<BR><A HREF=\"../src/folders.php\">"._("Click here to go back")."</A>.", $color);
       sqimap_logout($imapConnection);
    }
 
    if (isset($contain_subs) && $contain_subs == true)
-      $folder_name = "$folder_name$dm";
+      $folder_name = "$folder_name$delimiter";
 
-   if ($folder_prefix && (substr($folder_prefix, -1) != $dm)) {
-      $folder_prefix = $folder_prefix . $dm;
+   if ($folder_prefix && (substr($folder_prefix, -1) != $delimiter)) {
+      $folder_prefix = $folder_prefix . $delimiter;
    }
    if ($folder_prefix && (substr($subfolder, 0, strlen($folder_prefix)) != $folder_prefix)){
       $subfolder_orig = $subfolder;
    if (trim($subfolder_orig) == '') {
       sqimap_mailbox_create ($imapConnection, $folder_prefix.$folder_name, "");
    } else {
-      sqimap_mailbox_create ($imapConnection, $subfolder.$dm.$folder_name, "");
+      sqimap_mailbox_create ($imapConnection, $subfolder.$delimiter.$folder_name, "");
    }
 
    $location = get_location();
    header ("Location: $location/folders.php?success=create");
    sqimap_logout($imapConnection);
-?>
\ No newline at end of file
+?>
index a301f70ba9578161d9be6aceda4033bc61493635..140d1400f8befea3acbffb9adea3302e1b6ffa69 100644 (file)
@@ -23,9 +23,9 @@
    
    $imap_stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
    $boxes = sqimap_mailbox_list ($imap_stream);
-   $dm = sqimap_get_delimiter($imap_stream);
+   global $delimiter;
    
-   if (substr($mailbox, -1) == $dm)
+   if (substr($mailbox, -1) == $delimiter)
       $mailbox_no_dm = substr($mailbox, 0, strlen($mailbox) - 1); 
    else
       $mailbox_no_dm = $mailbox;
@@ -67,7 +67,7 @@
    //    on the end of the $mailbox string, and compare to that.
    $j = 0;
    for ($i = 0;$i < count($boxes);$i++) {
-      if (substr($boxes[$i]["unformatted"], 0, strlen($mailbox_no_dm . $dm)) == ($mailbox_no_dm . $dm)) {
+      if (substr($boxes[$i]["unformatted"], 0, strlen($mailbox_no_dm . $delimiter)) == ($mailbox_no_dm . $delimiter)) {
          addChildNodeToTree($boxes[$i]["unformatted"], $boxes[$i]["unformatted-dm"], $foldersTree);
       }
    }
@@ -75,7 +75,7 @@
 
    /** Lets start removing the folders and messages **/
    if (($move_to_trash == true) && ($can_move_to_trash == true)) { /** if they wish to move messages to the trash **/
-      walkTreeInPostOrderCreatingFoldersUnderTrash(0, $imap_stream, $foldersTree, $dm, $mailbox);
+      walkTreeInPostOrderCreatingFoldersUnderTrash(0, $imap_stream, $foldersTree, $mailbox);
       walkTreeInPreOrderDeleteFolders(0, $imap_stream, $foldersTree);
    } else { /** if they do NOT wish to move messages to the trash (or cannot)**/
       walkTreeInPreOrderDeleteFolders(0, $imap_stream, $foldersTree);
@@ -99,4 +99,4 @@
    
    echo "</BODY></HTML>";
    */
-?>
\ No newline at end of file
+?>
index 8807f6456c2bd9a72a3937e7c142942e143dfabb..4edacc2d79217102f9f3e5a7a7ecb167ca22cbdd 100644 (file)
    }
 
    $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
-   $dm = sqimap_get_delimiter($imapConnection);
+   global $delimiter;
 
-   if (strpos($orig, $dm))
-      $old_dir = substr($orig, 0, strrpos($orig, $dm));
+   if (strpos($orig, $delimiter))
+      $old_dir = substr($orig, 0, strrpos($orig, $delimiter));
    else
       $old_dir = "";
 
    if ($old_dir != "")
-      $newone = "$old_dir$dm$new_name";
+      $newone = "$old_dir$delimiter$new_name";
    else
       $newone = "$new_name";
 
@@ -41,8 +41,8 @@
    // Renaming a folder doesn't renames the folder but leaves you unsubscribed
    //    at least on Cyrus IMAP servers.
    if (isset($isfolder)) {
-      $newone = $newone.$dm;
-      $orig = $orig.$dm;
+      $newone = $newone.$delimiter;
+      $orig = $orig.$delimiter;
    }   
    sqimap_unsubscribe($imapConnection, $orig);
    sqimap_subscribe($imapConnection, $newone);
@@ -67,4 +67,4 @@
    sqimap_logout($imapConnection);
    $location = get_location();
    header ("Location: $location/folders.php?success=rename");
-?>
\ No newline at end of file
+?>
index 0af0f529c1873eefa18ca0c4901c14081f2b6e96..c297f146e3b4d932b3d42bd1397e6cfa882e7881 100644 (file)
 
    $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
 
-   $dm = sqimap_get_delimiter($imapConnection);
-   if (substr($old, strlen($old) - strlen($dm)) == $dm) {
+   global $delimiter;
+   if (substr($old, strlen($old) - strlen($delimiter)) == $delimiter) {
       $isfolder = true;
       $old = substr($old, 0, strlen($old) - 1);
    }
    
-   if (strpos($old, $dm)) {
-      $old_name = substr($old, strrpos($old, $dm)+1, strlen($old));
-      $old_parent = substr($old, 0, strrpos($old, $dm));
+   if (strpos($old, $delimiter)) {
+      $old_name = substr($old, strrpos($old, $delimiter)+1, strlen($old));
+      $old_parent = substr($old, 0, strrpos($old, $delimiter));
    } else {
       $old_name = $old;
       $old_parent = "";
@@ -49,4 +49,4 @@
 
    /** Log out this session **/
    sqimap_logout($imapConnection);
-?>
\ No newline at end of file
+?>
index 761d2e183ea7f67691c4bfc4a2c98c4ef7cde573..6f3879860359dc618b49c69a0e8c01eaa495c315 100644 (file)
@@ -16,7 +16,6 @@
    require_once('../functions/display_messages.php');
 
    $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
-   $dm = sqimap_get_delimiter($imapConnection);
 
    $location = get_location();
    if ($method == "sub") {
index 3e2ab9ff3954e5899f1a0716729adbb52530a776..a04ebe8139327637a1066d1b55a5204b2f8f497b 100644 (file)
@@ -19,6 +19,8 @@
     define('SM_BOX_UNCOLLAPSED', 0);
     define('SM_BOX_COLLAPSED',   1);
 
+    global $delimiter;
+
     // open a connection on the imap port (143)
     $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 10); // the 10 is to hide the output
 
@@ -58,7 +60,7 @@
         session_register('auto_create_done');
     }
 
-   function formatMailboxName($imapConnection, $box_array, $delimeter) {
+   function formatMailboxName($imapConnection, $box_array) {
       global $folder_prefix, $trash_folder, $sent_folder;
       global $color, $move_to_sent, $move_to_trash;
       global $unseen_notify, $unseen_type, $collapse_folders;
     echo '<SMALL>(<A HREF="../src/left_main.php" TARGET="left">';
     echo _("refresh folder list");
     echo '</A>)</SMALL></CENTER><BR>';
-    $delimeter = sqimap_get_delimiter($imapConnection);
 
     /* Lastly, display the folder list. */
     if (isset($collapse_folders) && $collapse_folders) {
     for ($i = 0;$i < count($boxes); $i++) {
         if ($boxes[$i]['visible'] == true) {
             $mailbox = $boxes[$i]['formatted'];
-            $mblevel = substr_count($boxes[$i]['unformatted'], $delimeter) + 1;
+            $mblevel = substr_count($boxes[$i]['unformatted'], $delimiter) + 1;
 
             /* Create the prefix for the folder name and link. */
             $prefix = str_repeat('  ',$mblevel);
                 }
                 $line .= '</FONT>';
             } else {
-                $line .= formatMailboxName($imapConnection, $boxes[$i], $delimeter);
+                $line .= formatMailboxName($imapConnection, $boxes[$i]);
             }
 
             /* Put the final touches on our folder line. */
      * This simple function checks if a box is another box's parent.
      */
     function is_parent_box($curbox_name, $parbox_name) {
-        global $delimeter;
+        global $delimiter;
 
         /* Extract the name of the parent of the current box. */
-        $curparts = explode($delimeter, $curbox_name);
+        $curparts = explode($delimiter, $curbox_name);
         $curname = array_pop($curparts);
-        $actual_parname = implode($delimeter, $curparts);
+        $actual_parname = implode($delimiter, $curparts);
         $actual_parname = substr($actual_parname,0,strlen($parbox_name));
 
         /* Compare the actual with the given parent name. */
index cb89d5ae633ace6c39e984998c073747f3588c30..1c4a30a8b1596e4d16974855ce01aa05c0f4ce23 100644 (file)
             $delimiter = sqimap_get_delimiter ($imapConnection);
         }
         sqimap_logout($imapConnection);
+        session_register('delimiter');
 
         $username = $login_username;
         session_register ('username');
         setcookie('key', $key, 0, $base_uri);
-        setcookie('delimiter', $delimiter, 0, $base_uri);
         do_hook ('login_verified');
     }
 
index 75839a2f1f787a71e27abb1195fbe6fa12aba75e..794f445dc4b45e455414a31266e1bcba240d9bfb 100644 (file)
@@ -35,7 +35,6 @@
    do_hook('logout');
    setcookie('username', '', 0, $base_uri);
    setcookie('key', '', 0, $base_uri);
-   setcookie('delimiter', '', 0, $base_uri);
    session_destroy();
 
    if ($signout_page) {