From: teepe Date: Wed, 14 Nov 2001 01:02:37 +0000 (+0000) Subject: cleanup of all code using delimiter X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=commitdiff_plain;h=525b7ae6ddd3cb500999021bb216d010fade1857 cleanup of all code using delimiter git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@1749 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- diff --git a/functions/imap_mailbox.php b/functions/imap_mailbox.php index 420d8ca4..0721eae3 100755 --- a/functions/imap_mailbox.php +++ b/functions/imap_mailbox.php @@ -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); @@ -133,8 +133,8 @@ ** 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++) { @@ -146,31 +146,31 @@ $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("  ", $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) @@ -209,6 +209,7 @@ 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; @@ -216,8 +217,6 @@ 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); @@ -256,7 +255,7 @@ /** 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]; @@ -300,7 +299,7 @@ $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(); @@ -320,7 +319,7 @@ 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; } @@ -330,7 +329,7 @@ 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; } @@ -340,7 +339,7 @@ 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; } @@ -373,11 +372,10 @@ ******************************************************************************/ 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 ); @@ -401,30 +399,30 @@ // 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("  ", $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); diff --git a/functions/tree.php b/functions/tree.php index f37c8422..d218e29b 100644 --- a/functions/tree.php +++ b/functions/tree.php @@ -90,29 +90,29 @@ } } - 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); } } @@ -126,4 +126,4 @@ echo $tree[$index]['value'] . '
'; } } -?> \ No newline at end of file +?> diff --git a/src/empty_trash.php b/src/empty_trash.php index 279af75e..7bb94d38 100644 --- a/src/empty_trash.php +++ b/src/empty_trash.php @@ -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 +?> diff --git a/src/folders_create.php b/src/folders_create.php index 1f25070b..97661a83 100644 --- a/src/folders_create.php +++ b/src/folders_create.php @@ -16,10 +16,10 @@ 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 ""; plain_error_message(_("Illegal folder name. Please select a different name.")."
"._("Click here to go back").".", $color); sqimap_logout($imapConnection); @@ -27,10 +27,10 @@ } 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; @@ -42,10 +42,10 @@ 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 +?> diff --git a/src/folders_delete.php b/src/folders_delete.php index a301f70b..140d1400 100644 --- a/src/folders_delete.php +++ b/src/folders_delete.php @@ -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 ""; */ -?> \ No newline at end of file +?> diff --git a/src/folders_rename_do.php b/src/folders_rename_do.php index 8807f645..4edacc2d 100644 --- a/src/folders_rename_do.php +++ b/src/folders_rename_do.php @@ -21,15 +21,15 @@ } $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 +?> diff --git a/src/folders_rename_getname.php b/src/folders_rename_getname.php index 0af0f529..c297f146 100644 --- a/src/folders_rename_getname.php +++ b/src/folders_rename_getname.php @@ -16,15 +16,15 @@ $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 +?> diff --git a/src/folders_subscribe.php b/src/folders_subscribe.php index 761d2e18..6f387986 100644 --- a/src/folders_subscribe.php +++ b/src/folders_subscribe.php @@ -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") { diff --git a/src/left_main.php b/src/left_main.php index 3e2ab9ff..a04ebe81 100644 --- a/src/left_main.php +++ b/src/left_main.php @@ -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; @@ -198,7 +200,6 @@ echo '('; echo _("refresh folder list"); echo ')
'; - $delimeter = sqimap_get_delimiter($imapConnection); /* Lastly, display the folder list. */ if (isset($collapse_folders) && $collapse_folders) { @@ -223,7 +224,7 @@ 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); @@ -244,7 +245,7 @@ } $line .= ''; } else { - $line .= formatMailboxName($imapConnection, $boxes[$i], $delimeter); + $line .= formatMailboxName($imapConnection, $boxes[$i]); } /* Put the final touches on our folder line. */ @@ -284,12 +285,12 @@ * 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. */ diff --git a/src/redirect.php b/src/redirect.php index cb89d5ae..1c4a30a8 100644 --- a/src/redirect.php +++ b/src/redirect.php @@ -81,11 +81,11 @@ $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'); } diff --git a/src/signout.php b/src/signout.php index 75839a2f..794f445d 100644 --- a/src/signout.php +++ b/src/signout.php @@ -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) {