added the new message index feature...(forgot edit this file earlyer)
[squirrelmail.git] / src / read_body.php
... / ...
CommitLineData
1<?php
2 session_start();
3
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");
16
17 include("../src/load_prefs.php");
18 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
19 sqimap_mailbox_select($imapConnection, $mailbox);
20
21 // $message contains all information about the message
22 // including header and body
23 $message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
24
25 echo "<HTML>";
26 echo "<BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";
27 displayPageHeader($color, $mailbox);
28
29 /** translate the subject and mailbox into url-able text **/
30 $url_subj = urlencode(trim(stripslashes($message["HEADER"]["SUBJECT"])));
31 $urlMailbox = urlencode($mailbox);
32 $url_replyto = urlencode($message["HEADER"]["REPLYTO"]);
33
34 $url_replytoall = urlencode($message["HEADER"]["REPLYTO"]);
35 $url_replytoallcc = urlencode(getLineOfAddrs($message["HEADER"]["TO"]) . ", " . getLineOfAddrs($message["HEADER"]["CC"]));
36
37 $dateString = getLongDateString($message["HEADER"]["DATE"]);
38
39 /** TEXT STRINGS DEFINITIONS **/
40 $echo_more = _("more");
41 $echo_less = _("less");
42
43 /** FORMAT THE TO STRING **/
44 $i = 0;
45 $to_string = "";
46 $to_ary = $message["HEADER"]["TO"];
47 while ($i < count($to_ary)) {
48 $to_ary[$i] = htmlspecialchars($to_ary[$i]);
49 if ($to_string)
50 $to_string = "$to_string<BR>$to_ary[$i]";
51 else
52 $to_string = "$to_ary[$i]";
53
54 $i++;
55 if (count($to_ary) > 1) {
56 if ($show_more == false) {
57 if ($i == 1) {
58 $to_string = "$to_string&nbsp;(<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>)";
59 $i = count($to_ary);
60 }
61 } else if ($i == 1) {
62 $to_string = "$to_string&nbsp;(<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>)";
63 }
64 }
65 }
66
67 /** FORMAT THE CC STRING **/
68 $i = 0;
69 $cc_string = "";
70 $cc_ary = $message["HEADER"]["CC"];
71 while ($i < count($cc_ary)) {
72 $cc_ary[$i] = htmlspecialchars($cc_ary[$i]);
73 if ($cc_string)
74 $cc_string = "$cc_string<BR>$cc_ary[$i]";
75 else
76 $cc_string = "$cc_ary[$i]";
77
78 $i++;
79 if (count($cc_ary) > 1) {
80 if ($show_more_cc == false) {
81 if ($i == 1) {
82 $cc_string = "$cc_string&nbsp;(<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>)";
83 $i = count($cc_ary);
84 }
85 } else if ($i == 1) {
86 $cc_string = "$cc_string&nbsp;(<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>)";
87 }
88 }
89 }
90
91 /** make sure everything will display in HTML format **/
92 $from_name = decodeHeader(htmlspecialchars($message["HEADER"]["FROM"]));
93 $subject = decodeHeader(htmlspecialchars(stripslashes($message["HEADER"]["SUBJECT"])));
94
95 echo "<BR>";
96 echo "<TABLE COLS=1 CELLSPACING=0 WIDTH=98% BORDER=0 ALIGN=CENTER CELLPADDING=0>\n";
97 echo " <TR><TD BGCOLOR=\"$color[0]\" WIDTH=100%>";
98 echo " <TABLE WIDTH=100% CELLSPACING=0 BORDER=0 COLS=2 CELLPADDING=3>";
99 echo " <TR>";
100 echo " <TD ALIGN=LEFT WIDTH=50%>";
101 echo " <SMALL>";
102 echo " <A HREF=\"right_main.php?sort=$sort&startMessage=$startMessage&mailbox=$urlMailbox\">";
103 echo _("Message List");
104 echo "</A>&nbsp;|&nbsp;";
105 echo " <A HREF=\"delete_message.php?mailbox=$urlMailbox&message=$passed_id&sort=$sort&startMessage=1\">";
106 echo _("Delete");
107 echo "</A>&nbsp;&nbsp;";
108 echo " </SMALL>";
109 echo " </TD><TD WIDTH=50% ALIGN=RIGHT>";
110 echo " <SMALL>";
111 echo " <A HREF=\"compose.php?forward_id=$passed_id&forward_subj=$url_subj&mailbox=$urlMailbox\">";
112 echo _("Forward");
113 echo "</A>&nbsp;|&nbsp;";
114 echo " <A HREF=\"compose.php?send_to=$url_replyto&reply_subj=$url_subj&reply_id=$passed_id&mailbox=$urlMailbox\">";
115 echo _("Reply");
116 echo "</A>&nbsp;|&nbsp;";
117 echo " <A HREF=\"compose.php?send_to=$url_replytoall&send_to_cc=$url_replytoallcc&reply_subj=$url_subj&reply_id=$passed_id&mailbox=$urlMailbox\">";
118 echo _("Reply All");
119 echo "</A>&nbsp;&nbsp;";
120 echo " </SMALL>";
121 echo " </TD>";
122 echo " </TR>";
123 echo " </TABLE>";
124 echo " </TD></TR>";
125 echo " <TR><TD CELLSPACING=0 WIDTH=100%>";
126 echo " <TABLE COLS=2 WIDTH=100% BORDER=0 CELLSPACING=0 CELLPADDING=3>\n";
127 echo " <TR>\n";
128 /** subject **/
129 echo " <TD BGCOLOR=\"$color[4]\" WIDTH=15% ALIGN=RIGHT>\n";
130 echo _("Subject:");
131 echo " </TD><TD BGCOLOR=\"$color[4]\" WIDTH=85%>\n";
132 echo " <B>$subject</B>\n";
133 echo " </TD>\n";
134 echo " </TR>\n";
135 /** from **/
136 echo " <TR>\n";
137 echo " <TD BGCOLOR=\"$color[4]\" WIDTH=15% ALIGN=RIGHT>\n";
138 echo _("From:");
139 echo " </TD><TD BGCOLOR=\"$color[4]\" WIDTH=85%>\n";
140 echo " <B>$from_name</B>\n";
141 echo " </TD>\n";
142 echo " </TR>\n";
143 /** date **/
144 echo " <TR>\n";
145 echo " <TD BGCOLOR=\"$color[4]\" WIDTH=15% ALIGN=RIGHT>\n";
146 echo _("Date:");
147 echo " </TD><TD BGCOLOR=\"$color[4]\" WIDTH=85%>\n";
148 echo " <B>$dateString</B>\n";
149 echo " </TD>\n";
150 echo " </TR>\n";
151 /** to **/
152 echo " <TR>\n";
153 echo " <TD BGCOLOR=\"$color[4]\" WIDTH=15% ALIGN=RIGHT VALIGN=TOP>\n";
154 echo _("To:");
155 echo " </TD><TD BGCOLOR=\"$color[4]\" WIDTH=85% VALIGN=TOP>\n";
156 echo " <B>$to_string</B>\n";
157 echo " </TD>\n";
158 echo " </TR>\n";
159 /** cc **/
160 if ($message["HEADER"]["CC"][0]) {
161 echo " <TR>\n";
162 echo " <TD BGCOLOR=\"$color[4]\" WIDTH=15% ALIGN=RIGHT VALIGN=TOP>\n";
163 echo " Cc:\n";
164 echo " </TD><TD BGCOLOR=\"$color[4]\" WIDTH=85% VALIGN=TOP>\n";
165 echo " <B>$cc_string</B>\n";
166 echo " </TD>\n";
167 echo " </TR>\n";
168 }
169 echo "</TABLE>";
170 echo " </TD></TR>";
171
172 echo " <TR><TD BGCOLOR=\"$color[4]\" WIDTH=100%>\n";
173 $body = formatBody($message, $color, $wrap_at);
174 echo "<BR>";
175
176 echo "$body";
177
178 echo " </TD></TR>\n";
179 echo " <TR><TD BGCOLOR=\"$color[9]\">&nbsp;</TD></TR>";
180 echo "</TABLE>\n";
181
182?>