Add support user customized config file (if exists) (#242)

* feat(/): add support user customized config file (if exists)

* Show current process ID in Status bar + Make fm_get_filesize function much more concise (#245)

* Update Simplified Chinese (#241)

* Feature Font Size Choose Options / Bug Fix Settings not visible in auth=false (#240)

* Bug fix and PR #245, #241, #240

Co-authored-by: 刘明野 <898310895@qq.com>
Co-authored-by: B Bharath Kumar Reddy <39063133+bbharathkumarreddy@users.noreply.github.com>
Co-authored-by: Prasath Mani <prasath.mani@publicissapient.com>
Co-authored-by: Prasath Mani <prasathmani@users.noreply.github.com>
This commit is contained in:
Nguyen The Anh 2020-05-24 12:20:25 +09:00 committed by GitHub
parent a0c595a8e1
commit 0826838917
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 118 additions and 14 deletions

View file

@ -100,11 +100,22 @@ $online_viewer = 'google';
// false => disable sticky header
$sticky_navbar = true;
// max upload file size
$max_upload_size_bytes = 2048;
// if User has the customized config file, try to use it to override the default config above
$user_config_file_path = 'user_config.php';
if(file_exists($user_config_file_path)) {
include($user_config_file_path);
}
// Maximum file upload size
// Increase the following values in php.ini to work properly
// memory_limit, upload_max_filesize, post_max_size
define('MAX_UPLOAD_SIZE', '2048');
// 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
@ -128,6 +139,9 @@ $ip_blacklist = array(
// --- EDIT BELOW CAREFULLY OR DO NOT EDIT AT ALL ---
// Set the max upload file size
define('MAX_UPLOAD_SIZE', $max_upload_size_bytes);
// private key and session name to store to the session
if ( !defined( 'FM_SESSION_ID')) {
define('FM_SESSION_ID', 'filemanager');
@ -2413,17 +2427,9 @@ function fm_get_size($file)
*/
function fm_get_filesize($size)
{
if ($size < 1000) {
return sprintf('%s B', $size);
} elseif (($size / 1024) < 1000) {
return sprintf('%s KB', round(($size / 1024), 2));
} elseif (($size / 1024 / 1024) < 1000) {
return sprintf('%s MB', round(($size / 1024 / 1024), 2));
} elseif (($size / 1024 / 1024 / 1024) < 1000) {
return sprintf('%s GB', round(($size / 1024 / 1024 / 1024), 2));
} else {
return sprintf('%s TB', round(($size / 1024 / 1024 / 1024 / 1024), 2));
}
$units = array('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
$power = $size > 0 ? floor(log($size, 1024)) : 0;
return sprintf('%s %s', round($size / pow(1024, $power), 2), $units[$power]);
}
/**
@ -3964,14 +3970,12 @@ function lng($txt) {
$tr['en']['ProcessID'] = 'Process ID';
$tr['en']['HideColumns'] = 'Hide Perms/Owner columns';
$tr['en']['Check Latest Version']= 'Check Latest Version'; $tr['en']['Generate new password hash'] = 'Generate new password hash';
$tr['en']['Folder is empty'] = 'Folder is empty';
$tr['en']['Created'] = 'Created';
$tr['en']['You are logged in'] = 'You are logged in';
$tr['en']['Login failed. Invalid username or password'] = 'Login failed. Invalid username or password';
$tr['en']['password_hash not supported, Upgrade PHP version'] = 'password_hash not supported, Upgrade PHP version';
$i18n = fm_get_translations($tr);
$tr = $i18n ? $i18n : $tr;

View file

@ -1416,4 +1416,4 @@
}
}
]
}
}

100
user_config.php Normal file
View file

@ -0,0 +1,100 @@
<?php
// Auth with login/password (set true/false to enable/disable it)
// Is independent from IP white- and blacklisting
$use_auth = true;
// 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 (username array)
$readonly_users = array(
'user'
);
// 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
);
// user specific directories
// array('Username' => 'Directory path', 'Username2' => 'Directory path', ...)
$directories_users = array();
// Enable highlight.js (https://highlightjs.org/) on view's page
$use_highlightjs = true;
// highlight.js style
$highlightjs_style = 'vs';
// Enable ace.js (https://ace.c9.io/) on view's page
$edit_files = true;
// Default timezone for date() and time() - 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 = $_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'];
// input encoding for iconv
$iconv_input_encoding = 'UTF-8';
// date() format for file modification date
$datetime_format = 'd.m.y H:i';
// allowed file extensions for upload and rename
// e.g. 'gif,png,jpg'
$allowed_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 = '?img=favicon';
// Array of files and folders excluded from listing
// e.r array('myfile.html', 'personal-folder')
$GLOBALS['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 dov viewer
$GLOBALS['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 = 2048;
?>