From 813eba2f5f4695bd30b895cd148658f3b90bf120 Mon Sep 17 00:00:00 2001 From: lkehresman Date: Mon, 21 Feb 2000 12:00:35 +0000 Subject: [PATCH] Rewrote imap functions git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@228 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- src/compose.php | 29 +++++++----------- src/delete_message.php | 7 ++--- src/download.php | 9 +++--- src/empty_trash.php | 18 +++++------ src/folders.php | 34 ++++++++++----------- src/folders_create.php | 40 +++++++++++++------------ src/folders_delete.php | 55 ++++++++++++++++------------------ src/folders_rename_do.php | 10 +++---- src/folders_rename_getname.php | 9 +++--- src/left_main.php | 33 ++++++++++---------- src/move_messages.php | 17 +++++------ src/options.php | 5 ++-- src/options_submit.php | 1 - src/read_body.php | 7 ++--- src/right_main.php | 13 +++----- 15 files changed, 130 insertions(+), 157 deletions(-) diff --git a/src/compose.php b/src/compose.php index b42a551e..6e73f0b1 100644 --- a/src/compose.php +++ b/src/compose.php @@ -11,7 +11,6 @@ include("../functions/strings.php"); include("../functions/page_header.php"); include("../functions/imap.php"); - include("../functions/mailbox.php"); include("../functions/date.php"); include("../functions/mime.php"); include("../functions/smtp.php"); @@ -20,7 +19,7 @@ include("../src/load_prefs.php"); echo "\n"; - $imapConnection = loginToImapServer($username, $key, $imapServerAddress, 0); + $imapConnection = sqimap_login($username, $key, $imapServerAddress, 0); displayPageHeader($color, "None"); // This function is used when not sending or adding attachments @@ -29,8 +28,8 @@ $reply_id, $send_to, $send_to_cc, $mailbox; if ($forward_id) { - selectMailbox($imapConnection, $mailbox, $numMessages); - $msg = fetchMessage($imapConnection, $forward_id, $mailbox); + sqimap_mailbox_select($imapConnection, $mailbox); + $msg = sqimap_get_message($imapConnection, $forward_id, $mailbox); if (containsType($msg, "text", "html", $ent_num)) { $body = decodeBody($msg["ENTITIES"][$ent_num]["BODY"], $msg["ENTITIES"][$ent_num]["ENCODING"]); @@ -65,8 +64,8 @@ } if ($reply_id) { - selectMailbox($imapConnection, $mailbox, $numMessages); - $msg = fetchMessage($imapConnection, $reply_id, $mailbox); + sqimap_mailbox_select($imapConnection, $mailbox); + $msg = sqimap_get_message($imapConnection, $reply_id, $mailbox); if (containsType($msg, "text", "html", $ent_num)) { $body = decodeBody($msg["ENTITIES"][$ent_num]["BODY"], $msg["ENTITIES"][$ent_num]["ENCODING"], false); @@ -98,10 +97,7 @@ } } - // Add some decoding information - $send_to = encodeEmailAddr($send_to); - // parses the field and returns only the email address - $send_to = decodeEmailAddr($send_to); + $send_to = sqimap_find_displayable_name($send_to); $send_to = strtolower($send_to); $send_to = ereg_replace("\"", "", $send_to); @@ -118,14 +114,9 @@ if ($sendcc[$i] == "") continue; - $sendcc[$i] = encodeEmailAddr($sendcc[$i]); - $sendcc[$i] = decodeEmailAddr($sendcc[$i]); - - $whofrom = encodeEmailAddr($msg["HEADER"]["FROM"]); - $whofrom = decodeEmailAddr($whofrom); - - $whoreplyto = encodeEmailAddr($msg["HEADER"]["REPLYTO"]); - $whoreplyto = decodeEmailAddr($whoreplyto); + $sendcc[$i] = sqimap_find_displayable_name($sendcc[$i]); + $whofrom = sqimap_find_displayable_name($msg["HEADER"]["FROM"]); + $whoreplyto = sqimap_find_email($msg["HEADER"]["REPLYTO"]); if ((strtolower(trim($sendcc[$i])) != strtolower(trim($whofrom))) && (strtolower(trim($sendcc[$i])) != strtolower(trim($whoreplyto))) && @@ -212,7 +203,7 @@ echo " \n"; echo " \n"; if ($use_signature == true) - echo "   
"; + echo "   
"; else echo "   
\n"; echo " \n"; diff --git a/src/delete_message.php b/src/delete_message.php index cf6a3657..8c1a12de 100644 --- a/src/delete_message.php +++ b/src/delete_message.php @@ -1,6 +1,5 @@ \n"; - $imapConnection = loginToImapServer($username, $key, $imapServerAddress, 0); - selectMailbox($imapConnection, $mailbox, $numMessages, $imapServerAddress); + $imapConnection = sqimap_login($username, $key, $imapServerAddress, 0); + sqimap_mailbox_select($imapConnection, $mailbox); displayPageHeader($color, $mailbox); - deleteMessages($imapConnection, $message, $message, $numMessages, $trash_folder, $move_to_trash, $auto_expunge, $mailbox); + sqimap_message_delete($imapConnection, $message, $message, $mailbox); messages_deleted_message($mailbox, $sort, $startMessage, $color); ?> diff --git a/src/download.php b/src/download.php index 6aa7a895..2a5b1a62 100644 --- a/src/download.php +++ b/src/download.php @@ -4,7 +4,6 @@ include("../functions/page_header.php"); include("../functions/imap.php"); include("../functions/mime.php"); - include("../functions/mailbox.php"); include("../functions/date.php"); include("../src/load_prefs.php"); @@ -30,12 +29,12 @@ echo ""; } - $imapConnection = loginToImapServer($username, $key, $imapServerAddress, 0); - selectMailbox($imapConnection, $mailbox, $numMessages); + $imapConnection = sqimap_login($username, $key, $imapServerAddress, 0); + sqimap_mailbox_select($imapConnection, $mailbox); // $message contains all information about the message // including header and body - $message = fetchMessage($imapConnection, $passed_id, $mailbox); + $message = sqimap_get_message($imapConnection, $passed_id, $mailbox); $type0 = $message["ENTITIES"][$passed_ent_id]["TYPE0"]; $type1 = $message["ENTITIES"][$passed_ent_id]["TYPE1"]; @@ -79,5 +78,5 @@ } } - fputs($imapConnection, "1 logout\n"); + sqimap_logout($imapConnection); ?> diff --git a/src/empty_trash.php b/src/empty_trash.php index 4e63c856..a5f39eae 100644 --- a/src/empty_trash.php +++ b/src/empty_trash.php @@ -1,6 +1,5 @@ \n"; displayPageHeader($color, $mailbox); messages_deleted_message($trash_folder, $sort, $startMessage, $color); - fputs($imapConnection, "1 logout"); + sqimap_logout($imapConnection); ?> diff --git a/src/folders.php b/src/folders.php index 4718e760..e51d47e9 100644 --- a/src/folders.php +++ b/src/folders.php @@ -3,7 +3,6 @@ include("../functions/strings.php"); include("../functions/page_header.php"); include("../functions/imap.php"); - include("../functions/mailbox.php"); include("../functions/array.php"); include("../src/load_prefs.php"); @@ -20,8 +19,8 @@ echo " \n"; echo "\n"; - $imapConnection = loginToImapServer($username, $key, $imapServerAddress, 0); - getFolderList($imapConnection, $boxes); + $imapConnection = sqimap_login ($username, $key, $imapServerAddress, 0); + $boxes = sqimap_mailbox_list($imapConnection); /** DELETING FOLDERS **/ echo "\n"; @@ -34,15 +33,15 @@ for ($i = 0; $i < count($boxes); $i++) { $use_folder = true; for ($p = 0; $p < count($special_folders); $p++) { - if ($boxes[$i]["UNFORMATTED"] == $special_folders[$p]) { + if ($boxes[$i]["unformatted"] == $special_folders[$p]) { $use_folder = false; - } else if (substr($boxes[$i]["UNFORMATTED"], 0, strlen($trash_folder)) == $trash_folder) { + } else if (substr($boxes[$i]["unformatted"], 0, strlen($trash_folder)) == $trash_folder) { $use_folder = false; } } if ($use_folder == true) { - $box = $boxes[$i]["UNFORMATTED"]; - $box2 = $boxes[$i]["FORMATTED"]; + $box = $boxes[$i]["unformatted"]; + $box2 = replace_spaces($boxes[$i]["formatted"]); echo "
"; /** Log out this session **/ - fputs($imapConnection, "1 logout"); + sqimap_logout($imapConnection); ?> diff --git a/src/left_main.php b/src/left_main.php index b29729fa..a674eaaf 100644 --- a/src/left_main.php +++ b/src/left_main.php @@ -18,14 +18,13 @@ include("../functions/array.php"); include("../functions/strings.php"); include("../functions/imap.php"); - include("../functions/mailbox.php"); function formatMailboxName($imapConnection, $mailbox, $real_box, $delimeter, $color, $move_to_trash) { require ("../config/config.php"); $mailboxURL = urlencode($real_box); - selectMailbox($imapConnection, $real_box, $numNessages); - $unseen = unseenMessages($imapConnection, $numUnseen); + sqimap_mailbox_select ($imapConnection, $real_box); + $unseen = sqimap_unseen_messages($imapConnection, $numUnseen); echo ""; if ($unseen) @@ -39,11 +38,11 @@ if ($special_color == true) { $line .= ""; - $line .= readShortMailboxName($mailbox, $delimeter); + $line .= replace_spaces($mailbox); $line .= ""; } else { $line .= ""; - $line .= readShortMailboxName($mailbox, $delimeter); + $line .= replace_spaces($mailbox); $line .= ""; } @@ -66,7 +65,7 @@ } // open a connection on the imap port (143) - $imapConnection = loginToImapServer($username, $key, $imapServerAddress, 10); // the 10 is to hide the output + $imapConnection = sqimap_login($username, $key, $imapServerAddress, 10); // the 10 is to hide the output /** If it was a successful login, lets load their preferences **/ include("../src/load_prefs.php"); @@ -75,40 +74,40 @@ echo ""; echo ""; } + echo ""; echo ""; - getFolderList($imapConnection, $boxes); + $boxes = sqimap_mailbox_list($imapConnection); echo "
"; - echo "Folders
"; + echo _("Folders") . "
"; echo "("; echo _("refresh folder list"); echo ")

