🌴 Sync 2026-03-05 23:51:42

This commit is contained in:
github-actions[bot] committed 2026-03-05 23:51:42 +08:00
1 parent 97c049ed0a
commit 0acff03804
14253 files changed
+3893239

No files matched your search

@@ -0,0 +1,12 @@
config main
option use_auth '1'
list auth_users 'admin:$2y$10$BewzfQXrlnUihprEgGt7ROMB9NigZcZkkwssIRYznF9fwMuObIZoa'
list auth_users 'user:$2y$10$Fg6Dz8oH9fPoZ2jJan5tZuv6Z4Kp7avtQ9bDfrdRntXtPeiMAZyGO'
list readonly_users 'user'
option date_format 'd.m.o'
option time_format 'H:i:s'
option show_second '0'
option favicon_path '/tinyfilemanager/rootfs/etc/tinyfilemanager/favicon.png'
option online_viewer '0'
+132
View File
@@ -0,0 +1,132 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2022-2023 muink
. "${IPKG_INSTROOT}/lib/functions.sh"
START=99
USE_PROCD=1
VERSION='2.6'
EXTRA_COMMANDS="check"
EXTRA_HELP=\
" check Check for version updates"
CONFIG_NAME='tinyfilemanager'
TYPEDSECTION='main'
WORKDIR="/www/tinyfilemanager"
VARDIR="/var/tinyfilemanager"
CONF="/var/etc/tinyfilemanager.conf"
HOMEPATH="tinyfilemanager/rootfs"
if [ "$(uci -q get $CONFIG_NAME.@$TYPEDSECTION[0].proxy_enabled)" == "1" ]; then
export ALL_PROXY=$(uci -q get $CONFIG_NAME.@$TYPEDSECTION[0].proxy_protocol)://$(uci -q get $CONFIG_NAME.@$TYPEDSECTION[0].proxy_server)
fi
validate_section() {
uci_load_validate $CONFIG_NAME $TYPEDSECTION "$1" "$2" \
'defconf:string' \
'use_auth:bool:0' \
'auth_users:list(string)' \
'readonly_users:list(string)' \
'global_readonly:bool:0' \
'root_path:directory' \
'date_format:or("d.m.o", "d-m-o", "d/m/o", "j.n.o", "j-n-o", "j/n/o", "o.m.d", "o-m-d", "o/m/d", "o.n.j", "o-n-j", "o/n/j"):d.m.o' \
'time_format:or("H\:i\:s", "G\:i\:s", "A h\:i\:s", "A g\:i\:s", "h\:i\:s A", "g\:i\:s A"):H\:i\:s' \
'show_second:bool:0' \
'favicon_path:string' \
'exclude_items:list(string)' \
'online_viewer:or("0", "google", "microsoft"):0' \
'max_upload_size:and(uinteger,max(2048))'
}
init_config() {
local defconf="$(sed -n '/^\/\/Default Configuration/,/^$/p' "$WORKDIR/index.php" | tr '\n' '|' | sed 's,|,\\n,g')"
sed -n "/\/\/ --- EDIT BELOW CONFIGURATION CAREFULLY ---/,/\/\/ --- EDIT BELOW CAREFULLY OR DO NOT EDIT AT ALL ---/{ \
s|// --- EDIT BELOW CONFIGURATION CAREFULLY ---|\<?php\n$defconf|; \
s|// --- EDIT BELOW CAREFULLY OR DO NOT EDIT AT ALL ---|?\>|; \
/\/\/ if User has the external config file, try to use it to override the default config above/,/^}/d; \
p \
}" "$WORKDIR/index.php" > "$1"
sed -Ei "s|(^\\\$root_path =)(.+)|\1 \\\$_SERVER['DOCUMENT_ROOT'].'/$HOMEPATH';|; \
s|(^\\\$root_url =)(.+)|\1 '$HOMEPATH';|; \
s|(^\\\$default_timezone =)(.+)|\1 '$(uci -q get system.@system[0].zonename)';| \
" "$1"
}
apply_config() {
[ "$2" == "0" ] || { >&2 echo "section $1 validation failed"; return 1; }
local _conf="$CONF"
local auth_users=$(echo "$auth_users"|sed -E "s/('[^']+'|[^' ]+)/'\1'/g; s|:|' => '|g; s|''|'|g; s|' '|',\\\n '|g; s|^| |")
local readonly_users=$(echo "$readonly_users"|sed -E "s/('[^']+'|[^' ]+)/'\1'/g; s|''|'|g; s|' '|',\\\n '|g; s|^| |")
local exclude_items=$(echo "$exclude_items"|sed -E "s/('[^']+'|[^' ]+)/'\1'/g; s|''|'|g; s|' '|',\\\n '|g; s|^| |")
[ -n "$defconf" ] && sed -Ei "s|^\\\$CONFIG\s*=.*|\$CONFIG = '$defconf'\;|" "$_conf"
[ "$use_auth" -eq "1" ] && sed -Ei "s|(^\\\$use_auth =)(.+)|\1 true;|" "$_conf" || sed -Ei "s|(^\\\$use_auth =)(.+)|\1 false;|" "$_conf"
[ "$global_readonly" -eq "1" ] && sed -Ei "s|(^\\\$global_readonly =)(.+)|\1 true;|" "$_conf" || sed -Ei "s|(^\\\$global_readonly =)(.+)|\1 false;|" "$_conf"
sed -Ei "/^\\\$auth_users /,/\);/{/^ /d}" "$_conf" && sed -Ei "/^\\\$auth_users /a\ $auth_users" "$_conf"
sed -Ei "/^\\\$readonly_users /,/\);/{/^ /d}" "$_conf" && sed -Ei "/^\\\$readonly_users /a\ $readonly_users" "$_conf"
sed -Ei "/^\\\$exclude_items /{s|array\(\);|array(\n);|}" "$_conf" && sed -Ei "/^\\\$exclude_items /a\ $exclude_items" "$_conf"
sed -Ei "s|(^\\\$default_timezone =)(.+)|\1 '$(uci -q get system.@system[0].zonename)';|" "$_conf"
if [ -n "$root_path" ]; then
sed -Ei "s|(^\\\$root_path =)(.+)|\1 \\\$_SERVER['DOCUMENT_ROOT'].'/${HOMEPATH}$root_path';|; \
s|(^\\\$root_url =)(.+)|\1 '${HOMEPATH}$root_path';| \
" "$_conf"
fi
sed -Ei "s|(^\\\$datetime_format =)(.+)|\1 '$date_format $time_format';|" "$_conf"
[ "$show_second" -eq "0" ] && sed -Ei "/^\\\$datetime_format =/{s|:s||}" "$_conf"
sed -Ei "s|(^\\\$favicon_path =)(.+)|\1 '$favicon_path';|" "$_conf"
if [ "$online_viewer" == "0" ]; then sed -Ei "s|(^\\\$online_viewer =)(.+)|\1 false;|" "$_conf"
else sed -Ei "s|(^\\\$online_viewer =)(.+)|\1 '$online_viewer';|" "$_conf"
fi
if [ "$(( $max_upload_size +0 ))" == "0" ]; then sed -Ei "s|(^\\\$max_upload_size_bytes =)(.+)|\1 26214400;|" "$_conf" #25M
else sed -Ei "s|(^\\\$max_upload_size_bytes =)(.+)|\1 $(( $max_upload_size * 1024**2 ));|" "$_conf"
fi
}
start_service() {
mkdir /var/etc 2>/dev/null
touch "$CONF"
ln -s "$CONF" "$WORKDIR/config.php" 2>/dev/null
init_config "$CONF"
config_load "$CONFIG_NAME"
config_foreach validate_section "$TYPEDSECTION" apply_config
# CONFIG save
procd_open_instance "config-save"
procd_set_param command "/usr/libexec/tinyfilemanager-config-save"
procd_set_param env CONF=$CONF
procd_set_param respawn
#procd_set_param stdout 1
#procd_set_param stderr 1
procd_close_instance
}
service_triggers() {
procd_add_reload_trigger "$CONFIG_NAME" 'system'
}
check() {
local owner='prasathmani'
local repo='tinyfilemanager'
mkdir $VARDIR 2>/dev/null
curl -sSL https://api.github.com/repos/$owner/$repo/releases \
| grep '"tag_name":' | sed "/$VERSION/,\${/$VERSION/b;d}" \
| sed -E 's|",||g; s|^.+"([^"]+)|\1|g' \
> "$VARDIR/releaseslist"
[ "$?" != 0 ] || sed -i 'i\master' "$VARDIR/releaseslist"
}
reload_service() {
restart "$@"
}
@@ -0,0 +1,33 @@
location = /tinyfilemanager/ {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
if (!-f $document_root$fastcgi_script_name) {
return 404;
}
# Mitigate https://httpoxy.org/ vulnerabilities
fastcgi_param HTTP_PROXY "";
#error_log /dev/null;
fastcgi_connect_timeout 300s;
fastcgi_read_timeout 300s;
fastcgi_send_timeout 300s;
fastcgi_buffer_size 32k;
fastcgi_buffers 4 32k;
fastcgi_busy_buffers_size 32k;
fastcgi_temp_file_write_size 32k;
client_body_timeout 10s;
send_timeout 60s; # default, increase if experiencing a lot of timeouts.
output_buffers 1 32k;
fastcgi_index index.php;
include fastcgi_params;
# Only throw it at PHP-FPM if file exists (prevents PHP exploits).
fastcgi_pass 127.0.0.1:1026; # or: unix:/var/run/php-fpm.sock;
# fastcgi_pass unix:/var/run/php8-fpm.sock;
# SCRIPT_FILENAME parameter is used for PHP FPM determining
# the script name. If it is not set in fastcgi_params file,
# i.e. /etc/nginx/fastcgi_params or in the parent contexts,
# please comment off following line:
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 234 B

@@ -0,0 +1,12 @@
#!/bin/sh
# uhttpd
uci -q get uhttpd.main.index_page|grep -i 'index.php' >/dev/null || uci add_list uhttpd.main.index_page='index.php'
uci -q get uhttpd.main.interpreter|grep -i '.php=/usr/bin/php-cgi' >/dev/null || uci add_list uhttpd.main.interpreter='.php=/usr/bin/php-cgi'
uci changes uhttpd|grep . >/dev/null && uci commit uhttpd
/etc/init.d/uhttpd reload
# nginx
[ -n "$(command -v nginx)" ] && /etc/init.d/nginx reload
exit 0