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