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