dd597f5aae1311506c72c8b9082af84f2d714bae
5 ** Copyright (c) 1999-2000 The SquirrelMail development team
6 ** Licensed under the GNU GPL. For full terms see the file COPYING.
8 ** This file is used for reading the msgs array and displaying
9 ** the resulting emails in the right frame.
14 if (!isset($config_php))
15 include("../config/config.php");
16 if (!isset($strings_php))
17 include("../functions/strings.php");
18 if (!isset($page_header_php))
19 include("../functions/page_header.php");
20 if (!isset($imap_php))
21 include("../functions/imap.php");
22 if (!isset($mime_php))
23 include("../functions/mime.php");
24 if (!isset($date_php))
25 include("../functions/date.php");
27 include("../src/load_prefs.php");
28 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
29 sqimap_mailbox_select($imapConnection, $mailbox);
30 displayPageHeader($color, $mailbox);
33 fputs ($imapConnection, "a003 FETCH $passed_id BODY[HEADER]\r\n");
34 $read = sqimap_read_data ($imapConnection, "a003", true, $a, $b);
37 echo "<table width=100% cellpadding=2 cellspacing=0 border=0 align=center>\n";
38 echo " <TR><TD BGCOLOR=\"$color[9]\" WIDTH=100%><center><b>" . _("Viewing full header") . "</b> - ";
39 if ($where && $what) {
40 // Got here from a search
41 echo "<a href=\"read_body.php?mailbox=".urlencode($mailbox)."&passed_id=$passed_id&where=".urlencode($where)."&what=".urlencode($what)."\">";
43 echo "<a href=\"read_body.php?mailbox=".urlencode($mailbox)."&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more\">";
45 echo ""._("View message") . "</a></b></center></td></tr></table>\n";
46 echo "<table width=99% cellpadding=2 cellspacing=0 border=0 align=center>\n";
48 for ($i=1; $i < count($read)-1; $i++
) {
49 $read[$i] = htmlspecialchars($read[$i]);
50 if (substr($read[$i], 0, 1) != "\t" &&
51 substr($read[$i], 0, 1) != " " &&
52 substr($read[$i], 0, 1) != "&" &&
54 $pre = substr($read[$i], 0, strpos($read[$i], ":"));
55 $read[$i] = str_replace("$pre", "<b>$pre</b>", decodeHeader($read[$i]));
59 echo "</pre></td></tr></table>\n";
60 echo "</body></html>";
64 // given an IMAP message id number, this will look it up in the cached and sorted msgs array and
65 // return the index. used for finding the next and previous messages
67 // returns the index of the next valid message from the array
68 function findNextMessage() {
69 global $msort, $currentArrayIndex, $msgs;
70 for (reset($msort); ($key = key($msort)), (isset($key)); next($msort)) {
71 if ($currentArrayIndex == $msgs[$key]["ID"]) {
75 return $msgs[$key]["ID"];
81 // returns the index of the previous message from the array
82 function findPreviousMessage() {
83 global $msort, $currentArrayIndex, $msgs;
84 for (reset($msort); ($key = key($msort)), (isset($key)); next($msort)) {
85 if ($currentArrayIndex == $msgs[$key]["ID"]) {
89 return $msgs[$key]["ID"];
96 $currentArrayIndex = $passed_id;
98 for ($i=0; $i < count($msgs); $i++) {
99 if ($msgs[$i]["ID"] == $passed_id) {
100 $currentArrayIndex = $i;
106 $currentArrayIndex = -1;
109 for ($i = 0; $i < count($msgs); $i++
) {
110 if ($msgs[$i]["ID"] == $passed_id)
111 $msgs[$i]["FLAG_SEEN"] = true;
114 // $message contains all information about the message
115 // including header and body
116 $message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
118 /** translate the subject and mailbox into url-able text **/
119 $url_subj = urlencode(trim(stripslashes($message->header
->subject
)));
120 $urlMailbox = urlencode($mailbox);
121 $url_replyto = urlencode($message->header
->replyto
);
123 $url_replytoall = urlencode($message->header
->replyto
);
124 $url_replytoallcc = getLineOfAddrs($message->header
->to
);
125 $url_replytoallcc_cc = getLineOfAddrs($message->header
->cc
);
126 if ($url_replytoallcc) {
127 if ($url_replytoallcc_cc) {
128 $url_replytoallcc .= ", " . $url_replytoallcc_cc;
131 if ($url_replytoallcc_cc) {
132 $url_replytoallcc = $url_replytoallcc_cc;
134 $url_replytoallcc = "";
137 $url_replytoallcc = urlencode($url_replytoallcc);
139 $dateString = getLongDateString($message->header
->date
);
140 $ent_num = findDisplayEntity($message);
142 /** TEXT STRINGS DEFINITIONS **/
143 $echo_more = _("more");
144 $echo_less = _("less");
146 /** FORMAT THE TO STRING **/
149 $to_ary = $message->header
->to
;
150 while ($i < count($to_ary)) {
151 $to_ary[$i] = htmlspecialchars(decodeHeader($to_ary[$i]));
154 $to_string = "$to_string<BR>$to_ary[$i]";
156 $to_string = "$to_ary[$i]";
159 if (count($to_ary) > 1) {
160 if ($show_more == false) {
162 if ($where && $what) {
164 $to_string = "$to_string (<A HREF=\"read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&where=".urlencode($where)."&what=".urlencode($what)."&show_more=1&show_more_cc=$show_more_cc\">$echo_more</A>)";
166 $to_string = "$to_string (<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>)";
170 } else if ($i == 1) {
171 if ($where && $what) {
173 $to_string = "$to_string (<A HREF=\"read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&where=".urlencode($where)."&what=".urlencode($what)."&show_more=0&show_more_cc=$show_more_cc\">$echo_less</A>)";
175 $to_string = "$to_string (<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>)";
181 /** FORMAT THE CC STRING **/
184 $cc_ary = $message->header
->cc
;
185 while ($i < count(decodeHeader($cc_ary))) {
186 $cc_ary[$i] = htmlspecialchars($cc_ary[$i]);
188 $cc_string = "$cc_string<BR>$cc_ary[$i]";
190 $cc_string = "$cc_ary[$i]";
193 if (count($cc_ary) > 1) {
194 if ($show_more_cc == false) {
196 if ($where && $what) {
198 $cc_string = "$cc_string (<A HREF=\"read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&what=".urlencode($what)."&where=".urlencode($where)."&show_more_cc=1&show_more=$show_more\">$echo_more</A>)";
200 $cc_string = "$cc_string (<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>)";
204 } else if ($i == 1) {
205 if ($where && $what) {
207 $cc_string = "$cc_string (<A HREF=\"read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&what=".urlencode($what)."&where=".urlencode($where)."&show_more_cc=0&show_more=$show_more\">$echo_less</A>)";
209 $cc_string = "$cc_string (<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>)";
215 /** make sure everything will display in HTML format **/
216 $from_name = decodeHeader(htmlspecialchars($message->header
->from
));
217 $subject = decodeHeader(htmlspecialchars(stripslashes($message->header
->subject
)));
220 echo "<TABLE COLS=1 CELLSPACING=0 WIDTH=100% BORDER=0 ALIGN=CENTER CELLPADDING=0>\n";
221 echo " <TR><TD BGCOLOR=\"$color[9]\" WIDTH=100%>";
222 echo " <TABLE WIDTH=100% CELLSPACING=0 BORDER=0 COLS=2 CELLPADDING=3>";
224 echo " <TD ALIGN=LEFT WIDTH=33%>";
226 if ($where && $what) {
227 echo " <A HREF=\"search.php?where=".urlencode($where)."&what=".urlencode($what)."&mailbox=$urlMailbox\">";
229 echo " <A HREF=\"right_main.php?use_mailbox_cache=1&sort=$sort&startMessage=$startMessage&mailbox=$urlMailbox\">";
231 echo _("Message List");
232 echo "</A> | ";
233 if ($where && $what) {
234 echo " <A HREF=\"delete_message.php?mailbox=$urlMailbox&message=$passed_id&where=".urlencode($where)."&what=".urlencode($what)."\">";
236 echo " <A HREF=\"delete_message.php?mailbox=$urlMailbox&message=$passed_id&sort=$sort&startMessage=1\">";
239 echo "</A> ";
241 echo " </TD><TD WIDTH=33% ALIGN=CENTER>";
243 if ($where && $what) {
245 if ($currentArrayIndex == -1) {
246 echo "Previous | Next";
248 $prev = findPreviousMessage();
249 $next = findNextMessage();
251 echo "<a href=\"read_body.php?passed_id=$prev&mailbox=$urlMailbox&sort=$sort&startMessage=$startMessage&show_more=0\">" . _("Previous") . "</A> | ";
253 echo _("Previous") . " | ";
255 echo "<a href=\"read_body.php?passed_id=$next&mailbox=$urlMailbox&sort=$sort&startMessage=$startMessage&show_more=0\">" . _("Next") . "</A>";
261 echo " </TD><TD WIDTH=33% ALIGN=RIGHT>";
263 echo " <A HREF=\"compose.php?forward_id=$passed_id&forward_subj=$url_subj&mailbox=$urlMailbox&ent_num=$ent_num\">";
265 echo "</A> | ";
266 echo " <A HREF=\"compose.php?send_to=$url_replyto&reply_subj=$url_subj&reply_id=$passed_id&mailbox=$urlMailbox&ent_num=$ent_num\">";
268 echo "</A> | ";
269 echo " <A HREF=\"compose.php?send_to=$url_replytoall&send_to_cc=$url_replytoallcc&reply_subj=$url_subj&reply_id=$passed_id&mailbox=$urlMailbox&ent_num=$ent_num\">";
271 echo "</A> ";
277 echo " <TR><TD CELLSPACING=0 WIDTH=100%>";
278 echo " <TABLE COLS=2 WIDTH=100% BORDER=0 CELLSPACING=0 CELLPADDING=3>\n";
281 echo " <TD BGCOLOR=\"$color[0]\" WIDTH=15% ALIGN=RIGHT>\n";
283 echo " </TD><TD BGCOLOR=\"$color[0]\" WIDTH=84%>\n";
284 echo " <B>$subject</B>\n";
286 if ($where && $what) {
287 // Got here from a search
288 echo " <TD WIDTH=1% bgcolor=\"$color[0]\" nowrap align=right><small><a href=\"read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&where=".urlencode($where)."&what=".urlencode($what)."&view_hdr=1\">" . _("View full header") . "</a></small> </td>";
290 echo " <TD WIDTH=1% bgcolor=\"$color[0]\" nowrap align=right><small><a href=\"read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&view_hdr=1\">" . _("View full header") . "</a></small> </td>";
295 echo " <TD BGCOLOR=\"$color[0]\" WIDTH=15% ALIGN=RIGHT>\n";
297 echo " </TD><TD BGCOLOR=\"$color[0]\" WIDTH=85% colspan=2>\n";
298 echo " <B>$from_name</B>\n";
303 echo " <TD BGCOLOR=\"$color[0]\" WIDTH=15% ALIGN=RIGHT>\n";
305 echo " </TD><TD BGCOLOR=\"$color[0]\" WIDTH=85% colspan=2>\n";
306 echo " <B>$dateString</B>\n";
311 echo " <TD BGCOLOR=\"$color[0]\" WIDTH=15% ALIGN=RIGHT VALIGN=TOP>\n";
313 echo " </TD><TD BGCOLOR=\"$color[0]\" WIDTH=85% VALIGN=TOP colspan=2>\n";
314 echo " <B>$to_string</B>\n";
318 if ($message->header
->cc
) {
320 echo " <TD BGCOLOR=\"$color[0]\" WIDTH=15% ALIGN=RIGHT VALIGN=TOP>\n";
322 echo " </TD><TD BGCOLOR=\"$color[0]\" WIDTH=85% VALIGN=TOP colspan=2>\n";
323 echo " <B>$cc_string</B>\n";
330 echo "<TABLE COLS=1 CELLSPACING=0 WIDTH=97% BORDER=0 ALIGN=CENTER CELLPADDING=0>\n";
332 echo " <TR><TD BGCOLOR=\"$color[4]\" WIDTH=100%>\n";
335 $body = formatBody($imapConnection, $message, $color, $wrap_at);
339 echo " </TD></TR>\n";
341 echo "<TABLE COLS=1 CELLSPACING=0 WIDTH=100% BORDER=0 ALIGN=CENTER CELLPADDING=0>\n";
342 echo " <TR><TD BGCOLOR=\"$color[9]\"> </TD></TR>";
345 sqimap_logout($imapConnection);