From a640647edd0776555b9d2083fd968b2317143c8c Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Sun, 19 Jul 2009 05:28:30 -0400
Subject: [PATCH] - handle big attachments with file pointers to not exceed memory_limit in rcmail_save_attachment()
---
plugins/filesystem_attachments/filesystem_attachments.php | 30 +++++++++++++++++-------------
1 files changed, 17 insertions(+), 13 deletions(-)
diff --git a/plugins/filesystem_attachments/filesystem_attachments.php b/plugins/filesystem_attachments/filesystem_attachments.php
index 9a6c0a8..f4b9b6d 100644
--- a/plugins/filesystem_attachments/filesystem_attachments.php
+++ b/plugins/filesystem_attachments/filesystem_attachments.php
@@ -73,21 +73,25 @@
function save($args)
{
$args['status'] = false;
- $rcmail = rcmail::get_instance();
- $temp_dir = unslashify($rcmail->config->get('temp_dir'));
- $tmp_path = tempnam($temp_dir, 'rcmAttmnt');
+
+ if (!$args['path']) {
+ $rcmail = rcmail::get_instance();
+ $temp_dir = unslashify($rcmail->config->get('temp_dir'));
+ $tmp_path = tempnam($temp_dir, 'rcmAttmnt');
- if ($fp = fopen($tmp_path, 'w')) {
- fwrite($fp, $args['data']);
- fclose($fp);
+ if ($fp = fopen($tmp_path, 'w')) {
+ fwrite($fp, $args['data']);
+ fclose($fp);
+ $args['path'] = $tmp_path;
+ } else
+ return $args;
+ }
+
+ $args['id'] = count($_SESSION['plugins']['filesystem_attachments']['tmp_files'])+1;
+ $args['status'] = true;
- $args['id'] = count($_SESSION['plugins']['filesystem_attachments']['tmp_files'])+1;
- $args['path'] = $tmp_path;
- $args['status'] = true;
-
- // Note the file for later cleanup
- $_SESSION['plugins']['filesystem_attachments']['tmp_files'][] = $tmp_path;
- }
+ // Note the file for later cleanup
+ $_SESSION['plugins']['filesystem_attachments']['tmp_files'][] = $args['path'];
return $args;
}
--
Gitblit v1.9.1