2 include("../config/config.php");
3 include("../functions/strings.php");
4 include("../functions/page_header.php");
5 include("../functions/imap.php");
6 include("../functions/mime.php");
7 include("../functions/mailbox.php");
8 include("../functions/date.php");
10 include("../src/load_prefs.php");
12 function viewText($color, $body, $id, $entid, $mailbox, $type1, $wrap_at) {
13 echo "<HTML><BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";
14 displayPageHeader($color, "None");
16 echo "<BR><TABLE WIDTH=90% BORDER=0 CELLSPACING=0 CELLPADDING=2 ALIGN=CENTER><TR><TD BGCOLOR=\"$color[0]\">";
18 echo _("Viewing a plain text attachment");
20 echo "</TD></TR><TR><TD BGCOLOR=\"$color[4]\">";
21 $urlmailbox = urlencode($mailbox);
22 echo "<FONT FACE=\"Arial, Helvetica\"><CENTER><A HREF=\"../src/download.php?absolute_dl=true&passed_id=$id&passed_ent_id=$entid&mailbox=$urlmailbox\">";
23 echo _("Download this as a file");
24 echo "</A></CENTER><BR><BR></FONT><TT>";
28 echo translateText($body, $wrap_at);
30 echo "</TT></TD></TR></TABLE>";
33 $imapConnection = loginToImapServer($username, $key, $imapServerAddress, 0);
34 selectMailbox($imapConnection, $mailbox, $numMessages);
36 // $message contains all information about the message
37 // including header and body
38 $message = fetchMessage($imapConnection, $passed_id, $mailbox);
40 $type0 = $message["ENTITIES"][$passed_ent_id]["TYPE0"];
41 $type1 = $message["ENTITIES"][$passed_ent_id]["TYPE1"];
42 $filename = $message["ENTITIES"][$passed_ent_id]["FILENAME"];
44 if (strlen($filename) < 1) {
45 $filename = "untitled$passed_ent_id";
48 if ($absolute_dl == "true") {
51 $body = decodeBody($message["ENTITIES"][$passed_ent_id]["BODY"], $message["ENTITIES"][$passed_ent_id]["ENCODING"]);
52 header("Content-type: $type0/$type1; name=\"$filename\"");
53 header("Content-Disposition: attachment; filename=\"$filename\"");
57 $body = decodeBody($message["ENTITIES"][$passed_ent_id]["BODY"], $message["ENTITIES"][$passed_ent_id]["ENCODING"]);
58 header("Content-type: $type0/$type1; name=\"$filename\"");
59 header("Content-Disposition: attachment; filename=\"$filename\"");
66 $body = decodeBody($message["ENTITIES"][$passed_ent_id]["BODY"], $message["ENTITIES"][$passed_ent_id]["ENCODING"]);
67 viewText($color, $body, $passed_id, $passed_ent_id, $mailbox, $type1, $wrap_at);
70 $body = decodeBody($message["ENTITIES"][$passed_ent_id]["BODY"], $message["ENTITIES"][$passed_ent_id]["ENCODING"]);
71 viewText($color, $body, $passed_id, $passed_ent_id, $mailbox, $type1, $wrap_at);
74 $body = decodeBody($message["ENTITIES"][$passed_ent_id]["BODY"], $message["ENTITIES"][$passed_ent_id]["ENCODING"]);
75 header("Content-type: $type0/$type1; name=\"$filename\"");
76 header("Content-Disposition: attachment; filename=\"$filename\"");
82 fputs($imapConnection, "1 logout\n");