From 1195c34026fc65eb8e0ca7a337fe4b406764dee8 Mon Sep 17 00:00:00 2001 From: lkehresman Date: Sat, 8 Jul 2000 11:13:09 +0000 Subject: [PATCH] - added a bunch of sqimap_logout's where none existed - deleting/moving takes you right back where you were - Folders section is handled better, removed notification screens - The options "cc" and "to and cc" were added to message highlighting git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@603 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- AUTHORS | 36 ++++++++++++--------- functions/display_messages.php | 40 +---------------------- functions/imap_messages.php | 14 +++++--- functions/mailbox_display.php | 9 +++++- functions/mime.php | 6 ++-- functions/smtp.php | 2 +- functions/strings.php | 34 ++++++++++++++++++++ index.php | 22 ++----------- src/compose.php | 22 +++++++++---- src/delete_message.php | 6 ++-- src/folders.php | 59 ++++++++++++++++++++++++---------- src/folders_create.php | 9 +++--- src/folders_delete.php | 6 ++-- src/folders_rename_do.php | 7 ++-- src/folders_subscribe.php | 6 ++++ src/left_main.php | 4 +-- src/move_messages.php | 16 +++------ src/options_folder.php | 3 +- src/options_highlight.php | 4 +++ src/read_body.php | 6 +--- src/webmail.php | 1 + 21 files changed, 171 insertions(+), 141 deletions(-) diff --git a/AUTHORS b/AUTHORS index 1b6441a6..1dc778a3 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,20 +1,24 @@ - Luke Ehresman (luke@squirrelmail.org), - Nathan Ehresman (nathan@squirrelmail.org), - Gustav Foseid (gustavf@squirrelmail.org), - Pål Løberg (pallo@squirrelmail.org), - Shane Wilson, - Sergiusz Pawlowicz, - Steve Gare, - Gerrit Padgham, - Matt Phillips, - David Whittington, - Lewis Bergman, + Developers: + ----------- + Luke Ehresman (luke@squirrelmail.org) + Nathan Ehresman (nathan@squirrelmail.org) + Gustav Foseid (gustavf@squirrelmail.org) + Pål Løberg (pallo@squirrelmail.org) + Shane Wilson + Sergiusz Pawlowicz + Steve Gare + Gerrit Padgham + Matt Phillips + David Whittington + Lewis Bergman Translations: - Norwegian: Gustav Foseid (gustavf@squirrelmail.org), - German: Chris Thil, - Russian: Konstantin Riabitsev, - Polish: Lukasz Klimek (casa@lo.pila.pl), + ------------- + Norwegian: Gustav Foseid (gustavf@squirrelmail.org) + German: Chris Thil + Russian: Konstantin Riabitsev + Polish: Lukasz Klimek (casa@lo.pila.pl) Help System: - Lewis Bergman + ------------ + Lewis Bergman diff --git a/functions/display_messages.php b/functions/display_messages.php index a212a754..242f48f6 100644 --- a/functions/display_messages.php +++ b/functions/display_messages.php @@ -53,44 +53,6 @@ echo ""; } - function messages_deleted_message($mailbox, $sort, $startMessage, $color) { - $urlMailbox = urlencode($mailbox); - - echo "
"; - echo ""; - echo " "; - echo " "; - echo "
"; - echo "
". _("Messages Deleted") ."
"; - echo "
"; - echo "

". _("The selected messages were deleted successfully.") ."
\n"; - echo "
"; - echo " "; - printf (_("Click here to return to %s"), $mailbox); - echo "."; - echo "
"; - echo "
"; - } - - function messages_moved_message($mailbox, $sort, $startMessage, $color) { - $urlMailbox = urlencode($mailbox); - - echo "
"; - echo ""; - echo " "; - echo " "; - echo "
"; - echo "
". _("Messages Moved") ."
"; - echo "
"; - echo "

". _("The selected messages were moved successfully.") ."
\n"; - echo "
"; - echo " "; - printf (_("Click here to return to %s"), $mailbox); - echo "."; - echo "
"; - echo "
"; - } - function error_message($message, $mailbox, $sort, $startMessage, $color) { $urlMailbox = urlencode($mailbox); @@ -102,7 +64,7 @@ echo " "; echo "

