mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-05-06 19:19:19 +02:00
Adjusting admin static pages edit page
This commit is contained in:
@@ -1,20 +1,20 @@
|
||||
<?php
|
||||
require_once __DIR__ . "/../../config/bootstrap.php";
|
||||
require_once __DIR__ . '/../../src/AdminAuth.php';
|
||||
require_once __DIR__ . "/../../src/AdminAuth.php";
|
||||
AdminAuth::requireLogin();
|
||||
|
||||
if (empty($_SESSION['csrf_token'])) {
|
||||
$_SESSION['csrf_token'] = bin2hex(random_bytes(32));
|
||||
if (empty($_SESSION["csrf_token"])) {
|
||||
$_SESSION["csrf_token"] = bin2hex(random_bytes(32));
|
||||
}
|
||||
|
||||
require_once __DIR__ . '/../../src/Database.php';
|
||||
require_once __DIR__ . "/../../src/Database.php";
|
||||
|
||||
$allowedSlugs = ['about', 'licenses', 'charte', 'contact'];
|
||||
$slug = $_GET['slug'] ?? '';
|
||||
$allowedSlugs = ["about", "licenses", "charte", "contact"];
|
||||
$slug = $_GET["slug"] ?? "";
|
||||
|
||||
if (!in_array($slug, $allowedSlugs)) {
|
||||
header('Location: /admin/pages.php');
|
||||
exit;
|
||||
header("Location: /admin/pages.php");
|
||||
exit();
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -27,8 +27,8 @@ try {
|
||||
die("Erreur: " . htmlspecialchars($e->getMessage()));
|
||||
}
|
||||
|
||||
$pageTitle = "Éditer : " . htmlspecialchars($page['title']);
|
||||
$extraJs = ['/assets/js/overtype.min.js'];
|
||||
$pageTitle = "Éditer : " . htmlspecialchars($page["title"]);
|
||||
$extraJs = ["/assets/js/overtype.min.js"];
|
||||
$extraJsInline = <<<'JS'
|
||||
var OT = window.OverType.default || window.OverType;
|
||||
var hidden = document.getElementById('content');
|
||||
@@ -40,22 +40,26 @@ var editor = new OT(document.getElementById('editor'), {
|
||||
});
|
||||
JS;
|
||||
?>
|
||||
<?php $isAdmin = true; $bodyClass = 'admin-body'; require_once APP_ROOT . '/templates/head.php'; ?>
|
||||
<?php include APP_ROOT . '/templates/header.php'; ?>
|
||||
<?php
|
||||
$isAdmin = true;
|
||||
$bodyClass = "admin-body";
|
||||
require_once APP_ROOT . "/templates/head.php";
|
||||
?>
|
||||
<?php include APP_ROOT . "/templates/header.php"; ?>
|
||||
|
||||
<main id="main-content">
|
||||
<h1>Éditer : <?= htmlspecialchars($page['title']) ?></h1>
|
||||
<h1>É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="csrf_token" value="<?= htmlspecialchars(
|
||||
$_SESSION["csrf_token"],
|
||||
) ?>">
|
||||
<input type="hidden" name="slug" value="<?= htmlspecialchars($slug) ?>">
|
||||
|
||||
<div>
|
||||
<label for="editor">Contenu (Markdown) :</label>
|
||||
<input type="hidden" id="content" name="content"
|
||||
value="<?= htmlspecialchars($page['content'] ?? '') ?>">
|
||||
value="<?= htmlspecialchars($page["content"] ?? "") ?>">
|
||||
<div id="editor"></div>
|
||||
</div>
|
||||
|
||||
<div class="admin-form-footer">
|
||||
<button type="submit" class="admin-btn">Enregistrer</button>
|
||||
@@ -63,4 +67,4 @@ JS;
|
||||
</div>
|
||||
</form>
|
||||
</main>
|
||||
<?php require_once APP_ROOT . '/templates/admin/footer.php'; ?>
|
||||
<?php require_once APP_ROOT . "/templates/admin/footer.php"; ?>
|
||||
|
||||
Reference in New Issue
Block a user