From 99007ec46311fab8463fbad42bc63fbf7bbd0123 Mon Sep 17 00:00:00 2001 From: vChabot Date: Thu, 22 Dec 2011 15:56:34 +0000 Subject: [PATCH] // preference admin controller updated and tools convertbyte too git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@11623 b9a71923-0436-4b27-9f14-aed3839534dd --- classes/Tools.php | 2 +- controllers/admin/AdminPreferencesController.php | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/classes/Tools.php b/classes/Tools.php index fa03b884a..b3bcde0b1 100644 --- a/classes/Tools.php +++ b/classes/Tools.php @@ -1916,7 +1916,7 @@ FileETag INode MTime Size else { $value_length = strlen($value); - $qty = substr($value, 0, $value_length - 1 ); + $qty = (int)substr($value, 0, $value_length - 1 ); $unit = strtolower(substr($value, $value_length - 1)); switch ($unit) { diff --git a/controllers/admin/AdminPreferencesController.php b/controllers/admin/AdminPreferencesController.php index ed64aa344..1585184fb 100644 --- a/controllers/admin/AdminPreferencesController.php +++ b/controllers/admin/AdminPreferencesController.php @@ -385,14 +385,15 @@ class AdminPreferencesControllerCore extends AdminController /** * Update PS_ATTACHMENT_MAXIMUM_SIZE */ - public function updateOptionPsAttachementMaximumSize($value) + public function updateOptionPsAttachmentMaximumSize($value) { if (!$value) return; - $upload_max_size = (int)str_replace('M', '', ini_get('upload_max_filesize')); - $post_max_size = (int)str_replace('M', '', ini_get('post_max_size')); - $max_size = $upload_max_size < $post_max_size ? $upload_max_size : $post_max_size; + $upload_max_size = Tools::convertBytes(ini_get('upload_max_filesize')); + $post_max_size = Tools::convertBytes(ini_get('post_max_size')); + $max_size = ($upload_max_size < $post_max_size ? $upload_max_size : $post_max_size) / 1048576; + // at this point, all values are in megaBytes $value = ($max_size < Tools::getValue('PS_ATTACHMENT_MAXIMUM_SIZE')) ? $max_size : Tools::getValue('PS_ATTACHMENT_MAXIMUM_SIZE'); Configuration::update('PS_ATTACHMENT_MAXIMUM_SIZE', $value); }