$message
\n"; echo "
"; - echo " "; + echo " "; printf (_("Click here to return to %s"), $mailbox); echo "."; echo " "; diff --git a/functions/imap_messages.php b/functions/imap_messages.php index c82e7a97..89be0e2a 100755 --- a/functions/imap_messages.php +++ b/functions/imap_messages.php @@ -45,7 +45,7 @@ } function sqimap_get_small_header ($imap_stream, $id, $sent) { - fputs ($imap_stream, "a001 FETCH $id BODY.PEEK[HEADER.FIELDS (Date To From Subject Message-Id X-Priority)]\r\n"); + fputs ($imap_stream, "a001 FETCH $id BODY.PEEK[HEADER.FIELDS (Date To From Cc Subject Message-Id X-Priority)]\r\n"); $read = sqimap_read_data ($imap_stream, "a001", true, $response, $message); $subject = _("(no subject)"); @@ -65,6 +65,8 @@ $priority = trim(substr($read[$i], 11)); } else if (eregi ("^message-id:", $read[$i])) { $messageid = trim(substr($read[$i], 11)); + } else if (eregi ("^cc:", $read[$i])) { + $cc = substr($read[$i], 3); } else if (eregi ("^date:", $read[$i])) { $date = substr($read[$i], 5); } else if (eregi ("^subject:", $read[$i])) { @@ -78,13 +80,14 @@ if ($sent == true) $header->from = $to; else - $header->from = $from; + $header->from = $from; $header->date = $date; $header->subject = $subject; $header->to = $to; $header->priority = $priority; $header->message_id = $messageid; + $header->cc = $cc; return $header; } @@ -113,9 +116,8 @@ ** the documentation folder for more information about this array. ******************************************************************************/ function sqimap_get_message ($imap_stream, $id, $mailbox) { - $header = sqimap_get_message_header($imap_stream, $id, $mailbox); - $msg = sqimap_get_message_body($imap_stream, &$header); + $msg = sqimap_get_message_body(&$header); return $msg; } @@ -324,11 +326,12 @@ /****************************************************************************** ** Returns the body of a message. ******************************************************************************/ - function sqimap_get_message_body ($imap_stream, &$header) { + function sqimap_get_message_body (&$header) { $id = $header->id; //fputs ($imap_stream, "a001 FETCH $id:$id BODY[TEXT]\r\n"); //$read = sqimap_read_data ($imap_stream, "a001", true, $response, $message); + /* $i = 0; $j = 0; while ($i < count($read)-1) { @@ -338,6 +341,7 @@ } $i++; } + */ return decodeMime($body, &$header); } diff --git a/functions/mailbox_display.php b/functions/mailbox_display.php index 9f82bfec..d1589cd5 100644 --- a/functions/mailbox_display.php +++ b/functions/mailbox_display.php @@ -27,7 +27,12 @@ if ($mailbox == $sent_folder) { $italic = ""; $italic_end = ""; } for ($i=0; $i < count($message_highlight_list); $i++) { - if (eregi($message_highlight_list[$i]["value"],$msg[strtoupper($message_highlight_list[$i]["match_type"])])) { + if ($message_highlight_list[$i]["match_type"] == "to_cc") { + if (eregi($message_highlight_list[$i]["value"],$msg["TO"]) || eregi($message_highlight_list[$i]["value"],$msg["CC"])) { + $hlt_color = $message_highlight_list[$i]["color"]; + continue; + } + } else if (eregi($message_highlight_list[$i]["value"],$msg[strtoupper($message_highlight_list[$i]["match_type"])])) { $hlt_color = $message_highlight_list[$i]["color"]; continue; } @@ -67,6 +72,7 @@ $subject[$q] = $hdr->subject; $to[$q] = $hdr->to; $priority[$q] = $hdr->priority; + $cc[$q] = $hdr->cc; $flags[$q] = sqimap_get_flags ($imapConnection, $q+1); } @@ -84,6 +90,7 @@ $messages[$j]["SUBJECT"] = decodeHeader($subject[$j]); $messages[$j]["TO"] = decodeHeader($to[$j]); $messages[$j]["PRIORITY"] = $priority[$j]; + $messages[$j]["CC"] = $cc[$j]; $num = 0; while ($num < count($flags[$j])) { diff --git a/functions/mime.php b/functions/mime.php index 4cf74790..ab021936 100644 --- a/functions/mime.php +++ b/functions/mime.php @@ -364,8 +364,9 @@ global $username, $key, $imapServerAddress, $imapPort; $imap_stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); sqimap_mailbox_select($imap_stream, $header->mailbox); - - return mime_structure ($imap_stream, $header); + $struct = mime_structure ($imap_stream, $header); + sqimap_logout($imap_stream); + return $struct; } // This is here for debugging purposese. It will print out a list @@ -433,6 +434,7 @@ $ent_num = findDisplayEntity ($message); $body = mime_fetch_body ($imap_stream, $id, $ent_num); + sqimap_logout($imap_stream); // If there are other types that shouldn't be formatted, add // them here diff --git a/functions/smtp.php b/functions/smtp.php index e6aa554c..4c273614 100644 --- a/functions/smtp.php +++ b/functions/smtp.php @@ -481,7 +481,7 @@ writeBody ($imap_stream, $body); sqimap_append_done ($imap_stream); } - + sqimap_logout($imap_stream); // Delete the files uploaded for attaching (if any). deleteAttachments(); } diff --git a/functions/strings.php b/functions/strings.php index 0cb53d5d..1270e027 100644 --- a/functions/strings.php +++ b/functions/strings.php @@ -173,4 +173,38 @@ function replace_escaped_spaces ($string) { return str_replace(" ", " ", $string); } + + function get_location () { + # This determines the location to forward to relative + # to your server. If this doesn't work correctly for + # you (although it should), you can remove all this + # code except the last two lines, and change the header() + # function to look something like this, customized to + # the location of SquirrelMail on your server: + # + # http://www.myhost.com/squirrelmail/src/login.php + + global $PHP_SELF, $SERVER_NAME, $HTTPS, $HTTP_HOST; + + // Get the path + $path = substr($PHP_SELF, 0, strrpos($PHP_SELF, '/')); + + // Check if this is a HTTPS or regular HTTP request + $proto = "http://"; + if(isset($HTTPS) && $HTTPS == 'on' ) { + $proto = "https://"; + } + + // Get the hostname from the Host header or server config. + // Fallback is to omit the server name and use a relative URI, + // although this is not RFC 2616 compliant. + if(isset($HTTP_HOST) && !empty($HTTP_HOST)) { + $location = $proto . $HTTP_HOST . $path; + } else if(isset($SERVER_NAME) && !empty($SERVER_NAME)) { + $location = $proto . $SERVER_NAME . $path; + } else { + $location = $path; + } + return $location; + } ?> diff --git a/index.php b/index.php index 0914d2fa..2e5cde83 100644 --- a/index.php +++ b/index.php @@ -1,25 +1,7 @@ diff --git a/src/compose.php b/src/compose.php index 60ff7582..0b90800d 100644 --- a/src/compose.php +++ b/src/compose.php @@ -49,13 +49,18 @@ else if ($reply_id) $id = $reply_id; + if ($id) { sqimap_mailbox_select($imapConnection, $mailbox); $message = sqimap_get_message($imapConnection, $id, $mailbox); - $message = getEntity($message, $ent_num); + if ($ent_num) + $message = getEntity($message, $ent_num); if ($message->header->type0 == "text" || $message->header->type1 == "message") { - $body = decodeBody(mime_fetch_body($imapConnection, $id, $message->header->entity_id), $message->header->encoding); + if ($ent_num) + $body = decodeBody(mime_fetch_body($imapConnection, $id, $ent_num), $message->header->encoding); + else + $body = decodeBody(mime_fetch_body($imapConnection, $id, 1), $message->header->encoding); } else { $body = ""; } @@ -68,14 +73,17 @@ $body_ary = explode("\n", $body); $body = ""; for ($i=0; $i < count($body_ary); $i++) { - $tmp = $body_ary[$i]; + if ($i==0 && $forward_id) + $tmp = _("-------- Original Message ---------\n") . $body_ary[$i]; + else + $tmp = $body_ary[$i]; if ($forward_id) - $body = "$body$tmp\n"; + $body .= "$body$tmp\n"; else - $body = "$body> $tmp\n"; + $body .= "$body> $tmp\n"; } - + return $body; } if (!$send_to) { @@ -292,6 +300,7 @@ checkInput(true); showInputForm(); + sqimap_logout($imapConnection); } } else if ($html_addr_search_done) { is_logged_in(); @@ -365,5 +374,6 @@ $newmail = true; newMail(); showInputForm(); + sqimap_logout($imapConnection); } ?> diff --git a/src/delete_message.php b/src/delete_message.php index 5caa9f29..fd274d3e 100644 --- a/src/delete_message.php +++ b/src/delete_message.php @@ -27,12 +27,10 @@ $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); sqimap_mailbox_select($imapConnection, $mailbox); - displayPageHeader($color, $mailbox); - sqimap_messages_delete($imapConnection, $message, $message, $mailbox); if ($auto_expunge) sqimap_mailbox_expunge($imapConnection, $mailbox); - messages_deleted_message($mailbox, $sort, $startMessage, $color); + $location = get_location(); + header ("Location: $location/right_main.php?sort=$sort&startMessage=$startMessage&mailbox=".urlencode($mailbox)); ?> - diff --git a/src/folders.php b/src/folders.php index ce164ae0..f4366b47 100644 --- a/src/folders.php +++ b/src/folders.php @@ -27,12 +27,31 @@ displayPageHeader($color, "None"); - echo "\n"; - echo "
\n"; + echo "
"; + echo "\n"; + echo " \n"; echo "
\n"; echo _("Folders"); echo "
\n"; + if ($success) { + echo "\n"; + echo " \n"; + echo "
\n"; + if ($success == "subscribe") { + echo "" . _("Subscribed successfully!") . "
"; + } else if ($success == "unsubscribe") { + echo "" . _("Unsubscribed successfully!") . "
"; + } else if ($success == "delete") { + echo "" . _("Deleted folder successfully!") . "
"; + } else if ($success == "create") { + echo "" . _("Created folder successfully!") . "
"; + } else if ($success == "rename") { + echo "" . _("Renamed successfully!") . "
"; + } + echo "
" . _("refresh folder list") . ""; + echo "

