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