true]); Security::requireAdmin(); require_once __DIR__ . '/../config/database.php'; $db = getDatabase(); $feedback = ''; $feedbackType = ''; // ── Sauvegarde ──────────────────────────────────────────── if ($_SERVER['REQUEST_METHOD'] === 'POST') { Security::verifyCsrf($_POST['csrf_token'] ?? ''); $saved = 0; foreach ($_POST as $key => $value) { if (str_starts_with($key, 'content_')) { $contentKey = substr($key, 8); // retire "content_" $stmt = $db->prepare( 'UPDATE site_content SET content_value = :val WHERE content_key = :key' ); $stmt->execute([ 'val' => trim($value), 'key' => $contentKey, ]); $saved++; } } $feedback = "{$saved} champ(s) enregistré(s) avec succès."; $feedbackType = 'success'; } // ── Chargement du contenu ───────────────────────────────── $rows = $db->query('SELECT * FROM site_content ORDER BY section ASC, id ASC')->fetchAll(); $content = []; $sections = []; foreach ($rows as $row) { $content[$row['content_key']] = $row; $sections[$row['section']][] = $row; } $sectionLabels = [ 'seo' => '🔍 SEO & Métadonnées', 'hero' => '🚀 Hero — Section principale', 'about' => '👤 À propos', 'contact' => '📬 Contact', 'footer' => '🔻 Footer', 'general' => '⚙️ Général', ]; ?>