X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=blobdiff_plain;f=src%2Fcompose.php;h=0e7dcfbe78f93cfc2f339b4cd1ca226b1606e390;hp=daae7b63b2f32fbffbe94e44f4a945513886d706;hb=c5d828b34ad16d7eccc94db221ed3aaa7fc85feb;hpb=1e62a204a9ceb60f3cde686d60efc85436a2fbd2 diff --git a/src/compose.php b/src/compose.php index daae7b63..0e7dcfbe 100644 --- a/src/compose.php +++ b/src/compose.php @@ -1,5 +1,11 @@ header; + 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 = ""; } - if ($forward_id) - $tmp = _("-------- Original Message ---------\n"); if ($message->header->type1 == "html") $body = strip_tags($body); $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"; + $tmp .= _("Subject") . ": " . $orig_header->subject . "\n"; + $tmp .= " " . _("From") . ": " . $orig_header->from . "\n"; + $tmp .= " " . _("To") . ": " . $orig_header->to[0] . "\n"; + if (count($orig_header->to) > 1) { + for ($x=1; $x < count($orig_header->to); $x++) { + $tmp .= " " . $orig_header->to[$x] . "\n"; + } + } + $tmp .= "\n" . $body_ary[$i]; + } else { + $tmp = $body_ary[$i]; + } if ($forward_id) $body = "$body$tmp\n"; else $body = "$body> $tmp\n"; } - + sqimap_mailbox_close($imapConnection); + return $body; } + $send_to = sqStripSlashes($send_to); + if (!$send_to) { $send_to = sqimap_find_email($send_to); } - $send_to = ereg_replace("\"", "", $send_to); - $send_to = stripslashes($send_to); - /** This formats a CC string if they hit "reply all" **/ if ($send_to_cc != "") { + $send_to_cc = ereg_replace( '"[^"]*"', "", $send_to_cc); $send_to_cc = ereg_replace(";", ",", $send_to_cc); $sendcc = explode(",", $send_to_cc); $send_to_cc = ""; @@ -111,7 +138,7 @@ $attachments, $subject, $newmail, $use_javascript_addr_book, $send_to_bcc, $reply_id, $mailbox; - $subject = decodeHeader($subject); + $subject = sqStripSlashes(decodeHeader($subject)); $reply_subj = decodeHeader($reply_subj); $forward_subj = decodeHeader($forward_subj); @@ -127,64 +154,61 @@ } echo "\n
\n"; + //echo "\n\n"; if ($reply_id) { echo "\n"; } - echo "\n"; - echo "\n"; + printf("\n", htmlspecialchars($mailbox)); + echo "
\n"; echo " \n"; - echo " \n"; echo " \n"; echo " \n"; - echo " \n"; echo " \n"; echo " \n"; - echo " \n"; echo " \n"; - echo " \n\n"; @@ -199,38 +223,44 @@ echo " "; } echo "\n \n"; + + do_hook("compose_button_row"); + echo " \n"; echo " \n\n"; echo " \n"; - echo " \n"; echo " \n"; - echo " \n"; // This code is for attachments echo " \n"; - echo " \n"; echo " \n"; if (isset($attachments) && count($attachments)>0) { - echo "
\n"; + echo " \n"; echo _("To:"); - echo " \n"; - if ($send_to) - echo "
\n"; - else - echo "
\n"; + echo "
\n"; + printf("
\n", + htmlspecialchars($send_to)); echo "
\n"; + echo " \n"; echo _("CC:"); - echo " \n"; - if ($send_to_cc) - echo "
\n"; - else - echo "
\n"; + echo "
\n"; + printf("
\n", + htmlspecialchars($send_to_cc)); echo "
\n"; + echo " \n"; echo _("BCC:"); echo " \n"; - if ($send_to_bcc) - echo "
\n"; - else - echo "
"; - + printf("
\n", + htmlspecialchars($send_to_bcc)); echo "
\n"; + echo " \n"; echo _("Subject:"); echo " \n"; if ($reply_subj) { $reply_subj = str_replace("\"", "'", $reply_subj); - $reply_subj = stripslashes($reply_subj); + $reply_subj = sqStripSlashes($reply_subj); $reply_subj = trim($reply_subj); if (substr(strtolower($reply_subj), 0, 3) != "re:") $reply_subj = "Re: $reply_subj"; - echo " "; + printf(" ", + htmlspecialchars($reply_subj)); } else if ($forward_subj) { $forward_subj = str_replace("\"", "'", $forward_subj); - $forward_subj = stripslashes($forward_subj); + $forward_subj = sqStripSlashes($forward_subj); $forward_subj = trim($forward_subj); if ((substr(strtolower($forward_subj), 0, 4) != "fwd:") && (substr(strtolower($forward_subj), 0, 5) != "[fwd:") && (substr(strtolower($forward_subj), 0, 6) != "[ fwd:")) $forward_subj = "[Fwd: $forward_subj]"; - echo " "; + printf(" ", + htmlspecialchars($forward_subj)); } else { - echo " "; + printf(" ", + htmlspecialchars($subject)); } echo "
\n"; - if ($use_signature == true && $newmail == true) - echo "   
"; - else - echo "   
\n"; + echo "
\n"; + echo "   
\n"; echo "
\n"; + echo " \n"; echo "
"._("Attach:"); - echo "
\n"; + echo " \n"; // echo " \n"; echo " \n"; - echo "   \n"; + echo "   \n"; echo "
\n"; + echo "
\n"; echo " "; - echo ""; + echo ""; while (list($localname, $remotename) = each($attachments)) { echo "\n"; echo "$remotename
\n"; @@ -243,6 +273,7 @@ echo "
\n"; echo "
"; + do_hook("compose_bottom"); } function showSentForm () { @@ -258,11 +289,7 @@ error message, show=true **/ global $body, $send_to, $subject, $color; - if ($body == "" && $subject == "") { - if ($show) - plain_error_message(_("You have not entered a message body or a subject."), $color); - return false; - } else if ($send_to == "") { + if ($send_to == "") { if ($show) plain_error_message(_("You have not filled in the \"To:\" field."), $color); return false; @@ -285,16 +312,17 @@ checkInput(true); showInputForm(); + sqimap_logout($imapConnection); } } else if ($html_addr_search_done) { - $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); + is_logged_in(); displayPageHeader($color, $mailbox); - $body = stripslashes($body); - $send_to = stripslashes($send_to); - $send_to_cc = stripslashes($send_to_cc); - $send_to_bcc = stripslashes($send_to_bcc); - $subject = stripslashes($subject); + $body = sqStripSlashes($body); + $send_to = sqStripSlashes($send_to); + $send_to_cc = sqStripSlashes($send_to_cc); + $send_to_bcc = sqStripSlashes($send_to_bcc); + $subject = sqStripSlashes($subject); for ($i=0; $i < count($send_to_search); $i++) { if ($send_to) @@ -310,11 +338,11 @@ showInputForm(); } else if ($html_addr_search) { - //* I am using an include so as to elminiate an extra unnecessary click. If you - //* can think of a better way, please implement it. + // I am using an include so as to elminiate an extra unnecessary click. If you + // can think of a better way, please implement it. include ("addrbook_search_html.php"); } else if (isset($attach)) { - $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); + is_logged_in(); displayPageHeader($color, $mailbox); $localfilename = md5("$attachfile, $attachfile_name, $REMOTE_IP, $REMOTE_PORT, $UNIQUE_ID, and everything else that may add entropy"); @@ -324,7 +352,7 @@ error_reporting(0); // Rename will produce error output if it fails if (!rename($attachfile, $attachment_dir.$localfilename)) { if (!copy($attachfile, $attachment_dir.$localfilename)) { - plain_error_message(_("Could not move/copy file. File not attached")); + plain_error_message(_("Could not move/copy file. File not attached"), $color); $failed = true; } } @@ -341,11 +369,11 @@ showInputForm(); } else if (isset($do_delete)) { - $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); + is_logged_in(); displayPageHeader($color, $mailbox); - while (list($key, $localname) = each($delete)) { - array_splice ($attachments, $key, 1); + while (list($lkey, $localname) = each($delete)) { + array_splice ($attachments, $lkey, 1); unlink ($attachment_dir.$localname); unlink ($attachment_dir.$localname.".info"); } @@ -358,5 +386,6 @@ $newmail = true; newMail(); showInputForm(); + sqimap_logout($imapConnection); } ?>