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