From fa31c56dce89abb6d2ee00e37c219d02671ae47c Mon Sep 17 00:00:00 2001 From: thomasmars Date: Mon, 29 May 2017 11:18:12 +0200 Subject: [PATCH] Fixed returnBytes function return correct amount of bytes --- h5p.classes.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/h5p.classes.php b/h5p.classes.php index 6a0799c..d39393d 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -2969,18 +2969,20 @@ class H5PCore { * @return int|string */ public static function returnBytes($val) { - $val = (int) trim($val); + $val = trim($val); $last = strtolower($val[strlen($val) - 1]); + $bytes = (int) $val; + switch ($last) { case 'g': - $val *= 1024; + $bytes *= 1024; case 'm': - $val *= 1024; + $bytes *= 1024; case 'k': - $val *= 1024; + $bytes *= 1024; } - return $val; + return $bytes; } /**