\n"; + } $imapConnection = sqimap_login ($username, $key, $imapServerAddress, $imapPort, 0); $boxes = sqimap_mailbox_list($imapConnection); @@ -61,10 +80,10 @@ if ($imap_server_type == "cyrus") { if ((!sqimap_mailbox_exists ($imapConnection, $sent_folder)) || (!sqimap_mailbox_exists ($imapConnection, $trash_folder))) { echo "\n"; - echo ""; - echo "
"; + echo "
"; echo _("Special Folder Options"); echo "
"; + echo "
"; echo _("In order for SquirrelMail to provide the full set of options you need to create the special folders listed below. Just click the check box and hit the create button."); echo "
\n"; if (!sqimap_mailbox_exists ($imapConnection, $sent_folder)) { @@ -79,11 +98,11 @@ } /** DELETING FOLDERS **/ - echo "\n"; - echo "
"; + echo "\n"; + echo ""; - echo "\n"; + echo "\n"; } else { echo _("No mailboxes found") . "

"; } + echo "\n"; /** CREATING FOLDERS **/ - echo ""; - echo "
\n"; + echo "\n"; + + echo "\n"; /** RENAMING FOLDERS **/ - echo ""; - echo ""; } $boxes_sub = $boxes; + + echo "\n"; /** UNSUBSCRIBE FOLDERS **/ - echo ""; - echo "
"; echo _("Delete Folder"); echo "
"; + echo "
"; $count_special_folders = 0; $num_max = 1; @@ -119,17 +138,18 @@ echo "\n"; - echo "
 
