From 5ebea63410d4f051988d83da3fbed999a6f19b52 Mon Sep 17 00:00:00 2001 From: Andrei Bautu Date: Sat, 26 Nov 2022 10:24:49 +0200 Subject: [PATCH 1/2] Add environmental variables for configuration --- tinyfilemanager.php | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/tinyfilemanager.php b/tinyfilemanager.php index e563bf9..6a8319d 100644 --- a/tinyfilemanager.php +++ b/tinyfilemanager.php @@ -132,9 +132,29 @@ $ip_blacklist = array( '::' // non-routable meta ipv6 ); + +if (getenv('TFM_USE_AUTH') !== false) { + $use_auth = filter_var(getenv('TFM_USE_AUTH'), FILTER_VALIDATE_BOOLEAN); +} + +if (getenv('TFM_AUTH_USERS') !== false) { + $auth_users = array_map( + function($x) { return explode('=', $x); }, + explode(',', getenv('TFM_AUTH_USERS')) + ); +} + +if (getenv('TFM_READONLY_USERS') !== false) { + $readonly_users = explode(',', getenv('TFM_READONLY_USERS')); +} + +if (getenv('TFM_ROOT_PATH') !== false) { + $root_path = getenv('TFM_ROOT_PATH'); +} + // if User has the external config file, try to use it to override the default config above [config.php] // sample config - https://tinyfilemanager.github.io/config-sample.txt -$config_file = __DIR__.'/config.php'; +$config_file = getenv('TFM_CONFIG_FILE') !== false ? getenv('TFM_CONFIG_FILE') : __DIR__.'/config.php'; if (is_readable($config_file)) { @include($config_file); } From 1d5dc4054384d6453b7a612a78da560830f1826b Mon Sep 17 00:00:00 2001 From: Andrei Bautu Date: Sat, 26 Nov 2022 10:24:49 +0200 Subject: [PATCH 2/2] Add environmental variables for configuration --- tinyfilemanager.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tinyfilemanager.php b/tinyfilemanager.php index 6a8319d..8dc183d 100644 --- a/tinyfilemanager.php +++ b/tinyfilemanager.php @@ -138,10 +138,11 @@ if (getenv('TFM_USE_AUTH') !== false) { } if (getenv('TFM_AUTH_USERS') !== false) { - $auth_users = array_map( - function($x) { return explode('=', $x); }, - explode(',', getenv('TFM_AUTH_USERS')) - ); + $auth_users = array(); + foreach(explode(',', getenv('TFM_AUTH_USERS')) as $u) { + $u = explode('=', $u); + $auth_users[$u[0]] = $u[1]; + } } if (getenv('TFM_READONLY_USERS') !== false) {