From 52fb3578b3e4758b0887f3c423ed02e2d77ff65e Mon Sep 17 00:00:00 2001 From: nickw Date: Wed, 13 Jan 2010 15:58:41 +0000 Subject: Creating a helper function to return INI values in bytes. git-svn-id: http://code.elgg.org/elgg/trunk@3804 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/elgglib.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'engine/lib') diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php index c0d19743a..3224fe4e2 100644 --- a/engine/lib/elgglib.php +++ b/engine/lib/elgglib.php @@ -2447,6 +2447,32 @@ function elgg_validate_action_url($link) { return elgg_http_build_url($url); } +/** + * Returns the PHP INI setting in bytes + * + * @param str $setting + * @return int + * @since 1.7 + * @link http://www.php.net/manual/en/function.ini-get.php + */ +function elgg_get_ini_setting_in_bytes($setting) { + // retrieve INI setting + $val = ini_get($setting); + + // convert INI setting when shorthand notation is used + $last = strtolower($val[strlen($val)-1]); + switch($last) { + case 'g': + $val *= 1024; + case 'm': + $val *= 1024; + case 'k': + $val *= 1024; + } + + // return byte value + return $val; +} /** * Server javascript pages. -- cgit v1.2.3