From 8f7315af7348b9fa4a24902383c908e3ff8c0e53 Mon Sep 17 00:00:00 2001 From: fallas Date: Wed, 31 Oct 2001 14:58:57 +0000 Subject: [PATCH] Removed dependance upon /dev/null allowing for use Windows/IIS. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@1666 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- src/draft_actions.php | 59 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 51 insertions(+), 8 deletions(-) diff --git a/src/draft_actions.php b/src/draft_actions.php index a383a1bf..8fb8251c 100644 --- a/src/draft_actions.php +++ b/src/draft_actions.php @@ -2,7 +2,7 @@ require_once ('../src/validate.php'); /* Print all the needed RFC822 headers */ - function write822HeaderForDraft ($fp, $t, $c, $b, $subject, $more_headers) { + function write822HeaderForDraft ($fp, $t, $c, $b, $subject, $more_headers, $send_it) { global $REMOTE_ADDR, $SERVER_NAME, $REMOTE_PORT; global $data_dir, $username, $popuser, $domain, $version, $useSendmail; global $default_charset, $HTTP_VIA, $HTTP_X_FORWARDED_FOR; @@ -90,11 +90,55 @@ require_once ('../src/validate.php'); } // Write the header - fputs ($fp, $header); + if ($send_it) { + fputs ($fp, $header); + } return $headerlength; } + // Send the body + function writeBodyForDraft ($fp, $passedBody, $send_it) { + global $default_charset; + + $attachmentlength = 0; + + if (isMultipart()) { + $body = '--'.mimeBoundary()."\r\n"; + + if ($default_charset != "") + $body .= "Content-Type: text/plain; charset=$default_charset\r\n"; + else + $body .= "Content-Type: text/plain\r\n"; + + $body .= "Content-Transfer-Encoding: 8bit\r\n\r\n"; + $body .= $passedBody . "\r\n\r\n"; + if ($send_it) { + fputs ($fp, $body); + } + + $attachmentlength = attachFiles($fp); + + if (!isset($postbody)) $postbody = ""; + $postbody .= "\r\n--".mimeBoundary()."--\r\n\r\n"; + if ($send_it) { + fputs ($fp, $postbody); + } + } else { + $body = $passedBody . "\r\n"; + if ($send_it) { + fputs ($fp, $body); + } + $postbody = "\r\n"; + if ($send_it) { + fputs ($fp, $postbody); + } + } + + return (strlen($body) + strlen($postbody) + $attachmentlength); + } + + function saveMessageAsDraft($t, $c, $b, $subject, $body, $reply_id) { global $useSendmail, $msg_id, $is_reply, $mailbox, $onetimepad; global $data_dir, $username, $domain, $key, $version, $sent_folder, $imapServerAddress, $imapPort; @@ -103,17 +147,16 @@ require_once ('../src/validate.php'); $imap_stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, 1); - $fp = fopen("/dev/null", a); - $headerlength = write822HeaderForDraft ($fp, $t, $c, $b, $subject, $more_headers); - $bodylength = writeBody ($fp, $body); - fclose ($fp); + $fp = ""; + $headerlength = write822HeaderForDraft ($fp, $t, $c, $b, $subject, $more_headers, FALSE); + $bodylength = writeBodyForDraft ($fp, $body, FALSE); $length = ($headerlength + $bodylength); if (sqimap_mailbox_exists ($imap_stream, $draft_folder)) { sqimap_append ($imap_stream, $draft_folder, $length); - write822HeaderForDraft ($imap_stream, $t, $c, $b, $subject, $more_headers); - writeBody ($imap_stream, $body); + write822HeaderForDraft ($imap_stream, $t, $c, $b, $subject, $more_headers, TRUE); + writeBodyForDraft ($imap_stream, $body, TRUE); sqimap_append_done ($imap_stream); } sqimap_logout($imap_stream); -- 2.25.1