4 if (!isset($config_php))
5 include("../config/config.php");
6 if (!isset($strings_php))
7 include("../functions/strings.php");
8 if (!isset($page_header_php))
9 include("../functions/page_header.php");
10 if (!isset($imap_php))
11 include("../functions/imap.php");
12 if (!isset($mime_php))
13 include("../functions/mime.php");
14 if (!isset($date_php))
15 include("../functions/date.php");
17 // given an IMAP message id number, this will look it up in the cached and sorted msgs array and
18 // return the index. used for finding the next and previous messages
20 // returns the index of the next valid message from the array
21 function findNextMessage() {
22 global $currentArrayIndex, $msgs;
23 if ($currentArrayIndex < (count($msgs)-1))
24 return $msgs[$currentArrayIndex+
1]["ID"];
28 // returns the index of the previous message from the array
29 function findPreviousMessage() {
30 global $currentArrayIndex, $msgs;
31 if ($currentArrayIndex > 0)
32 return $msgs[$currentArrayIndex-1]["ID"];
37 for ($i=0; $i < count($msgs); $i++
) {
38 if ($msgs[$i]["ID"] == $passed_id) {
39 $currentArrayIndex = $i;
44 $currentArrayIndex = -1;
47 include("../src/load_prefs.php");
48 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
49 sqimap_mailbox_select($imapConnection, $mailbox);
51 // $message contains all information about the message
52 // including header and body
53 $message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
56 echo "<BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";
57 displayPageHeader($color, $mailbox);
59 /** translate the subject and mailbox into url-able text **/
60 $url_subj = urlencode(trim(stripslashes($message["HEADER"]["SUBJECT"])));
61 $urlMailbox = urlencode($mailbox);
62 $url_replyto = urlencode($message["HEADER"]["REPLYTO"]);
64 $url_replytoall = urlencode($message["HEADER"]["REPLYTO"]);
65 $url_replytoallcc = urlencode(getLineOfAddrs($message["HEADER"]["TO"]) . ", " . getLineOfAddrs($message["HEADER"]["CC"]));
67 $dateString = getLongDateString($message["HEADER"]["DATE"]);
69 /** TEXT STRINGS DEFINITIONS **/
70 $echo_more = _("more");
71 $echo_less = _("less");
73 /** FORMAT THE TO STRING **/
76 $to_ary = $message["HEADER"]["TO"];
77 while ($i < count($to_ary)) {
78 $to_ary[$i] = htmlspecialchars($to_ary[$i]);
80 $to_string = "$to_string<BR>$to_ary[$i]";
82 $to_string = "$to_ary[$i]";
85 if (count($to_ary) > 1) {
86 if ($show_more == false) {
88 $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>)";
92 $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>)";
97 /** FORMAT THE CC STRING **/
100 $cc_ary = $message["HEADER"]["CC"];
101 while ($i < count($cc_ary)) {
102 $cc_ary[$i] = htmlspecialchars($cc_ary[$i]);
104 $cc_string = "$cc_string<BR>$cc_ary[$i]";
106 $cc_string = "$cc_ary[$i]";
109 if (count($cc_ary) > 1) {
110 if ($show_more_cc == false) {
112 $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>)";
115 } else if ($i == 1) {
116 $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>)";
121 /** make sure everything will display in HTML format **/
122 $from_name = decodeHeader(htmlspecialchars($message["HEADER"]["FROM"]));
123 $subject = decodeHeader(htmlspecialchars(stripslashes($message["HEADER"]["SUBJECT"])));
126 echo "<TABLE COLS=1 CELLSPACING=0 WIDTH=98% BORDER=0 ALIGN=CENTER CELLPADDING=0>\n";
127 echo " <TR><TD BGCOLOR=\"$color[0]\" WIDTH=100%>";
128 echo " <TABLE WIDTH=100% CELLSPACING=0 BORDER=0 COLS=2 CELLPADDING=3>";
130 echo " <TD ALIGN=LEFT WIDTH=33%>";
132 echo " <A HREF=\"right_main.php?use_mailbox_cache=1&sort=$sort&startMessage=$startMessage&mailbox=$urlMailbox\">";
133 echo _("Message List");
134 echo "</A> | ";
135 echo " <A HREF=\"delete_message.php?mailbox=$urlMailbox&message=$passed_id&sort=$sort&startMessage=1\">";
137 echo "</A> ";
139 echo " </TD><TD WIDTH=33% ALIGN=CENTER>";
141 if ($currentArrayIndex == -1) {
142 echo "Previous | Next";
144 $prev = findPreviousMessage();
145 $next = findNextMessage();
147 echo "<a href=\"read_body.php?passed_id=$prev&mailbox=$mailbox&sort=$sort&startMessage=$startMessage&show_more=0\">" . _("Previous") . "</A> | ";
149 echo _("Previous") . " | ";
151 echo "<a href=\"read_body.php?passed_id=$next&mailbox=$mailbox&sort=$sort&startMessage=$startMessage&show_more=0\">" . _("Next") . "</A>";
156 echo " </TD><TD WIDTH=33% ALIGN=RIGHT>";
158 echo " <A HREF=\"compose.php?forward_id=$passed_id&forward_subj=$url_subj&mailbox=$urlMailbox\">";
160 echo "</A> | ";
161 echo " <A HREF=\"compose.php?send_to=$url_replyto&reply_subj=$url_subj&reply_id=$passed_id&mailbox=$urlMailbox\">";
163 echo "</A> | ";
164 echo " <A HREF=\"compose.php?send_to=$url_replytoall&send_to_cc=$url_replytoallcc&reply_subj=$url_subj&reply_id=$passed_id&mailbox=$urlMailbox\">";
166 echo "</A> ";
172 echo " <TR><TD CELLSPACING=0 WIDTH=100%>";
173 echo " <TABLE COLS=2 WIDTH=100% BORDER=0 CELLSPACING=0 CELLPADDING=3>\n";
176 echo " <TD BGCOLOR=\"$color[4]\" WIDTH=15% ALIGN=RIGHT>\n";
178 echo " </TD><TD BGCOLOR=\"$color[4]\" WIDTH=85%>\n";
179 echo " <B>$subject</B>\n";
184 echo " <TD BGCOLOR=\"$color[4]\" WIDTH=15% ALIGN=RIGHT>\n";
186 echo " </TD><TD BGCOLOR=\"$color[4]\" WIDTH=85%>\n";
187 echo " <B>$from_name</B>\n";
192 echo " <TD BGCOLOR=\"$color[4]\" WIDTH=15% ALIGN=RIGHT>\n";
194 echo " </TD><TD BGCOLOR=\"$color[4]\" WIDTH=85%>\n";
195 echo " <B>$dateString</B>\n";
200 echo " <TD BGCOLOR=\"$color[4]\" WIDTH=15% ALIGN=RIGHT VALIGN=TOP>\n";
202 echo " </TD><TD BGCOLOR=\"$color[4]\" WIDTH=85% VALIGN=TOP>\n";
203 echo " <B>$to_string</B>\n";
207 if ($message["HEADER"]["CC"][0]) {
209 echo " <TD BGCOLOR=\"$color[4]\" WIDTH=15% ALIGN=RIGHT VALIGN=TOP>\n";
211 echo " </TD><TD BGCOLOR=\"$color[4]\" WIDTH=85% VALIGN=TOP>\n";
212 echo " <B>$cc_string</B>\n";
219 echo " <TR><TD BGCOLOR=\"$color[4]\" WIDTH=100%>\n";
220 $body = formatBody($message, $color, $wrap_at);
225 echo " </TD></TR>\n";
226 echo " <TR><TD BGCOLOR=\"$color[9]\"> </TD></TR>";