| 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, 0); |
| 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 | /** TEXT STRINGS DEFINITIONS **/ |
| 34 | $echo_more = _("more"); |
| 35 | $echo_less = _("less"); |
| 36 | |
| 37 | /** FORMAT THE TO STRING **/ |
| 38 | $i = 0; |
| 39 | $to_string = ""; |
| 40 | $to_ary = $message["HEADER"]["TO"]; |
| 41 | while ($i < count($to_ary)) { |
| 42 | $to_ary[$i] = htmlspecialchars($to_ary[$i]); |
| 43 | if ($to_string) |
| 44 | $to_string = "$to_string<BR>$to_ary[$i]"; |
| 45 | else |
| 46 | $to_string = "$to_ary[$i]"; |
| 47 | |
| 48 | $i++; |
| 49 | if (count($to_ary) > 1) { |
| 50 | if ($show_more == false) { |
| 51 | if ($i == 1) { |
| 52 | $to_string = "$to_string (<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>)"; |
| 53 | $i = count($to_ary); |
| 54 | } |
| 55 | } else if ($i == 1) { |
| 56 | $to_string = "$to_string (<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>)"; |
| 57 | } |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | /** FORMAT THE CC STRING **/ |
| 62 | $i = 0; |
| 63 | $cc_string = ""; |
| 64 | $cc_ary = $message["HEADER"]["CC"]; |
| 65 | while ($i < count($cc_ary)) { |
| 66 | $cc_ary[$i] = htmlspecialchars($cc_ary[$i]); |
| 67 | if ($cc_string) |
| 68 | $cc_string = "$cc_string<BR>$cc_ary[$i]"; |
| 69 | else |
| 70 | $cc_string = "$cc_ary[$i]"; |
| 71 | |
| 72 | $i++; |
| 73 | if (count($cc_ary) > 1) { |
| 74 | if ($show_more_cc == false) { |
| 75 | if ($i == 1) { |
| 76 | $cc_string = "$cc_string (<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>)"; |
| 77 | $i = count($cc_ary); |
| 78 | } |
| 79 | } else if ($i == 1) { |
| 80 | $cc_string = "$cc_string (<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>)"; |
| 81 | } |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | /** make sure everything will display in HTML format **/ |
| 86 | $from_name = htmlspecialchars($message["HEADER"]["FROM"]); |
| 87 | $subject = htmlspecialchars(stripslashes($message["HEADER"]["SUBJECT"])); |
| 88 | |
| 89 | echo "<BR>"; |
| 90 | echo "<TABLE COLS=1 CELLSPACING=0 WIDTH=98% BORDER=0 ALIGN=CENTER CELLPADDING=0>\n"; |
| 91 | echo " <TR><TD BGCOLOR=\"$color[0]\" WIDTH=100%>"; |
| 92 | echo " <TABLE WIDTH=100% CELLSPACING=0 BORDER=0 COLS=2 CELLPADDING=3>"; |
| 93 | echo " <TR>"; |
| 94 | echo " <TD ALIGN=LEFT WIDTH=50%>"; |
| 95 | echo " <FONT FACE=\"Arial,Helvetica\" SIZE=2>"; |
| 96 | echo " <A HREF=\"right_main.php?sort=$sort&startMessage=$startMessage&mailbox=$urlMailbox\">"; |
| 97 | echo _("Message List"); |
| 98 | echo "</A> | "; |
| 99 | echo " <A HREF=\"delete_message.php?mailbox=$urlMailbox&message=$passed_id&sort=$sort&startMessage=1\">"; |
| 100 | echo _("Delete"); |
| 101 | echo "</A> "; |
| 102 | echo " </FONT>"; |
| 103 | echo " </TD><TD WIDTH=50% ALIGN=RIGHT>"; |
| 104 | echo " <FONT FACE=\"Arial,Helvetica\" SIZE=2>"; |
| 105 | echo " <A HREF=\"compose.php?forward_id=$passed_id&forward_subj=$url_subj&mailbox=$urlMailbox\">"; |
| 106 | echo _("Forward"); |
| 107 | echo "</A> | "; |
| 108 | echo " <A HREF=\"compose.php?send_to=$url_replyto&reply_subj=$url_subj&reply_id=$passed_id&mailbox=$urlMailbox\">"; |
| 109 | echo _("Reply"); |
| 110 | echo "</A> | "; |
| 111 | echo " <A HREF=\"compose.php?send_to=$url_replytoall&send_to_cc=$url_replytoallcc&reply_subj=$url_subj&reply_id=$passed_id&mailbox=$urlMailbox\">"; |
| 112 | echo _("Reply All"); |
| 113 | echo "</A> "; |
| 114 | echo " </FONT>"; |
| 115 | echo " </TD>"; |
| 116 | echo " </TR>"; |
| 117 | echo " </TABLE>"; |
| 118 | echo " </TD></TR>"; |
| 119 | echo " <TR><TD CELLSPACING=0 WIDTH=100%>"; |
| 120 | echo " <TABLE COLS=2 WIDTH=100% BORDER=0 CELLSPACING=0 CELLPADDING=3>\n"; |
| 121 | echo " <TR>\n"; |
| 122 | /** subject **/ |
| 123 | echo " <TD BGCOLOR=\"$color[4]\" WIDTH=15% ALIGN=RIGHT>\n"; |
| 124 | echo " <FONT FACE=\"Arial,Helvetica\">"; |
| 125 | echo _("Subject:"); |
| 126 | echo "</FONT>\n"; |
| 127 | echo " </TD><TD BGCOLOR=\"$color[4]\" WIDTH=85%>\n"; |
| 128 | echo " <FONT FACE=\"Arial,Helvetica\"><B>$subject</B></FONT>\n"; |
| 129 | echo " </TD>\n"; |
| 130 | echo " </TR>\n"; |
| 131 | /** from **/ |
| 132 | echo " <TR>\n"; |
| 133 | echo " <TD BGCOLOR=\"$color[4]\" WIDTH=15% ALIGN=RIGHT>\n"; |
| 134 | echo " <FONT FACE=\"Arial,Helvetica\">"; |
| 135 | echo _("From:"); |
| 136 | echo "</FONT>\n"; |
| 137 | echo " </TD><TD BGCOLOR=\"$color[4]\" WIDTH=85%>\n"; |
| 138 | echo " <FONT FACE=\"Arial,Helvetica\"><B>$from_name</B></FONT>\n"; |
| 139 | echo " </TD>\n"; |
| 140 | echo " </TR>\n"; |
| 141 | /** date **/ |
| 142 | echo " <TR>\n"; |
| 143 | echo " <TD BGCOLOR=\"$color[4]\" WIDTH=15% ALIGN=RIGHT>\n"; |
| 144 | echo " <FONT FACE=\"Arial,Helvetica\">"; |
| 145 | echo _("Date:"); |
| 146 | echo "</FONT>\n"; |
| 147 | echo " </TD><TD BGCOLOR=\"$color[4]\" WIDTH=85%>\n"; |
| 148 | echo " <FONT FACE=\"Arial,Helvetica\"><B>$dateString</B></FONT>\n"; |
| 149 | echo " </TD>\n"; |
| 150 | echo " </TR>\n"; |
| 151 | /** to **/ |
| 152 | echo " <TR>\n"; |
| 153 | echo " <TD BGCOLOR=\"$color[4]\" WIDTH=15% ALIGN=RIGHT VALIGN=TOP>\n"; |
| 154 | echo " <FONT FACE=\"Arial,Helvetica\">"; |
| 155 | echo _("To:"); |
| 156 | echo "</FONT>\n"; |
| 157 | echo " </TD><TD BGCOLOR=\"$color[4]\" WIDTH=85% VALIGN=TOP>\n"; |
| 158 | echo " <FONT FACE=\"Arial,Helvetica\"><B>$to_string</B></FONT>\n"; |
| 159 | echo " </TD>\n"; |
| 160 | echo " </TR>\n"; |
| 161 | /** cc **/ |
| 162 | if ($message["HEADER"]["CC"][0]) { |
| 163 | echo " <TR>\n"; |
| 164 | echo " <TD BGCOLOR=\"$color[4]\" WIDTH=15% ALIGN=RIGHT VALIGN=TOP>\n"; |
| 165 | echo " <FONT FACE=\"Arial,Helvetica\">Cc:</FONT>\n"; |
| 166 | echo " </TD><TD BGCOLOR=\"$color[4]\" WIDTH=85% VALIGN=TOP>\n"; |
| 167 | echo " <FONT FACE=\"Arial,Helvetica\"><B>$cc_string</B></FONT>\n"; |
| 168 | echo " </TD>\n"; |
| 169 | echo " </TR>\n"; |
| 170 | } |
| 171 | echo "</TABLE>"; |
| 172 | echo " </TD></TR>"; |
| 173 | |
| 174 | echo " <TR><TD BGCOLOR=\"$color[4]\" WIDTH=100%>\n"; |
| 175 | $body = formatBody($message, $color, $wrap_at); |
| 176 | echo "<BR>"; |
| 177 | |
| 178 | echo "$body"; |
| 179 | |
| 180 | echo " </TD></TR>\n"; |
| 181 | echo " <TR><TD BGCOLOR=\"$color[9]\"> </TD></TR>"; |
| 182 | echo "</TABLE>\n"; |
| 183 | |
| 184 | ?> |