diff --git a/.session_id b/.session_id
new file mode 100644
index 0000000..245e4c1
--- /dev/null
+++ b/.session_id
@@ -0,0 +1 @@
+jbuvnmdmjhe702uecv5o643pb7
\ No newline at end of file
diff --git a/admin_landing_pages.php b/admin_landing_pages.php
index 47ba94a..e05fddf 100644
--- a/admin_landing_pages.php
+++ b/admin_landing_pages.php
@@ -4,7 +4,7 @@ declare(strict_types=1);
require_once __DIR__ . '/includes/app.php';
require_once __DIR__ . '/includes/layout.php';
-if (empty($_SESSION['user_id']) || $_SESSION['role'] !== 'admin') {
+if (empty($_SESSION['user_id']) || $_SESSION['user_role'] !== 'admin') {
header('Location: ' . url_with_lang('login.php'));
exit;
}
@@ -42,7 +42,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
}
if ($action === 'create') {
- $stmt = $pdo->prepare("INSERT INTO landing_sections (title, subtitle, content, image_path, layout, button_text, button_link, section_order, is_active) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)");
+ $stmt = $pdo->prepare("INSERT INTO landing_sections (title, subtitle, content, image_path, layout, button_text, button_link, section_order, is_active, section_type) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, 'custom')");
$stmt->execute([$title, $subtitle, $content, $image_path, $layout, $button_text, $button_link, $section_order, $is_active]);
set_flash('success', 'Section created successfully.');
} else {
@@ -55,9 +55,16 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
} elseif ($action === 'delete') {
$id = $_POST['id'] ?? null;
if ($id) {
- $stmt = $pdo->prepare("DELETE FROM landing_sections WHERE id=?");
+ $stmt = $pdo->prepare("SELECT section_type FROM landing_sections WHERE id=?");
$stmt->execute([$id]);
- set_flash('success', 'Section deleted successfully.');
+ $sec = $stmt->fetch();
+ if ($sec && $sec['section_type'] !== 'custom') {
+ set_flash('danger', 'Built-in sections cannot be deleted, but you can hide them by unchecking Active.');
+ } else {
+ $stmt = $pdo->prepare("DELETE FROM landing_sections WHERE id=?");
+ $stmt->execute([$id]);
+ set_flash('success', 'Section deleted successfully.');
+ }
}
header('Location: ' . url_with_lang('admin_landing_pages.php'));
exit;
@@ -120,12 +127,13 @@ render_header(t('app_name') . ' - Landing Pages', 'admin');
+ Not applicable for most built-in sections.
-