6b96544a |
1 | <? |
2a32fc83 |
2 | session_start(); |
3 | |
d068c0ec |
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"); |
6b96544a |
16 | |
d3cdb279 |
17 | include("../src/load_prefs.php"); |
18 | |
11307a4c |
19 | function viewText($color, $body, $id, $entid, $mailbox, $type1, $wrap_at) { |
7831268e |
20 | echo "<HTML><BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n"; |
21 | displayPageHeader($color, "None"); |
22 | |
23 | echo "<BR><TABLE WIDTH=90% BORDER=0 CELLSPACING=0 CELLPADDING=2 ALIGN=CENTER><TR><TD BGCOLOR=\"$color[0]\">"; |
180c2c09 |
24 | echo "<B><CENTER>"; |
25 | echo _("Viewing a plain text attachment"); |
26 | echo "</CENTER></B>"; |
7831268e |
27 | echo "</TD></TR><TR><TD BGCOLOR=\"$color[4]\">"; |
28 | $urlmailbox = urlencode($mailbox); |
2a32fc83 |
29 | echo "<CENTER><A HREF=\"../src/download.php?PHPSESSID=$PHPSESSID&absolute_dl=true&passed_id=$id&passed_ent_id=$entid&mailbox=$urlmailbox\">"; |
180c2c09 |
30 | echo _("Download this as a file"); |
aae41ae9 |
31 | echo "</A></CENTER><BR><BR><TT>"; |
0a4cf77a |
32 | if ($type1 == "html") |
11307a4c |
33 | echo $body; |
0a4cf77a |
34 | else |
11307a4c |
35 | echo translateText($body, $wrap_at); |
0a4cf77a |
36 | |
7831268e |
37 | echo "</TT></TD></TR></TABLE>"; |
38 | } |
39 | |
e1469126 |
40 | $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); |
813eba2f |
41 | sqimap_mailbox_select($imapConnection, $mailbox); |
6b96544a |
42 | |
43 | // $message contains all information about the message |
44 | // including header and body |
813eba2f |
45 | $message = sqimap_get_message($imapConnection, $passed_id, $mailbox); |
6b96544a |
46 | |
47 | $type0 = $message["ENTITIES"][$passed_ent_id]["TYPE0"]; |
48 | $type1 = $message["ENTITIES"][$passed_ent_id]["TYPE1"]; |
49 | $filename = $message["ENTITIES"][$passed_ent_id]["FILENAME"]; |
6b96544a |
50 | |
7831268e |
51 | if (strlen($filename) < 1) { |
7085fa78 |
52 | $filename = "untitled$passed_ent_id"; |
7831268e |
53 | } |
6b96544a |
54 | |
7831268e |
55 | if ($absolute_dl == "true") { |
56 | switch($type0) { |
57 | case "text": |
58 | $body = decodeBody($message["ENTITIES"][$passed_ent_id]["BODY"], $message["ENTITIES"][$passed_ent_id]["ENCODING"]); |
78509c54 |
59 | header("Content-type: $type0/$type1; name=\"$filename\""); |
7831268e |
60 | header("Content-Disposition: attachment; filename=\"$filename\""); |
d3cdb279 |
61 | echo trim($body); |
7831268e |
62 | break; |
63 | default: |
64 | $body = decodeBody($message["ENTITIES"][$passed_ent_id]["BODY"], $message["ENTITIES"][$passed_ent_id]["ENCODING"]); |
78509c54 |
65 | header("Content-type: $type0/$type1; name=\"$filename\""); |
6b96544a |
66 | header("Content-Disposition: attachment; filename=\"$filename\""); |
67 | echo $body; |
7831268e |
68 | break; |
69 | } |
70 | } else { |
71 | switch ($type0) { |
72 | case "text": |
73 | $body = decodeBody($message["ENTITIES"][$passed_ent_id]["BODY"], $message["ENTITIES"][$passed_ent_id]["ENCODING"]); |
11307a4c |
74 | viewText($color, $body, $passed_id, $passed_ent_id, $mailbox, $type1, $wrap_at); |
7831268e |
75 | break; |
76 | case "message": |
77 | $body = decodeBody($message["ENTITIES"][$passed_ent_id]["BODY"], $message["ENTITIES"][$passed_ent_id]["ENCODING"]); |
11307a4c |
78 | viewText($color, $body, $passed_id, $passed_ent_id, $mailbox, $type1, $wrap_at); |
7831268e |
79 | break; |
80 | default: |
81 | $body = decodeBody($message["ENTITIES"][$passed_ent_id]["BODY"], $message["ENTITIES"][$passed_ent_id]["ENCODING"]); |
78509c54 |
82 | header("Content-type: $type0/$type1; name=\"$filename\""); |
6b96544a |
83 | header("Content-Disposition: attachment; filename=\"$filename\""); |
84 | echo $body; |
7831268e |
85 | break; |
86 | } |
6b96544a |
87 | } |
88 | |
813eba2f |
89 | sqimap_logout($imapConnection); |
7831268e |
90 | ?> |