X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=blobdiff_plain;f=src%2Fdownload.php;h=a74796399bb58a698909c3ae6c0e4796a27d2bdc;hp=c754caf030bd2c9ff1dec353dcc310e3e32fca3a;hb=d36f3e63f3952acee3577825d9ecc5e45abcf028;hpb=bf99108f830f678dd1be5fd875447b3a8ae51bca diff --git a/src/download.php b/src/download.php index c754caf0..a7479639 100644 --- a/src/download.php +++ b/src/download.php @@ -9,40 +9,52 @@ ** Also allows displaying of attachments when possible. **/ - session_start(); - if (!isset($config_php)) include("../config/config.php"); if (!isset($strings_php)) include("../functions/strings.php"); - if (!isset($page_header_php)) - include("../functions/page_header.php"); if (!isset($imap_php)) include("../functions/imap.php"); if (!isset($mime_php)) include("../functions/mime.php"); if (!isset($date_php)) include("../functions/date.php"); + if (!isset($i18n_php)) + include("../functions/i18n.php"); include("../src/load_prefs.php"); function viewText($color, $body, $id, $entid, $mailbox, $type1, $wrap_at) { + global $where, $what, $charset; + global $startMessage; + + displayPageHeader($color, "None"); - echo "
"; + echo "
"; echo "
"; echo _("Viewing a text attachment") . " - "; - echo "". _("View message") . ""; - echo "
"; - echo "
"; + if ($where && $what) { + // from a search + echo "". _("View message") . ""; + } else { + echo "". _("View message") . ""; + } + $urlmailbox = urlencode($mailbox); - echo "
"; + echo "
"; echo _("Download this as a file"); - echo "


"; - if ($type1 == "html") - echo $body; - else - echo translateText($body, $wrap_at); + echo "
"; + echo ""; + echo "
"; + + echo "
"; + echo "
"; + + if ($type1 != "html") + translateText($body, $wrap_at, $charset); + + echo $body; echo "
"; } @@ -63,6 +75,7 @@ $header = $message->header; $body = mime_fetch_body($imapConnection, $passed_id, $passed_ent_id); + $charset = $header->charset; $type0 = $header->type0; $type1 = $header->type1; $filename = decodeHeader($header->filename); @@ -95,20 +108,21 @@ switch($type0) { case "text": $body = decodeBody($body, $header->encoding); - header("Content-type: application/octet-stream; name=\"$filename\""); header("Content-Disposition: attachment; filename=\"$filename\""); + header("Content-type: application/octet-stream; name=\"$filename\""); + set_up_language(getPref($data_dir, $username, "language")); if ($type1 == "plain") { - echo _("Subject") . ": " . decodeHeader(stripslashes($top_header->subject)) . "\n"; - echo " " . _("From") . ": " . decodeHeader(stripslashes($top_header->from)) . "\n"; - echo " " . _("To") . ": " . decodeHeader(stripslashes(getLineOfAddrs($top_header->to))) . "\n"; + echo _("Subject") . ": " . decodeHeader(sqStripSlashes($top_header->subject)) . "\n"; + echo " " . _("From") . ": " . decodeHeader(sqStripSlashes($top_header->from)) . "\n"; + echo " " . _("To") . ": " . decodeHeader(sqStripSlashes(getLineOfAddrs($top_header->to))) . "\n"; echo " " . _("Date") . ": " . getLongDateString($top_header->date) . "\n\n"; } echo trim($body); break; default: $body = decodeBody($body, $header->encoding); - header("Content-type: application/octet-stream; name=\"$filename\""); header("Content-Disposition: attachment; filename=\"$filename\""); + header("Content-type: application/octet-stream; name=\"$filename\""); echo $body; break; } @@ -116,20 +130,23 @@ switch ($type0) { case "text": $body = decodeBody($body, $header->encoding); + include("../functions/page_header.php"); viewText($color, $body, $passed_id, $passed_ent_id, $mailbox, $type1, $wrap_at); break; case "message": $body = decodeBody($body, $header->encoding); + include("../functions/page_header.php"); viewText($color, $body, $passed_id, $passed_ent_id, $mailbox, $type1, $wrap_at); break; default: $body = decodeBody($body, $header->encoding); - header("Content-type: $type0/$type1; name=\"$filename\""); header("Content-Disposition: attachment; filename=\"$filename\""); + header("Content-type: $type0/$type1; name=\"$filename\""); echo $body; break; } } + sqimap_mailbox_close($imapConnection); sqimap_logout($imapConnection); ?>