mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-05-07 03:29:19 +02:00
admin: merge status + logs into unified system.php with instant tabs
Replace the separate /admin/status.php and /admin/logs.php pages with a single /admin/system.php page organised around a tab bar. - system.php — top-level tab bar: 'Statut' + one tab per log file (nginx accès, nginx erreurs, PHP-FPM). Switching tabs is a plain href (?tab=…) so no JS required for navigation; the lines-selector SELECT triggers a location change on 'change' for instant reload without a submit button. - Status tab preserves all existing service cards, PHP runtime grid, and disk-usage bar from the old status.php. - Log tabs preserve line-count selector, file metadata bar, and per-line colour coding from the old logs.php. - New: copy-to-clipboard button on each log output block (Clipboard API with textarea execCommand fallback). - status.php / logs.php replaced with 301 redirect stubs so existing bookmarks and links keep working. - templates/admin/head.php: 'Statut' + 'Journaux' nav items replaced with a single 'Système' item; active state covers all three page names for redirect compatibility.
This commit is contained in:
4
TODO.md
4
TODO.md
@@ -334,5 +334,5 @@ Goal: rename the tables and column to the canonical M2M pattern (`tags`, `thesis
|
|||||||
- [x] Add server log viewer in admin panel (tail nginx error/access logs via SSH or log endpoint)
|
- [x] Add server log viewer in admin panel (tail nginx error/access logs via SSH or log endpoint)
|
||||||
- [ ] Add nginx config deploy flow to admin panel (upload `scripts/deploy-server.sh`, run remotely)
|
- [ ] Add nginx config deploy flow to admin panel (upload `scripts/deploy-server.sh`, run remotely)
|
||||||
- [x] Add admin user management UI — password change/set for PHP auth layer (`public/admin/account.php` + `actions/account.php`; "Compte" nav link; account CSS)
|
- [x] Add admin user management UI — password change/set for PHP auth layer (`public/admin/account.php` + `actions/account.php`; "Compte" nav link; account CSS)
|
||||||
- [ ] Merge `status.php` and `logs.php` into a single `system.php` page; remove "Statut" and "Journaux" nav links, add single "Système" link; preserve all existing content in their respective sections
|
- [x] Merge `status.php` and `logs.php` into a single `system.php` page; remove "Statut" and "Journaux" nav links, add single "Système" link; preserve all existing content in their respective sections
|
||||||
- [ ] Rework logs UI: replace the select-then-click-Afficher flow with instant tabs (nginx access, nginx error, php-fpm); switching tabs loads the selected log immediately without a form submit; add a copy-to-clipboard button per log view
|
- [x] Rework logs UI: replace the select-then-click-Afficher flow with instant tabs (nginx access, nginx error, php-fpm); switching tabs loads the selected log immediately without a form submit; add a copy-to-clipboard button per log view
|
||||||
|
|||||||
@@ -1,279 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
require_once __DIR__ . "/../../config/bootstrap.php";
|
// Redirects legacy /admin/logs.php → /admin/system.php?tab=nginx_access
|
||||||
require_once __DIR__ . '/../../src/AdminAuth.php';
|
header('Location: /admin/system.php?tab=nginx_access', true, 301);
|
||||||
AdminAuth::requireLogin();
|
exit;
|
||||||
|
|
||||||
$pageTitle = "Journaux serveur";
|
|
||||||
|
|
||||||
// ── Log file definitions ──────────────────────────────────────────────────────
|
|
||||||
// Paths match the nginx config (posterg_access.log / posterg_error.log).
|
|
||||||
// On the dev server these files won't exist; we handle that gracefully.
|
|
||||||
const LOG_FILES = [
|
|
||||||
'nginx_error' => ['label' => 'nginx — erreurs', 'path' => '/var/log/nginx/posterg_error.log'],
|
|
||||||
'nginx_access' => ['label' => 'nginx — accès', 'path' => '/var/log/nginx/posterg_access.log'],
|
|
||||||
'php_error' => ['label' => 'PHP-FPM — erreurs', 'path' => '/var/log/php8.4-fpm.log'],
|
|
||||||
];
|
|
||||||
|
|
||||||
const ALLOWED_LINES = [50, 100, 200, 500];
|
|
||||||
|
|
||||||
// ── Input validation ──────────────────────────────────────────────────────────
|
|
||||||
$selectedKey = $_GET['log'] ?? 'nginx_error';
|
|
||||||
$selectedN = isset($_GET['n']) ? (int) $_GET['n'] : 100;
|
|
||||||
|
|
||||||
if (!array_key_exists($selectedKey, LOG_FILES)) {
|
|
||||||
$selectedKey = 'nginx_error';
|
|
||||||
}
|
|
||||||
if (!in_array($selectedN, ALLOWED_LINES, true)) {
|
|
||||||
$selectedN = 100;
|
|
||||||
}
|
|
||||||
|
|
||||||
$logDef = LOG_FILES[$selectedKey];
|
|
||||||
$logPath = $logDef['path'];
|
|
||||||
|
|
||||||
// ── Read log ──────────────────────────────────────────────────────────────────
|
|
||||||
$lines = null; // null = unavailable, [] = empty, [...] = lines
|
|
||||||
$readError = null;
|
|
||||||
|
|
||||||
if (!function_exists('exec')) {
|
|
||||||
$readError = "exec() est désactivé sur ce serveur.";
|
|
||||||
} elseif (!file_exists($logPath)) {
|
|
||||||
$readError = "Fichier introuvable : " . htmlspecialchars($logPath);
|
|
||||||
} elseif (!is_readable($logPath)) {
|
|
||||||
$readError = "Fichier non lisible (permissions insuffisantes) : " . htmlspecialchars($logPath);
|
|
||||||
} else {
|
|
||||||
$output = [];
|
|
||||||
$rc = 0;
|
|
||||||
// tail -n N ensures we never load the whole file into memory
|
|
||||||
exec('tail -n ' . intval($selectedN) . ' ' . escapeshellarg($logPath) . ' 2>/dev/null', $output, $rc);
|
|
||||||
if ($rc !== 0) {
|
|
||||||
$readError = "Erreur lors de la lecture du fichier journal.";
|
|
||||||
} else {
|
|
||||||
// Reverse so newest lines appear first
|
|
||||||
$lines = array_reverse($output);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ── File metadata ─────────────────────────────────────────────────────────────
|
|
||||||
$fileMeta = null;
|
|
||||||
if (file_exists($logPath)) {
|
|
||||||
$size = filesize($logPath);
|
|
||||||
$mtime = filemtime($logPath);
|
|
||||||
$fileMeta = [
|
|
||||||
'size' => $size > 1048576
|
|
||||||
? number_format($size / 1048576, 2) . ' MB'
|
|
||||||
: number_format($size / 1024, 1) . ' KB',
|
|
||||||
'mtime' => date('d/m/Y H:i:s', $mtime),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
// ── Log-level classifier (for nginx error log coloring) ───────────────────────
|
|
||||||
/**
|
|
||||||
* Returns a CSS class based on the log level token in a log line.
|
|
||||||
* nginx error lines look like: 2024/01/15 12:34:56 [error] 1234#1234: …
|
|
||||||
* nginx access lines: 1.2.3.4 - - [15/Jan/2024:12:34:56 +0000] "GET / HTTP/1.1" 200 …
|
|
||||||
*/
|
|
||||||
function logLineClass(string $line): string {
|
|
||||||
// nginx error log: [crit], [error], [warn], [notice], [info], [debug]
|
|
||||||
if (preg_match('/\[(crit|emerg|alert)\]/', $line)) return 'log-crit';
|
|
||||||
if (preg_match('/\[error\]/', $line)) return 'log-error';
|
|
||||||
if (preg_match('/\[warn\]/', $line)) return 'log-warn';
|
|
||||||
if (preg_match('/\[notice\]/', $line)) return 'log-notice';
|
|
||||||
// access log: highlight HTTP 4xx / 5xx
|
|
||||||
if (preg_match('/" [45]\d\d /', $line)) return 'log-error';
|
|
||||||
if (preg_match('/" 3\d\d /', $line)) return 'log-notice';
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
require_once APP_ROOT . '/templates/admin/head.php';
|
|
||||||
?>
|
|
||||||
|
|
||||||
<style>
|
|
||||||
/* ── Log viewer layout ─────────────────────────────────────────────────── */
|
|
||||||
.log-toolbar {
|
|
||||||
display: flex;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
align-items: center;
|
|
||||||
gap: .6rem;
|
|
||||||
margin-bottom: 1.25rem;
|
|
||||||
}
|
|
||||||
.log-toolbar select,
|
|
||||||
.log-toolbar input[type=submit] {
|
|
||||||
background: var(--admin-bg-alt);
|
|
||||||
border: 1px solid var(--admin-border);
|
|
||||||
color: var(--admin-text);
|
|
||||||
border-radius: 4px;
|
|
||||||
padding: .4rem .7rem;
|
|
||||||
font-size: .85rem;
|
|
||||||
font-family: inherit;
|
|
||||||
}
|
|
||||||
.log-toolbar select:focus { outline: 2px solid var(--admin-purple); }
|
|
||||||
.log-toolbar input[type=submit] {
|
|
||||||
cursor: pointer;
|
|
||||||
background: var(--admin-purple);
|
|
||||||
border-color: var(--admin-purple);
|
|
||||||
color: #fff;
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
|
||||||
.log-toolbar input[type=submit]:hover { opacity: .85; }
|
|
||||||
|
|
||||||
.log-meta {
|
|
||||||
font-size: .78rem;
|
|
||||||
color: var(--admin-text-muted);
|
|
||||||
font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
|
|
||||||
margin-bottom: .75rem;
|
|
||||||
display: flex;
|
|
||||||
gap: 1.5rem;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
}
|
|
||||||
.log-meta span::before { content: attr(data-label) ": "; opacity: .6; }
|
|
||||||
|
|
||||||
.log-unavailable {
|
|
||||||
background: var(--admin-bg-alt);
|
|
||||||
border: 1px solid var(--admin-border);
|
|
||||||
border-radius: 4px;
|
|
||||||
padding: 1.5rem;
|
|
||||||
color: var(--admin-text-muted);
|
|
||||||
font-size: .88rem;
|
|
||||||
}
|
|
||||||
.log-unavailable .log-unavail-path {
|
|
||||||
font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
|
|
||||||
font-size: .8rem;
|
|
||||||
margin-top: .4rem;
|
|
||||||
opacity: .7;
|
|
||||||
}
|
|
||||||
|
|
||||||
.log-empty {
|
|
||||||
color: var(--admin-text-muted);
|
|
||||||
font-size: .88rem;
|
|
||||||
padding: 1rem 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Log output block */
|
|
||||||
.log-output {
|
|
||||||
background: #0d0d0d;
|
|
||||||
border: 1px solid var(--admin-border);
|
|
||||||
border-radius: 4px;
|
|
||||||
padding: 1rem;
|
|
||||||
overflow-x: auto;
|
|
||||||
font-family: ui-monospace, "SFMono-Regular", Consolas, "Courier New", monospace;
|
|
||||||
font-size: .76rem;
|
|
||||||
line-height: 1.55;
|
|
||||||
max-height: 72vh;
|
|
||||||
overflow-y: auto;
|
|
||||||
/* Reverse scroll so newest (first in DOM) is at top */
|
|
||||||
}
|
|
||||||
|
|
||||||
.log-line {
|
|
||||||
display: block;
|
|
||||||
white-space: pre;
|
|
||||||
padding: .05rem .1rem;
|
|
||||||
border-radius: 2px;
|
|
||||||
color: #bbb;
|
|
||||||
}
|
|
||||||
.log-line + .log-line { border-top: 1px solid rgba(255,255,255,.03); }
|
|
||||||
|
|
||||||
.log-crit { color: #ff7070; background: rgba(200,0,0,.12); }
|
|
||||||
.log-error { color: #f08080; }
|
|
||||||
.log-warn { color: #ffd080; }
|
|
||||||
.log-notice { color: #a0c8ff; }
|
|
||||||
|
|
||||||
/* line number gutter */
|
|
||||||
.log-line::before {
|
|
||||||
content: attr(data-n);
|
|
||||||
display: inline-block;
|
|
||||||
min-width: 4ch;
|
|
||||||
margin-right: .75rem;
|
|
||||||
opacity: .3;
|
|
||||||
text-align: right;
|
|
||||||
user-select: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.log-count-badge {
|
|
||||||
background: var(--admin-bg-alt);
|
|
||||||
border: 1px solid var(--admin-border);
|
|
||||||
border-radius: 3px;
|
|
||||||
font-size: .76rem;
|
|
||||||
padding: .15rem .5rem;
|
|
||||||
color: var(--admin-text-muted);
|
|
||||||
font-family: ui-monospace, monospace;
|
|
||||||
}
|
|
||||||
.log-refresh-note {
|
|
||||||
font-size: .78rem;
|
|
||||||
color: var(--admin-text-muted);
|
|
||||||
margin-bottom: 1.25rem;
|
|
||||||
}
|
|
||||||
.log-refresh-note a { color: var(--admin-purple); text-decoration: none; }
|
|
||||||
.log-refresh-note a:hover { text-decoration: underline; }
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<main class="admin-main">
|
|
||||||
<h1 class="admin-page-title">Journaux serveur</h1>
|
|
||||||
|
|
||||||
<p class="log-refresh-note">
|
|
||||||
Affiché le <?= date('d/m/Y à H:i:s') ?> —
|
|
||||||
<a href="?log=<?= htmlspecialchars($selectedKey) ?>&n=<?= $selectedN ?>">Rafraîchir</a>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<!-- Toolbar: log selector + line count -->
|
|
||||||
<form class="log-toolbar" method="get" action="">
|
|
||||||
<select name="log" aria-label="Fichier journal">
|
|
||||||
<?php foreach (LOG_FILES as $key => $def): ?>
|
|
||||||
<option value="<?= htmlspecialchars($key) ?>"
|
|
||||||
<?= $key === $selectedKey ? 'selected' : '' ?>>
|
|
||||||
<?= htmlspecialchars($def['label']) ?>
|
|
||||||
</option>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select name="n" aria-label="Nombre de lignes">
|
|
||||||
<?php foreach (ALLOWED_LINES as $n): ?>
|
|
||||||
<option value="<?= $n ?>" <?= $n === $selectedN ? 'selected' : '' ?>>
|
|
||||||
<?= $n ?> dernières lignes
|
|
||||||
</option>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<input type="submit" value="Afficher">
|
|
||||||
|
|
||||||
<?php if ($lines !== null && count($lines) > 0): ?>
|
|
||||||
<span class="log-count-badge"><?= count($lines) ?> ligne(s)</span>
|
|
||||||
<?php endif; ?>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<!-- File metadata -->
|
|
||||||
<?php if ($fileMeta): ?>
|
|
||||||
<div class="log-meta">
|
|
||||||
<span data-label="Fichier"><?= htmlspecialchars($logPath) ?></span>
|
|
||||||
<span data-label="Taille"><?= $fileMeta['size'] ?></span>
|
|
||||||
<span data-label="Modifié"><?= $fileMeta['mtime'] ?></span>
|
|
||||||
</div>
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
<!-- Output -->
|
|
||||||
<?php if ($readError !== null): ?>
|
|
||||||
<div class="log-unavailable">
|
|
||||||
<strong>Journaux non disponibles</strong>
|
|
||||||
<div class="log-unavail-path"><?= $readError ?></div>
|
|
||||||
<?php if (php_sapi_name() === 'cli-server'): ?>
|
|
||||||
<div style="margin-top:.6rem;font-size:.8rem;opacity:.7;">
|
|
||||||
En environnement de développement, les logs nginx ne sont pas disponibles.
|
|
||||||
Cette page est pleinement fonctionnelle sur le serveur de production.
|
|
||||||
</div>
|
|
||||||
<?php endif; ?>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<?php elseif (empty($lines)): ?>
|
|
||||||
<div class="log-empty">Le fichier journal est vide.</div>
|
|
||||||
|
|
||||||
<?php else: ?>
|
|
||||||
<div class="log-output" role="log" aria-live="off" aria-label="Contenu du journal">
|
|
||||||
<?php foreach ($lines as $i => $line): ?>
|
|
||||||
<span class="log-line <?= logLineClass($line) ?>"
|
|
||||||
data-n="<?= count($lines) - $i ?>"><?= htmlspecialchars($line, ENT_QUOTES | ENT_SUBSTITUTE) ?></span>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
</div>
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
</main>
|
|
||||||
|
|
||||||
<?php require_once APP_ROOT . '/templates/admin/footer.php'; ?>
|
|
||||||
|
|||||||
@@ -1,350 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
require_once __DIR__ . "/../../config/bootstrap.php";
|
// Redirects legacy /admin/status.php → /admin/system.php?tab=status
|
||||||
require_once __DIR__ . '/../../src/AdminAuth.php';
|
header('Location: /admin/system.php?tab=status', true, 301);
|
||||||
AdminAuth::requireLogin();
|
exit;
|
||||||
|
|
||||||
$pageTitle = "Statut serveur";
|
|
||||||
|
|
||||||
// ── helpers ──────────────────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Run a shell command safely and return trimmed stdout.
|
|
||||||
* Returns null if exec is disabled or the command fails.
|
|
||||||
*/
|
|
||||||
function safeExec(string $cmd): ?string {
|
|
||||||
if (!function_exists('exec')) return null;
|
|
||||||
$output = [];
|
|
||||||
$rc = 0;
|
|
||||||
exec($cmd . ' 2>/dev/null', $output, $rc);
|
|
||||||
return $rc === 0 ? trim(implode("\n", $output)) : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check whether a systemd unit is active.
|
|
||||||
* Returns 'active', 'inactive', 'failed', or null when unavailable.
|
|
||||||
*/
|
|
||||||
function systemdStatus(string $unit): ?string {
|
|
||||||
$raw = safeExec("systemctl is-active " . escapeshellarg($unit));
|
|
||||||
if ($raw === null) return null;
|
|
||||||
return in_array($raw, ['active', 'inactive', 'failed', 'activating', 'deactivating'], true)
|
|
||||||
? $raw : 'unknown';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Perform a local HTTP HEAD/GET and return [http_code, latency_ms] or null.
|
|
||||||
*/
|
|
||||||
function localHttpCheck(string $url): ?array {
|
|
||||||
if (!function_exists('curl_init')) return null;
|
|
||||||
$ch = curl_init($url);
|
|
||||||
curl_setopt_array($ch, [
|
|
||||||
CURLOPT_RETURNTRANSFER => true,
|
|
||||||
CURLOPT_NOBODY => true,
|
|
||||||
CURLOPT_TIMEOUT => 5,
|
|
||||||
CURLOPT_CONNECTTIMEOUT => 3,
|
|
||||||
CURLOPT_SSL_VERIFYPEER => false,
|
|
||||||
CURLOPT_SSL_VERIFYHOST => 0,
|
|
||||||
CURLOPT_FOLLOWLOCATION => true,
|
|
||||||
CURLOPT_MAXREDIRS => 3,
|
|
||||||
]);
|
|
||||||
$start = microtime(true);
|
|
||||||
curl_exec($ch);
|
|
||||||
$ms = (int) round((microtime(true) - $start) * 1000);
|
|
||||||
$code = (int) curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
|
||||||
// curl_close() is a no-op since PHP 8.0 and deprecated in PHP 8.5; omitted.
|
|
||||||
unset($ch);
|
|
||||||
return $code > 0 ? [$code, $ms] : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ── data collection ───────────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
$checks = [];
|
|
||||||
|
|
||||||
// 1. nginx
|
|
||||||
$nginxStatus = systemdStatus('nginx');
|
|
||||||
$nginxVersion = safeExec('nginx -v 2>&1 | head -1');
|
|
||||||
$checks['nginx'] = [
|
|
||||||
'label' => 'nginx',
|
|
||||||
'status' => $nginxStatus,
|
|
||||||
'detail' => $nginxVersion,
|
|
||||||
];
|
|
||||||
|
|
||||||
// 2. php-fpm (try versioned names: php8.2-fpm, php8.3-fpm, php-fpm)
|
|
||||||
$phpFpmStatus = null;
|
|
||||||
$phpFpmUnit = null;
|
|
||||||
foreach (['php8.3-fpm', 'php8.2-fpm', 'php8.1-fpm', 'php-fpm'] as $unit) {
|
|
||||||
$s = systemdStatus($unit);
|
|
||||||
if ($s !== null && $s !== 'unknown') {
|
|
||||||
$phpFpmStatus = $s;
|
|
||||||
$phpFpmUnit = $unit;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$checks['php_fpm'] = [
|
|
||||||
'label' => 'php-fpm' . ($phpFpmUnit ? " ($phpFpmUnit)" : ''),
|
|
||||||
'status' => $phpFpmStatus,
|
|
||||||
'detail' => null,
|
|
||||||
];
|
|
||||||
|
|
||||||
// 3. Site HTTP ping
|
|
||||||
$siteUrl = (isset($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . ($_SERVER['HTTP_HOST'] ?? 'localhost') . '/';
|
|
||||||
$httpResult = localHttpCheck($siteUrl);
|
|
||||||
$checks['site_http'] = [
|
|
||||||
'label' => 'Site HTTP',
|
|
||||||
'status' => $httpResult !== null ? ($httpResult[0] < 500 ? 'active' : 'failed') : null,
|
|
||||||
'detail' => $httpResult !== null ? "HTTP {$httpResult[0]} — {$httpResult[1]} ms" : 'curl indisponible',
|
|
||||||
];
|
|
||||||
|
|
||||||
// 4. Database file
|
|
||||||
require_once APP_ROOT . '/src/Database.php';
|
|
||||||
$dbPath = APP_ROOT . '/storage/test.db';
|
|
||||||
$dbExists = file_exists($dbPath);
|
|
||||||
$dbWritable = $dbExists && is_writable($dbPath);
|
|
||||||
$dbSizeBytes = $dbExists ? filesize($dbPath) : null;
|
|
||||||
$dbSizeHuman = $dbSizeBytes !== null
|
|
||||||
? ($dbSizeBytes > 1048576
|
|
||||||
? number_format($dbSizeBytes / 1048576, 1) . ' MB'
|
|
||||||
: number_format($dbSizeBytes / 1024, 1) . ' KB')
|
|
||||||
: 'N/A';
|
|
||||||
|
|
||||||
// Quick DB sanity: count rows
|
|
||||||
$dbRowCount = null;
|
|
||||||
if ($dbExists) {
|
|
||||||
try {
|
|
||||||
$db = new Database();
|
|
||||||
$stmt = $db->getConnection()->query("SELECT COUNT(*) FROM theses");
|
|
||||||
$dbRowCount = (int) $stmt->fetchColumn();
|
|
||||||
} catch (Throwable $e) {
|
|
||||||
$dbRowCount = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$checks['database'] = [
|
|
||||||
'label' => 'Base de données SQLite',
|
|
||||||
'status' => $dbExists ? ($dbWritable ? 'active' : 'inactive') : 'failed',
|
|
||||||
'detail' => $dbExists
|
|
||||||
? ($dbRowCount !== null ? "$dbRowCount thèses — $dbSizeHuman" : "Lecture impossible — $dbSizeHuman")
|
|
||||||
: 'Fichier introuvable',
|
|
||||||
];
|
|
||||||
|
|
||||||
// 5. Storage directory
|
|
||||||
$storageDir = APP_ROOT . '/storage';
|
|
||||||
$storageWritable = is_dir($storageDir) && is_writable($storageDir);
|
|
||||||
$bannersDir = $storageDir . '/banners';
|
|
||||||
$coversDir = $storageDir . '/covers';
|
|
||||||
$checks['storage'] = [
|
|
||||||
'label' => 'Répertoire storage',
|
|
||||||
'status' => $storageWritable ? 'active' : ($storageDir ? 'inactive' : 'failed'),
|
|
||||||
'detail' => $storageWritable
|
|
||||||
? implode(' · ', array_filter([
|
|
||||||
is_dir($bannersDir) ? ('banners/ ' . count(array_diff(scandir($bannersDir), ['.','..'])) . ' fichiers') : null,
|
|
||||||
is_dir($coversDir) ? ('covers/ ' . count(array_diff(scandir($coversDir), ['.','..'])) . ' fichiers') : null,
|
|
||||||
]))
|
|
||||||
: 'Non accessible en écriture',
|
|
||||||
];
|
|
||||||
|
|
||||||
// 6. Maintenance mode
|
|
||||||
$maintenanceOn = file_exists(APP_ROOT . '/storage/maintenance.flag');
|
|
||||||
$checks['maintenance'] = [
|
|
||||||
'label' => 'Mode maintenance',
|
|
||||||
'status' => $maintenanceOn ? 'warn' : 'active',
|
|
||||||
'detail' => $maintenanceOn ? 'Activé — site public inaccessible' : 'Désactivé',
|
|
||||||
];
|
|
||||||
|
|
||||||
// 7. PHP info
|
|
||||||
$phpInfo = [
|
|
||||||
'version' => PHP_VERSION,
|
|
||||||
'sapi' => PHP_SAPI,
|
|
||||||
'memory_limit' => ini_get('memory_limit'),
|
|
||||||
'upload_max' => ini_get('upload_max_filesize'),
|
|
||||||
'post_max' => ini_get('post_max_size'),
|
|
||||||
'max_exec' => ini_get('max_execution_time') . 's',
|
|
||||||
];
|
|
||||||
|
|
||||||
// 8. Disk usage (partition containing APP_ROOT)
|
|
||||||
$diskTotal = disk_total_space(APP_ROOT);
|
|
||||||
$diskFree = disk_free_space(APP_ROOT);
|
|
||||||
$diskUsed = $diskTotal - $diskFree;
|
|
||||||
function humanBytes(int $bytes): string {
|
|
||||||
if ($bytes > 1073741824) return number_format($bytes / 1073741824, 1) . ' GB';
|
|
||||||
if ($bytes > 1048576) return number_format($bytes / 1048576, 1) . ' MB';
|
|
||||||
return number_format($bytes / 1024, 1) . ' KB';
|
|
||||||
}
|
|
||||||
$diskPct = $diskTotal > 0 ? (int) round($diskUsed / $diskTotal * 100) : 0;
|
|
||||||
|
|
||||||
// ── label helpers ─────────────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
function statusLabel(string $status): string {
|
|
||||||
return match($status) {
|
|
||||||
'active' => '● En ligne',
|
|
||||||
'inactive' => '○ Inactif',
|
|
||||||
'failed' => '✕ Erreur',
|
|
||||||
'warn' => '⚠ Attention',
|
|
||||||
default => '? Inconnu',
|
|
||||||
};
|
|
||||||
}
|
|
||||||
function statusClass(string $status): string {
|
|
||||||
return match($status) {
|
|
||||||
'active' => 'status-ok',
|
|
||||||
'inactive' => 'status-warn',
|
|
||||||
'warn' => 'status-warn',
|
|
||||||
'failed' => 'status-err',
|
|
||||||
default => 'status-unknown',
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
require_once APP_ROOT . '/templates/admin/head.php';
|
|
||||||
?>
|
|
||||||
|
|
||||||
<style>
|
|
||||||
.srv-grid {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
|
|
||||||
gap: 1rem;
|
|
||||||
margin-bottom: 2.5rem;
|
|
||||||
}
|
|
||||||
.srv-card {
|
|
||||||
background: var(--admin-bg-alt);
|
|
||||||
border: 1px solid var(--admin-border);
|
|
||||||
border-radius: 5px;
|
|
||||||
padding: 1rem 1.25rem;
|
|
||||||
}
|
|
||||||
.srv-card__header {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-between;
|
|
||||||
margin-bottom: .4rem;
|
|
||||||
}
|
|
||||||
.srv-card__name {
|
|
||||||
font-size: .82rem;
|
|
||||||
text-transform: uppercase;
|
|
||||||
letter-spacing: .07em;
|
|
||||||
color: var(--admin-text-muted);
|
|
||||||
font-weight: 500;
|
|
||||||
}
|
|
||||||
.srv-card__detail {
|
|
||||||
font-size: .8rem;
|
|
||||||
color: var(--admin-text-muted);
|
|
||||||
margin-top: .25rem;
|
|
||||||
font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
|
|
||||||
}
|
|
||||||
.status-ok { color: #4caf50; font-weight: 600; font-size: .85rem; }
|
|
||||||
.status-warn { color: #ffc107; font-weight: 600; font-size: .85rem; }
|
|
||||||
.status-err { color: #e05555; font-weight: 600; font-size: .85rem; }
|
|
||||||
.status-unknown { color: #888; font-weight: 600; font-size: .85rem; }
|
|
||||||
|
|
||||||
.srv-section-title {
|
|
||||||
font-size: .82rem;
|
|
||||||
text-transform: uppercase;
|
|
||||||
letter-spacing: .1em;
|
|
||||||
color: var(--admin-text-muted);
|
|
||||||
border-bottom: 1px solid var(--admin-border);
|
|
||||||
padding-bottom: .4rem;
|
|
||||||
margin: 0 0 1rem;
|
|
||||||
font-weight: 500;
|
|
||||||
}
|
|
||||||
.php-grid {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
|
|
||||||
gap: .5rem .75rem;
|
|
||||||
margin-bottom: 2.5rem;
|
|
||||||
}
|
|
||||||
.php-item {
|
|
||||||
background: var(--admin-bg-alt);
|
|
||||||
border: 1px solid var(--admin-border);
|
|
||||||
border-radius: 4px;
|
|
||||||
padding: .5rem .75rem;
|
|
||||||
}
|
|
||||||
.php-item__key {
|
|
||||||
font-size: .75rem;
|
|
||||||
text-transform: uppercase;
|
|
||||||
letter-spacing: .06em;
|
|
||||||
color: var(--admin-text-muted);
|
|
||||||
}
|
|
||||||
.php-item__val {
|
|
||||||
font-size: .92rem;
|
|
||||||
font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
|
|
||||||
color: var(--admin-text);
|
|
||||||
margin-top: .15rem;
|
|
||||||
}
|
|
||||||
.disk-bar-wrap {
|
|
||||||
background: var(--admin-border);
|
|
||||||
border-radius: 3px;
|
|
||||||
height: 6px;
|
|
||||||
margin-top: .5rem;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
.disk-bar {
|
|
||||||
height: 100%;
|
|
||||||
border-radius: 3px;
|
|
||||||
background: <?= $diskPct > 85 ? '#e05555' : ($diskPct > 70 ? '#ffc107' : '#4caf50') ?>;
|
|
||||||
width: <?= $diskPct ?>%;
|
|
||||||
transition: width .3s;
|
|
||||||
}
|
|
||||||
.disk-stats {
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
font-size: .78rem;
|
|
||||||
color: var(--admin-text-muted);
|
|
||||||
margin-top: .25rem;
|
|
||||||
}
|
|
||||||
.admin-refresh-note {
|
|
||||||
font-size: .78rem;
|
|
||||||
color: var(--admin-text-muted);
|
|
||||||
margin-bottom: 1.5rem;
|
|
||||||
}
|
|
||||||
.admin-refresh-note a {
|
|
||||||
color: var(--admin-purple);
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
.admin-refresh-note a:hover { text-decoration: underline; }
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<main class="admin-main">
|
|
||||||
<h1 class="admin-page-title">Statut serveur</h1>
|
|
||||||
|
|
||||||
<p class="admin-refresh-note">
|
|
||||||
Vérification effectuée le <?= date('d/m/Y à H:i:s') ?> —
|
|
||||||
<a href="?">Rafraîchir</a>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<!-- Services -->
|
|
||||||
<h2 class="srv-section-title">Services</h2>
|
|
||||||
<div class="srv-grid">
|
|
||||||
<?php foreach ($checks as $check): ?>
|
|
||||||
<?php $st = $check['status'] ?? 'unknown'; ?>
|
|
||||||
<div class="srv-card">
|
|
||||||
<div class="srv-card__header">
|
|
||||||
<span class="srv-card__name"><?= htmlspecialchars($check['label']) ?></span>
|
|
||||||
<span class="<?= statusClass($st) ?>"><?= statusLabel($st) ?></span>
|
|
||||||
</div>
|
|
||||||
<?php if (!empty($check['detail'])): ?>
|
|
||||||
<div class="srv-card__detail"><?= htmlspecialchars($check['detail']) ?></div>
|
|
||||||
<?php endif; ?>
|
|
||||||
</div>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- PHP runtime -->
|
|
||||||
<h2 class="srv-section-title">Environnement PHP</h2>
|
|
||||||
<div class="php-grid">
|
|
||||||
<?php foreach ($phpInfo as $key => $val): ?>
|
|
||||||
<div class="php-item">
|
|
||||||
<div class="php-item__key"><?= htmlspecialchars($key) ?></div>
|
|
||||||
<div class="php-item__val"><?= htmlspecialchars($val) ?></div>
|
|
||||||
</div>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Disk -->
|
|
||||||
<h2 class="srv-section-title">Espace disque</h2>
|
|
||||||
<div style="max-width:420px;margin-bottom:2.5rem;">
|
|
||||||
<div class="disk-bar-wrap"><div class="disk-bar"></div></div>
|
|
||||||
<div class="disk-stats">
|
|
||||||
<span><?= humanBytes($diskUsed) ?> utilisé (<?= $diskPct ?>%)</span>
|
|
||||||
<span><?= humanBytes($diskFree) ?> libre / <?= humanBytes($diskTotal) ?></span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</main>
|
|
||||||
|
|
||||||
<?php require_once APP_ROOT . '/templates/admin/footer.php'; ?>
|
|
||||||
|
|||||||
698
public/admin/system.php
Normal file
698
public/admin/system.php
Normal file
@@ -0,0 +1,698 @@
|
|||||||
|
<?php
|
||||||
|
require_once __DIR__ . "/../../config/bootstrap.php";
|
||||||
|
require_once __DIR__ . '/../../src/AdminAuth.php';
|
||||||
|
AdminAuth::requireLogin();
|
||||||
|
|
||||||
|
$pageTitle = "Système";
|
||||||
|
|
||||||
|
// ═══════════════════════════════════════════════════════════════════════════════
|
||||||
|
// SECTION 1 — STATUS DATA
|
||||||
|
// ═══════════════════════════════════════════════════════════════════════════════
|
||||||
|
|
||||||
|
function safeExec(string $cmd): ?string {
|
||||||
|
if (!function_exists('exec')) return null;
|
||||||
|
$output = [];
|
||||||
|
$rc = 0;
|
||||||
|
exec($cmd . ' 2>/dev/null', $output, $rc);
|
||||||
|
return $rc === 0 ? trim(implode("\n", $output)) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function systemdStatus(string $unit): ?string {
|
||||||
|
$raw = safeExec("systemctl is-active " . escapeshellarg($unit));
|
||||||
|
if ($raw === null) return null;
|
||||||
|
return in_array($raw, ['active', 'inactive', 'failed', 'activating', 'deactivating'], true)
|
||||||
|
? $raw : 'unknown';
|
||||||
|
}
|
||||||
|
|
||||||
|
function localHttpCheck(string $url): ?array {
|
||||||
|
if (!function_exists('curl_init')) return null;
|
||||||
|
$ch = curl_init($url);
|
||||||
|
curl_setopt_array($ch, [
|
||||||
|
CURLOPT_RETURNTRANSFER => true,
|
||||||
|
CURLOPT_NOBODY => true,
|
||||||
|
CURLOPT_TIMEOUT => 5,
|
||||||
|
CURLOPT_CONNECTTIMEOUT => 3,
|
||||||
|
CURLOPT_SSL_VERIFYPEER => false,
|
||||||
|
CURLOPT_SSL_VERIFYHOST => 0,
|
||||||
|
CURLOPT_FOLLOWLOCATION => true,
|
||||||
|
CURLOPT_MAXREDIRS => 3,
|
||||||
|
]);
|
||||||
|
$start = microtime(true);
|
||||||
|
curl_exec($ch);
|
||||||
|
$ms = (int) round((microtime(true) - $start) * 1000);
|
||||||
|
$code = (int) curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||||
|
unset($ch);
|
||||||
|
return $code > 0 ? [$code, $ms] : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function humanBytes(int $bytes): string {
|
||||||
|
if ($bytes > 1073741824) return number_format($bytes / 1073741824, 1) . ' GB';
|
||||||
|
if ($bytes > 1048576) return number_format($bytes / 1048576, 1) . ' MB';
|
||||||
|
return number_format($bytes / 1024, 1) . ' KB';
|
||||||
|
}
|
||||||
|
|
||||||
|
function statusLabel(string $status): string {
|
||||||
|
return match($status) {
|
||||||
|
'active' => '● En ligne',
|
||||||
|
'inactive' => '○ Inactif',
|
||||||
|
'failed' => '✕ Erreur',
|
||||||
|
'warn' => '⚠ Attention',
|
||||||
|
default => '? Inconnu',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function statusClass(string $status): string {
|
||||||
|
return match($status) {
|
||||||
|
'active' => 'status-ok',
|
||||||
|
'inactive' => 'status-warn',
|
||||||
|
'warn' => 'status-warn',
|
||||||
|
'failed' => 'status-err',
|
||||||
|
default => 'status-unknown',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
$checks = [];
|
||||||
|
|
||||||
|
// nginx
|
||||||
|
$nginxStatus = systemdStatus('nginx');
|
||||||
|
$nginxVersion = safeExec('nginx -v 2>&1 | head -1');
|
||||||
|
$checks['nginx'] = [
|
||||||
|
'label' => 'nginx',
|
||||||
|
'status' => $nginxStatus,
|
||||||
|
'detail' => $nginxVersion,
|
||||||
|
];
|
||||||
|
|
||||||
|
// php-fpm
|
||||||
|
$phpFpmStatus = null;
|
||||||
|
$phpFpmUnit = null;
|
||||||
|
foreach (['php8.3-fpm', 'php8.2-fpm', 'php8.1-fpm', 'php-fpm'] as $unit) {
|
||||||
|
$s = systemdStatus($unit);
|
||||||
|
if ($s !== null && $s !== 'unknown') {
|
||||||
|
$phpFpmStatus = $s;
|
||||||
|
$phpFpmUnit = $unit;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$checks['php_fpm'] = [
|
||||||
|
'label' => 'php-fpm' . ($phpFpmUnit ? " ($phpFpmUnit)" : ''),
|
||||||
|
'status' => $phpFpmStatus,
|
||||||
|
'detail' => null,
|
||||||
|
];
|
||||||
|
|
||||||
|
// Site HTTP ping
|
||||||
|
$siteUrl = (isset($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . ($_SERVER['HTTP_HOST'] ?? 'localhost') . '/';
|
||||||
|
$httpResult = localHttpCheck($siteUrl);
|
||||||
|
$checks['site_http'] = [
|
||||||
|
'label' => 'Site HTTP',
|
||||||
|
'status' => $httpResult !== null ? ($httpResult[0] < 500 ? 'active' : 'failed') : null,
|
||||||
|
'detail' => $httpResult !== null ? "HTTP {$httpResult[0]} — {$httpResult[1]} ms" : 'curl indisponible',
|
||||||
|
];
|
||||||
|
|
||||||
|
// Database
|
||||||
|
require_once APP_ROOT . '/src/Database.php';
|
||||||
|
$dbPath = APP_ROOT . '/storage/test.db';
|
||||||
|
$dbExists = file_exists($dbPath);
|
||||||
|
$dbWritable = $dbExists && is_writable($dbPath);
|
||||||
|
$dbSizeBytes = $dbExists ? filesize($dbPath) : null;
|
||||||
|
$dbSizeHuman = $dbSizeBytes !== null
|
||||||
|
? ($dbSizeBytes > 1048576
|
||||||
|
? number_format($dbSizeBytes / 1048576, 1) . ' MB'
|
||||||
|
: number_format($dbSizeBytes / 1024, 1) . ' KB')
|
||||||
|
: 'N/A';
|
||||||
|
|
||||||
|
$dbRowCount = null;
|
||||||
|
if ($dbExists) {
|
||||||
|
try {
|
||||||
|
$db = new Database();
|
||||||
|
$stmt = $db->getConnection()->query("SELECT COUNT(*) FROM theses");
|
||||||
|
$dbRowCount = (int) $stmt->fetchColumn();
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
$dbRowCount = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$checks['database'] = [
|
||||||
|
'label' => 'Base de données SQLite',
|
||||||
|
'status' => $dbExists ? ($dbWritable ? 'active' : 'inactive') : 'failed',
|
||||||
|
'detail' => $dbExists
|
||||||
|
? ($dbRowCount !== null ? "$dbRowCount thèses — $dbSizeHuman" : "Lecture impossible — $dbSizeHuman")
|
||||||
|
: 'Fichier introuvable',
|
||||||
|
];
|
||||||
|
|
||||||
|
// Storage directory
|
||||||
|
$storageDir = APP_ROOT . '/storage';
|
||||||
|
$storageWritable = is_dir($storageDir) && is_writable($storageDir);
|
||||||
|
$bannersDir = $storageDir . '/banners';
|
||||||
|
$coversDir = $storageDir . '/covers';
|
||||||
|
$checks['storage'] = [
|
||||||
|
'label' => 'Répertoire storage',
|
||||||
|
'status' => $storageWritable ? 'active' : ($storageDir ? 'inactive' : 'failed'),
|
||||||
|
'detail' => $storageWritable
|
||||||
|
? implode(' · ', array_filter([
|
||||||
|
is_dir($bannersDir) ? ('banners/ ' . count(array_diff(scandir($bannersDir), ['.','..'])) . ' fichiers') : null,
|
||||||
|
is_dir($coversDir) ? ('covers/ ' . count(array_diff(scandir($coversDir), ['.','..'])) . ' fichiers') : null,
|
||||||
|
]))
|
||||||
|
: 'Non accessible en écriture',
|
||||||
|
];
|
||||||
|
|
||||||
|
// Maintenance mode
|
||||||
|
$maintenanceOn = file_exists(APP_ROOT . '/storage/maintenance.flag');
|
||||||
|
$checks['maintenance'] = [
|
||||||
|
'label' => 'Mode maintenance',
|
||||||
|
'status' => $maintenanceOn ? 'warn' : 'active',
|
||||||
|
'detail' => $maintenanceOn ? 'Activé — site public inaccessible' : 'Désactivé',
|
||||||
|
];
|
||||||
|
|
||||||
|
// PHP info
|
||||||
|
$phpInfo = [
|
||||||
|
'version' => PHP_VERSION,
|
||||||
|
'sapi' => PHP_SAPI,
|
||||||
|
'memory_limit' => ini_get('memory_limit'),
|
||||||
|
'upload_max' => ini_get('upload_max_filesize'),
|
||||||
|
'post_max' => ini_get('post_max_size'),
|
||||||
|
'max_exec' => ini_get('max_execution_time') . 's',
|
||||||
|
];
|
||||||
|
|
||||||
|
// Disk
|
||||||
|
$diskTotal = disk_total_space(APP_ROOT);
|
||||||
|
$diskFree = disk_free_space(APP_ROOT);
|
||||||
|
$diskUsed = $diskTotal - $diskFree;
|
||||||
|
$diskPct = $diskTotal > 0 ? (int) round($diskUsed / $diskTotal * 100) : 0;
|
||||||
|
|
||||||
|
// ═══════════════════════════════════════════════════════════════════════════════
|
||||||
|
// SECTION 2 — LOGS DATA
|
||||||
|
// ═══════════════════════════════════════════════════════════════════════════════
|
||||||
|
|
||||||
|
const LOG_FILES = [
|
||||||
|
'nginx_access' => ['label' => 'nginx — accès', 'path' => '/var/log/nginx/posterg_access.log'],
|
||||||
|
'nginx_error' => ['label' => 'nginx — erreurs', 'path' => '/var/log/nginx/posterg_error.log'],
|
||||||
|
'php_error' => ['label' => 'PHP-FPM — erreurs', 'path' => '/var/log/php8.4-fpm.log'],
|
||||||
|
];
|
||||||
|
|
||||||
|
const ALLOWED_LINES = [50, 100, 200, 500];
|
||||||
|
|
||||||
|
// Active tab: 'status' or a log key
|
||||||
|
$activeTab = $_GET['tab'] ?? 'nginx_access';
|
||||||
|
if ($activeTab === 'status') {
|
||||||
|
$activeTab = 'status';
|
||||||
|
} elseif (!array_key_exists($activeTab, LOG_FILES)) {
|
||||||
|
$activeTab = 'nginx_access';
|
||||||
|
}
|
||||||
|
|
||||||
|
$selectedN = isset($_GET['n']) ? (int) $_GET['n'] : 100;
|
||||||
|
if (!in_array($selectedN, ALLOWED_LINES, true)) {
|
||||||
|
$selectedN = 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read the tail of a log file. Returns null on error, [] if empty, or string[].
|
||||||
|
* $errorMsg is set on failure.
|
||||||
|
*/
|
||||||
|
function readLogTail(string $logPath, int $n, ?string &$errorMsg): ?array {
|
||||||
|
$errorMsg = null;
|
||||||
|
if (!function_exists('exec')) {
|
||||||
|
$errorMsg = "exec() est désactivé sur ce serveur.";
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (!file_exists($logPath)) {
|
||||||
|
$errorMsg = "Fichier introuvable : " . htmlspecialchars($logPath);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (!is_readable($logPath)) {
|
||||||
|
$errorMsg = "Fichier non lisible (permissions insuffisantes) : " . htmlspecialchars($logPath);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
$output = [];
|
||||||
|
$rc = 0;
|
||||||
|
exec('tail -n ' . intval($n) . ' ' . escapeshellarg($logPath) . ' 2>/dev/null', $output, $rc);
|
||||||
|
if ($rc !== 0) {
|
||||||
|
$errorMsg = "Erreur lors de la lecture du fichier journal.";
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return array_reverse($output); // newest first
|
||||||
|
}
|
||||||
|
|
||||||
|
function logLineClass(string $line): string {
|
||||||
|
if (preg_match('/\[(crit|emerg|alert)\]/', $line)) return 'log-crit';
|
||||||
|
if (preg_match('/\[error\]/', $line)) return 'log-error';
|
||||||
|
if (preg_match('/\[warn\]/', $line)) return 'log-warn';
|
||||||
|
if (preg_match('/\[notice\]/', $line)) return 'log-notice';
|
||||||
|
if (preg_match('/" [45]\d\d /', $line)) return 'log-error';
|
||||||
|
if (preg_match('/" 3\d\d /', $line)) return 'log-notice';
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pre-load the active log tab if it's a log key
|
||||||
|
$logLines = null;
|
||||||
|
$logError = null;
|
||||||
|
$logFileMeta = null;
|
||||||
|
|
||||||
|
if ($activeTab !== 'status') {
|
||||||
|
$logPath = LOG_FILES[$activeTab]['path'];
|
||||||
|
$logLines = readLogTail($logPath, $selectedN, $logError);
|
||||||
|
if (file_exists($logPath)) {
|
||||||
|
$sz = filesize($logPath);
|
||||||
|
$logFileMeta = [
|
||||||
|
'size' => $sz > 1048576
|
||||||
|
? number_format($sz / 1048576, 2) . ' MB'
|
||||||
|
: number_format($sz / 1024, 1) . ' KB',
|
||||||
|
'mtime' => date('d/m/Y H:i:s', filemtime($logPath)),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
require_once APP_ROOT . '/templates/admin/head.php';
|
||||||
|
?>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
/* ── System page tabs ──────────────────────────────────────────────────── */
|
||||||
|
.sys-tabs {
|
||||||
|
display: flex;
|
||||||
|
gap: 0;
|
||||||
|
border-bottom: 1px solid var(--admin-border);
|
||||||
|
margin-bottom: 1.75rem;
|
||||||
|
}
|
||||||
|
.sys-tab {
|
||||||
|
display: inline-block;
|
||||||
|
padding: .55rem 1.1rem;
|
||||||
|
font-size: .84rem;
|
||||||
|
font-weight: 500;
|
||||||
|
color: var(--admin-text-muted);
|
||||||
|
text-decoration: none;
|
||||||
|
border-bottom: 2px solid transparent;
|
||||||
|
margin-bottom: -1px;
|
||||||
|
transition: color .15s, border-color .15s;
|
||||||
|
}
|
||||||
|
.sys-tab:hover {
|
||||||
|
color: var(--admin-text);
|
||||||
|
}
|
||||||
|
.sys-tab.active {
|
||||||
|
color: var(--admin-purple);
|
||||||
|
border-bottom-color: var(--admin-purple);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ── Status cards ──────────────────────────────────────────────────────── */
|
||||||
|
.srv-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
|
||||||
|
gap: 1rem;
|
||||||
|
margin-bottom: 2.5rem;
|
||||||
|
}
|
||||||
|
.srv-card {
|
||||||
|
background: var(--admin-bg-alt);
|
||||||
|
border: 1px solid var(--admin-border);
|
||||||
|
border-radius: 5px;
|
||||||
|
padding: 1rem 1.25rem;
|
||||||
|
}
|
||||||
|
.srv-card__header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
margin-bottom: .4rem;
|
||||||
|
}
|
||||||
|
.srv-card__name {
|
||||||
|
font-size: .82rem;
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: .07em;
|
||||||
|
color: var(--admin-text-muted);
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
.srv-card__detail {
|
||||||
|
font-size: .8rem;
|
||||||
|
color: var(--admin-text-muted);
|
||||||
|
margin-top: .25rem;
|
||||||
|
font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
|
||||||
|
}
|
||||||
|
.status-ok { color: #4caf50; font-weight: 600; font-size: .85rem; }
|
||||||
|
.status-warn { color: #ffc107; font-weight: 600; font-size: .85rem; }
|
||||||
|
.status-err { color: #e05555; font-weight: 600; font-size: .85rem; }
|
||||||
|
.status-unknown { color: #888; font-weight: 600; font-size: .85rem; }
|
||||||
|
|
||||||
|
.srv-section-title {
|
||||||
|
font-size: .82rem;
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: .1em;
|
||||||
|
color: var(--admin-text-muted);
|
||||||
|
border-bottom: 1px solid var(--admin-border);
|
||||||
|
padding-bottom: .4rem;
|
||||||
|
margin: 0 0 1rem;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ── PHP info grid ─────────────────────────────────────────────────────── */
|
||||||
|
.php-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
|
||||||
|
gap: .5rem .75rem;
|
||||||
|
margin-bottom: 2.5rem;
|
||||||
|
}
|
||||||
|
.php-item {
|
||||||
|
background: var(--admin-bg-alt);
|
||||||
|
border: 1px solid var(--admin-border);
|
||||||
|
border-radius: 4px;
|
||||||
|
padding: .5rem .75rem;
|
||||||
|
}
|
||||||
|
.php-item__key {
|
||||||
|
font-size: .75rem;
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: .06em;
|
||||||
|
color: var(--admin-text-muted);
|
||||||
|
}
|
||||||
|
.php-item__val {
|
||||||
|
font-size: .92rem;
|
||||||
|
font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
|
||||||
|
color: var(--admin-text);
|
||||||
|
margin-top: .15rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ── Disk bar ──────────────────────────────────────────────────────────── */
|
||||||
|
.disk-bar-wrap {
|
||||||
|
background: var(--admin-border);
|
||||||
|
border-radius: 3px;
|
||||||
|
height: 6px;
|
||||||
|
margin-top: .5rem;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
.disk-bar {
|
||||||
|
height: 100%;
|
||||||
|
border-radius: 3px;
|
||||||
|
background: <?= $diskPct > 85 ? '#e05555' : ($diskPct > 70 ? '#ffc107' : '#4caf50') ?>;
|
||||||
|
width: <?= $diskPct ?>%;
|
||||||
|
transition: width .3s;
|
||||||
|
}
|
||||||
|
.disk-stats {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
font-size: .78rem;
|
||||||
|
color: var(--admin-text-muted);
|
||||||
|
margin-top: .25rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ── Log viewer ────────────────────────────────────────────────────────── */
|
||||||
|
.log-toolbar {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
align-items: center;
|
||||||
|
gap: .6rem;
|
||||||
|
margin-bottom: 1.25rem;
|
||||||
|
}
|
||||||
|
.log-toolbar select {
|
||||||
|
background: var(--admin-bg-alt);
|
||||||
|
border: 1px solid var(--admin-border);
|
||||||
|
color: var(--admin-text);
|
||||||
|
border-radius: 4px;
|
||||||
|
padding: .4rem .7rem;
|
||||||
|
font-size: .85rem;
|
||||||
|
font-family: inherit;
|
||||||
|
}
|
||||||
|
.log-toolbar select:focus { outline: 2px solid var(--admin-purple); }
|
||||||
|
|
||||||
|
.log-meta {
|
||||||
|
font-size: .78rem;
|
||||||
|
color: var(--admin-text-muted);
|
||||||
|
font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
|
||||||
|
margin-bottom: .75rem;
|
||||||
|
display: flex;
|
||||||
|
gap: 1.5rem;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
.log-meta span::before { content: attr(data-label) ": "; opacity: .6; }
|
||||||
|
|
||||||
|
.log-unavailable {
|
||||||
|
background: var(--admin-bg-alt);
|
||||||
|
border: 1px solid var(--admin-border);
|
||||||
|
border-radius: 4px;
|
||||||
|
padding: 1.5rem;
|
||||||
|
color: var(--admin-text-muted);
|
||||||
|
font-size: .88rem;
|
||||||
|
}
|
||||||
|
.log-unavail-path {
|
||||||
|
font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
|
||||||
|
font-size: .8rem;
|
||||||
|
margin-top: .4rem;
|
||||||
|
opacity: .7;
|
||||||
|
}
|
||||||
|
.log-unavail-dev {
|
||||||
|
margin-top: .6rem;
|
||||||
|
font-size: .8rem;
|
||||||
|
opacity: .7;
|
||||||
|
}
|
||||||
|
.log-empty {
|
||||||
|
color: var(--admin-text-muted);
|
||||||
|
font-size: .88rem;
|
||||||
|
padding: 1rem 0;
|
||||||
|
}
|
||||||
|
.log-output {
|
||||||
|
background: #0d0d0d;
|
||||||
|
border: 1px solid var(--admin-border);
|
||||||
|
border-radius: 4px;
|
||||||
|
padding: 1rem;
|
||||||
|
overflow-x: auto;
|
||||||
|
font-family: ui-monospace, "SFMono-Regular", Consolas, "Courier New", monospace;
|
||||||
|
font-size: .76rem;
|
||||||
|
line-height: 1.55;
|
||||||
|
max-height: 62vh;
|
||||||
|
overflow-y: auto;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
.log-line {
|
||||||
|
display: block;
|
||||||
|
white-space: pre;
|
||||||
|
padding: .05rem .1rem;
|
||||||
|
border-radius: 2px;
|
||||||
|
color: #bbb;
|
||||||
|
}
|
||||||
|
.log-line + .log-line { border-top: 1px solid rgba(255,255,255,.03); }
|
||||||
|
.log-crit { color: #ff7070; background: rgba(200,0,0,.12); }
|
||||||
|
.log-error { color: #f08080; }
|
||||||
|
.log-warn { color: #ffd080; }
|
||||||
|
.log-notice { color: #a0c8ff; }
|
||||||
|
.log-line::before {
|
||||||
|
content: attr(data-n);
|
||||||
|
display: inline-block;
|
||||||
|
min-width: 4ch;
|
||||||
|
margin-right: .75rem;
|
||||||
|
opacity: .3;
|
||||||
|
text-align: right;
|
||||||
|
user-select: none;
|
||||||
|
}
|
||||||
|
.log-count-badge {
|
||||||
|
background: var(--admin-bg-alt);
|
||||||
|
border: 1px solid var(--admin-border);
|
||||||
|
border-radius: 3px;
|
||||||
|
font-size: .76rem;
|
||||||
|
padding: .15rem .5rem;
|
||||||
|
color: var(--admin-text-muted);
|
||||||
|
font-family: ui-monospace, monospace;
|
||||||
|
}
|
||||||
|
.log-copy-btn {
|
||||||
|
position: absolute;
|
||||||
|
top: .6rem;
|
||||||
|
right: .6rem;
|
||||||
|
background: var(--admin-bg-alt);
|
||||||
|
border: 1px solid var(--admin-border);
|
||||||
|
color: var(--admin-text-muted);
|
||||||
|
border-radius: 4px;
|
||||||
|
font-size: .76rem;
|
||||||
|
padding: .25rem .6rem;
|
||||||
|
cursor: pointer;
|
||||||
|
font-family: inherit;
|
||||||
|
transition: color .15s, border-color .15s;
|
||||||
|
z-index: 2;
|
||||||
|
}
|
||||||
|
.log-copy-btn:hover {
|
||||||
|
color: var(--admin-text);
|
||||||
|
border-color: var(--admin-purple);
|
||||||
|
}
|
||||||
|
.log-copy-btn.copied {
|
||||||
|
color: #4caf50;
|
||||||
|
border-color: #4caf50;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sys-refresh-note {
|
||||||
|
font-size: .78rem;
|
||||||
|
color: var(--admin-text-muted);
|
||||||
|
margin-bottom: 1.25rem;
|
||||||
|
}
|
||||||
|
.sys-refresh-note a {
|
||||||
|
color: var(--admin-purple);
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
.sys-refresh-note a:hover { text-decoration: underline; }
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<main class="admin-main">
|
||||||
|
<h1 class="admin-page-title">Système</h1>
|
||||||
|
|
||||||
|
<p class="sys-refresh-note">
|
||||||
|
Affiché le <?= date('d/m/Y à H:i:s') ?> —
|
||||||
|
<a href="?tab=<?= htmlspecialchars($activeTab) ?>&n=<?= $selectedN ?>">Rafraîchir</a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<!-- ── Tab bar ─────────────────────────────────────────────────────── -->
|
||||||
|
<nav class="sys-tabs" aria-label="Sections système">
|
||||||
|
<a href="?tab=status"
|
||||||
|
class="sys-tab <?= $activeTab === 'status' ? 'active' : '' ?>">Statut</a>
|
||||||
|
<?php foreach (LOG_FILES as $key => $def): ?>
|
||||||
|
<a href="?tab=<?= htmlspecialchars($key) ?>&n=<?= $selectedN ?>"
|
||||||
|
class="sys-tab <?= $activeTab === $key ? 'active' : '' ?>">
|
||||||
|
<?= htmlspecialchars($def['label']) ?>
|
||||||
|
</a>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<?php if ($activeTab === 'status'): ?>
|
||||||
|
<!-- ════════════════════════════════════════════════════════════════════
|
||||||
|
STATUS PANEL
|
||||||
|
════════════════════════════════════════════════════════════════════ -->
|
||||||
|
|
||||||
|
<h2 class="srv-section-title">Services</h2>
|
||||||
|
<div class="srv-grid">
|
||||||
|
<?php foreach ($checks as $check): ?>
|
||||||
|
<?php $st = $check['status'] ?? 'unknown'; ?>
|
||||||
|
<div class="srv-card">
|
||||||
|
<div class="srv-card__header">
|
||||||
|
<span class="srv-card__name"><?= htmlspecialchars($check['label']) ?></span>
|
||||||
|
<span class="<?= statusClass($st) ?>"><?= statusLabel($st) ?></span>
|
||||||
|
</div>
|
||||||
|
<?php if (!empty($check['detail'])): ?>
|
||||||
|
<div class="srv-card__detail"><?= htmlspecialchars($check['detail']) ?></div>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h2 class="srv-section-title">Environnement PHP</h2>
|
||||||
|
<div class="php-grid">
|
||||||
|
<?php foreach ($phpInfo as $key => $val): ?>
|
||||||
|
<div class="php-item">
|
||||||
|
<div class="php-item__key"><?= htmlspecialchars($key) ?></div>
|
||||||
|
<div class="php-item__val"><?= htmlspecialchars($val) ?></div>
|
||||||
|
</div>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h2 class="srv-section-title">Espace disque</h2>
|
||||||
|
<div style="max-width:420px;margin-bottom:2.5rem;">
|
||||||
|
<div class="disk-bar-wrap"><div class="disk-bar"></div></div>
|
||||||
|
<div class="disk-stats">
|
||||||
|
<span><?= humanBytes($diskUsed) ?> utilisé (<?= $diskPct ?>%)</span>
|
||||||
|
<span><?= humanBytes($diskFree) ?> libre / <?= humanBytes($diskTotal) ?></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php else: ?>
|
||||||
|
<!-- ════════════════════════════════════════════════════════════════════
|
||||||
|
LOG PANEL
|
||||||
|
════════════════════════════════════════════════════════════════════ -->
|
||||||
|
|
||||||
|
<!-- Lines selector (submits via JS on change; no button needed) -->
|
||||||
|
<div class="log-toolbar">
|
||||||
|
<label for="lines-select" style="font-size:.84rem;color:var(--admin-text-muted);">
|
||||||
|
Afficher
|
||||||
|
</label>
|
||||||
|
<select id="lines-select" aria-label="Nombre de lignes">
|
||||||
|
<?php foreach (ALLOWED_LINES as $n): ?>
|
||||||
|
<option value="<?= $n ?>" <?= $n === $selectedN ? 'selected' : '' ?>>
|
||||||
|
<?= $n ?> dernières lignes
|
||||||
|
</option>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</select>
|
||||||
|
<?php if ($logLines !== null && count($logLines) > 0): ?>
|
||||||
|
<span class="log-count-badge"><?= count($logLines) ?> ligne(s)</span>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- File metadata -->
|
||||||
|
<?php if ($logFileMeta): ?>
|
||||||
|
<div class="log-meta">
|
||||||
|
<span data-label="Fichier"><?= htmlspecialchars(LOG_FILES[$activeTab]['path']) ?></span>
|
||||||
|
<span data-label="Taille"><?= $logFileMeta['size'] ?></span>
|
||||||
|
<span data-label="Modifié"><?= $logFileMeta['mtime'] ?></span>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<!-- Log output -->
|
||||||
|
<?php if ($logError !== null): ?>
|
||||||
|
<div class="log-unavailable">
|
||||||
|
<strong>Journaux non disponibles</strong>
|
||||||
|
<div class="log-unavail-path"><?= $logError ?></div>
|
||||||
|
<?php if (php_sapi_name() === 'cli-server'): ?>
|
||||||
|
<div class="log-unavail-dev">
|
||||||
|
En environnement de développement, les logs nginx ne sont pas disponibles.
|
||||||
|
Cette page est pleinement fonctionnelle sur le serveur de production.
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php elseif (empty($logLines)): ?>
|
||||||
|
<div class="log-empty">Le fichier journal est vide.</div>
|
||||||
|
|
||||||
|
<?php else: ?>
|
||||||
|
<div class="log-output" id="log-output" role="log" aria-live="off" aria-label="Contenu du journal">
|
||||||
|
<button class="log-copy-btn" id="log-copy-btn" type="button" title="Copier le contenu">
|
||||||
|
Copier
|
||||||
|
</button>
|
||||||
|
<?php foreach ($logLines as $i => $line): ?>
|
||||||
|
<span class="log-line <?= logLineClass($line) ?>"
|
||||||
|
data-n="<?= count($logLines) - $i ?>"><?= htmlspecialchars($line, ENT_QUOTES | ENT_SUBSTITUTE) ?></span>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
</main>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
(function () {
|
||||||
|
// ── Instant tab switch on lines-select change ──────────────────────
|
||||||
|
var sel = document.getElementById('lines-select');
|
||||||
|
if (sel) {
|
||||||
|
sel.addEventListener('change', function () {
|
||||||
|
var url = new URL(window.location.href);
|
||||||
|
url.searchParams.set('n', this.value);
|
||||||
|
window.location.href = url.toString();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Copy-to-clipboard ─────────────────────────────────────────────
|
||||||
|
var copyBtn = document.getElementById('log-copy-btn');
|
||||||
|
var logOut = document.getElementById('log-output');
|
||||||
|
if (copyBtn && logOut) {
|
||||||
|
copyBtn.addEventListener('click', function () {
|
||||||
|
// Collect text from all .log-line spans (strip the gutter number
|
||||||
|
// rendered via CSS ::before — it's not in the DOM text content).
|
||||||
|
var lines = Array.from(logOut.querySelectorAll('.log-line'))
|
||||||
|
.map(function (el) { return el.textContent; })
|
||||||
|
.join('\n');
|
||||||
|
|
||||||
|
if (navigator.clipboard && navigator.clipboard.writeText) {
|
||||||
|
navigator.clipboard.writeText(lines).then(function () {
|
||||||
|
copyBtn.textContent = '✓ Copié';
|
||||||
|
copyBtn.classList.add('copied');
|
||||||
|
setTimeout(function () {
|
||||||
|
copyBtn.textContent = 'Copier';
|
||||||
|
copyBtn.classList.remove('copied');
|
||||||
|
}, 2000);
|
||||||
|
}).catch(function () {
|
||||||
|
fallbackCopy(lines);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
fallbackCopy(lines);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function fallbackCopy(text) {
|
||||||
|
var ta = document.createElement('textarea');
|
||||||
|
ta.value = text;
|
||||||
|
ta.style.cssText = 'position:fixed;opacity:0;top:0;left:0';
|
||||||
|
document.body.appendChild(ta);
|
||||||
|
ta.select();
|
||||||
|
try { document.execCommand('copy'); } catch (e) {}
|
||||||
|
document.body.removeChild(ta);
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<?php require_once APP_ROOT . '/templates/admin/footer.php'; ?>
|
||||||
@@ -29,8 +29,7 @@
|
|||||||
<a href="/admin/import.php" class="admin-nav__link <?= $currentPage === 'import.php' ? 'active' : '' ?>">Importer une liste de TFE</a>
|
<a href="/admin/import.php" class="admin-nav__link <?= $currentPage === 'import.php' ? 'active' : '' ?>">Importer une liste de TFE</a>
|
||||||
<a href="/admin/pages.php" class="admin-nav__link <?= in_array($currentPage, ['pages.php','pages-edit.php']) ? 'active' : '' ?>">Pages statiques</a>
|
<a href="/admin/pages.php" class="admin-nav__link <?= in_array($currentPage, ['pages.php','pages-edit.php']) ? 'active' : '' ?>">Pages statiques</a>
|
||||||
<a href="/admin/tags.php" class="admin-nav__link <?= $currentPage === 'tags.php' ? 'active' : '' ?>">Mots-clés</a>
|
<a href="/admin/tags.php" class="admin-nav__link <?= $currentPage === 'tags.php' ? 'active' : '' ?>">Mots-clés</a>
|
||||||
<a href="/admin/status.php" class="admin-nav__link <?= $currentPage === 'status.php' ? 'active' : '' ?>">Statut</a>
|
<a href="/admin/system.php" class="admin-nav__link <?= in_array($currentPage, ['system.php','status.php','logs.php']) ? 'active' : '' ?>">Système</a>
|
||||||
<a href="/admin/logs.php" class="admin-nav__link <?= $currentPage === 'logs.php' ? 'active' : '' ?>">Journaux</a>
|
|
||||||
<a href="/admin/account.php" class="admin-nav__link <?= $currentPage === 'account.php' ? 'active' : '' ?>">Compte</a>
|
<a href="/admin/account.php" class="admin-nav__link <?= $currentPage === 'account.php' ? 'active' : '' ?>">Compte</a>
|
||||||
<?php if ($thesisId && in_array($currentPage, ['edit.php', 'thanks.php'])): ?>
|
<?php if ($thesisId && in_array($currentPage, ['edit.php', 'thanks.php'])): ?>
|
||||||
<a href="/admin/edit.php?id=<?= intval($thesisId) ?>" class="admin-nav__link <?= $currentPage === 'edit.php' ? 'active' : '' ?>">Modifier</a>
|
<a href="/admin/edit.php?id=<?= intval($thesisId) ?>" class="admin-nav__link <?= $currentPage === 'edit.php' ? 'active' : '' ?>">Modifier</a>
|
||||||
|
|||||||
Reference in New Issue
Block a user