"; + echo "
"; echo _("Create Folder"); echo "
"; + echo "
"; echo "
\n"; echo "
\n"; echo _("as a subfolder of"); @@ -174,13 +194,15 @@ echo "
"; } echo "\n"; - echo "

 
"; + echo "
"; echo _("Rename a Folder"); echo "
"; + echo "
"; if ($count_special_folders < count($boxes)) { echo "
\n"; echo "
 
"; + echo "
"; echo _("Unsubscribe/Subscribe"); echo "
"; + echo "
"; if ($count_special_folders < count($boxes)) { echo "\n"; echo "
"; + echo "
"; if ($count_special_folders <= count($boxes)) { $imap_stream = sqimap_login ($username, $key, $imapServerAddress, $imapPort, 1); $boxes_all = sqimap_mailbox_list_all ($imap_stream); @@ -260,6 +283,7 @@ echo "
"; } + sqimap_logout($imapConnection); ?> diff --git a/src/folders_create.php b/src/folders_create.php index 505e10a7..ee58120d 100644 --- a/src/folders_create.php +++ b/src/folders_create.php @@ -53,9 +53,10 @@ } fputs($imapConnection, "1 logout\n"); -// if ($auto_forward == true) { -// header ("Location: webmail.php?right_frame=folders.php"); -// } else { + $location = get_location(); + header ("Location: $location/folders.php?success=create"); + sqimap_logout($imapConnection); + /* displayPageHeader($color, "None"); echo "


"; echo _("Folder Created!"); @@ -67,6 +68,6 @@ echo _("to continue."); echo "
"; echo ""; -// } + */ ?> diff --git a/src/folders_delete.php b/src/folders_delete.php index d3a1ff30..e98794b7 100644 --- a/src/folders_delete.php +++ b/src/folders_delete.php @@ -31,8 +31,6 @@ include("../src/load_prefs.php"); - displayPageHeader($color, "None"); - $imap_stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); $boxes = sqimap_mailbox_list ($imap_stream); @@ -86,6 +84,9 @@ /** Log out this session **/ sqimap_logout($imap_stream); + $location = get_location(); + header ("Location: $location/folders.php?success=delete"); + /* echo "


