mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-05-06 11:09:18 +02:00
SQLite performance (Database::__construct): - PRAGMA journal_mode = WAL: eliminates full-DB read locks on write, safe for concurrent PHP-FPM workers - PRAGMA synchronous = NORMAL: durable on commit without full fsync per write - PRAGMA cache_size = -8000: ~8 MB page cache per connection Accessibility foundation (WCAG 2.1 AA): - common.css: add .sr-only utility, .skip-link (hidden until focused), global :focus-visible (2px purple outline, 2px offset), prefers-reduced-motion guard; remove bare outline:none from .site-search__input - admin.css: same :focus-visible, skip-link, and motion guard scoped to admin purple; remove outline:none from .admin-input/.admin-select/ .admin-textarea and .admin-filters select (both had :focus border rules already, so focus is still visually communicated) - search.css: remove outline:none from .search-filter-select (already has :focus border-color rule) - All 5 public pages (index, search, tfe, apropos, licence): add <a href="#main-content" class="skip-link"> as first child of <body>; add id="main-content" to <main> - templates/admin/head.php: same skip link; aria-label="Navigation admin" on <nav>; id="main-content" on all 10 admin <main> elements All 4 test suites pass (unit, integration, security, rate-limit).
68 lines
2.2 KiB
PHP
68 lines
2.2 KiB
PHP
<?php
|
|
require_once __DIR__ . "/../../config/bootstrap.php";
|
|
require_once __DIR__ . '/../../src/AdminAuth.php';
|
|
AdminAuth::requireLogin();
|
|
|
|
if (empty($_SESSION['csrf_token'])) {
|
|
$_SESSION['csrf_token'] = bin2hex(random_bytes(32));
|
|
}
|
|
|
|
require_once __DIR__ . '/../../src/Database.php';
|
|
|
|
$allowedSlugs = ['about', 'licenses', 'charte', 'contact'];
|
|
$slug = $_GET['slug'] ?? '';
|
|
|
|
if (!in_array($slug, $allowedSlugs)) {
|
|
header('Location: /admin/pages.php');
|
|
exit;
|
|
}
|
|
|
|
try {
|
|
$db = new Database();
|
|
$page = $db->getPage($slug);
|
|
if (!$page) {
|
|
die("Page introuvable.");
|
|
}
|
|
} catch (Exception $e) {
|
|
die("Erreur: " . htmlspecialchars($e->getMessage()));
|
|
}
|
|
|
|
$pageTitle = "Éditer : " . htmlspecialchars($page['title']);
|
|
?>
|
|
<?php require_once APP_ROOT . '/templates/admin/head.php'; ?>
|
|
|
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/easymde/dist/easymde.min.css">
|
|
|
|
<main class="admin-main" id="main-content">
|
|
<h1 class="admin-page-title">Éditer : <?= htmlspecialchars($page['title']) ?></h1>
|
|
|
|
<form action="/admin/actions/page.php" method="post" class="admin-form">
|
|
<input type="hidden" name="csrf_token" value="<?= htmlspecialchars($_SESSION['csrf_token']) ?>">
|
|
<input type="hidden" name="slug" value="<?= htmlspecialchars($slug) ?>">
|
|
|
|
<div class="admin-form-row" style="align-items:start;">
|
|
<label class="admin-label" for="content">Contenu (Markdown) :</label>
|
|
<textarea class="admin-textarea" id="content" name="content"
|
|
rows="20"><?= htmlspecialchars($page['content'] ?? '') ?></textarea>
|
|
</div>
|
|
|
|
<div class="admin-submit-wrap">
|
|
<button type="submit" class="admin-btn">Enregistrer</button>
|
|
<a href="/admin/pages.php" class="admin-btn-secondary" style="margin-left:.75rem;">Annuler</a>
|
|
</div>
|
|
</form>
|
|
</main>
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/easymde/dist/easymde.min.js"></script>
|
|
<script>
|
|
var easyMDE = new EasyMDE({
|
|
element: document.getElementById('content'),
|
|
spellChecker: false,
|
|
status: ['lines', 'words'],
|
|
minHeight: '400px',
|
|
toolbarTips: true
|
|
});
|
|
</script>
|
|
|
|
<?php require_once APP_ROOT . '/templates/admin/footer.php'; ?>
|