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 $msort, $currentArrayIndex, $msgs;
23 for (reset($msort); ($key = key($msort)), (isset($key)); next($msort)) {
24 if ($currentArrayIndex == $msgs[$key]["ID"]) {
28 return $msgs[$key]["ID"];
34 // returns the index of the previous message from the array
35 function findPreviousMessage() {
36 global $msort, $currentArrayIndex, $msgs;
37 for (reset($msort); ($key = key($msort)), (isset($key)); next($msort)) {
38 if ($currentArrayIndex == $msgs[$key]["ID"]) {
42 return $msgs[$key]["ID"];
49 $currentArrayIndex = $passed_id;
51 for ($i=0; $i < count($msgs); $i++) {
52 if ($msgs[$i]["ID"] == $passed_id) {
53 $currentArrayIndex = $i;
59 $currentArrayIndex = -1;
62 for ($i = 0; $i < count($msgs); $i++
) {
63 if ($msgs[$i]["ID"] == $passed_id)
64 $msgs[$i]["FLAG_SEEN"] = true;
67 include("../src/load_prefs.php");
68 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
69 sqimap_mailbox_select($imapConnection, $mailbox);
71 // $message contains all information about the message
72 // including header and body
73 $message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
75 displayPageHeader($color, $mailbox);
77 /** translate the subject and mailbox into url-able text **/
78 $url_subj = urlencode(trim(stripslashes($message->header
->subject
)));
79 $urlMailbox = urlencode($mailbox);
80 $url_replyto = urlencode($message->header
->replyto
);
82 $url_replytoall = urlencode($message->header
->replyto
);
83 $url_replytoallcc = urlencode(getLineOfAddrs($message->header
->to
) . ", " . getLineOfAddrs($message->header
->cc
));
85 $dateString = getLongDateString($message->header
->date
);
87 /** TEXT STRINGS DEFINITIONS **/
88 $echo_more = _("more");
89 $echo_less = _("less");
91 /** FORMAT THE TO STRING **/
94 $to_ary = $message->header
->to
;
95 while ($i < count($to_ary)) {
96 $to_ary[$i] = htmlspecialchars($to_ary[$i]);
99 $to_string = "$to_string<BR>$to_ary[$i]";
101 $to_string = "$to_ary[$i]";
104 if (count($to_ary) > 1) {
105 if ($show_more == false) {
107 $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>)";
110 } else if ($i == 1) {
111 $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>)";
116 /** FORMAT THE CC STRING **/
119 $cc_ary = $message->header
->cc
;
120 while ($i < count($cc_ary)) {
121 $cc_ary[$i] = htmlspecialchars($cc_ary[$i]);
123 $cc_string = "$cc_string<BR>$cc_ary[$i]";
125 $cc_string = "$cc_ary[$i]";
128 if (count($cc_ary) > 1) {
129 if ($show_more_cc == false) {
131 $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>)";
134 } else if ($i == 1) {
135 $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>)";
140 /** make sure everything will display in HTML format **/
141 $from_name = decodeHeader(htmlspecialchars($message->header
->from
));
142 $subject = decodeHeader(htmlspecialchars(stripslashes($message->header
->subject
)));
145 echo "<TABLE COLS=1 CELLSPACING=0 WIDTH=98% BORDER=0 ALIGN=CENTER CELLPADDING=0>\n";
146 echo " <TR><TD BGCOLOR=\"$color[0]\" WIDTH=100%>";
147 echo " <TABLE WIDTH=100% CELLSPACING=0 BORDER=0 COLS=2 CELLPADDING=3>";
149 echo " <TD ALIGN=LEFT WIDTH=33%>";
151 echo " <A HREF=\"right_main.php?use_mailbox_cache=1&sort=$sort&startMessage=$startMessage&mailbox=$urlMailbox\">";
152 echo _("Message List");
153 echo "</A> | ";
154 echo " <A HREF=\"delete_message.php?mailbox=$urlMailbox&message=$passed_id&sort=$sort&startMessage=1\">";
156 echo "</A> ";
158 echo " </TD><TD WIDTH=33% ALIGN=CENTER>";
160 if ($currentArrayIndex == -1) {
161 echo "Previous | Next";
163 $prev = findPreviousMessage();
164 $next = findNextMessage();
166 echo "<a href=\"read_body.php?passed_id=$prev&mailbox=$mailbox&sort=$sort&startMessage=$startMessage&show_more=0\">" . _("Previous") . "</A> | ";
168 echo _("Previous") . " | ";
170 echo "<a href=\"read_body.php?passed_id=$next&mailbox=$mailbox&sort=$sort&startMessage=$startMessage&show_more=0\">" . _("Next") . "</A>";
175 echo " </TD><TD WIDTH=33% ALIGN=RIGHT>";
177 echo " <A HREF=\"compose.php?forward_id=$passed_id&forward_subj=$url_subj&mailbox=$urlMailbox\">";
179 echo "</A> | ";
180 echo " <A HREF=\"compose.php?send_to=$url_replyto&reply_subj=$url_subj&reply_id=$passed_id&mailbox=$urlMailbox\">";
182 echo "</A> | ";
183 echo " <A HREF=\"compose.php?send_to=$url_replytoall&send_to_cc=$url_replytoallcc&reply_subj=$url_subj&reply_id=$passed_id&mailbox=$urlMailbox\">";
185 echo "</A> ";
191 echo " <TR><TD CELLSPACING=0 WIDTH=100%>";
192 echo " <TABLE COLS=2 WIDTH=100% BORDER=0 CELLSPACING=0 CELLPADDING=3>\n";
195 echo " <TD BGCOLOR=\"$color[4]\" WIDTH=15% ALIGN=RIGHT>\n";
197 echo " </TD><TD BGCOLOR=\"$color[4]\" WIDTH=85%>\n";
198 echo " <B>$subject</B>\n";
203 echo " <TD BGCOLOR=\"$color[4]\" WIDTH=15% ALIGN=RIGHT>\n";
205 echo " </TD><TD BGCOLOR=\"$color[4]\" WIDTH=85%>\n";
206 echo " <B>$from_name</B>\n";
211 echo " <TD BGCOLOR=\"$color[4]\" WIDTH=15% ALIGN=RIGHT>\n";
213 echo " </TD><TD BGCOLOR=\"$color[4]\" WIDTH=85%>\n";
214 echo " <B>$dateString</B>\n";
219 echo " <TD BGCOLOR=\"$color[4]\" WIDTH=15% ALIGN=RIGHT VALIGN=TOP>\n";
221 echo " </TD><TD BGCOLOR=\"$color[4]\" WIDTH=85% VALIGN=TOP>\n";
222 echo " <B>$to_string</B>\n";
226 if ($message->header
->cc
) {
228 echo " <TD BGCOLOR=\"$color[4]\" WIDTH=15% ALIGN=RIGHT VALIGN=TOP>\n";
230 echo " </TD><TD BGCOLOR=\"$color[4]\" WIDTH=85% VALIGN=TOP>\n";
231 echo " <B>$cc_string</B>\n";
238 echo " <TR><TD BGCOLOR=\"$color[4]\" WIDTH=100%>\n";
239 $body = formatBody($message, $color, $wrap_at);
244 echo " </TD></TR>\n";
245 echo " <TR><TD BGCOLOR=\"$color[9]\"> </TD></TR>";