mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-05-06 11:09:18 +02:00
Replace four presentational class names in admin.css with structural selectors
that target native HTML elements already present in every admin template:
.admin-main → .admin-body main
.admin-page-title → .admin-body main > h1
.admin-table → .admin-body table
.admin-fieldset → .admin-body fieldset
.admin-fieldset-legend → .admin-body legend
Also migrate the .admin-main > section / h2 / dl / dt / dd block to
.admin-body main > section so the thanks-page section styles survive.
Add .admin-body main > table { margin-top: 1.5rem } to absorb the inline
style="margin-top:1.5rem" that was on tags.php's <table class="admin-table">.
All 10 affected admin templates updated (add, edit, account, index, import,
pages, pages-edit, tags, system, thanks) — class attributes removed where
the element alone is now the selector. Zero visual changes.
561 lines
22 KiB
PHP
561 lines
22 KiB
PHP
<?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();
|
|
$dbRowCount = $db->getThesisCount();
|
|
} 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];
|
|
|
|
// Nginx config paths (live deployed, then local reference fallback)
|
|
const NGINX_CONFIG_LIVE = '/etc/nginx/sites-available/posterg';
|
|
const NGINX_CONFIG_LOCAL = APP_ROOT . '/nginx/posterg.conf';
|
|
|
|
// Active tab: 'status', 'nginx_config', or a log key
|
|
$activeTab = $_GET['tab'] ?? 'nginx_access';
|
|
if ($activeTab === 'status' || $activeTab === 'nginx_config') {
|
|
// valid as-is
|
|
} 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' && $activeTab !== 'nginx_config') {
|
|
$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)),
|
|
];
|
|
}
|
|
}
|
|
|
|
// Pre-load nginx config tab
|
|
$nginxConfigLines = null;
|
|
$nginxConfigSource = null;
|
|
$nginxConfigError = null;
|
|
$nginxConfigMeta = null;
|
|
|
|
if ($activeTab === 'nginx_config') {
|
|
// Try live deployed config first, fall back to local reference copy
|
|
$livePath = NGINX_CONFIG_LIVE;
|
|
$localPath = NGINX_CONFIG_LOCAL;
|
|
|
|
if (file_exists($livePath) && is_readable($livePath)) {
|
|
$raw = file($livePath, FILE_IGNORE_NEW_LINES);
|
|
if ($raw !== false) {
|
|
$nginxConfigLines = $raw;
|
|
$nginxConfigSource = 'live';
|
|
$sz = filesize($livePath);
|
|
$nginxConfigMeta = [
|
|
'path' => $livePath,
|
|
'size' => $sz > 1048576
|
|
? number_format($sz / 1048576, 2) . ' MB'
|
|
: number_format($sz / 1024, 1) . ' KB',
|
|
'mtime' => date('d/m/Y H:i:s', filemtime($livePath)),
|
|
];
|
|
}
|
|
}
|
|
|
|
if ($nginxConfigLines === null && file_exists($localPath) && is_readable($localPath)) {
|
|
$raw = file($localPath, FILE_IGNORE_NEW_LINES);
|
|
if ($raw !== false) {
|
|
$nginxConfigLines = $raw;
|
|
$nginxConfigSource = 'local';
|
|
$sz = filesize($localPath);
|
|
$nginxConfigMeta = [
|
|
'path' => $localPath,
|
|
'size' => $sz > 1048576
|
|
? number_format($sz / 1048576, 2) . ' MB'
|
|
: number_format($sz / 1024, 1) . ' KB',
|
|
'mtime' => date('d/m/Y H:i:s', filemtime($localPath)),
|
|
];
|
|
}
|
|
}
|
|
|
|
if ($nginxConfigLines === null) {
|
|
$nginxConfigError = file_exists($livePath)
|
|
? "Fichier non lisible (permissions insuffisantes) : " . htmlspecialchars($livePath)
|
|
: "Config live introuvable (" . htmlspecialchars($livePath) . ") et config locale introuvable (" . htmlspecialchars($localPath) . ").";
|
|
}
|
|
}
|
|
|
|
$isAdmin = true; $bodyClass = 'admin-body';
|
|
$extraCss = ['/assets/css/system.css'];
|
|
$extraJsInline = <<<'JS'
|
|
(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);
|
|
}
|
|
})();
|
|
JS;
|
|
require_once APP_ROOT . '/templates/head.php';
|
|
?>
|
|
<?php include APP_ROOT . '/templates/header.php'; ?>
|
|
|
|
|
|
|
|
<main id="main-content">
|
|
<h1>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; ?>
|
|
<a href="?tab=nginx_config"
|
|
class="sys-tab <?= $activeTab === 'nginx_config' ? 'active' : '' ?>">nginx — config</a>
|
|
</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;">
|
|
<?php
|
|
$diskColor = $diskPct > 85 ? '#e05555' : ($diskPct > 70 ? '#ffc107' : '#4caf50');
|
|
?>
|
|
<div class="disk-bar-wrap">
|
|
<div class="disk-bar" style="--disk-pct:<?= $diskPct ?>%;--disk-color:<?= $diskColor ?>"></div>
|
|
</div>
|
|
<div class="disk-stats">
|
|
<span><?= humanBytes($diskUsed) ?> utilisé (<?= $diskPct ?>%)</span>
|
|
<span><?= humanBytes($diskFree) ?> libre / <?= humanBytes($diskTotal) ?></span>
|
|
</div>
|
|
</div>
|
|
|
|
<?php elseif ($activeTab === 'nginx_config'): ?>
|
|
<!-- ════════════════════════════════════════════════════════════════════
|
|
NGINX CONFIG PANEL
|
|
════════════════════════════════════════════════════════════════════ -->
|
|
|
|
<?php if ($nginxConfigMeta): ?>
|
|
<div class="log-meta">
|
|
<span data-label="Fichier"><?= htmlspecialchars($nginxConfigMeta['path']) ?></span>
|
|
<span data-label="Taille"><?= $nginxConfigMeta['size'] ?></span>
|
|
<span data-label="Modifié"><?= $nginxConfigMeta['mtime'] ?></span>
|
|
<?php if ($nginxConfigSource === 'live'): ?>
|
|
<span class="nginx-source-badge nginx-source-badge--live">● Config déployée</span>
|
|
<?php else: ?>
|
|
<span class="nginx-source-badge nginx-source-badge--local">⚠ Référence locale (config live inaccessible)</span>
|
|
<?php endif; ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<?php if ($nginxConfigError !== null): ?>
|
|
<div class="log-unavailable">
|
|
<strong>Configuration nginx non disponible</strong>
|
|
<div class="log-unavail-path"><?= htmlspecialchars($nginxConfigError) ?></div>
|
|
<?php if (php_sapi_name() === 'cli-server'): ?>
|
|
<div class="log-unavail-dev">
|
|
En développement, <code>/etc/nginx/sites-available/posterg</code> n'existe pas.
|
|
La config de référence se trouve dans <code>nginx/posterg.conf</code>.
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<?php elseif (empty($nginxConfigLines)): ?>
|
|
<div class="log-empty">Le fichier de configuration est vide.</div>
|
|
|
|
<?php else: ?>
|
|
<?php
|
|
// Minimal nginx syntax coloring — applied per line
|
|
function nginxLineClass(string $line): string {
|
|
$trimmed = ltrim($line);
|
|
if ($trimmed === '' || str_starts_with($trimmed, '#')) return 'nginx-comment';
|
|
if (preg_match('/^\s*(location|server|upstream|events|http|geo|map|types)\b/', $line)) return 'nginx-block';
|
|
return 'nginx-directive';
|
|
}
|
|
?>
|
|
<div class="log-output" id="log-output" role="region" aria-label="Configuration nginx">
|
|
<button class="log-copy-btn" id="log-copy-btn" type="button" title="Copier la configuration">
|
|
Copier
|
|
</button>
|
|
<?php foreach ($nginxConfigLines as $i => $line): ?>
|
|
<span class="log-line <?= nginxLineClass($line) ?>"
|
|
data-n="<?= $i + 1 ?>"><?= htmlspecialchars($line, ENT_QUOTES | ENT_SUBSTITUTE) ?></span>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<?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>
|
|
|
|
|
|
<?php require_once APP_ROOT . '/templates/admin/footer.php'; ?>
|