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