884929fec97995baee5ceb459ef2e91a66798803
4 if (!isset($config_php))
5 include("../config/config.php");
6 if (!isset($strings_php))
7 include("../functions/strings.php");
8 if (!isset($page_header_php))
9 include("../functions/page_header.php");
10 if (!isset($imap_php))
11 include("../functions/imap.php");
12 if (!isset($mime_php))
13 include("../functions/mime.php");
14 if (!isset($date_php))
15 include("../functions/date.php");
17 include("../src/load_prefs.php");
19 function viewText($color, $body, $id, $entid, $mailbox, $type1, $wrap_at) {
20 displayPageHeader($color, "None");
22 echo "<BR><TABLE WIDTH=90% BORDER=0 CELLSPACING=0 CELLPADDING=2 ALIGN=CENTER><TR><TD BGCOLOR=\"$color[0]\">";
24 echo _("Viewing a plain text attachment");
26 echo "</TD></TR><TR><TD BGCOLOR=\"$color[4]\">";
27 $urlmailbox = urlencode($mailbox);
28 echo "<CENTER><A HREF=\"../src/download.php?absolute_dl=true&passed_id=$id&passed_ent_id=$entid&mailbox=$urlmailbox\">";
29 echo _("Download this as a file");
30 echo "</A></CENTER><BR><BR><TT>";
34 echo translateText($body, $wrap_at);
36 echo "</TT></TD></TR></TABLE>";
39 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
40 sqimap_mailbox_select($imapConnection, $mailbox);
42 // $message contains all information about the message
43 // including header and body
44 $message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
46 // lets redefine message as this particular entity that we wish to display.
47 // it should hold only the header for this entity. We need to fetch the body
48 // yet before we can display anything.
49 $message = getEntity($message, $passed_ent_id);
51 $header = $message->header
;
52 $body = mime_fetch_body($imapConnection, $passed_id, $passed_ent_id);
54 $type0 = $header->type0
;
55 $type1 = $header->type1
;
56 $filename = $header->filename
;
58 if (strlen($filename) < 1) {
59 $filename = "untitled$passed_ent_id";
62 if ($absolute_dl == "true") {
65 $body = decodeBody($body, $header->encoding
);
66 header("Content-type: $type0/$type1; name=\"$filename\"");
67 header("Content-Disposition: attachment; filename=\"$filename\"");
71 $body = decodeBody($body, $header->encoding
);
72 header("Content-type: $type0/$type1; name=\"$filename\"");
73 header("Content-Disposition: attachment; filename=\"$filename\"");
80 $body = decodeBody($body, $header->encoding
);
81 viewText($color, $body, $passed_id, $passed_ent_id, $mailbox, $type1, $wrap_at);
84 $body = decodeBody($body, $header->encoding
);
85 viewText($color, $body, $passed_id, $passed_ent_id, $mailbox, $type1, $wrap_at);
88 $body = decodeBody($body, $header->encoding
);
89 header("Content-type: $type0/$type1; name=\"$filename\"");
90 header("Content-Disposition: attachment; filename=\"$filename\"");
96 sqimap_logout($imapConnection);