/**
* draft_actions.php
*
- * Copyright (c) 1999-2001 The Squirrelmail Development Team
+ * Copyright (c) 1999-2002 The SquirrelMail Project Team
* Licensed under the GNU GPL. For full terms see the file COPYING.
*
* $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. */
/* 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";
}
/* 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 != ""){
$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";
}
-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;
- global $draft_folder, $attachment_dir;
+function saveMessageAsDraft($t, $c, $b, $subject, $body, $reply_id, $prio = 3, $session) {
+ global $useSendmail, $msg_id, $is_reply, $mailbox, $onetimepad,
+ $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);
+
$tmpDraftFile = "draft-" . GenerateRandomString(32, '', 7);
- while ( file_exists($attachment_dir .$tmpDraftFile)){
+ $full_tmpDraftFile = "$hashed_attachment_dir/$tmpDraftFile";
+ while (file_exists($full_tmpDraftFile)){
$tmpDraftFile = "draft-" . GenerateRandomString(32, '', 7);
+ $full_tmpDraftFile = "$hashed_attachment_dir/$tmpDraftFile";
}
- $fp = fopen($attachment_dir . $tmpDraftFile, 'w');
+ $fp = fopen($full_tmpDraftFile, 'wb');
- $headerlength = write822HeaderForDraft ($fp, $t, $c, $b, $subject, $more_headers, FALSE);
- $bodylength = writeBodyForDraft ($fp, $body, FALSE);
+ $headerlength = write822HeaderForDraft
+ ($fp, $t, $c, $b, $subject, $more_headers, $session);
+ $bodylength = writeBodyForDraft ($fp, $body, $session);
fclose($fp);
$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, TRUE);
- writeBodyForDraft ($imap_stream, $body, TRUE);
+ write822HeaderForDraft
+ ($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($attachment_dir . $tmpDraftFile)){
- unlink ($attachment_dir . $tmpDraftFile);
+ if (file_exists($full_tmpDraftFile)){
+ unlink ($full_tmpDraftFile);
}
return $length;
}
+
?>