X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=src%2Fdraft_actions.php;h=db4032785be25f612a0a3bb2f68a07ba96e12941;hb=95dcee50e4d7ffe1d0b686377042ff3b735bc81c;hp=1926374c76d1a694647b2958fbcd9af53d9e7a0b;hpb=15e6162eacc97158393bc75aed3afeb7b19c24a6;p=squirrelmail.git diff --git a/src/draft_actions.php b/src/draft_actions.php index 1926374c..db403278 100644 --- a/src/draft_actions.php +++ b/src/draft_actions.php @@ -9,14 +9,31 @@ * $Id$ */ -require_once ('../src/validate.php'); +/* Path for SquirrelMail required files. */ +define('SM_PATH','../'); + +/* SquirrelMail required files. */ +require_once(SM_PATH . 'include/validate.php'); /* Print all the needed RFC822 headers */ -function write822HeaderForDraft ($fp, $t, $c, $b, $subject, $more_headers) { - global $REMOTE_ADDR, $SERVER_NAME, $REMOTE_PORT; - global $data_dir, $username, $popuser, $domain, $version, $useSendmail; - global $default_charset, $HTTP_VIA, $HTTP_X_FORWARDED_FOR; - global $REMOTE_HOST, $identity; +function write822HeaderForDraft ($fp, $t, $c, $b, $subject, $more_headers, $session) { + global $data_dir, $username, $popuser, $domain, $version, $useSendmail, + $default_charset, $identity, $_SERVER; + + /* get those globals */ + $REMOTE_ADDR = $_SERVER['REMOTE_ADDR']; + $SERVER_NAME = $_SERVER['SERVER_NAME']; + $REMOTE_PORT = $_SERVER['REMOTE_PORT']; + + if(isset($_SERVER['REMOTE_HOST'])) { + $REMOTE_HOST = $_SERVER['REMOTE_HOST']; + } + if(isset($_SERVER['HTTP_VIA'])) { + $HTTP_VIA = $_SERVER['HTTP_VIA']; + } + if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { + $HTTP_X_FORWARDED_FOR = $_SERVER['HTTP_X_FORWARDED_FOR']; + } /* Storing the header to make sure the header is the same */ /* everytime the header is printed. */ @@ -84,7 +101,7 @@ function write822HeaderForDraft ($fp, $t, $c, $b, $subject, $more_headers) { /* Do the MIME-stuff */ $header .= "MIME-Version: 1.0\r\n"; - if (isMultipart()) { + if (isMultipart($session)) { $header .= 'Content-Type: multipart/mixed; boundary="'; $header .= mimeBoundary(); $header .= "\"\r\n"; @@ -107,12 +124,12 @@ function write822HeaderForDraft ($fp, $t, $c, $b, $subject, $more_headers) { } /* Send the body */ -function writeBodyForDraft ($fp, $passedBody) { +function writeBodyForDraft ($fp, $passedBody, $session) { global $default_charset; $attachmentlength = 0; - if (isMultipart()) { + if (isMultipart($session)) { $body = '--'.mimeBoundary()."\r\n"; if ($default_charset != ""){ @@ -125,7 +142,7 @@ function writeBodyForDraft ($fp, $passedBody) { $body .= $passedBody . "\r\n\r\n"; fputs ($fp, $body); - $attachmentlength = attachFiles($fp); + $attachmentlength = attachFiles($fp, $session); if (!isset($postbody)) $postbody = ""; $postbody .= "\r\n--".mimeBoundary()."--\r\n\r\n"; @@ -141,12 +158,20 @@ function writeBodyForDraft ($fp, $passedBody) { } -function saveMessageAsDraft($t, $c, $b, $subject, $body, $reply_id) { +function saveMessageAsDraft($t, $c, $b, $subject, $body, $reply_id, $prio = 3, $session) { global $useSendmail, $msg_id, $is_reply, $mailbox, $onetimepad, - $data_dir, $username, $domain, $key, $version, $sent_folder, - $imapServerAddress, $imapPort, $draft_folder, $attachment_dir; + $data_dir, $domain, $version, $sent_folder, + $imapServerAddress, $imapPort, $draft_folder, $attachment_dir, + $default_use_priority, $_SESSION, $_COOKIE; $more_headers = Array(); + $username = $_SESSION['username']; + $key = $_COOKIE['key']; + + if ($default_use_priority) { + $more_headers = array_merge($more_headers, createPriorityHeaders($prio)); + } + $imap_stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, 1); $hashed_attachment_dir = getHashedDir($username, $attachment_dir); @@ -157,11 +182,11 @@ function saveMessageAsDraft($t, $c, $b, $subject, $body, $reply_id) { $tmpDraftFile = "draft-" . GenerateRandomString(32, '', 7); $full_tmpDraftFile = "$hashed_attachment_dir/$tmpDraftFile"; } - $fp = fopen($full_tmpDraftFile, 'w'); + $fp = fopen($full_tmpDraftFile, 'wb'); $headerlength = write822HeaderForDraft - ($fp, $t, $c, $b, $subject, $more_headers, FALSE); - $bodylength = writeBodyForDraft ($fp, $body, FALSE); + ($fp, $t, $c, $b, $subject, $more_headers, $session); + $bodylength = writeBodyForDraft ($fp, $body, $session); fclose($fp); $length = ($headerlength + $bodylength); @@ -169,17 +194,18 @@ function saveMessageAsDraft($t, $c, $b, $subject, $body, $reply_id) { if (sqimap_mailbox_exists ($imap_stream, $draft_folder)) { sqimap_append ($imap_stream, $draft_folder, $length); write822HeaderForDraft - ($imap_stream, $t, $c, $b, $subject, $more_headers, TRUE); - writeBodyForDraft ($imap_stream, $body, TRUE); + ($imap_stream, $t, $c, $b, $subject, $more_headers, $session); + writeBodyForDraft ($imap_stream, $body, $session); sqimap_append_done ($imap_stream); } sqimap_logout($imap_stream); if ($length){ - ClearAttachments(); + ClearAttachments($session); } if (file_exists($full_tmpDraftFile)){ unlink ($full_tmpDraftFile); } return $length; } + ?>