diff --git a/admin/ad_edit.php b/admin/ad_edit.php
new file mode 100644
index 0000000..a6ce844
--- /dev/null
+++ b/admin/ad_edit.php
@@ -0,0 +1,146 @@
+prepare("SELECT * FROM ads_images WHERE id = ?");
+ $stmt->execute([$id]);
+ $ad = $stmt->fetch();
+ if ($ad) {
+ $isEdit = true;
+ } else {
+ header("Location: ads.php");
+ exit;
+ }
+}
+
+if ($_SERVER['REQUEST_METHOD'] === 'POST') {
+ $title = trim($_POST['title']);
+ $sort_order = (int)$_POST['sort_order'];
+ $is_active = isset($_POST['is_active']) ? 1 : 0;
+ $image_path = $isEdit ? $ad['image_path'] : null;
+
+ if (isset($_FILES['image']) && $_FILES['image']['error'] === UPLOAD_ERR_OK) {
+ $uploadDir = __DIR__ . '/../assets/images/ads/';
+ if (!is_dir($uploadDir)) {
+ mkdir($uploadDir, 0755, true);
+ }
+
+ $fileInfo = pathinfo($_FILES['image']['name']);
+ $fileExt = strtolower($fileInfo['extension']);
+ $allowedExts = ['jpg', 'jpeg', 'png', 'gif', 'webp'];
+
+ if (in_array($fileExt, $allowedExts)) {
+ $fileName = uniqid('ad_') . '.' . $fileExt;
+ $targetFile = $uploadDir . $fileName;
+
+ if (move_uploaded_file($_FILES['image']['tmp_name'], $targetFile)) {
+ $image_path = 'assets/images/ads/' . $fileName;
+ } else {
+ $message = '
Failed to upload image.
';
+ }
+ } else {
+ $message = 'Invalid file type. Allowed: jpg, png, gif, webp.
';
+ }
+ }
+
+ if (empty($image_path) && !$isEdit) {
+ $message = 'Image is required for new advertisements.
';
+ }
+
+ if (empty($message)) {
+ try {
+ if ($isEdit) {
+ $stmt = $pdo->prepare("UPDATE ads_images SET title = ?, sort_order = ?, is_active = ?, image_path = ? WHERE id = ?");
+ $stmt->execute([$title, $sort_order, $is_active, $image_path, $id]);
+ header("Location: ads.php?success=updated");
+ exit;
+ } else {
+ $stmt = $pdo->prepare("INSERT INTO ads_images (title, sort_order, is_active, image_path) VALUES (?, ?, ?, ?)");
+ $stmt->execute([$title, $sort_order, $is_active, $image_path]);
+ header("Location: ads.php?success=created");
+ exit;
+ }
+ } catch (PDOException $e) {
+ $message = 'Database error: ' . $e->getMessage() . '
';
+ }
+ }
+}
+
+if (!$isEdit) {
+ $ad = [
+ 'title' => $_POST['title'] ?? '',
+ 'sort_order' => $_POST['sort_order'] ?? 0,
+ 'is_active' => 1,
+ 'image_path' => ''
+ ];
+}
+
+include 'includes/header.php';
+?>
+
+
+
+= $message ?>
+
+
+
+
\ No newline at end of file
diff --git a/admin/ads.php b/admin/ads.php
new file mode 100644
index 0000000..823914c
--- /dev/null
+++ b/admin/ads.php
@@ -0,0 +1,120 @@
+exec("CREATE TABLE IF NOT EXISTS ads_images (
+ id INT AUTO_INCREMENT PRIMARY KEY,
+ image_path VARCHAR(255) NOT NULL,
+ title VARCHAR(255) DEFAULT NULL,
+ sort_order INT DEFAULT 0,
+ is_active TINYINT(1) DEFAULT 1,
+ created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
+)");
+
+if (isset($_GET['delete'])) {
+ $id = $_GET['delete'];
+
+ // Get image path to delete file
+ $stmt = $pdo->prepare("SELECT image_path FROM ads_images WHERE id = ?");
+ $stmt->execute([$id]);
+ $ad = $stmt->fetch();
+
+ if ($ad) {
+ $fullPath = __DIR__ . '/../' . $ad['image_path'];
+ if (file_exists($fullPath) && is_file($fullPath)) {
+ unlink($fullPath);
+ }
+ $pdo->prepare("DELETE FROM ads_images WHERE id = ?")->execute([$id]);
+ }
+
+ header("Location: ads.php");
+ exit;
+}
+
+$query = "SELECT * FROM ads_images ORDER BY sort_order ASC, created_at DESC";
+$ads_pagination = paginate_query($pdo, $query);
+$ads = $ads_pagination['data'];
+
+include 'includes/header.php';
+?>
+
+
+
+
Advertisement Slider
+
Manage pictures for the public ads display page.
+
+
+ Add Image
+
+
+
+
+
+
+ These images will be displayed in a slider on the
ads.php page.
+ You can upload up to 7 images for optimal performance.
+
+
+
+
+
+
+
+
+
+
+
+
+ | Order |
+ Preview |
+ Title / Caption |
+ Status |
+ Actions |
+
+
+
+
+
+ | = $ad['sort_order'] ?> |
+
+
+ |
+
+ = htmlspecialchars($ad['title'] ?: 'No title') ?>
+ = htmlspecialchars($ad['image_path']) ?>
+ |
+
+
+ Active
+
+ Inactive
+
+ |
+
+
+
+ |
+
+
+
+
+ |
+
+ No advertisement images found. Click "Add Image" to get started.
+ |
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/admin/includes/footer.php b/admin/includes/footer.php
index ca10c72..f30cd78 100644
--- a/admin/includes/footer.php
+++ b/admin/includes/footer.php
@@ -2,8 +2,14 @@
+
+