}
sqimap_logout($imap_stream);
}
+ session_write_close();
if ($compose_new_win == '1') {
if ( !isset($pageheader_sent) || !$pageheader_sent ) {
Header("Location: $location/compose.php?saved_draft=yes&session=$composesession");
exit();
}
unset($compose_messages[$session]);
+
/* if it is resumed draft, delete draft message */
if ( isset($delete_draft)) {
$imap_stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, false);
}
sqimap_logout($imap_stream);
}
+ session_write_close();
if ($compose_new_win == '1') {
if ( !isset($pageheader_sent) || !$pageheader_sent ) {
Header("Location: $location/compose.php?mail_sent=yes");
$composeMessage = $compose_messages[$session];
foreach($delete as $index) {
if (!empty($composeMessage->entities) && isset($composeMessage->entities[$index])) {
- $attached_file = $composeMessage->entities[$index]->att_local_name;
- if (file_exists($attached_file)) {
- unlink ($attached_file);
- }
+ $composeMessage->entities[$index]->purgeAttachments();
unset ($composeMessage->entities[$index]);
}
}
} else {
$mailprio = '';
}
- //ClearAttachments($session);
$identity = '';
$from_o = $orig_header->from;
/* True if FAILURE */
function saveAttachedFiles($session) {
- global $_FILES, $attachment_dir, $attachments, $username,
+ global $_FILES, $attachment_dir, $username,
$data_dir, $compose_messages;
/* get out of here if no file was attached at all */
sqsession_register($compose_messages , 'compose_messages');
}
-/**
- * Given a composeMessage, recursively delete all temporary files in the
- * attachment dir for each body part of that message.
- */
-function ClearAttachments($composeMessage) {
- if ($composeMessage->att_local_name) {
- $attached_file = $composeMessage->att_local_name;
- if (file_exists($attached_file)) {
- unlink($attached_file);
- }
- }
- for ($i=0, $entCount=count($composeMessage->entities);$i< $entCount; ++$i) {
- ClearAttachments($composeMessage->entities[$i]);
- }
-}
-
/* parse values like 8M and 2k into bytes */
function getByteSize($ini_size) {
sqimap_append_done ($imap_stream, $draft_folder);
sqimap_logout($imap_stream);
unset ($imap_deliver);
- ClearAttachments($composeMessage);
+ $composeMessage->purgeAttachments();
return $length;
} else {
$msg = '<br />'.sprintf(_("Error: Draft folder %s does not exist."), $draft_folder);
global $passed_id, $mailbox, $action, $what, $iAccount,$startMessage;
- ClearAttachments($composeMessage);
+ $composeMessage->purgeAttachments();
if ($action == 'reply' || $action == 'reply_all') {
$aMailbox = sqm_api_mailbox_select($imap_stream, $iAccount, $mailbox,array('setindex' => $what, 'offset' => $startMessage),array());
//sqimap_mailbox_select ($imap_stream, $mailbox);
$readmessage, TRUE);
}
-function ClearAttachments() {
- global $username, $attachments, $attachment_dir;
-
- $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
-
- $rem_attachments = array();
- if (isset($attachments)) {
- foreach ($attachments as $info) {
- if ($info['session'] == -1) {
- $attached_file = "$hashed_attachment_dir/$info[localfilename]";
- if (file_exists($attached_file)) {
- unlink($attached_file);
- }
- } else {
- $rem_attachments[] = $info;
- }
- }
- }
- $attachments = $rem_attachments;
-}
-
function formatRecipientString($recipients, $item ) {
global $show_more_cc, $show_more, $show_more_bcc,
$PHP_SELF;
$message->is_mdnsent = true;
$aMailbox['MSG_HEADERS'][$passed_id]['MESSAGE_OBJECT'] = $message;
}
- ClearAttachments();
}
}
/***********************************************/
sqsession_register($mailbox_cache,'mailbox_cache');
?>
-</body></html>
\ No newline at end of file
+</body></html>
require_once(SM_PATH . 'functions/html.php');
/* Erase any lingering attachments */
-if (isset($attachments) && is_array($attachments)
- && sizeof($attachments)){
- $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
- foreach ($attachments as $info) {
- $attached_file = "$hashed_attachment_dir/$info[localfilename]";
- if (file_exists($attached_file)) {
- unlink($attached_file);
- }
- }
+sqgetGlobalVar('compose_messages', $compose_messages, SQ_SESSION);
+foreach($compose_messages as $composeMessage) {
+ $composeMessage->purgeAttachments();
}
if (!isset($frame_top)) {
?>
</body>
-</html>
\ No newline at end of file
+</html>