From e2980e871fd9d7e769cf19b58c03574d386e542e Mon Sep 17 00:00:00 2001 From: Klaus Weidenbach Date: Sat, 16 May 2015 11:12:39 +0200 Subject: Add functions to parse and get some values from php.ini. Get upload limits from php.ini. These functions will be used for checking against upload limits and to give information in the frontend. Wasn't sure in which file to put these functions, so I created a new one include/environment.php. --- include/environment.php | 66 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 include/environment.php (limited to 'include/environment.php') diff --git a/include/environment.php b/include/environment.php new file mode 100644 index 000000000..47ad241a7 --- /dev/null +++ b/include/environment.php @@ -0,0 +1,66 @@ + 8388608 + * + * \note This method does not recognise other human readable formats like + * 8MB, etc. + * + * @todo Make this function more universal useable. MB, T, etc. + * + * @param string $val value from php.ini e.g. 2M, 8M + * @return int size in bytes + */ +function phpiniSizeToBytes($val) { + $val = trim($val); + $unit = strtolower($val[strlen($val)-1]); + switch($unit) { + case 'g': + $val *= 1024; + case 'm': + $val *= 1024; + case 'k': + $val *= 1024; + } + + return (int)$val; +} \ No newline at end of file -- cgit v1.2.3