From 28a60f6bee5ecbec21e4bb4ed74750c42e7f1975 Mon Sep 17 00:00:00 2001 From: alec Date: Fri, 25 Nov 2011 13:47:07 +0000 Subject: - 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 git-svn-id: https://svn.roundcube.net/trunk@5490 208e9e7b-5314-0410-a742-e7e81cd9613c --- roundcubemail/program/include/main.inc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'roundcubemail/program/include/main.inc') diff --git a/roundcubemail/program/include/main.inc b/roundcubemail/program/include/main.inc index 002501804..8a08125eb 100644 --- a/roundcubemail/program/include/main.inc +++ b/roundcubemail/program/include/main.inc @@ -1845,6 +1845,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 * -- cgit v1.2.3