From 7aacb7cc5a163917d4fe8c8d8150fcabaaed6b06 Mon Sep 17 00:00:00 2001 From: dMetzger Date: Thu, 20 Sep 2012 09:49:41 +0000 Subject: [PATCH] [-] Installer : removed calls to Tools in installer (replace by local function) #PSCFV-4113 --- install-dev/init.php | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/install-dev/init.php b/install-dev/init.php index 26daa31a1..ffa9d7e4a 100644 --- a/install-dev/init.php +++ b/install-dev/init.php @@ -69,5 +69,35 @@ if (!@ini_get('date.timezone')) @date_default_timezone_set('UTC'); // Try to improve memory limit if it's under 32M -if (Tools::getMemoryLimit() < Tools::getOctets('32M')) - ini_set('memory_limit', '32M'); \ No newline at end of file +if (psinstall_get_memory_limit() < psinstall_get_octets('32M')) + ini_set('memory_limit', '32M'); + +function psinstall_get_octets($option) +{ + if (preg_match('/[0-9]+k/i', $option)) + return 1024 * (int)$option; + + if (preg_match('/[0-9]+m/i', $option)) + return 1024 * 1024 * (int)$option; + + if (preg_match('/[0-9]+g/i', $option)) + return 1024 * 1024 * 1024 * (int)$option; + + return $option; +} + +function psinstall_get_memory_limit() +{ + $memory_limit = @ini_get('memory_limit'); + + if (preg_match('/[0-9]+k/i', $memory_limit)) + return 1024 * (int)$memory_limit; + + if (preg_match('/[0-9]+m/i', $memory_limit)) + return 1024 * 1024 * (int)$memory_limit; + + if (preg_match('/[0-9]+g/i', $memory_limit)) + return 1024 * 1024 * 1024 * (int)$memory_limit; + + return $memory_limit; +} \ No newline at end of file