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