summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authoralecpl <alec@alec.pl>2009-07-19 09:28:30 +0000
committeralecpl <alec@alec.pl>2009-07-19 09:28:30 +0000
commita640647edd0776555b9d2083fd968b2317143c8c (patch)
treec3e02d7cd644a2d78f4deb6af096c5a890c6cf97 /plugins
parent4439d2a86250504857bb201f50c94f60b0b8439d (diff)
- handle big attachments with file pointers to not exceed memory_limit in rcmail_save_attachment()
Diffstat (limited to 'plugins')
-rw-r--r--plugins/database_attachments/database_attachments.php4
-rw-r--r--plugins/filesystem_attachments/filesystem_attachments.php32
2 files changed, 22 insertions, 14 deletions
diff --git a/plugins/database_attachments/database_attachments.php b/plugins/database_attachments/database_attachments.php
index 28ccde4b3..a8ac62e26 100644
--- a/plugins/database_attachments/database_attachments.php
+++ b/plugins/database_attachments/database_attachments.php
@@ -63,6 +63,10 @@ class database_attachments extends filesystem_attachments
$rcmail = rcmail::get_instance();
$key = $this->_key($args['name']);
+
+ if ($args['path'])
+ $args['data'] = file_get_contents($args['path']);
+
$data = base64_encode($args['data']);
$status = $rcmail->db->query(
diff --git a/plugins/filesystem_attachments/filesystem_attachments.php b/plugins/filesystem_attachments/filesystem_attachments.php
index 9a6c0a81d..f4b9b6d7d 100644
--- a/plugins/filesystem_attachments/filesystem_attachments.php
+++ b/plugins/filesystem_attachments/filesystem_attachments.php
@@ -73,21 +73,25 @@ class filesystem_attachments extends rcube_plugin
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 ($fp = fopen($tmp_path, 'w')) {
- fwrite($fp, $args['data']);
- fclose($fp);
+
+ 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);
+ $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;
}