59177427 |
1 | <?php |
2a32fc83 |
2 | session_start(); |
3 | |
d068c0ec |
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"); |
be69e508 |
16 | |
90033b64 |
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 |
19 | |
20 | // returns the index of the next valid message from the array |
21 | function findNextMessage() { |
53524fa0 |
22 | global $msort, $currentArrayIndex, $msgs; |
23 | for (reset($msort); ($key = key($msort)), (isset($key)); next($msort)) { |
24 | if ($currentArrayIndex == $msgs[$key]["ID"]) { |
25 | next($msort); |
26 | $key = key($msort); |
27 | if (isset($key)) |
28 | return $msgs[$key]["ID"]; |
29 | } |
30 | } |
90033b64 |
31 | return -1; |
32 | } |
33 | |
34 | // returns the index of the previous message from the array |
35 | function findPreviousMessage() { |
53524fa0 |
36 | global $msort, $currentArrayIndex, $msgs; |
37 | for (reset($msort); ($key = key($msort)), (isset($key)); next($msort)) { |
38 | if ($currentArrayIndex == $msgs[$key]["ID"]) { |
39 | prev($msort); |
40 | $key = key($msort); |
41 | if (isset($key)) |
42 | return $msgs[$key]["ID"]; |
43 | } |
44 | } |
90033b64 |
45 | return -1; |
46 | } |
47 | |
48 | if (isset($msgs)) { |
53524fa0 |
49 | $currentArrayIndex = $passed_id; |
50 | /* |
90033b64 |
51 | for ($i=0; $i < count($msgs); $i++) { |
52 | if ($msgs[$i]["ID"] == $passed_id) { |
53 | $currentArrayIndex = $i; |
54 | break; |
55 | } |
56 | } |
53524fa0 |
57 | */ |
90033b64 |
58 | } else { |
59 | $currentArrayIndex = -1; |
60 | } |
61 | |
1108e8bb |
62 | for ($i = 0; $i < count($msgs); $i++) { |
63 | if ($msgs[$i]["ID"] == $passed_id) |
64 | $msgs[$i]["FLAG_SEEN"] = true; |
65 | } |
66 | |
d3cdb279 |
67 | include("../src/load_prefs.php"); |
e1469126 |
68 | $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); |
813eba2f |
69 | sqimap_mailbox_select($imapConnection, $mailbox); |
be69e508 |
70 | |
f7fb20fe |
71 | // $message contains all information about the message |
72 | // including header and body |
813eba2f |
73 | $message = sqimap_get_message($imapConnection, $passed_id, $mailbox); |
31f3d7c0 |
74 | |
d4467150 |
75 | echo "<HTML>"; |
f8f9bed9 |
76 | echo "<BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n"; |
77 | displayPageHeader($color, $mailbox); |
d4467150 |
78 | |
f7fb20fe |
79 | /** translate the subject and mailbox into url-able text **/ |
e39d73e5 |
80 | $url_subj = urlencode(trim(stripslashes($message["HEADER"]["SUBJECT"]))); |
8467bf00 |
81 | $urlMailbox = urlencode($mailbox); |
5c55c295 |
82 | $url_replyto = urlencode($message["HEADER"]["REPLYTO"]); |
be69e508 |
83 | |
4bfed9f3 |
84 | $url_replytoall = urlencode($message["HEADER"]["REPLYTO"]); |
85 | $url_replytoallcc = urlencode(getLineOfAddrs($message["HEADER"]["TO"]) . ", " . getLineOfAddrs($message["HEADER"]["CC"])); |
86 | |
f7fb20fe |
87 | $dateString = getLongDateString($message["HEADER"]["DATE"]); |
31f3d7c0 |
88 | |
b581fa60 |
89 | /** TEXT STRINGS DEFINITIONS **/ |
90 | $echo_more = _("more"); |
91 | $echo_less = _("less"); |
92 | |
078a40a4 |
93 | /** FORMAT THE TO STRING **/ |
2844086d |
94 | $i = 0; |
95 | $to_string = ""; |
f7fb20fe |
96 | $to_ary = $message["HEADER"]["TO"]; |
2844086d |
97 | while ($i < count($to_ary)) { |
f7fb20fe |
98 | $to_ary[$i] = htmlspecialchars($to_ary[$i]); |
be8e07f8 |
99 | |
2844086d |
100 | if ($to_string) |
101 | $to_string = "$to_string<BR>$to_ary[$i]"; |
102 | else |
103 | $to_string = "$to_ary[$i]"; |
104 | |
105 | $i++; |
106 | if (count($to_ary) > 1) { |
107 | if ($show_more == false) { |
108 | if ($i == 1) { |
9f2215a1 |
109 | $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>)"; |
2844086d |
110 | $i = count($to_ary); |
111 | } |
112 | } else if ($i == 1) { |
9f2215a1 |
113 | $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>)"; |
2844086d |
114 | } |
115 | } |
116 | } |
117 | |
078a40a4 |
118 | /** FORMAT THE CC STRING **/ |
119 | $i = 0; |
120 | $cc_string = ""; |
f7fb20fe |
121 | $cc_ary = $message["HEADER"]["CC"]; |
078a40a4 |
122 | while ($i < count($cc_ary)) { |
f7fb20fe |
123 | $cc_ary[$i] = htmlspecialchars($cc_ary[$i]); |
078a40a4 |
124 | if ($cc_string) |
125 | $cc_string = "$cc_string<BR>$cc_ary[$i]"; |
126 | else |
127 | $cc_string = "$cc_ary[$i]"; |
128 | |
129 | $i++; |
130 | if (count($cc_ary) > 1) { |
131 | if ($show_more_cc == false) { |
132 | if ($i == 1) { |
9f2215a1 |
133 | $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>)"; |
078a40a4 |
134 | $i = count($cc_ary); |
135 | } |
136 | } else if ($i == 1) { |
9f2215a1 |
137 | $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>)"; |
078a40a4 |
138 | } |
139 | } |
140 | } |
141 | |
f7fb20fe |
142 | /** make sure everything will display in HTML format **/ |
9cccb418 |
143 | $from_name = decodeHeader(htmlspecialchars($message["HEADER"]["FROM"])); |
144 | $subject = decodeHeader(htmlspecialchars(stripslashes($message["HEADER"]["SUBJECT"]))); |
078a40a4 |
145 | |
8467bf00 |
146 | echo "<BR>"; |
4809f489 |
147 | echo "<TABLE COLS=1 CELLSPACING=0 WIDTH=98% BORDER=0 ALIGN=CENTER CELLPADDING=0>\n"; |
f8f9bed9 |
148 | echo " <TR><TD BGCOLOR=\"$color[0]\" WIDTH=100%>"; |
4809f489 |
149 | echo " <TABLE WIDTH=100% CELLSPACING=0 BORDER=0 COLS=2 CELLPADDING=3>"; |
31f3d7c0 |
150 | echo " <TR>"; |
90033b64 |
151 | echo " <TD ALIGN=LEFT WIDTH=33%>"; |
aae41ae9 |
152 | echo " <SMALL>"; |
90033b64 |
153 | echo " <A HREF=\"right_main.php?use_mailbox_cache=1&sort=$sort&startMessage=$startMessage&mailbox=$urlMailbox\">"; |
b581fa60 |
154 | echo _("Message List"); |
155 | echo "</A> | "; |
9f2215a1 |
156 | echo " <A HREF=\"delete_message.php?mailbox=$urlMailbox&message=$passed_id&sort=$sort&startMessage=1\">"; |
b581fa60 |
157 | echo _("Delete"); |
158 | echo "</A> "; |
aae41ae9 |
159 | echo " </SMALL>"; |
90033b64 |
160 | echo " </TD><TD WIDTH=33% ALIGN=CENTER>"; |
161 | echo " <SMALL>\n"; |
162 | if ($currentArrayIndex == -1) { |
163 | echo "Previous | Next"; |
164 | } else { |
165 | $prev = findPreviousMessage(); |
166 | $next = findNextMessage(); |
167 | if ($prev != -1) |
168 | echo "<a href=\"read_body.php?passed_id=$prev&mailbox=$mailbox&sort=$sort&startMessage=$startMessage&show_more=0\">" . _("Previous") . "</A> | "; |
169 | else |
170 | echo _("Previous") . " | "; |
171 | if ($next != -1) |
172 | echo "<a href=\"read_body.php?passed_id=$next&mailbox=$mailbox&sort=$sort&startMessage=$startMessage&show_more=0\">" . _("Next") . "</A>"; |
173 | else |
174 | echo _("Next"); |
175 | } |
176 | echo " </SMALL>\n"; |
177 | echo " </TD><TD WIDTH=33% ALIGN=RIGHT>"; |
aae41ae9 |
178 | echo " <SMALL>"; |
9f2215a1 |
179 | echo " <A HREF=\"compose.php?forward_id=$passed_id&forward_subj=$url_subj&mailbox=$urlMailbox\">"; |
b581fa60 |
180 | echo _("Forward"); |
181 | echo "</A> | "; |
9f2215a1 |
182 | echo " <A HREF=\"compose.php?send_to=$url_replyto&reply_subj=$url_subj&reply_id=$passed_id&mailbox=$urlMailbox\">"; |
b581fa60 |
183 | echo _("Reply"); |
184 | echo "</A> | "; |
9f2215a1 |
185 | echo " <A HREF=\"compose.php?send_to=$url_replytoall&send_to_cc=$url_replytoallcc&reply_subj=$url_subj&reply_id=$passed_id&mailbox=$urlMailbox\">"; |
b581fa60 |
186 | echo _("Reply All"); |
187 | echo "</A> "; |
aae41ae9 |
188 | echo " </SMALL>"; |
31f3d7c0 |
189 | echo " </TD>"; |
190 | echo " </TR>"; |
191 | echo " </TABLE>"; |
8467bf00 |
192 | echo " </TD></TR>"; |
4809f489 |
193 | echo " <TR><TD CELLSPACING=0 WIDTH=100%>"; |
97afcee9 |
194 | echo " <TABLE COLS=2 WIDTH=100% BORDER=0 CELLSPACING=0 CELLPADDING=3>\n"; |
be69e508 |
195 | echo " <TR>\n"; |
196 | /** subject **/ |
4809f489 |
197 | echo " <TD BGCOLOR=\"$color[4]\" WIDTH=15% ALIGN=RIGHT>\n"; |
b581fa60 |
198 | echo _("Subject:"); |
f8f9bed9 |
199 | echo " </TD><TD BGCOLOR=\"$color[4]\" WIDTH=85%>\n"; |
aae41ae9 |
200 | echo " <B>$subject</B>\n"; |
be69e508 |
201 | echo " </TD>\n"; |
202 | echo " </TR>\n"; |
203 | /** from **/ |
204 | echo " <TR>\n"; |
4809f489 |
205 | echo " <TD BGCOLOR=\"$color[4]\" WIDTH=15% ALIGN=RIGHT>\n"; |
b581fa60 |
206 | echo _("From:"); |
f8f9bed9 |
207 | echo " </TD><TD BGCOLOR=\"$color[4]\" WIDTH=85%>\n"; |
aae41ae9 |
208 | echo " <B>$from_name</B>\n"; |
be69e508 |
209 | echo " </TD>\n"; |
210 | echo " </TR>\n"; |
211 | /** date **/ |
212 | echo " <TR>\n"; |
4809f489 |
213 | echo " <TD BGCOLOR=\"$color[4]\" WIDTH=15% ALIGN=RIGHT>\n"; |
32c7898c |
214 | echo _("Date:"); |
f8f9bed9 |
215 | echo " </TD><TD BGCOLOR=\"$color[4]\" WIDTH=85%>\n"; |
aae41ae9 |
216 | echo " <B>$dateString</B>\n"; |
be69e508 |
217 | echo " </TD>\n"; |
218 | echo " </TR>\n"; |
2844086d |
219 | /** to **/ |
220 | echo " <TR>\n"; |
4809f489 |
221 | echo " <TD BGCOLOR=\"$color[4]\" WIDTH=15% ALIGN=RIGHT VALIGN=TOP>\n"; |
b581fa60 |
222 | echo _("To:"); |
f8f9bed9 |
223 | echo " </TD><TD BGCOLOR=\"$color[4]\" WIDTH=85% VALIGN=TOP>\n"; |
aae41ae9 |
224 | echo " <B>$to_string</B>\n"; |
2844086d |
225 | echo " </TD>\n"; |
226 | echo " </TR>\n"; |
078a40a4 |
227 | /** cc **/ |
f7fb20fe |
228 | if ($message["HEADER"]["CC"][0]) { |
078a40a4 |
229 | echo " <TR>\n"; |
4809f489 |
230 | echo " <TD BGCOLOR=\"$color[4]\" WIDTH=15% ALIGN=RIGHT VALIGN=TOP>\n"; |
aae41ae9 |
231 | echo " Cc:\n"; |
f8f9bed9 |
232 | echo " </TD><TD BGCOLOR=\"$color[4]\" WIDTH=85% VALIGN=TOP>\n"; |
aae41ae9 |
233 | echo " <B>$cc_string</B>\n"; |
078a40a4 |
234 | echo " </TD>\n"; |
235 | echo " </TR>\n"; |
236 | } |
4809f489 |
237 | echo "</TABLE>"; |
238 | echo " </TD></TR>"; |
be69e508 |
239 | |
f8f9bed9 |
240 | echo " <TR><TD BGCOLOR=\"$color[4]\" WIDTH=100%>\n"; |
11307a4c |
241 | $body = formatBody($message, $color, $wrap_at); |
4809f489 |
242 | echo "<BR>"; |
5c55c295 |
243 | |
7831268e |
244 | echo "$body"; |
d4467150 |
245 | |
7831268e |
246 | echo " </TD></TR>\n"; |
247 | echo " <TR><TD BGCOLOR=\"$color[9]\"> </TD></TR>"; |
be69e508 |
248 | echo "</TABLE>\n"; |
249 | |
b581fa60 |
250 | ?> |