Skip to content

Commit 934334b

Browse files
authored
Updates
1 parent bed4479 commit 934334b

12 files changed

Lines changed: 237 additions & 271 deletions

File tree

.github/workflows/software-version-check.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,21 @@ jobs:
256256
grep "^FONTAWESOME_VER=" enginescript-variables.txt >> .github/temp_versions.txt
257257
fi
258258
259+
# TinyFileManager
260+
echo "::debug::Fetching TinyFileManager version..."
261+
TFM_API_RESPONSE=$(curl -s https://api.github.com/repos/prasathmani/tinyfilemanager/releases/latest)
262+
echo "::debug::TinyFileManager API Response: $TFM_API_RESPONSE"
263+
264+
LATEST_TFM=$(echo "$TFM_API_RESPONSE" | jq -r '.tag_name // empty')
265+
echo "::debug::Parsed TinyFileManager version: '$LATEST_TFM'"
266+
267+
if [[ -n "$LATEST_TFM" && "$LATEST_TFM" != "null" ]]; then
268+
check_version "TINYFILEMANAGER_VER" "$LATEST_TFM"
269+
else
270+
echo "::warning::Failed to fetch TinyFileManager version, keeping current version"
271+
grep "^TINYFILEMANAGER_VER=" enginescript-variables.txt >> .github/temp_versions.txt
272+
fi
273+
259274
# Update date only if versions changed
260275
if [[ "$CHANGES_DETECTED" = true ]]; then
261276
echo "changes_detected=true" >> $GITHUB_OUTPUT

CHANGELOG.md

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,78 @@
1-
# Changelog
1+
# Chan## 2025-07-07
2+
3+
### 🏷️ OFFICIAL RELEASE INTEGRATION
4+
- **Version Management**: Switched TinyFileManager to official tagged releases instead of master branch
5+
- **Release Tracking**: Added `TINYFILEMANAGER_VER="2.6"` to `enginescript-variables.txt`
6+
- Uses official GitHub release tags instead of master branch
7+
- Downloads from `https://github.com/prasathmani/tinyfilemanager/archive/refs/tags/{version}.tar.gz`
8+
- Ensures stable, tested releases rather than development code
9+
- **Automated Updates**: Integrated TinyFileManager into GitHub Actions version checking workflow
10+
- Automatically detects new releases via GitHub API
11+
- Updates version variable when new stable releases are available
12+
- Includes in centralized dependency tracking system
13+
- **Complete Reference Cleanup**: Removed all traces of deprecated custom wrapper system
14+
- Eliminated all references to removed `filemanager.php` from API and control panel
15+
- Removed all mentions of `/etc/enginescript/filemanager.conf` from scripts
16+
- Updated control panel links to point directly to `/enginescript/tinyfilemanager/tinyfilemanager.php`
17+
- Converted `reset-filemanager-password.sh` to informational notice about native configuration
18+
- **Installation Updates**: Modified installation scripts to use versioned releases
19+
- Admin control panel script now uses `${TINYFILEMANAGER_VER}` variable
20+
- Proper TAR.GZ extraction instead of ZIP for better compatibility
21+
- Removed filemanager.conf creation from installation and update scripts
22+
23+
### 🔄 COMPLETE FILE MANAGER OVERHAULog
224

325
All notable changes to EngineScript will be documented in this file.
426

527
Changes are organized by date, with the most recent changes listed first.
628

29+
## 2025-07-07
30+
31+
### � COMPLETE FILE MANAGER OVERHAUL
32+
- **Official TinyFileManager Integration**: Completely replaced custom wrapper with official GitHub repository
33+
- **Repository Download**: Now downloads and extracts the complete official TinyFileManager from GitHub
34+
- Downloads latest master branch as ZIP from `https://github.com/prasathmani/tinyfilemanager/archive/refs/heads/master.zip`
35+
- Extracts to `/var/www/admin/enginescript/tinyfilemanager/` directory
36+
- Includes all official files, documentation, and features from the upstream project
37+
- **Custom Configuration Removal**: Eliminated complex custom authentication wrapper entirely
38+
- Removed `filemanager.php` custom wrapper with 100+ lines of authentication logic
39+
- Simplified to basic redirect: `header('Location: /enginescript/tinyfilemanager/');`
40+
- No more rate limiting, session management, or custom security headers in wrapper
41+
- **Native Configuration**: Uses official TinyFileManager configuration system
42+
- Created `/config/var/www/admin/tinyfilemanager/config.php` with basic EngineScript defaults
43+
- Default credentials: admin/admin (users can edit config.php directly)
44+
- Root path restricted to `/var/www` for security
45+
- Standard TinyFileManager settings with sensible defaults
46+
- **Installation Simplification**: Streamlined installation process in admin control panel script
47+
- Downloads official ZIP archive instead of single PHP file
48+
- Extracts complete project structure with proper permissions
49+
- Copies EngineScript configuration file during installation
50+
- Comprehensive error handling for download and extraction
51+
- **Legacy System Deprecation**: Marked custom configuration system as legacy
52+
- Updated `update-config-files.sh` to indicate native configuration usage
53+
- Removed dependency on `/etc/enginescript/filemanager.conf`
54+
- Simplified to direct editing of TinyFileManager's native config.php
55+
56+
### �🔧 FILE MANAGER SIMPLIFICATION
57+
- **Password Wrapper Removal**: Removed complex password wrapper and authentication workarounds from file manager
58+
- **Configuration Cleanup**: Removed `fm_password_hash` from file manager configuration file
59+
- Simplified `/config/etc/enginescript/filemanager.conf` to use basic username/password authentication
60+
- Removed automatic password hashing functionality that was causing compatibility issues
61+
- Streamlined configuration to focus on basic authentication settings
62+
- **PHP Authentication Simplification**: Removed complex password validation and hashing logic from `filemanager.php`
63+
- Eliminated password hash validation and placeholder checking routines
64+
- Removed dependency on PHP password_hash() function for authentication
65+
- Simplified credential loading to use direct username/password from configuration
66+
- Added basic default values (admin/admin) for immediate functionality
67+
- **Update Script Cleanup**: Removed password hashing logic from configuration update script
68+
- Simplified `update-config-files.sh` to handle basic credential updates without hashing
69+
- Removed PHP password_hash() calls that were causing authentication failures
70+
- Streamlined credential transfer from main configuration to file manager config
71+
- **Back to Basics Approach**: Returned to simple, straightforward file manager authentication
72+
- Eliminated complex authentication wrapper that was preventing proper login
73+
- Focused on reliable, basic authentication mechanism
74+
- Removed unnecessary security layers that were creating usability issues
75+
776
## 2025-07-06
877

978
### �🔧 DASHBOARD UX IMPROVEMENTS

config/etc/enginescript/filemanager.conf

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
11
# EngineScript File Manager Configuration
22
#
33
# This file contains the configuration for the Tiny File Manager integration
4-
# Default credentials for file manager access
4+
# Basic settings for file manager access
55
#
6-
# Security: This file contains sensitive information
6+
# Security: This file contains configuration settings
77
# Ensure proper file permissions: chmod 600 /etc/enginescript/filemanager.conf
88

99
# File Manager Authentication
1010
# Username for file manager access
1111
fm_username=
1212

13-
# Password for file manager access (will be populated from main credentials file)
13+
# Password for file manager access
1414
fm_password=
1515

16-
# Hashed password (automatically generated from fm_password)
17-
fm_password_hash=
18-
1916
# Root directory for file browsing (default: /var/www)
2017
fm_root_path=/var/www
2118

config/var/www/admin/control-panel/api.php

Lines changed: 14 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -415,52 +415,28 @@ function handleAlerts() {
415415

416416
function handleFileManagerStatus() {
417417
try {
418-
$fm_file = __DIR__ . '/filemanager.php';
419-
$tfm_file = __DIR__ . '/tinyfilemanager.php';
420-
$config_file = '/etc/enginescript/filemanager.conf';
421-
$credentials_file = '/home/EngineScript/enginescript-install-options.txt';
422-
423-
// Check if configuration exists and get username
424-
$fm_username = null;
425-
$config_exists = false;
426-
$config_populated = false;
427-
$credentials_configured = false;
428-
429-
if (file_exists($config_file)) {
430-
$config_content = file_get_contents($config_file);
431-
if (preg_match('/fm_username=(.+)/m', $config_content, $matches)) {
432-
$username = trim($matches[1]);
433-
if (!empty($username)) {
434-
$fm_username = $username;
435-
$config_populated = true;
436-
}
437-
}
438-
$config_exists = true;
418+
// Load EngineScript variables to get current version
419+
$variables = [];
420+
if (file_exists('/usr/local/bin/enginescript/enginescript-variables.txt')) {
421+
$content = file_get_contents('/usr/local/bin/enginescript/enginescript-variables.txt');
422+
preg_match('/TINYFILEMANAGER_VER="([^"]*)"/', $content, $matches);
423+
$current_version = isset($matches[1]) ? $matches[1] : '2.6';
424+
} else {
425+
$current_version = '2.6';
439426
}
440427

441-
// Check if main credentials are configured
442-
if (file_exists($credentials_file)) {
443-
$cred_content = file_get_contents($credentials_file);
444-
if (strpos($cred_content, 'FILEMANAGER_USERNAME="PLACEHOLDER"') === false &&
445-
strpos($cred_content, 'FILEMANAGER_PASSWORD="PLACEHOLDER"') === false) {
446-
$credentials_configured = true;
447-
}
448-
}
428+
$tfm_file = '/var/www/admin/enginescript/tinyfilemanager/tinyfilemanager.php';
429+
$tfm_config = '/var/www/admin/enginescript/tinyfilemanager/config.php';
449430

450431
$status = [
451-
'available' => file_exists($fm_file),
452-
'tfm_downloaded' => file_exists($tfm_file),
453-
'tfm_age_days' => file_exists($tfm_file) ? round((time() - filemtime($tfm_file)) / (24 * 60 * 60)) : null,
454-
'config_exists' => $config_exists,
455-
'config_populated' => $config_populated,
456-
'credentials_configured' => $credentials_configured,
457-
'username' => $fm_username,
432+
'available' => file_exists($tfm_file),
433+
'config_exists' => file_exists($tfm_config),
458434
'writable_dirs' => [
459435
'/var/www' => is_writable('/var/www'),
460436
'/tmp' => is_writable('/tmp')
461437
],
462-
'url' => '/filemanager.php',
463-
'password_reset_command' => 'sudo /usr/local/bin/enginescript/scripts/functions/shared/reset-filemanager-password.sh'
438+
'url' => '/enginescript/tinyfilemanager/tinyfilemanager.php',
439+
'version' => $current_version
464440
];
465441

466442
echo json_encode(sanitizeOutput($status)); // codacy:ignore - echo required for JSON API response
Lines changed: 5 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -1,130 +1,10 @@
11
<?php
22
/**
3-
* Tiny File Manager Integration for EngineScript Admin
4-
* Secure file management interface with restricted access
5-
*
6-
* @version 1.0.0
7-
* @security HIGH - File system access
3+
* Simple redirect to Tiny File Manager
4+
* Official TinyFileManager from GitHub repository
85
*/
96

10-
// Security checks - prevent direct access
11-
if (!isset($_SERVER['HTTP_HOST']) || !isset($_SERVER['REQUEST_URI'])) {
12-
http_response_code(403);
13-
die('Direct access forbidden');
14-
}
15-
16-
// Basic authentication check (integrate with your auth system)
17-
session_start();
18-
$client_ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : 'unknown';
19-
20-
// Rate limiting for file operations
21-
$rate_limit_key = 'fm_rate_' . hash('sha256', $client_ip);
22-
if (!isset($_SESSION[$rate_limit_key])) {
23-
$_SESSION[$rate_limit_key] = ['count' => 0, 'reset' => time() + 300]; // 5 minute window
24-
}
25-
26-
if (time() > $_SESSION[$rate_limit_key]['reset']) {
27-
$_SESSION[$rate_limit_key] = ['count' => 0, 'reset' => time() + 300];
28-
}
29-
30-
if ($_SESSION[$rate_limit_key]['count'] >= 50) { // 50 operations per 5 minutes
31-
http_response_code(429);
32-
die('Rate limit exceeded for file operations');
33-
}
34-
35-
$_SESSION[$rate_limit_key]['count']++;
36-
37-
// Load file manager configuration
38-
$fm_config_file = '/etc/enginescript/filemanager.conf';
39-
$fm_config = [];
40-
41-
if (file_exists($fm_config_file)) {
42-
$config_content = file_get_contents($fm_config_file);
43-
$config_lines = explode("\n", $config_content);
44-
45-
foreach ($config_lines as $line) {
46-
$line = trim($line);
47-
if (empty($line) || strpos($line, '#') === 0) {
48-
continue; // Skip empty lines and comments
49-
}
50-
51-
if (strpos($line, '=') !== false) {
52-
list($key, $value) = explode('=', $line, 2);
53-
$fm_config[trim($key)] = trim($value);
54-
}
55-
}
56-
}
57-
58-
// Set values from configuration file only - no defaults
59-
$fm_username = isset($fm_config['fm_username']) && !empty($fm_config['fm_username']) ? $fm_config['fm_username'] : null;
60-
$fm_password_hash = isset($fm_config['fm_password_hash']) && !empty($fm_config['fm_password_hash']) ? $fm_config['fm_password_hash'] : null;
61-
62-
// Check if credentials are properly configured
63-
if (empty($fm_username) || empty($fm_password_hash)) {
64-
// Check if main credentials file exists and has been configured
65-
if (file_exists('/home/EngineScript/enginescript-install-options.txt')) {
66-
$credentials_content = file_get_contents('/home/EngineScript/enginescript-install-options.txt');
67-
68-
// Check if credentials are still PLACEHOLDER values
69-
if (strpos($credentials_content, 'FILEMANAGER_USERNAME="PLACEHOLDER"') !== false ||
70-
strpos($credentials_content, 'FILEMANAGER_PASSWORD="PLACEHOLDER"') !== false) {
71-
72-
die('File Manager credentials not configured. Please edit your credentials file with command: es.config');
73-
} else {
74-
// Credentials configured but config file not updated
75-
die('File Manager configuration needs to be updated. Please run: sudo /usr/local/bin/enginescript/scripts/functions/shared/update-config-files.sh');
76-
}
77-
} else {
78-
die('EngineScript credentials file not found. Please ensure EngineScript is properly installed.');
79-
}
80-
}
81-
82-
$fm_root_path = isset($fm_config['fm_root_path']) && !empty($fm_config['fm_root_path']) ? $fm_config['fm_root_path'] : '/var/www';
83-
$fm_max_upload = isset($fm_config['fm_max_upload_size']) && !empty($fm_config['fm_max_upload_size']) ? (int)$fm_config['fm_max_upload_size'] : 104857600;
84-
$fm_readonly = isset($fm_config['fm_readonly']) && $fm_config['fm_readonly'] === 'true' ? true : false;
85-
86-
// Additional security headers
87-
header('X-Frame-Options: SAMEORIGIN');
88-
header('X-Content-Type-Options: nosniff');
89-
header('X-XSS-Protection: 1; mode=block');
90-
header('Referrer-Policy: strict-origin-when-cross-origin');
91-
92-
// Log file manager access
93-
$log_entry = date('Y-m-d H:i:s') . " [FILE_MANAGER] Access from IP: " . $client_ip . "\n";
94-
error_log($log_entry, 3, '/var/log/enginescript-filemanager.log');
95-
96-
// Download and include Tiny File Manager
97-
$tfm_file = __DIR__ . '/tinyfilemanager.php';
98-
$tfm_url = 'https://raw.githubusercontent.com/prasathmani/tinyfilemanager/master/tinyfilemanager.php';
99-
100-
// Download TFM if not exists or older than 30 days
101-
if (!file_exists($tfm_file) || (time() - filemtime($tfm_file)) > (30 * 24 * 60 * 60)) {
102-
$tfm_content = @file_get_contents($tfm_url);
103-
if ($tfm_content !== false) {
104-
file_put_contents($tfm_file, $tfm_content);
105-
chmod($tfm_file, 0644);
106-
} else {
107-
die('Unable to download Tiny File Manager. Please check internet connection.');
108-
}
109-
}
110-
111-
// Modify TFM file to use our credentials
112-
if (file_exists($tfm_file)) {
113-
$tfm_content = file_get_contents($tfm_file);
114-
115-
// Replace the hardcoded auth_users array with our credentials
116-
$new_auth_array = '$auth_users = array(\'' . $fm_username . '\' => \'' . $fm_password_hash . '\');';
117-
118-
// Pattern to match the existing $auth_users array (handles multi-line arrays)
119-
$pattern = '/\$auth_users\s*=\s*array\s*\([^;]*\);/s';
120-
121-
if (preg_match($pattern, $tfm_content)) {
122-
$tfm_content = preg_replace($pattern, $new_auth_array, $tfm_content);
123-
file_put_contents($tfm_file, $tfm_content);
124-
}
125-
126-
include $tfm_file;
127-
} else {
128-
die('Tiny File Manager not found. Please check installation.');
129-
}
7+
// Redirect to the official TinyFileManager installation
8+
header('Location: /enginescript/tinyfilemanager/');
9+
exit;
13010
?>

config/var/www/admin/control-panel/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ <h3>Adminer</h3>
421421
</div>
422422
</a>
423423

424-
<a href="/filemanager.php" target="_blank" rel="noopener noreferrer" class="tool-card" id="filemanager-tool">
424+
<a href="/enginescript/tinyfilemanager/tinyfilemanager.php" target="_blank" rel="noopener noreferrer" class="tool-card" id="filemanager-tool">
425425
<div class="tool-icon">
426426
<i class="fas fa-folder-open"></i>
427427
</div>
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?php
2+
/**
3+
* EngineScript TinyFileManager Configuration
4+
* Basic configuration for official TinyFileManager
5+
*/
6+
7+
// Basic authentication - users can modify this file directly
8+
$auth_users = array(
9+
'admin' => '$2y$10$3F7VnbFpPHIyFODrUQOgXKvGLgKfBgHZQT7xU8xvQ9qLpG3Rn7bCy' // password: admin
10+
);
11+
12+
// Set as non-global auth
13+
$use_auth = true;
14+
$readonly_users = array();
15+
16+
// Root path for file browsing - restrict to web directories
17+
$root_path = '/var/www';
18+
19+
// Root URL for links (leave blank for auto-detection)
20+
$root_url = '';
21+
22+
// Max upload size in bytes (100MB)
23+
$max_upload_size_bytes = 104857600;
24+
25+
// Exclude specific files/folders from listing
26+
$exclude_items = array(
27+
'.git',
28+
'.github',
29+
'.gitignore',
30+
'.htaccess',
31+
'config.php'
32+
);
33+
34+
// Theme (light, dark)
35+
$theme = 'light';
36+
37+
// Default timezone
38+
date_default_timezone_set('UTC');
39+
40+
// Edit files in popup or same window
41+
$edit_files = true;
42+
43+
// Enable/disable file and folder management
44+
$readonly = false;
45+
46+
// Session name for authentication
47+
$session_name = 'filemanager';
48+
49+
// Show directory size
50+
$show_dirs_size = false;
51+
52+
// Check for updates
53+
$check_for_updates = false;
54+
55+
// Online office viewer
56+
$online_viewer = false;
57+
58+
// Sticky navbar
59+
$sticky_navbar = true;
60+
?>

0 commit comments

Comments
 (0)