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