Removed a lot of the warnings generated when PHP has all warnings enabled.
[squirrelmail.git] / src / compose.php
index 4c226b81576ff8230afec58a68b4f0390a24c2ca..841d0c007e007c7ed3f0c5cc3b0e2832e971b92d 100644 (file)
     **  - Start new mail
     **  - Add an attachment
     **  - Send mail
+    **
+    ** $Id$
     **/
 
    session_start();
 
-   if (!isset($config_php))
-      include("../config/config.php");
    if (!isset($strings_php))
       include("../functions/strings.php");
+   if (!isset($config_php))
+      include("../config/config.php");
    if (!isset($page_header_php))
       include("../functions/page_header.php");
    if (!isset($imap_php))
 
       if ($forward_id)
          $id = $forward_id;
-      else if ($reply_id)
+      elseif ($reply_id)
          $id = $reply_id;
 
 
-      if ($id) {
+      if (isset($id)) {
          sqimap_mailbox_select($imapConnection, $mailbox);
          $message = sqimap_get_message($imapConnection, $id, $mailbox);
          $orig_header = $message->header;
          
          $body = ereg_replace('\\\\', '\\\\', $body);
 
-         sqimap_mailbox_close($imapConnection);
          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));
-        fgets($imapConnection, 256);
-        fgets($imapConnection, 256);
-      fclose ($fp);
+      
+//      Don't know why these lines were included
+//        fgets($imapConnection, 256);
+//        fgets($imapConnection, 256);
 
+      fclose ($fp);
+      
       $attachments[$localfilename] = $filename;
       
       }
          echo "// --></SCRIPT>\n\n";
       }
 
-      echo "\n<FORM name=compose action=\"compose.php\" METHOD=POST ENCTYPE=\"multipart/form-data\">\n";
-      //echo "\n<FORM name=compose action=\"compose.php\" METHOD=POST>\n";
+      echo "\n<FORM name=compose action=\"compose.php\" METHOD=POST ENCTYPE=\"multipart/form-data\"";
+      do_hook("compose_form");
+         echo ">\n";
       if ($reply_id) {
          echo "<input type=hidden name=reply_id value=$reply_id>\n";
       }                 
       $mailbox = "INBOX";
 
    if(isset($send)) {
-      if ($HTTP_POST_FILES['attachfile']['tmp_name'] &&
+      if (isset($HTTP_POST_FILES['attachfile']) &&
+          $HTTP_POST_FILES['attachfile']['tmp_name'] &&
           $HTTP_POST_FILES['attachfile']['tmp_name'] != 'none')
           $AttachFailure = saveAttachedFiles();
-      if (checkInput(false) && ! $AttachFailure) {
+      if (checkInput(false) && ! isset($AttachFailure)) {
          $urlMailbox = urlencode ($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 {
          showInputForm();
          //sqimap_logout($imapConnection);
       }
-   } else if ($html_addr_search_done) {
+   } else if (isset($html_addr_search_done)) {
       is_logged_in();
       displayPageHeader($color, $mailbox);
 
       }
       
       showInputForm();
-   } else if ($html_addr_search) {
+   } else if (isset($html_addr_search)) {
       // I am using an include so as to elminiate an extra unnecessary click.  If you
       // can think of a better way, please implement it.
       include ("./addrbook_search_html.php");
       }
 
       showInputForm();
-       } else if ($smtpErrors) {
+       } else if (isset($smtpErrors)) {
       $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
       displayPageHeader($color, $mailbox);
 
 
       $newmail = true;
                
-      if ($forward_id && $ent_num)  getAttachments(0);
+      if (isset($forward_id) && isset($ent_num))  getAttachments(0);
               
       newMail();
       showInputForm();