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