added "reply to all" function
[squirrelmail.git] / src / compose.php
CommitLineData
8467bf00 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");
f7fb20fe 8 include("../functions/mime.php");
9
d3cdb279 10 include("../src/load_prefs.php");
8467bf00 11
f8f9bed9 12 echo "<HTML><BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";
8467bf00 13 $imapConnection = loginToImapServer($username, $key, $imapServerAddress);
f8f9bed9 14 displayPageHeader($color, "None");
31f3d7c0 15
e39d73e5 16 if ($forward_id) {
2844086d 17 selectMailbox($imapConnection, $mailbox, $numMessages);
97be2168 18 $msg = fetchMessage($imapConnection, $forward_id, $mailbox);
e39d73e5 19
78509c54 20 if (containsType($msg, "text", "html", $ent_num)) {
21 $body = decodeBody($msg["ENTITIES"][$ent_num]["BODY"], $msg["ENTITIES"][$ent_num]["ENCODING"]);
22 } else if (containsType($msg, "text", "plain", $ent_num)) {
23 $body = decodeBody($msg["ENTITIES"][$ent_num]["BODY"], $msg["ENTITIES"][$ent_num]["ENCODING"]);
24 }
25 // add other primary displaying msg types here
26 else {
27 // find any type that's displayable
28 if (containsType($msg, "text", "any_type", $ent_num)) {
29 $body = decodeBody($msg["ENTITIES"][$ent_num]["BODY"], $msg["ENTITIES"][$ent_num]["ENCODING"]);
30 } else if (containsType($msg, "msg", "any_type", $ent_num)) {
31 $body = decodeBody($msg["ENTITIES"][$ent_num]["BODY"], $msg["ENTITIES"][$ent_num]["ENCODING"]);
32 } else {
33 $body = "No Message";
34 }
35 }
36
37 $type1 = $msg["ENTITIES"][$ent_num]["TYPE1"];
38
e39d73e5 39 $tmp = "-------- Original Message ---------\n";
78509c54 40 $body_ary = explode("\n", $body);
41 $body = "";
e39d73e5 42 for ($i=0;$i < count($body_ary);$i++) {
78509c54 43 if ($type1 == "html")
44 $tmp .= strip_tags($body_ary[$i]);
45 else
46 $tmp .= $body_ary[$i];
47 $body = "$body$tmp\n";
e39d73e5 48 $tmp = "";
49 }
50 }
51
52 if ($reply_id) {
53 selectMailbox($imapConnection, $mailbox, $numMessages);
97be2168 54 $msg = fetchMessage($imapConnection, $reply_id, $mailbox);
5c55c295 55
78509c54 56 if (containsType($msg, "text", "html", $ent_num)) {
57 $body = decodeBody($msg["ENTITIES"][$ent_num]["BODY"], $msg["ENTITIES"][$ent_num]["ENCODING"], false);
58 } else if (containsType($msg, "text", "plain", $ent_num)) {
59 $body = decodeBody($msg["ENTITIES"][$ent_num]["BODY"], $msg["ENTITIES"][$ent_num]["ENCODING"], false);
60 }
61 // add other primary displaying msg types here
62 else {
63 // find any type that's displayable
64 if (containsType($msg, "text", "any_type", $ent_num)) {
65 $body = decodeBody($msg["ENTITIES"][$ent_num]["BODY"], $msg["ENTITIES"][$ent_num]["ENCODING"], false);
66 } else if (containsType($msg, "msg", "any_type", $ent_num)) {
67 $body = decodeBody($msg["ENTITIES"][$ent_num]["BODY"], $msg["ENTITIES"][$ent_num]["ENCODING"], false);
68 } else {
69 $body = "No Message";
70 }
71 }
72
73 $type1 = $msg["ENTITIES"][$ent_num]["TYPE1"];
74
75 $body_ary = explode("\n", $body);
76 $body = "";
31f3d7c0 77 for ($i=0;$i < count($body_ary);$i++) {
78509c54 78 if ($type1 == "html")
79 $tmp = strip_tags($body_ary[$i]);
80 else
81 $tmp = $body_ary[$i];
82 $body = "$body> $tmp\n";
31f3d7c0 83 }
84 }
8467bf00 85
7ce342dc 86 // Add some decoding information
87 $send_to = encodeEmailAddr($send_to);
88 // parses the field and returns only the email address
89 $send_to = decodeEmailAddr($send_to);
90
91 $send_to = strtolower($send_to);
e39d73e5 92 $send_to = ereg_replace("\"", "", $send_to);
93 $send_to = stripslashes($send_to);
94
4bfed9f3 95 if ($send_to_cc != "") {
96 $send_to_cc = strtolower($send_to_cc);
97 $send_to_cc = ereg_replace("\"", "", $send_to_cc);
98 $send_to_cc = stripslashes($send_to_cc);
99 }
100
b8ea4ed6 101 echo "<FORM action=\"compose_send.php\" METHOD=POST>\n";
5c55c295 102 echo "<TABLE COLS=2 WIDTH=50 ALIGN=CENTER CELLSPACING=0 BORDER=0>\n";
40ee9452 103 echo " <TR>\n";
f8f9bed9 104 echo " <TD WIDTH=50 BGCOLOR=\"$color[4]\" ALIGN=RIGHT>\n";
40ee9452 105 echo " <FONT FACE=\"Arial,Helvetica\">To: </FONT>\n";
f8f9bed9 106 echo " </TD><TD WIDTH=% \"$color[4]\" ALIGN=LEFT>\n";
31f3d7c0 107 if ($send_to)
108 echo " <INPUT TYPE=TEXT NAME=passed_to VALUE=\"$send_to\" SIZE=60><BR>";
109 else
110 echo " <INPUT TYPE=TEXT NAME=passed_to SIZE=60><BR>";
40ee9452 111 echo " </TD>\n";
112 echo " </TR>\n";
113 echo " <TR>\n";
f8f9bed9 114 echo " <TD WIDTH=50 BGCOLOR=\"$color[4]\" ALIGN=RIGHT>\n";
40ee9452 115 echo " <FONT FACE=\"Arial,Helvetica\">CC:</FONT>\n";
f8f9bed9 116 echo " </TD><TD WIDTH=% BGCOLOR=\"$color[4]\" ALIGN=LEFT>\n";
4bfed9f3 117 if ($send_to_cc)
118 echo " <INPUT TYPE=TEXT NAME=passed_cc SIZE=60 VALUE=\"$send_to_cc\"><BR>";
119 else
120 echo " <INPUT TYPE=TEXT NAME=passed_cc SIZE=60><BR>";
40ee9452 121 echo " </TD>\n";
122 echo " </TR>\n";
123 echo " <TR>\n";
f8f9bed9 124 echo " <TD WIDTH=50 BGCOLOR=\"$color[4]\" ALIGN=RIGHT>\n";
40ee9452 125 echo " <FONT FACE=\"Arial,Helvetica\">BCC:</FONT>\n";
f8f9bed9 126 echo " </TD><TD WIDTH=% BGCOLOR=\"$color[4]\" ALIGN=LEFT>\n";
40ee9452 127 echo " <INPUT TYPE=TEXT NAME=passed_bcc SIZE=60><BR>";
128 echo " </TD>\n";
129 echo " </TR>\n";
ff89ac8a 130
40ee9452 131 echo " <TR>\n";
f8f9bed9 132 echo " <TD WIDTH=50 BGCOLOR=\"$color[4]\" ALIGN=RIGHT>\n";
40ee9452 133 echo " <FONT FACE=\"Arial,Helvetica\">Subject:</FONT>\n";
f8f9bed9 134 echo " </TD><TD WIDTH=% BGCOLOR=\"$color[4]\" ALIGN=LEFT>\n";
40884065 135 if ($reply_subj) {
136 $reply_subj = str_replace("\"", "'", $reply_subj);
137 $reply_subj = stripslashes($reply_subj);
5c55c295 138 $reply_subj = trim($reply_subj);
139 if (substr(strtolower($reply_subj), 0, 3) != "re:")
140 $reply_subj = "Re: $reply_subj";
141 echo " <INPUT TYPE=TEXT NAME=passed_subject SIZE=60 VALUE=\"$reply_subj\">";
40884065 142 } else if ($forward_subj) {
5c55c295 143 $forward_subj = str_replace("\"", "'", $forward_subj);
144 $forward_subj = stripslashes($forward_subj);
145 $forward_subj = trim($forward_subj);
146 if ((substr(strtolower($forward_subj), 0, 4) != "fwd:") &&
147 (substr(strtolower($forward_subj), 0, 5) != "[fwd:") &&
148 (substr(strtolower($forward_subj), 0, 6) != "[ fwd:"))
149 $forward_subj = "[Fwd: $forward_subj]";
150 echo " <INPUT TYPE=TEXT NAME=passed_subject SIZE=60 VALUE=\"$forward_subj\">";
40884065 151 } else {
ff89ac8a 152 echo " <INPUT TYPE=TEXT NAME=passed_subject SIZE=60>";
40884065 153 }
ff89ac8a 154 echo "&nbsp;&nbsp;<INPUT TYPE=SUBMIT VALUE=\"Send\"><BR>";
40ee9452 155 echo " </TD>\n";
156 echo " </TR>\n";
ff89ac8a 157 echo " <TR>\n";
f8f9bed9 158 echo " <TD BGCOLOR=\"$color[4]\" COLSPAN=2>\n";
f804972b 159 if ($use_signature == true)
160 echo " &nbsp;&nbsp;<TEXTAREA NAME=passed_body ROWS=20 COLS=\"$editor_size\" WRAP=HARD>$body\n\n$signature</TEXTAREA><BR>";
161 else
162 echo " &nbsp;&nbsp;<TEXTAREA NAME=passed_body ROWS=20 COLS=\"$editor_size\" WRAP=HARD>$body</TEXTAREA><BR>";
ff89ac8a 163 echo " </TD>";
164 echo " </TR>\n";
40ee9452 165 echo "</TABLE>\n";
ff89ac8a 166 echo "<CENTER><INPUT TYPE=SUBMIT VALUE=\"Send\"></CENTER>";
8467bf00 167 echo "</FORM>";
168?>