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 | |
f8f9bed9 |
75 | displayPageHeader($color, $mailbox); |
d4467150 |
76 | |
f7fb20fe |
77 | /** translate the subject and mailbox into url-able text **/ |
8beafbbc |
78 | $url_subj = urlencode(trim(stripslashes($message->header->subject))); |
8467bf00 |
79 | $urlMailbox = urlencode($mailbox); |
8beafbbc |
80 | $url_replyto = urlencode($message->header->replyto); |
be69e508 |
81 | |
8beafbbc |
82 | $url_replytoall = urlencode($message->header->replyto); |
83 | $url_replytoallcc = urlencode(getLineOfAddrs($message->header->to) . ", " . getLineOfAddrs($message->header->cc)); |
4bfed9f3 |
84 | |
8beafbbc |
85 | $dateString = getLongDateString($message->header->date); |
429f8906 |
86 | $ent_num = findDisplayEntity($message); |
31f3d7c0 |
87 | |
b581fa60 |
88 | /** TEXT STRINGS DEFINITIONS **/ |
89 | $echo_more = _("more"); |
90 | $echo_less = _("less"); |
91 | |
078a40a4 |
92 | /** FORMAT THE TO STRING **/ |
2844086d |
93 | $i = 0; |
94 | $to_string = ""; |
8beafbbc |
95 | $to_ary = $message->header->to; |
2844086d |
96 | while ($i < count($to_ary)) { |
f7fb20fe |
97 | $to_ary[$i] = htmlspecialchars($to_ary[$i]); |
be8e07f8 |
98 | |
2844086d |
99 | if ($to_string) |
100 | $to_string = "$to_string<BR>$to_ary[$i]"; |
101 | else |
102 | $to_string = "$to_ary[$i]"; |
103 | |
104 | $i++; |
105 | if (count($to_ary) > 1) { |
106 | if ($show_more == false) { |
107 | if ($i == 1) { |
9f2215a1 |
108 | $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 |
109 | $i = count($to_ary); |
110 | } |
111 | } else if ($i == 1) { |
9f2215a1 |
112 | $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 |
113 | } |
114 | } |
115 | } |
116 | |
078a40a4 |
117 | /** FORMAT THE CC STRING **/ |
118 | $i = 0; |
119 | $cc_string = ""; |
8beafbbc |
120 | $cc_ary = $message->header->cc; |
078a40a4 |
121 | while ($i < count($cc_ary)) { |
f7fb20fe |
122 | $cc_ary[$i] = htmlspecialchars($cc_ary[$i]); |
078a40a4 |
123 | if ($cc_string) |
124 | $cc_string = "$cc_string<BR>$cc_ary[$i]"; |
125 | else |
126 | $cc_string = "$cc_ary[$i]"; |
127 | |
128 | $i++; |
129 | if (count($cc_ary) > 1) { |
130 | if ($show_more_cc == false) { |
131 | if ($i == 1) { |
9f2215a1 |
132 | $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 |
133 | $i = count($cc_ary); |
134 | } |
135 | } else if ($i == 1) { |
9f2215a1 |
136 | $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 |
137 | } |
138 | } |
139 | } |
140 | |
f7fb20fe |
141 | /** make sure everything will display in HTML format **/ |
8beafbbc |
142 | $from_name = decodeHeader(htmlspecialchars($message->header->from)); |
143 | $subject = decodeHeader(htmlspecialchars(stripslashes($message->header->subject))); |
078a40a4 |
144 | |
8467bf00 |
145 | echo "<BR>"; |
4809f489 |
146 | echo "<TABLE COLS=1 CELLSPACING=0 WIDTH=98% BORDER=0 ALIGN=CENTER CELLPADDING=0>\n"; |
f8f9bed9 |
147 | echo " <TR><TD BGCOLOR=\"$color[0]\" WIDTH=100%>"; |
4809f489 |
148 | echo " <TABLE WIDTH=100% CELLSPACING=0 BORDER=0 COLS=2 CELLPADDING=3>"; |
31f3d7c0 |
149 | echo " <TR>"; |
90033b64 |
150 | echo " <TD ALIGN=LEFT WIDTH=33%>"; |
aae41ae9 |
151 | echo " <SMALL>"; |
90033b64 |
152 | echo " <A HREF=\"right_main.php?use_mailbox_cache=1&sort=$sort&startMessage=$startMessage&mailbox=$urlMailbox\">"; |
b581fa60 |
153 | echo _("Message List"); |
154 | echo "</A> | "; |
9f2215a1 |
155 | echo " <A HREF=\"delete_message.php?mailbox=$urlMailbox&message=$passed_id&sort=$sort&startMessage=1\">"; |
b581fa60 |
156 | echo _("Delete"); |
157 | echo "</A> "; |
aae41ae9 |
158 | echo " </SMALL>"; |
90033b64 |
159 | echo " </TD><TD WIDTH=33% ALIGN=CENTER>"; |
160 | echo " <SMALL>\n"; |
161 | if ($currentArrayIndex == -1) { |
9988d19e |
162 | echo "Previous | Next"; |
90033b64 |
163 | } else { |
164 | $prev = findPreviousMessage(); |
165 | $next = findNextMessage(); |
166 | if ($prev != -1) |
167 | echo "<a href=\"read_body.php?passed_id=$prev&mailbox=$mailbox&sort=$sort&startMessage=$startMessage&show_more=0\">" . _("Previous") . "</A> | "; |
168 | else |
169 | echo _("Previous") . " | "; |
170 | if ($next != -1) |
171 | echo "<a href=\"read_body.php?passed_id=$next&mailbox=$mailbox&sort=$sort&startMessage=$startMessage&show_more=0\">" . _("Next") . "</A>"; |
172 | else |
173 | echo _("Next"); |
174 | } |
175 | echo " </SMALL>\n"; |
176 | echo " </TD><TD WIDTH=33% ALIGN=RIGHT>"; |
aae41ae9 |
177 | echo " <SMALL>"; |
429f8906 |
178 | echo " <A HREF=\"compose.php?forward_id=$passed_id&forward_subj=$url_subj&mailbox=$urlMailbox&ent_num=$ent_num\">"; |
b581fa60 |
179 | echo _("Forward"); |
180 | echo "</A> | "; |
429f8906 |
181 | echo " <A HREF=\"compose.php?send_to=$url_replyto&reply_subj=$url_subj&reply_id=$passed_id&mailbox=$urlMailbox&ent_num=$ent_num\">"; |
b581fa60 |
182 | echo _("Reply"); |
183 | echo "</A> | "; |
429f8906 |
184 | 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\">"; |
b581fa60 |
185 | echo _("Reply All"); |
186 | echo "</A> "; |
aae41ae9 |
187 | echo " </SMALL>"; |
31f3d7c0 |
188 | echo " </TD>"; |
189 | echo " </TR>"; |
190 | echo " </TABLE>"; |
8467bf00 |
191 | echo " </TD></TR>"; |
4809f489 |
192 | echo " <TR><TD CELLSPACING=0 WIDTH=100%>"; |
97afcee9 |
193 | echo " <TABLE COLS=2 WIDTH=100% BORDER=0 CELLSPACING=0 CELLPADDING=3>\n"; |
be69e508 |
194 | echo " <TR>\n"; |
195 | /** subject **/ |
4809f489 |
196 | echo " <TD BGCOLOR=\"$color[4]\" WIDTH=15% ALIGN=RIGHT>\n"; |
b581fa60 |
197 | echo _("Subject:"); |
f8f9bed9 |
198 | echo " </TD><TD BGCOLOR=\"$color[4]\" WIDTH=85%>\n"; |
aae41ae9 |
199 | echo " <B>$subject</B>\n"; |
be69e508 |
200 | echo " </TD>\n"; |
201 | echo " </TR>\n"; |
202 | /** from **/ |
203 | echo " <TR>\n"; |
4809f489 |
204 | echo " <TD BGCOLOR=\"$color[4]\" WIDTH=15% ALIGN=RIGHT>\n"; |
b581fa60 |
205 | echo _("From:"); |
f8f9bed9 |
206 | echo " </TD><TD BGCOLOR=\"$color[4]\" WIDTH=85%>\n"; |
aae41ae9 |
207 | echo " <B>$from_name</B>\n"; |
be69e508 |
208 | echo " </TD>\n"; |
209 | echo " </TR>\n"; |
210 | /** date **/ |
211 | echo " <TR>\n"; |
4809f489 |
212 | echo " <TD BGCOLOR=\"$color[4]\" WIDTH=15% ALIGN=RIGHT>\n"; |
32c7898c |
213 | echo _("Date:"); |
f8f9bed9 |
214 | echo " </TD><TD BGCOLOR=\"$color[4]\" WIDTH=85%>\n"; |
aae41ae9 |
215 | echo " <B>$dateString</B>\n"; |
be69e508 |
216 | echo " </TD>\n"; |
217 | echo " </TR>\n"; |
2844086d |
218 | /** to **/ |
219 | echo " <TR>\n"; |
4809f489 |
220 | echo " <TD BGCOLOR=\"$color[4]\" WIDTH=15% ALIGN=RIGHT VALIGN=TOP>\n"; |
b581fa60 |
221 | echo _("To:"); |
f8f9bed9 |
222 | echo " </TD><TD BGCOLOR=\"$color[4]\" WIDTH=85% VALIGN=TOP>\n"; |
aae41ae9 |
223 | echo " <B>$to_string</B>\n"; |
2844086d |
224 | echo " </TD>\n"; |
225 | echo " </TR>\n"; |
078a40a4 |
226 | /** cc **/ |
8beafbbc |
227 | if ($message->header->cc) { |
078a40a4 |
228 | echo " <TR>\n"; |
4809f489 |
229 | echo " <TD BGCOLOR=\"$color[4]\" WIDTH=15% ALIGN=RIGHT VALIGN=TOP>\n"; |
aae41ae9 |
230 | echo " Cc:\n"; |
f8f9bed9 |
231 | echo " </TD><TD BGCOLOR=\"$color[4]\" WIDTH=85% VALIGN=TOP>\n"; |
aae41ae9 |
232 | echo " <B>$cc_string</B>\n"; |
078a40a4 |
233 | echo " </TD>\n"; |
234 | echo " </TR>\n"; |
235 | } |
4809f489 |
236 | echo "</TABLE>"; |
237 | echo " </TD></TR>"; |
be69e508 |
238 | |
f8f9bed9 |
239 | echo " <TR><TD BGCOLOR=\"$color[4]\" WIDTH=100%>\n"; |
11307a4c |
240 | $body = formatBody($message, $color, $wrap_at); |
4809f489 |
241 | echo "<BR>"; |
5c55c295 |
242 | |
7831268e |
243 | echo "$body"; |
d4467150 |
244 | |
7831268e |
245 | echo " </TD></TR>\n"; |
246 | echo " <TR><TD BGCOLOR=\"$color[9]\"> </TD></TR>"; |
be69e508 |
247 | echo "</TABLE>\n"; |
248 | |
b581fa60 |
249 | ?> |