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