added gettext support.
[squirrelmail.git] / src / read_body.php
CommitLineData
be69e508 1<?
2 include("../config/config.php");
3 include("../functions/strings.php");
4 include("../functions/page_header.php");
5 include("../functions/imap.php");
f7fb20fe 6 include("../functions/mime.php");
be69e508 7 include("../functions/mailbox.php");
8 include("../functions/date.php");
9
d3cdb279 10 include("../src/load_prefs.php");
11
be69e508 12 $imapConnection = loginToImapServer($username, $key, $imapServerAddress);
13 selectMailbox($imapConnection, $mailbox, $numMessages);
14
f7fb20fe 15 // $message contains all information about the message
16 // including header and body
97be2168 17 $message = fetchMessage($imapConnection, $passed_id, $mailbox);
31f3d7c0 18
d4467150 19 echo "<HTML>";
f8f9bed9 20 echo "<BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";
21 displayPageHeader($color, $mailbox);
d4467150 22
f7fb20fe 23 /** translate the subject and mailbox into url-able text **/
e39d73e5 24 $url_subj = urlencode(trim(stripslashes($message["HEADER"]["SUBJECT"])));
8467bf00 25 $urlMailbox = urlencode($mailbox);
5c55c295 26 $url_replyto = urlencode($message["HEADER"]["REPLYTO"]);
be69e508 27
4bfed9f3 28 $url_replytoall = urlencode($message["HEADER"]["REPLYTO"]);
29 $url_replytoallcc = urlencode(getLineOfAddrs($message["HEADER"]["TO"]) . ", " . getLineOfAddrs($message["HEADER"]["CC"]));
30
f7fb20fe 31 $dateString = getLongDateString($message["HEADER"]["DATE"]);
31f3d7c0 32
078a40a4 33 /** FORMAT THE TO STRING **/
2844086d 34 $i = 0;
35 $to_string = "";
f7fb20fe 36 $to_ary = $message["HEADER"]["TO"];
2844086d 37 while ($i < count($to_ary)) {
f7fb20fe 38 $to_ary[$i] = htmlspecialchars($to_ary[$i]);
2844086d 39 if ($to_string)
40 $to_string = "$to_string<BR>$to_ary[$i]";
41 else
42 $to_string = "$to_ary[$i]";
43
44 $i++;
45 if (count($to_ary) > 1) {
46 if ($show_more == false) {
47 if ($i == 1) {
078a40a4 48 $to_string = "$to_string&nbsp;(<A HREF=\"read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&sort=$sort&startMessage=$startMessage&show_more=1&show_more_cc=$show_more_cc\">more</A>)";
2844086d 49 $i = count($to_ary);
50 }
51 } else if ($i == 1) {
078a40a4 52 $to_string = "$to_string&nbsp;(<A HREF=\"read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&sort=$sort&startMessage=$startMessage&show_more=0&show_more_cc=$show_more_cc\">less</A>)";
2844086d 53 }
54 }
55 }
56
078a40a4 57 /** FORMAT THE CC STRING **/
58 $i = 0;
59 $cc_string = "";
f7fb20fe 60 $cc_ary = $message["HEADER"]["CC"];
078a40a4 61 while ($i < count($cc_ary)) {
f7fb20fe 62 $cc_ary[$i] = htmlspecialchars($cc_ary[$i]);
078a40a4 63 if ($cc_string)
64 $cc_string = "$cc_string<BR>$cc_ary[$i]";
65 else
66 $cc_string = "$cc_ary[$i]";
67
68 $i++;
69 if (count($cc_ary) > 1) {
70 if ($show_more_cc == false) {
71 if ($i == 1) {
72 $cc_string = "$cc_string&nbsp;(<A HREF=\"read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&sort=$sort&startMessage=$startMessage&show_more_cc=1&show_more=$show_more\">more</A>)";
73 $i = count($cc_ary);
74 }
75 } else if ($i == 1) {
76 $cc_string = "$cc_string&nbsp;(<A HREF=\"read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&sort=$sort&startMessage=$startMessage&show_more_cc=0&show_more=$show_more\">less</A>)";
77 }
78 }
79 }
80
f7fb20fe 81 /** make sure everything will display in HTML format **/
82 $from_name = htmlspecialchars($message["HEADER"]["FROM"]);
e39d73e5 83 $subject = htmlspecialchars(stripslashes($message["HEADER"]["SUBJECT"]));
078a40a4 84
8467bf00 85 echo "<BR>";
4809f489 86 echo "<TABLE COLS=1 CELLSPACING=0 WIDTH=98% BORDER=0 ALIGN=CENTER CELLPADDING=0>\n";
f8f9bed9 87 echo " <TR><TD BGCOLOR=\"$color[0]\" WIDTH=100%>";
4809f489 88 echo " <TABLE WIDTH=100% CELLSPACING=0 BORDER=0 COLS=2 CELLPADDING=3>";
31f3d7c0 89 echo " <TR>";
90 echo " <TD ALIGN=LEFT WIDTH=50%>";
91 echo " <FONT FACE=\"Arial,Helvetica\" SIZE=2>";
4bfed9f3 92 echo " <A HREF=\"right_main.php?sort=$sort&startMessage=$startMessage&mailbox=$urlMailbox\">Message List</A>&nbsp;|&nbsp;";
31f3d7c0 93 echo " <A HREF=\"delete_message.php?mailbox=$urlMailbox&message=$passed_id&sort=$sort&startMessage=1\">Delete</A>&nbsp;&nbsp;";
94 echo " </FONT>";
95 echo " </TD><TD WIDTH=50% ALIGN=RIGHT>";
96 echo " <FONT FACE=\"Arial,Helvetica\" SIZE=2>";
4bfed9f3 97 echo " <A HREF=\"compose.php?forward_id=$passed_id&forward_subj=$url_subj&mailbox=$urlMailbox\">Forward</A>&nbsp;|&nbsp;";
98 echo " <A HREF=\"compose.php?send_to=$url_replyto&reply_subj=$url_subj&reply_id=$passed_id&mailbox=$urlMailbox\">Reply</A>&nbsp;|&nbsp;";
99 echo " <A HREF=\"compose.php?send_to=$url_replytoall&send_to_cc=$url_replytoallcc&reply_subj=$url_subj&reply_id=$passed_id&mailbox=$urlMailbox\">Reply All</A>&nbsp;&nbsp;";
31f3d7c0 100 echo " </FONT>";
101 echo " </TD>";
102 echo " </TR>";
103 echo " </TABLE>";
8467bf00 104 echo " </TD></TR>";
4809f489 105 echo " <TR><TD CELLSPACING=0 WIDTH=100%>";
97afcee9 106 echo " <TABLE COLS=2 WIDTH=100% BORDER=0 CELLSPACING=0 CELLPADDING=3>\n";
be69e508 107 echo " <TR>\n";
108 /** subject **/
4809f489 109 echo " <TD BGCOLOR=\"$color[4]\" WIDTH=15% ALIGN=RIGHT>\n";
be69e508 110 echo " <FONT FACE=\"Arial,Helvetica\">Subject:</FONT>\n";
f8f9bed9 111 echo " </TD><TD BGCOLOR=\"$color[4]\" WIDTH=85%>\n";
be69e508 112 echo " <FONT FACE=\"Arial,Helvetica\"><B>$subject</B></FONT>\n";
113 echo " </TD>\n";
114 echo " </TR>\n";
115 /** from **/
116 echo " <TR>\n";
4809f489 117 echo " <TD BGCOLOR=\"$color[4]\" WIDTH=15% ALIGN=RIGHT>\n";
be69e508 118 echo " <FONT FACE=\"Arial,Helvetica\">From:</FONT>\n";
f8f9bed9 119 echo " </TD><TD BGCOLOR=\"$color[4]\" WIDTH=85%>\n";
be69e508 120 echo " <FONT FACE=\"Arial,Helvetica\"><B>$from_name</B></FONT>\n";
121 echo " </TD>\n";
122 echo " </TR>\n";
123 /** date **/
124 echo " <TR>\n";
4809f489 125 echo " <TD BGCOLOR=\"$color[4]\" WIDTH=15% ALIGN=RIGHT>\n";
be69e508 126 echo " <FONT FACE=\"Arial,Helvetica\">Date:</FONT>\n";
f8f9bed9 127 echo " </TD><TD BGCOLOR=\"$color[4]\" WIDTH=85%>\n";
9774bdef 128 echo " <FONT FACE=\"Arial,Helvetica\"><B>$dateString</B></FONT>\n";
be69e508 129 echo " </TD>\n";
130 echo " </TR>\n";
2844086d 131 /** to **/
132 echo " <TR>\n";
4809f489 133 echo " <TD BGCOLOR=\"$color[4]\" WIDTH=15% ALIGN=RIGHT VALIGN=TOP>\n";
2844086d 134 echo " <FONT FACE=\"Arial,Helvetica\">To:</FONT>\n";
f8f9bed9 135 echo " </TD><TD BGCOLOR=\"$color[4]\" WIDTH=85% VALIGN=TOP>\n";
2844086d 136 echo " <FONT FACE=\"Arial,Helvetica\"><B>$to_string</B></FONT>\n";
137 echo " </TD>\n";
138 echo " </TR>\n";
078a40a4 139 /** cc **/
f7fb20fe 140 if ($message["HEADER"]["CC"][0]) {
078a40a4 141 echo " <TR>\n";
4809f489 142 echo " <TD BGCOLOR=\"$color[4]\" WIDTH=15% ALIGN=RIGHT VALIGN=TOP>\n";
078a40a4 143 echo " <FONT FACE=\"Arial,Helvetica\">Cc:</FONT>\n";
f8f9bed9 144 echo " </TD><TD BGCOLOR=\"$color[4]\" WIDTH=85% VALIGN=TOP>\n";
078a40a4 145 echo " <FONT FACE=\"Arial,Helvetica\"><B>$cc_string</B></FONT>\n";
146 echo " </TD>\n";
147 echo " </TR>\n";
148 }
4809f489 149 echo "</TABLE>";
150 echo " </TD></TR>";
be69e508 151
f8f9bed9 152 echo " <TR><TD BGCOLOR=\"$color[4]\" WIDTH=100%>\n";
11307a4c 153 $body = formatBody($message, $color, $wrap_at);
4809f489 154 echo "<BR>";
5c55c295 155
7831268e 156 echo "$body";
d4467150 157
7831268e 158 echo " </TD></TR>\n";
159 echo " <TR><TD BGCOLOR=\"$color[9]\">&nbsp;</TD></TR>";
be69e508 160 echo "</TABLE>\n";
161
162?>