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