tinyfilemanager/config.php
Joao Alves 470e1e6d81 Added environment variables read from files (secrets).
Updated base image to php 8.2.13/apline3.18
2023-12-11 16:47:41 +00:00

230 lines
7.4 KiB
PHP

<?php
/*
#################################################################################################################
This is an OPTIONAL configuration file.
The role of this file is to make updating of "tinyfilemanager.php" easier.
So you can:
-Feel free to remove completely this file and configure "tinyfilemanager.php" as a single file application.
or
-Put inside this file all the static configuration you want and forgot to configure "tinyfilemanager.php".
#################################################################################################################
*/
// Auth with login/password
// set true/false to enable/disable it
// Is independent from IP white- and blacklisting
$use_auth = true;
// Login user name and password
// Users: array('Username' => 'Password', 'Username2' => 'Password2', ...)
// Generate secure password hash - https://tinyfilemanager.github.io/docs/pwd.html
$auth_users = array(
# 'admin' => '$2y$10$/K.hjNr84lLNDt8fTXjoI.DBp6PpeyoJ.mGwrrLuCZfAwfSAGqhOW', //admin@123
# 'user' => '$2y$10$Fg6Dz8oH9fPoZ2jJan5tZuv6Z4Kp7avtQ9bDfrdRntXtPeiMAZyGO' //12345
);
// Readonly users
// e.g. array('users', 'guest', ...)
$readonly_users = array(
// 'user'
);
function encode_password_if_not_encoded($password) {
if (substr($password,0,3) == '$2y') {
return $password;
} else {
return password_hash($password, PASSWORD_BCRYPT);
}
}
function getenv_file($envvar) {
$envfile = getenv($envvar . '_FILENAME');
if ($envfile !== false && file_exists($envfile)) {
$file = fopen($envfile, "r");
$readed = fread($file, filesize($envfile));
fclose($file);
return $readed;
} elseif (getenv($envvar) !== false) {
return getenv($envvar);
} else {
return false;
}
}
$use_ldap = false;
// LDAP With variables:
/*
$use_ldap = true;
$ldap_server = 'ldap://theserver:389';
$ldap_searchfilter = 'dc=EXAMPLE,dc=ORG';
$ldap_domain = 'example';
$ldap_filter = '(|(sAMAccountName=%s)(UserPrincipalName=%s))';
$ldap_admin_groups = 'CN=tinyfilemanager-admins,OU=GROUPS,DC=example,DC=org;CN=tinyfilemanager-managers,OU=GROUPS,DC=example,DC=org';
$ldap_user_groups = 'CN=tinyfilemanager-users,OU=GROUPS,DC=example,DC=org';
$ldap_audit_field = 'samaccountname';
*/
// LDAP With envrionment variables:
if (getenv_file('LDAP_URL') !== false) {
if (!function_exists("ldap_connect")) {
die ("get_ldap_auth(): php-ldap is not installed. Search aborted.");
}
$use_ldap = true;
$ldap_server = getenv_file('LDAP_URL');
$ldap_searchfilter = getenv_file('LDAP_BASE_SEARCH');
$ldap_domain = (getenv_file('LDAP_DOMAIN') !== false) ? getenv_file('LDAP_DOMAIN') : '';
$ldap_filter = (getenv_file('LDAP_FILTER') !== false) ? getenv_file('LDAP_FILTER') : '(|(sAMAccountName=%s)(UserPrincipalName=%s))';
if (getenv_file('LDAP_ADMIN_GROUPS') !== false) {
$ldap_admin_groups = explode(';', getenv_file('LDAP_ADMIN_GROUPS'));
}
if (getenv_file('LDAP_USER_GROUPS') !== false) {
$ldap_user_groups = explode(';', getenv_file('LDAP_USER_GROUPS'));
}
$ldap_audit_field = 'samaccountname';
}
// Local Users/Admins:
if ( getenv_file('ADMIN_USER') !== false && getenv_file('ADMIN_PASS') !== false) {
$auth_users[getenv_file('ADMIN_USER')] = encode_password_if_not_encoded(getenv_file('ADMIN_PASS'));
}
if ( getenv_file('RO_USER') !== false && getenv_file('RO_PASS') !== false) {
$auth_users[getenv_file('RO_USER')] = encode_password_if_not_encoded(getenv_file('RO_PASS'));
array_push($readonly_users, getenv_file('RO_USER'));
}
// Set to false to disable auditing:
$use_auditing = true;
// syslog settings:
$use_syslog = false;
/*
$use_syslog = true;
$syslog_server = 'syslogserver.example.org';
$syslog_port = 514;
$syslog_proto = 'udp';
$syslog_json = false;
$syslog_facility = 13;
$syslog_hostname = gethostname();
*/
if (getenv_file('SYSLOG_SERVER') !== false) {
$use_syslog = true;
$syslog_server = getenv_file('SYSLOG_SERVER');
$syslog_port = (getenv_file('SYSLOG_PORT') !== false) ? intval(getenv_file('SYSLOG_PORT')) : 514;
$syslog_proto = (getenv_file('SYSLOG_PROTO') !== false) ? strtolower(getenv_file('SYSLOG_PROTO')) : 'udp';
$syslog_json = (getenv_file('SYSLOG_JSON') !== false) ? true : false;
$syslog_facility = (getenv_file('SYSLOG_FACILITY') !== false) ? intval(getenv_file('SYSLOG_FACILITY')) : 13; // LogAudit
if ($syslog_facility < 0 || $syslog_facility > 23 ) { // Value must be between 0 and 23
$syslog_facility = 13;
}
$syslog_hostname = gethostname();
}
//set application theme
$theme = 'light';
//options - 'light' and 'dark'
if ( getenv_file('THEME') !== false) {
$theme = getenv_file('THEME');
}
// Enable highlight.js (https://highlightjs.org/) on view's page
$use_highlightjs = true;
// highlight.js style
// for dark theme use 'ir-black'
if ($theme == 'light') {
$highlightjs_style = 'vs';
} else {
$highlightjs_style = 'ir-black';
}
// Enable ace.js (https://ace.c9.io/) on view's page
$edit_files = true;
// Default timezone for date() and time()
// Doc - http://php.net/manual/en/timezones.php
$default_timezone = 'Etc/UTC'; // UTC
// Root path for file manager
// use absolute path of directory i.e: '/var/www/folder' or $_SERVER['DOCUMENT_ROOT'].'/folder'
$root_path = getenv_file('ROOT_FS') !== false ? getenv_file('ROOT_FS') : $_SERVER['DOCUMENT_ROOT'];
// Root url for links in file manager.Relative to $http_host. Variants: '', 'path/to/subfolder'
// Will not working if $root_path will be outside of server document root
$root_url = '';
// Server hostname. Can set manually if wrong
$http_host = $_SERVER['HTTP_HOST'];
// user specific directories
// array('Username' => 'Directory path', 'Username2' => 'Directory path', ...)
$directories_users = array();
// input encoding for iconv
$iconv_input_encoding = 'UTF-8';
// date() format for file modification date
// Doc - https://www.php.net/manual/en/datetime.format.php
$datetime_format = 'Y-m-d H:i:s';
// Allowed file extensions for create and rename files
// e.g. 'txt,html,css,js'
$allowed_file_extensions = '';
// Allowed file extensions for upload files
// e.g. 'gif,png,jpg,html,txt'
$allowed_upload_extensions = '';
// Favicon path. This can be either a full url to an .PNG image, or a path based on the document root.
// full path, e.g http://example.com/favicon.png
// local path, e.g images/icons/favicon.png
$favicon_path = '';
// Files and folders to excluded from listing
// e.g. array('myfile.html', 'personal-folder', '*.php', ...)
$exclude_items = array();
// Online office Docs Viewer
// Availabe rules are 'google', 'microsoft' or false
// google => View documents using Google Docs Viewer
// microsoft => View documents using Microsoft Web Apps Viewer
// false => disable online doc viewer
$online_viewer = 'google';
// Sticky Nav bar
// true => enable sticky header
// false => disable sticky header
$sticky_navbar = true;
// max upload file size
$max_upload_size_bytes = 5000000000; // size 5,000,000,000 bytes (~5GB)
// Possible rules are 'OFF', 'AND' or 'OR'
// OFF => Don't check connection IP, defaults to OFF
// AND => Connection must be on the whitelist, and not on the blacklist
// OR => Connection must be on the whitelist, or not on the blacklist
$ip_ruleset = 'OFF';
// Should users be notified of their block?
$ip_silent = true;
// IP-addresses, both ipv4 and ipv6
$ip_whitelist = array(
'127.0.0.1', // local ipv4
'::1' // local ipv6
);
// IP-addresses, both ipv4 and ipv6
$ip_blacklist = array(
'0.0.0.0', // non-routable meta ipv4
'::' // non-routable meta ipv6
);
?>