mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-05-06 11:09:18 +02:00
94 lines
3.4 KiB
PHP
94 lines
3.4 KiB
PHP
<?php
|
|
require_once __DIR__ . "/../../bootstrap.php";
|
|
require_once __DIR__ . '/../../src/AdminAuth.php';
|
|
AdminAuth::requireLogin();
|
|
|
|
$pageTitle = "Paramètres";
|
|
|
|
$hasPassword = AdminAuth::hasPassword();
|
|
$maintenanceOn = file_exists(APP_ROOT . '/storage/maintenance.flag');
|
|
|
|
require_once APP_ROOT . '/src/Database.php';
|
|
require_once APP_ROOT . '/src/SmtpRelay.php';
|
|
$db = new Database();
|
|
$siteSettings = $db->getAllSettings();
|
|
$stats = $db->getThesesStats();
|
|
$smtpSettings = SmtpRelay::getSettings($db);
|
|
$smtpConfigured = SmtpRelay::isConfigured($db);
|
|
|
|
// ── System section ────────────────────────────────────────────────────────────
|
|
require_once APP_ROOT . '/src/SystemCache.php';
|
|
require_once APP_ROOT . '/src/Controllers/SystemController.php';
|
|
|
|
$_db2 = new Database();
|
|
$_cache = new SystemCache($_db2->getPDO());
|
|
$_controller = new SystemController($_db2, $_cache);
|
|
|
|
if (isset($_GET['refresh']) && $_GET['refresh'] === '1') {
|
|
$_controller->invalidateAll();
|
|
}
|
|
|
|
$statusData = $_controller->getStatusData();
|
|
$checks = $statusData['checks'];
|
|
$statusCached = $statusData['cached'];
|
|
$statusCacheAge = $statusData['cacheAge'];
|
|
|
|
$phpInfo = $_controller->getPhpInfo();
|
|
$diskInfo = $_controller->getDiskInfo();
|
|
|
|
$diskTotal = $diskInfo['total'];
|
|
$diskFree = $diskInfo['free'];
|
|
$diskUsed = $diskInfo['used'];
|
|
$diskPct = $diskInfo['pct'];
|
|
$diskColor = SystemController::diskColor($diskPct);
|
|
|
|
// ── Logs section ──────────────────────────────────────────────────────────────
|
|
$activeTab = $_GET['tab'] ?? 'nginx_access';
|
|
if ($activeTab === 'status') {
|
|
$activeTab = 'nginx_access';
|
|
} elseif ($activeTab !== 'nginx_config' && !array_key_exists($activeTab, SystemController::LOG_FILES)) {
|
|
$activeTab = 'nginx_access';
|
|
}
|
|
|
|
$selectedN = isset($_GET['n']) ? (int) $_GET['n'] : 100;
|
|
if (!in_array($selectedN, SystemController::ALLOWED_LINES, true)) {
|
|
$selectedN = 100;
|
|
}
|
|
|
|
$logLines = null;
|
|
$logError = null;
|
|
$logFileMeta = null;
|
|
|
|
$nginxConfigLines = null;
|
|
$nginxConfigSource = null;
|
|
$nginxConfigError = null;
|
|
$nginxConfigMeta = null;
|
|
|
|
if ($activeTab === 'nginx_config') {
|
|
$nginxData = $_controller->getNginxConfigData();
|
|
$nginxConfigLines = $nginxData['lines'];
|
|
$nginxConfigSource = $nginxData['source'];
|
|
$nginxConfigMeta = $nginxData['meta'];
|
|
$nginxConfigError = $nginxData['error'];
|
|
} else {
|
|
$logData = $_controller->getLogData($activeTab, $selectedN);
|
|
$logLines = $logData['lines'];
|
|
$logError = $logData['error'];
|
|
$logFileMeta = $logData['meta'];
|
|
}
|
|
|
|
$collapsed = $_COOKIE['sys_collapsed'] ?? null;
|
|
$statusInitiallyCollapsed = $collapsed === '1';
|
|
|
|
// ── Page setup ────────────────────────────────────────────────────────────────
|
|
if (empty($_SESSION['csrf_token'])) {
|
|
$_SESSION['csrf_token'] = bin2hex(random_bytes(32));
|
|
}
|
|
|
|
$isAdmin = true; $bodyClass = 'admin-body';
|
|
$extraCss = ['/assets/css/system.css'];
|
|
require_once APP_ROOT . '/templates/head.php';
|
|
include APP_ROOT . '/templates/header.php';
|
|
include APP_ROOT . '/templates/admin/parametres.php';
|
|
require_once APP_ROOT . '/templates/admin/footer.php';
|