From f3c941a1accce89d5285275ec87ec8b0bd54992f Mon Sep 17 00:00:00 2001 From: Andrei Bautu Date: Sat, 26 Nov 2022 08:57:31 +0200 Subject: [PATCH 1/4] Fix PHP 8 incompatibility --- tinyfilemanager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tinyfilemanager.php b/tinyfilemanager.php index e563bf9..9daf0b1 100644 --- a/tinyfilemanager.php +++ b/tinyfilemanager.php @@ -2133,7 +2133,7 @@ $tableTheme = (FM_THEME == "dark") ? "text-white bg-dark table-dark" : "bg-white } else { ?> - + '.fm_get_filesize($all_files_size).'' ?> '.$num_files.'' ?> '.$num_folders.'' ?> From 348de7135430330de155ec3c81ce4a630ff467a0 Mon Sep 17 00:00:00 2001 From: Andrei Bautu Date: Sat, 26 Nov 2022 10:24:49 +0200 Subject: [PATCH 2/4] Add environmental variables for configuration --- tinyfilemanager.php | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/tinyfilemanager.php b/tinyfilemanager.php index 9daf0b1..dc7c048 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 5ebea63410d4f051988d83da3fbed999a6f19b52 Mon Sep 17 00:00:00 2001 From: Andrei Bautu Date: Sat, 26 Nov 2022 10:24:49 +0200 Subject: [PATCH 3/4] 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 4/4] 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) {