"; echo _("Folder Deleted!"); echo "

"; @@ -97,4 +98,5 @@ echo "
"; echo ""; + */ ?> diff --git a/src/folders_rename_do.php b/src/folders_rename_do.php index 67de7ea5..f6108e11 100644 --- a/src/folders_rename_do.php +++ b/src/folders_rename_do.php @@ -59,7 +59,6 @@ include("../src/load_prefs.php"); - $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); $dm = sqimap_get_delimiter($imapConnection); if (strpos($orig, $dm)) @@ -90,7 +89,10 @@ /** Log out this session **/ sqimap_logout($imapConnection); - + $location = get_location(); + header ("Location: $location/folders.php?success=rename"); + sqimap_logout($imapConnection); + /* displayPageHeader($color, "None"); echo "


"; echo _("Folder Renamed!"); @@ -103,4 +105,5 @@ echo "
"; echo ""; + */ ?> diff --git a/src/folders_subscribe.php b/src/folders_subscribe.php index ddaccc75..42325261 100644 --- a/src/folders_subscribe.php +++ b/src/folders_subscribe.php @@ -27,13 +27,18 @@ $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); $dm = sqimap_get_delimiter($imapConnection); + $location = get_location(); if ($method == "sub") { $mailbox = trim($mailbox); sqimap_subscribe ($imapConnection, $mailbox); + header("Location: $location/folders.php?success=subscribe"); } else { sqimap_unsubscribe ($imapConnection, $mailbox); + header("Location: $location/folders.php?success=unsubscribe"); } + sqimap_logout($imapConnection); + /* displayPageHeader($color, "None"); echo "


"; if ($method == "sub") { @@ -51,5 +56,6 @@ echo _("to continue."); echo "
"; echo ""; + */ ?> diff --git a/src/left_main.php b/src/left_main.php index 5ec8a4f3..4a435097 100644 --- a/src/left_main.php +++ b/src/left_main.php @@ -126,8 +126,6 @@ echo "\n$line
\n"; } - - fclose($imapConnection); - + sqimap_logout($imapConnection); ?> diff --git a/src/move_messages.php b/src/move_messages.php index de17ca93..3281867b 100644 --- a/src/move_messages.php +++ b/src/move_messages.php @@ -68,12 +68,8 @@ if ($auto_expunge) { sqimap_mailbox_expunge($imapConnection, $mailbox); } - if ($auto_forward) { - header ("Location: right_main.php"); - } else { - displayPageHeader($color, $mailbox); - messages_deleted_message($mailbox, $sort, $startMessage, $color); - } + $location = get_location(); + header ("Location: $location/right_main.php?sort=$sort&startMessage=$startMessage&mailbox=". urlencode($mailbox)); } else { displayPageHeader($color, $mailbox); error_message(_("No messages were selected."), $mailbox, $sort, $startMessage, $color); @@ -98,12 +94,8 @@ if ($auto_expunge == true) sqimap_mailbox_expunge($imapConnection, $mailbox); - if ($auto_forward) { - header ("Location: right_main.php"); - } else { - displayPageHeader($color, $mailbox); - messages_moved_message($mailbox, $sort, $startMessage, $color); - } + $location = get_location(); + header ("Location: $location/right_main.php?sort=$sort&startMessage=$startMessage&mailbox=". urlencode($mailbox)); } else { displayPageHeader($color, $mailbox); error_message(_("No messages were selected."), $mailbox, $sort, $startMessage, $color); diff --git a/src/options_folder.php b/src/options_folder.php index 4955f35b..306f9148 100644 --- a/src/options_folder.php +++ b/src/options_folder.php @@ -31,8 +31,7 @@ $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); $boxes = sqimap_mailbox_list($imapConnection, $boxes); - fputs($imapConnection, "1 logout\n"); - + sqimap_logout($imapConnection); ?> "; echo "
diff --git a/src/options_highlight.php b/src/options_highlight.php index 09ce1466..44060331 100644 --- a/src/options_highlight.php +++ b/src/options_highlight.php @@ -155,6 +155,10 @@ else echo "
 
\n"; + sqimap_logout($imapConnection); ?> diff --git a/src/webmail.php b/src/webmail.php index ee37c639..aad2e838 100644 --- a/src/webmail.php +++ b/src/webmail.php @@ -49,6 +49,7 @@ do_hook ("login_before"); // verify that username and password are correct $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); + sqimap_logout($imapConnection); do_hook ("login_verified"); } -- 2.25.1