|
|
|
@ -6497,6 +6497,64 @@ function api_set_setting_last_update() { |
|
|
|
|
api_set_setting('settings_latest_update', api_get_utc_datetime()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Tries to set memory limit, if authorized and new limit is higher than current |
|
|
|
|
* @param string New memory limit |
|
|
|
|
* @return bool True on success, false on failure or current is higher than suggested |
|
|
|
|
* @assert (null) === false |
|
|
|
|
* @assert (-1) === false |
|
|
|
|
* @assert (0) === true |
|
|
|
|
* @assert ('1G') === true |
|
|
|
|
*/ |
|
|
|
|
function api_set_memory_limit($mem){ |
|
|
|
|
//if ini_set() not available, this function is useless |
|
|
|
|
if (!function_exists('ini_set') || is_null($mem) || $mem == -1) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$memory_limit = ini_get('memory_limit'); |
|
|
|
|
if (api_get_bytes_memory_limit($mem) > api_get_bytes_memory_limit($memory_limit)){ |
|
|
|
|
ini_set('memory_limit', $mem); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
/** |
|
|
|
|
* Gets memory limit in bytes |
|
|
|
|
* @param string The memory size (128M, 1G, 1000K, etc) |
|
|
|
|
* @return int |
|
|
|
|
* @assert (null) === false |
|
|
|
|
* @assert ('1t') === 1099511627776 |
|
|
|
|
* @assert ('1g') === 1073741824 |
|
|
|
|
* @assert ('1m') === 1048576 |
|
|
|
|
* @assert ('100k') === 102400 |
|
|
|
|
*/ |
|
|
|
|
function api_get_bytes_memory_limit($mem){ |
|
|
|
|
$size = strtolower(substr($mem,-1)); |
|
|
|
|
|
|
|
|
|
switch ($size) { |
|
|
|
|
case 't': |
|
|
|
|
$mem = intval(substr($mem,-1))*1024*1024*1024*1024; |
|
|
|
|
break; |
|
|
|
|
case 'g': |
|
|
|
|
$mem = intval(substr($mem,0,-1))*1024*1024*1024; |
|
|
|
|
break; |
|
|
|
|
case 'm': |
|
|
|
|
$mem = intval(substr($mem,0,-1))*1024*1024; |
|
|
|
|
break; |
|
|
|
|
case 'k': |
|
|
|
|
$mem = intval(substr($mem,0,-1))*1024; |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
// we assume it's integer only |
|
|
|
|
$mem = intval($mem); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
return $mem; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Sends email using the phpmailer class |
|
|
|
|
* Sender name and email can be specified, if not specified |
|
|
|
@ -6803,7 +6861,6 @@ function api_get_language_interface() { |
|
|
|
|
|
|
|
|
|
function getConfigurationArray($confPath) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function api_get_default_course_document() |
|
|
|
|