fixed default setting for Exhcnage
[squirrelmail.git] / src / compose.php
index 841d0c007e007c7ed3f0c5cc3b0e2832e971b92d..904ad0d9fa1b1eba806dc1945cdcb8fdb9745ab2 100644 (file)
@@ -40,6 +40,9 @@
 
    include("../src/load_prefs.php");
 
+   if (!isset($attachments))
+       $attachments = array();
+
    // This function is used when not sending or adding attachments
    function newMail () {
       global $forward_id, $imapConnection, $msg, $ent_num, $body_ary, $body,
              $body = $bodyTop . $body;
          }
          
-         $body = ereg_replace('\\\\', '\\\\', $body);
-
          return;
       }
 
         // Write Attachment to file
         $fp = fopen ($attachment_dir.$localfilename, "w");
       fputs ($fp, decodeBody(mime_fetch_body($imapConnection, $forward_id, $message->header->entity_id), $message->header->encoding));
-      
-//      Don't know why these lines were included
-//        fgets($imapConnection, 256);
-//        fgets($imapConnection, 256);
-
       fclose ($fp);
       
       $attachments[$localfilename] = $filename;
       echo "     <TD BGCOLOR=\"$color[0]\" VALIGN=TOP ALIGN=RIGHT>\n";
       echo "      <SMALL><BR></SMALL>"._("Attach:");
       echo "      </td><td ALIGN=left BGCOLOR=\"$color[0]\">\n";
-      //      echo "      <INPUT TYPE=\"hidden\" name=\"MAX_FILE_SIZE\"\n";
-      //      echo "      value=\"10000\">\n";
       echo "      <INPUT NAME=\"attachfile\" SIZE=48 TYPE=\"file\">\n";
       echo "      &nbsp;&nbsp;<input type=\"submit\" name=\"attach\"";
       echo " value=\"" . _("Add") ."\">\n";
          }
       }
       
-      if (!$failed) {
+      if (!isset($failed) || !$failed) {
          // Write information about the file
          $fp = fopen ($attachment_dir.$localfilename.".info", "w");
          fputs ($fp, $HTTP_POST_FILES['attachfile']['type']."\n".$HTTP_POST_FILES['attachfile']['name']."\n");
       }
     }
 
-   if (($mailbox == "") || ($mailbox == "None"))
+   // Workaround for RedHat PHP 4.0.4pl1-3
+   // Also for Konq problems?
+   if (isset($mailbox))     $mailbox = trim($mailbox);
+   if (isset($send_to))     $send_to = trim($send_to);
+   if (isset($send_to_cc))  $send_to_cc = trim($send_to_cc);
+   if (isset($send_to_bcc)) $send_to_bcc = trim($send_to_bcc);
+   if (isset($subject))     $subject = trim($subject);
+   if (isset($body))        $body = trim($body);
+   if (isset($attachfile))  $attachfile = trim($attachfile);
+   // End of workaround
+   
+   if (!isset($mailbox) || $mailbox == "" || ($mailbox == "None"))
       $mailbox = "INBOX";
 
    if(isset($send)) {
           $HTTP_POST_FILES['attachfile']['tmp_name'] &&
           $HTTP_POST_FILES['attachfile']['tmp_name'] != 'none')
           $AttachFailure = saveAttachedFiles();
-      if (checkInput(false) && ! isset($AttachFailure)) {
-         $urlMailbox = urlencode ($mailbox);
-        if (! isset($reply_id))
-            $reply_id = 0;
+      if (checkInput(false) && !isset($AttachFailure)) {
+         $urlMailbox = urlencode (trim($mailbox));
+         if (! isset($reply_id))
+             $reply_id = 0;
          sendMessage($send_to, $send_to_cc, $send_to_bcc, $subject, $body, $reply_id);
          header ("Location: right_main.php?mailbox=$urlMailbox&sort=$sort&startMessage=1");
       } else {
       sqimap_logout($imapConnection);
    }
 ?>
-