Compare commits
2 commits
227e7bba7f
...
c346252f55
Author | SHA1 | Date | |
---|---|---|---|
|
c346252f55 | ||
|
d461b28b7d |
4 changed files with 67 additions and 4 deletions
|
@ -7,9 +7,13 @@ data_directory: "${root_directory_path}/data"
|
|||
# Temporary files root directory
|
||||
tmp_root_directory: "${data_directory}/tmp"
|
||||
|
||||
# Temporary uploading files directory
|
||||
# Temporary uploading files directory (optional, default: PHP ini default)
|
||||
upload_tmp_directory: ${tmp_root_directory}/uploading"
|
||||
|
||||
# Uploading file size limit (in bytes, example: 104857600 == 100Mb)
|
||||
# (optional, default: PHP ini default)
|
||||
upload_max_filesize: 104857600
|
||||
|
||||
# Main pagetitle
|
||||
main_pagetitle: "Eesyphp"
|
||||
|
||||
|
|
|
@ -7,9 +7,13 @@ data_directory: "${root_directory_path}/data"
|
|||
# Temporary files root directory
|
||||
tmp_root_directory: "${data_directory}/tmp"
|
||||
|
||||
# Temporary uploading files directory
|
||||
# Temporary uploading files directory (optional, default: PHP ini default)
|
||||
upload_tmp_directory: ${tmp_root_directory}/uploading"
|
||||
|
||||
# Uploading file size limit (in bytes, example: 104857600 == 100Mb)
|
||||
# (optional, default: PHP ini default)
|
||||
upload_max_filesize: 104857600
|
||||
|
||||
# Main pagetitle
|
||||
main_pagetitle: "Eesyphp"
|
||||
|
||||
|
|
34
src/App.php
34
src/App.php
|
@ -51,8 +51,14 @@ class App {
|
|||
$sentry_span = new SentrySpan('app.init', 'Application initialization');
|
||||
|
||||
// Define upload_tmp_dir
|
||||
if (is_string(self::get('upload_tmp_directory')))
|
||||
ini_set('upload_tmp_dir', self::get('upload_tmp_directory'));
|
||||
if (self::isset('upload_tmp_directory'))
|
||||
ini_set('upload_tmp_dir', self::get('upload_tmp_directory', null, 'string'));
|
||||
if (self::isset('upload_max_filesize')) {
|
||||
ini_set('upload_max_filesize', self::get('upload_max_filesize', null, 'string'));
|
||||
// post_max_size must be larger than upload_max_filesize
|
||||
// See: https://www.php.net/manual/en/ini.core.php#ini.post-max-size
|
||||
ini_set('post_max_size', strval(self::get('upload_max_filesize', null, 'int') * 1.1));
|
||||
}
|
||||
|
||||
if (self :: get('log.enabled', true, 'bool'))
|
||||
Log::init();
|
||||
|
@ -85,6 +91,17 @@ class App {
|
|||
return !is_null(self :: $root_directory_path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a specific configuration variable is set
|
||||
*
|
||||
* @param string $key The configuration variable key
|
||||
* @param array|null $config Optional configuration to use instead of current loaded configuration
|
||||
* @return bool
|
||||
**/
|
||||
public static function isset($key, &$config=null) {
|
||||
return Config::isset($key, self :: $options) || (Config::loaded() && Config::isset($key));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a specific option value
|
||||
*
|
||||
|
@ -108,6 +125,19 @@ class App {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a specific option value
|
||||
*
|
||||
* @param string $key The configuration variable key
|
||||
* @param mixed $value The configuration variable value
|
||||
* @return boolean
|
||||
**/
|
||||
public static function set($key, $value) {
|
||||
if (Config::isset($key, self :: $options))
|
||||
return Config::set($key, $value, self :: $options);
|
||||
return Config::set($key, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retreive application root directory path
|
||||
* @return string|null
|
||||
|
|
|
@ -101,6 +101,31 @@ Class Config {
|
|||
self :: $extra_variables[$key] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a specific configuration variable is set
|
||||
*
|
||||
* @param string $key The configuration variable key
|
||||
* @param array|null $config Optional configuration to use instead of current loaded configuration
|
||||
* @return bool
|
||||
**/
|
||||
public static function isset($key, &$config=null) {
|
||||
if (array_key_exists($key, self :: $extra_variables))
|
||||
return true;
|
||||
if (!is_array($config) && !self :: loaded()) {
|
||||
Log :: fatal('Configuration not loaded (on checking if %s is set)', $key);
|
||||
exit(1);
|
||||
}
|
||||
$exploded_key = explode('.', $key);
|
||||
if (!is_array($exploded_key)) return false;
|
||||
$value = is_array($config)?$config:self :: $config;
|
||||
foreach ($exploded_key as $k) {
|
||||
if (!is_array($value) || !isset($value[$k]))
|
||||
return false;
|
||||
$value = $value[$k];
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a specific configuration variable value
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue