Added the config file back again
[squirrelmail.git] / src / compose.php
index ac450160b701413147ae849554d098e0100c2628..d0a6cc312b29d3016bad8294d923fc26513adaec 100644 (file)
@@ -7,6 +7,7 @@
    include("../functions/date.php");
    include("../functions/mime.php");
 
+   include("../src/load_prefs.php");
 
    echo "<HTML><BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";
    $imapConnection = loginToImapServer($username, $key, $imapServerAddress);
 
    if ($forward_id) {
       selectMailbox($imapConnection, $mailbox, $numMessages);
-      $msg = fetchMessage($imapConnection, $forward_id);
+      $msg = fetchMessage($imapConnection, $forward_id, $mailbox);
+
+      if (containsType($msg, "text", "html", $ent_num)) {
+         $body = decodeBody($msg["ENTITIES"][$ent_num]["BODY"], $msg["ENTITIES"][$ent_num]["ENCODING"]);
+      } else if (containsType($msg, "text", "plain", $ent_num)) {
+         $body = decodeBody($msg["ENTITIES"][$ent_num]["BODY"], $msg["ENTITIES"][$ent_num]["ENCODING"]);
+      }
+      // add other primary displaying msg types here
+      else {
+         // find any type that's displayable
+         if (containsType($msg, "text", "any_type", $ent_num)) {
+            $body = decodeBody($msg["ENTITIES"][$ent_num]["BODY"], $msg["ENTITIES"][$ent_num]["ENCODING"]);
+         } else if (containsType($msg, "msg", "any_type", $ent_num)) {
+            $body = decodeBody($msg["ENTITIES"][$ent_num]["BODY"], $msg["ENTITIES"][$ent_num]["ENCODING"]);
+         } else {
+            $body = "No Message";
+         }
+      }
+
+      $type1 = $msg["ENTITIES"][$ent_num]["TYPE1"];
 
-      $body_ary = formatBody($msg);
       $tmp = "-------- Original Message ---------\n";
+      $body_ary = explode("\n", $body);
+      $body = "";
       for ($i=0;$i < count($body_ary);$i++) {
-         $tmp .= strip_tags($body_ary[$i]);
-         $tmp = substr($tmp, 0, strlen($tmp) -1);
-         $body = "$body$tmp";
+         if ($type1 == "html")
+            $tmp .= strip_tags($body_ary[$i]);
+         else
+            $tmp .= $body_ary[$i];
+         $body = "$body$tmp\n";
          $tmp = "";
       }
    }
 
    if ($reply_id) {
       selectMailbox($imapConnection, $mailbox, $numMessages);
-      $msg = fetchMessage($imapConnection, $reply_id);
+      $msg = fetchMessage($imapConnection, $reply_id, $mailbox);
 
-      $body_ary = formatBody($msg);
+      if (containsType($msg, "text", "html", $ent_num)) {
+         $body = decodeBody($msg["ENTITIES"][$ent_num]["BODY"], $msg["ENTITIES"][$ent_num]["ENCODING"], false);
+      } else if (containsType($msg, "text", "plain", $ent_num)) {
+         $body = decodeBody($msg["ENTITIES"][$ent_num]["BODY"], $msg["ENTITIES"][$ent_num]["ENCODING"], false);
+      }
+      // add other primary displaying msg types here
+      else {
+         // find any type that's displayable
+         if (containsType($msg, "text", "any_type", $ent_num)) {
+            $body = decodeBody($msg["ENTITIES"][$ent_num]["BODY"], $msg["ENTITIES"][$ent_num]["ENCODING"], false);
+         } else if (containsType($msg, "msg", "any_type", $ent_num)) {
+            $body = decodeBody($msg["ENTITIES"][$ent_num]["BODY"], $msg["ENTITIES"][$ent_num]["ENCODING"], false);
+         } else {
+            $body = "No Message";
+         }
+      }
+
+      $type1 = $msg["ENTITIES"][$ent_num]["TYPE1"];
+
+      $body_ary = explode("\n", $body);
+      $body = "";
       for ($i=0;$i < count($body_ary);$i++) {
-         $tmp = strip_tags($body_ary[$i]);
-         $tmp = substr($tmp, 0, strlen($tmp) -1);
-         $body = "$body> $tmp";
+         if ($type1 == "html")
+            $tmp = strip_tags($body_ary[$i]);
+         else
+            $tmp = $body_ary[$i];
+         $body = "$body> $tmp\n";
       }
    }
 
+   // Add some decoding information
+   $send_to = encodeEmailAddr($send_to);
+   // parses the field and returns only the email address
+   $send_to = decodeEmailAddr($send_to);
+
+   $send_to = strtolower($send_to);
    $send_to = ereg_replace("\"", "", $send_to);
    $send_to = stripslashes($send_to);
 
    echo "   </TR>\n";
    echo "   <TR>\n";
    echo "      <TD BGCOLOR=\"$color[4]\" COLSPAN=2>\n";
-   echo "         &nbsp;&nbsp;<TEXTAREA NAME=passed_body ROWS=20 COLS=76 WRAP=HARD>$body</TEXTAREA><BR>";
+   echo "         &nbsp;&nbsp;<TEXTAREA NAME=passed_body ROWS=20 COLS=\"$editor_size\" WRAP=HARD>$body</TEXTAREA><BR>";
    echo "      </TD>";
    echo "   </TR>\n";
    echo "</TABLE>\n";