Add system update feature, git-ignore local configs, and fix homepage request logging
- Exclude config.json and admin.json in .gitignore so live settings/passwords are never overwritten by git - Auto-generate config.json and admin.json with defaults if missing - Add config.json.example and admin.json.example reference templates - Add System Update page (/admin/update) in Admin Console to pull updates via Git with 1 click - Log effective page name in index.php instead of literal 'auto' - Add extra HAProxy/PFSense proxy headers to RequestLogger::getClientIp()
This commit is contained in:
+27
-2
@@ -20,10 +20,35 @@ class AdminAuth
|
||||
private function loadAdminConfig(): array
|
||||
{
|
||||
$path = $this->config['admin_config'];
|
||||
$examplePath = dirname($path) . '/admin.json.example';
|
||||
|
||||
if (!file_exists($path)) {
|
||||
return ['users' => [], 'security' => []];
|
||||
if (file_exists($examplePath)) {
|
||||
@copy($examplePath, $path);
|
||||
} else {
|
||||
$defaultAdminConfig = [
|
||||
'users' => [
|
||||
[
|
||||
'username' => 'admin',
|
||||
'password_hash' => password_hash('admin', PASSWORD_BCRYPT),
|
||||
'role' => 'admin',
|
||||
'created' => date('Y-m-d'),
|
||||
]
|
||||
],
|
||||
'security' => [
|
||||
'session_timeout' => 1800,
|
||||
'max_login_attempts' => 5,
|
||||
'lockout_duration' => 900,
|
||||
]
|
||||
];
|
||||
$dir = dirname($path);
|
||||
if (!is_dir($dir)) {
|
||||
@mkdir($dir, 0755, true);
|
||||
}
|
||||
@file_put_contents($path, json_encode($defaultAdminConfig, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
}
|
||||
$data = json_decode(file_get_contents($path), true);
|
||||
$data = file_exists($path) ? json_decode(file_get_contents($path), true) : null;
|
||||
return is_array($data) ? $data : ['users' => [], 'security' => []];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user