"; echo "\n"; - $delimeter = findMailboxDelimeter($imapConnection); + $delimeter = sqimap_get_delimiter($imapConnection); for ($i = 0;$i < count($boxes); $i++) { $line = ""; - $mailbox = $boxes[$i]["FORMATTED"]; - $boxFlags = getMailboxFlags($imapConnection, $boxes[$i]["RAW"]); + $mailbox = $boxes[$i]["formatted"]; - if (trim($boxFlags[0]) != "") { + if ($boxes[$i]["flags"]) { $noselect = false; - for ($h = 0; $h < count($boxFlags); $h++) { - if (strtolower($boxFlags[$h]) == "noselect") + for ($h = 0; $h < count($boxes[$i]["flags"]); $h++) { + if (strtolower($boxes[$i]["flags"][$h]) == "noselect") $noselect = true; } if ($noselect == true) { $line .= ""; - $line .= readShortMailboxName($mailbox, $delimeter); + $line .= replace_spaces(readShortMailboxName($mailbox, $delimeter)); $line .= ""; } else { - $line .= formatMailboxName($imapConnection, $mailbox, $boxes[$i]["UNFORMATTED"], $delimeter, $color, $move_to_trash); + $line .= formatMailboxName($imapConnection, $mailbox, $boxes[$i]["unformatted"], $delimeter, $color, $move_to_trash); } } else { - $line .= formatMailboxName($imapConnection, $mailbox, $boxes[$i]["UNFORMATTED"], $delimeter, $color, $move_to_trash); + $line .= formatMailboxName($imapConnection, $mailbox, $boxes[$i]["unformatted"], $delimeter, $color, $move_to_trash); } echo "$line
"; } diff --git a/src/move_messages.php b/src/move_messages.php index 1ca57888..da8d6707 100644 --- a/src/move_messages.php +++ b/src/move_messages.php @@ -1,6 +1,5 @@ diff --git a/src/options.php b/src/options.php index 6adb81ec..600ab71e 100644 --- a/src/options.php +++ b/src/options.php @@ -1,6 +1,5 @@ \n"; diff --git a/src/options_submit.php b/src/options_submit.php index ca5ba4d2..b123a996 100644 --- a/src/options_submit.php +++ b/src/options_submit.php @@ -1,6 +1,5 @@ "; echo "\n"; diff --git a/src/right_main.php b/src/right_main.php index 11710fa7..40f01c0a 100644 --- a/src/right_main.php +++ b/src/right_main.php @@ -29,7 +29,6 @@ include("../functions/date.php"); include("../functions/page_header.php"); include("../functions/array.php"); - include("../functions/mailbox.php"); include("../functions/mailbox_display.php"); include("../functions/display_messages.php"); @@ -49,7 +48,7 @@ ///////////////////////////////////////////////////////////////////////////////// // open a connection on the imap port (143) - $imapConnection = loginToImapServer($username, $key, $imapServerAddress, 0); + $imapConnection = sqimap_login($username, $key, $imapServerAddress, 0); /** If it was a successful login, lets load their preferences **/ include("../src/load_prefs.php"); @@ -65,18 +64,14 @@ exit; } - // switch to the mailbox, and get the number of messages in it. - selectMailbox($imapConnection, $mailbox, $numMessages); - - // Display the header at the top of the page + sqimap_mailbox_select($imapConnection, $mailbox); + $numMessages = sqimap_get_num_messages ($imapConnection, $mailbox); displayPageHeader($color, $mailbox); - // Get the list of messages for this mailbox showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort, $color); // close the connection - fputs($imapConnection, "1 logout\n"); - fclose($imapConnection); + sqimap_logout ($imapConnection); ?>
-- 2.25.1