summaryrefslogtreecommitdiff
path: root/program/include/main.inc
diff options
context:
space:
mode:
authoralecpl <alec@alec.pl>2011-11-25 13:47:07 +0000
committeralecpl <alec@alec.pl>2011-11-25 13:47:07 +0000
commite0960f6365b4b0af314d955847b9422067c83eb2 (patch)
tree158714b9d499cd6bdb5dec392de13c178a129ea3 /program/include/main.inc
parent9b33118bf57345fed8ca0d250b492a8d0e711730 (diff)
- Prevent from memory_limit exceeding when trying to parse big messages bodies (#1487424):
don't try to parse it, display notice with a link to download it directly
Diffstat (limited to 'program/include/main.inc')
-rw-r--r--program/include/main.inc15
1 files changed, 15 insertions, 0 deletions
diff --git a/program/include/main.inc b/program/include/main.inc
index 002501804..8a08125eb 100644
--- a/program/include/main.inc
+++ b/program/include/main.inc
@@ -1846,6 +1846,21 @@ function rcmail_user_date()
/**
+ * Check if we can process not exceeding memory_limit
+ *
+ * @param integer Required amount of memory
+ * @return boolean
+ */
+function rcmail_mem_check($need)
+{
+ $mem_limit = parse_bytes(ini_get('memory_limit'));
+ $memory = function_exists('memory_get_usage') ? memory_get_usage() : 16*1024*1024; // safe value: 16MB
+
+ return $mem_limit && $memory + $need > $mem_limit ? false : true;
+}
+
+
+/**
* Check if working in SSL mode
*
* @param integer HTTPS port number