Added "CC" to read_body.php, and rewrote the code to handle getting TO and CC
[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/mailbox.php");
7 include("../functions/date.php");
8
9 $imapConnection = loginToImapServer($username, $key, $imapServerAddress);
10 selectMailbox($imapConnection, $mailbox, $numMessages);
11
12 echo "<HTML><BODY TEXT=\"#000000\" BGCOLOR=\"#FFFFFF\" LINK=\"#0000EE\" VLINK=\"#0000EE\" ALINK=\"#0000EE\">\n";
13 displayPageHeader($mailbox);
14 $body = fetchBody($imapConnection, $passed_id);
15 getMessageHeaders($imapConnection, $passed_id, $passed_id, $f, $s, $d);
16 getMessageHeadersTo($imapConnection, $passed_id, $t);
17 getMessageHeadersCc($imapConnection, $passed_id, $c);
18
19 $subject = $s[0];
20 $url_subj = urlencode(trim($subject));
21
22 $d[0] = ereg_replace(" ", " ", $d[0]);
23 $dateParts = explode(" ", trim($d[0]));
24 $dateString = getLongDateString($dateParts);
25
26 $from_name = getSenderName($f[0]);
27 $urlMailbox = urlencode($mailbox);
28
29 $url_from = trim(decodeEmailAddr($f[0]));
30 $url_from = urlencode($url_from);
31
32 /** FORMAT THE TO STRING **/
33 $i = 0;
34 $to_string = "";
35 $to_ary = $t;
36 while ($i < count($to_ary)) {
37 if ($to_string)
38 $to_string = "$to_string<BR>$to_ary[$i]";
39 else
40 $to_string = "$to_ary[$i]";
41
42 $i++;
43 if (count($to_ary) > 1) {
44 if ($show_more == false) {
45 if ($i == 1) {
46 $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>)";
47 $i = count($to_ary);
48 }
49 } else if ($i == 1) {
50 $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>)";
51 }
52 }
53 }
54
55 /** FORMAT THE CC STRING **/
56 $i = 0;
57 $cc_string = "";
58 $cc_ary = $c;
59 while ($i < count($cc_ary)) {
60 if ($cc_string)
61 $cc_string = "$cc_string<BR>$cc_ary[$i]";
62 else
63 $cc_string = "$cc_ary[$i]";
64
65 $i++;
66 if (count($cc_ary) > 1) {
67 if ($show_more_cc == false) {
68 if ($i == 1) {
69 $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>)";
70 $i = count($cc_ary);
71 }
72 } else if ($i == 1) {
73 $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>)";
74 }
75 }
76 }
77
78
79
80 echo "<BR>";
81 echo "<TABLE COLS=1 WIDTH=95% BORDER=0 ALIGN=CENTER CELLPADDING=2>\n";
82 echo " <TR><TD BGCOLOR=DCDCDC WIDTH=100%>";
83 echo " <TABLE WIDTH=100% BORDER=0 COLS=2>";
84 echo " <TR>";
85 echo " <TD ALIGN=LEFT WIDTH=50%>";
86 echo " <FONT FACE=\"Arial,Helvetica\" SIZE=2>";
87 echo " <A HREF=\"right_main.php?sort=$sort&startMessage=$startMessage&mailbox=$urlMailbox\">Message List</A>&nbsp;&nbsp;";
88 echo " <A HREF=\"delete_message.php?mailbox=$urlMailbox&message=$passed_id&sort=$sort&startMessage=1\">Delete</A>&nbsp;&nbsp;";
89 echo " </FONT>";
90 echo " </TD><TD WIDTH=50% ALIGN=RIGHT>";
91 echo " <FONT FACE=\"Arial,Helvetica\" SIZE=2>";
92 echo " <A HREF=\"compose.php?forward_id=$passed_id&forward_subj=$url_subj&mailbox=$urlMailbox\">Forward</A>&nbsp;&nbsp;";
93 echo " <A HREF=\"compose.php?send_to=$url_from&reply_subj=$url_subj&reply_id=$passed_id&mailbox=$urlMailbox\">Reply</A>&nbsp;&nbsp;";
94 echo " </FONT>";
95 echo " </TD>";
96 echo " </TR>";
97 echo " </TABLE>";
98 echo " </TD></TR>";
99 echo " <TR><TD BGCOLOR=FFFFFF WIDTH=100%>";
100 echo " <TABLE COLS=2 WIDTH=100% BORDER=0 CELLSPACING=0 CELLPADDING=2>\n";
101 echo " <TR>\n";
102 /** subject **/
103 echo " <TD BGCOLOR=FFFFFF WIDTH=15% ALIGN=RIGHT>\n";
104 echo " <FONT FACE=\"Arial,Helvetica\">Subject:</FONT>\n";
105 echo " </TD><TD BGCOLOR=FFFFFF WIDTH=85%>\n";
106 echo " <FONT FACE=\"Arial,Helvetica\"><B>$subject</B></FONT>\n";
107 echo " </TD>\n";
108 echo " </TR>\n";
109 /** from **/
110 echo " <TR>\n";
111 echo " <TD BGCOLOR=FFFFFF WIDTH=15% ALIGN=RIGHT>\n";
112 echo " <FONT FACE=\"Arial,Helvetica\">From:</FONT>\n";
113 echo " </TD><TD BGCOLOR=FFFFFF WIDTH=85%>\n";
114 echo " <FONT FACE=\"Arial,Helvetica\"><B>$from_name</B></FONT>\n";
115 echo " </TD>\n";
116 echo " </TR>\n";
117 /** date **/
118 echo " <TR>\n";
119 echo " <TD BGCOLOR=FFFFFF WIDTH=15% ALIGN=RIGHT>\n";
120 echo " <FONT FACE=\"Arial,Helvetica\">Date:</FONT>\n";
121 echo " </TD><TD BGCOLOR=FFFFFF WIDTH=85%>\n";
122 echo " <FONT FACE=\"Arial,Helvetica\"><B>$dateString</B></FONT>\n";
123 echo " </TD>\n";
124 echo " </TR>\n";
125 /** to **/
126 echo " <TR>\n";
127 echo " <TD BGCOLOR=FFFFFF WIDTH=15% ALIGN=RIGHT VALIGN=TOP>\n";
128 echo " <FONT FACE=\"Arial,Helvetica\">To:</FONT>\n";
129 echo " </TD><TD BGCOLOR=FFFFFF WIDTH=85% VALIGN=TOP>\n";
130 echo " <FONT FACE=\"Arial,Helvetica\"><B>$to_string</B></FONT>\n";
131 echo " </TD>\n";
132 echo " </TR>\n";
133 /** cc **/
134 if ($c[0]) {
135 echo " <TR>\n";
136 echo " <TD BGCOLOR=FFFFFF WIDTH=15% ALIGN=RIGHT VALIGN=TOP>\n";
137 echo " <FONT FACE=\"Arial,Helvetica\">Cc:</FONT>\n";
138 echo " </TD><TD BGCOLOR=FFFFFF WIDTH=85% VALIGN=TOP>\n";
139 echo " <FONT FACE=\"Arial,Helvetica\"><B>$cc_string</B></FONT>\n";
140 echo " </TD>\n";
141 echo " </TR>\n";
142 }
143 echo " </TABLE></TD></TR>\n";
144
145 echo " <TR><TD BGCOLOR=FFFFFF WIDTH=100%><BR>\n";
146 $i = 0;
147 while ($i < count($body)) {
148 echo "$body[$i]";
149 $i++;
150 }
151 echo " <BR></TD></TR>\n";
152 echo " <TR><TD BGCOLOR=DCDCDC>&nbsp;</TD></TR>";
153 echo "</TABLE>\n";
154
155 ?>