๐Ÿš€ Hostinger Optimized
๐Ÿ–ฅ๏ธ Server: LiteSpeed
๐Ÿ’ป System: Linux s20058.bom1.stableserver.net 5.14.0-611.55.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue May 19 15:19:29 EDT 2026 x86_64
๐Ÿ‘ค User: skhata (1324)
๐Ÿ˜ PHP: 8.4.20
๐Ÿšซ Disabled: โœจ NONE

๐Ÿ’ป Terminal

๐Ÿ“ /home/skhata/chandrasons.com/public
$

๐Ÿ“„ hero-slides.php

๐Ÿ“ Path: /home/skhata/pimsnepal.com.np/admin/hero-slides.php
๐Ÿ“Š Size: 5.12 KB
๐Ÿ”’ Perm: 0644
๐Ÿ“ MIME: text/x-php
<?php
require_once __DIR__ . '/../includes/functions.php';
requireAdmin();
require __DIR__ . '/includes/ui.php';
$pageTitle = 'Hero / Banner Slides';

if ($_SERVER['REQUEST_METHOD'] === 'POST' && csrfVerify($_POST['csrf_token'] ?? null)) {
    $action = $_POST['action'] ?? '';
    if ($action === 'save') {
        $id = (int) ($_POST['id'] ?? 0);
        $imagePath = handleUpload('image', 'gallery');
        $fields = [
            trim($_POST['badge'] ?? ''),
            trim($_POST['title'] ?? ''),
            trim($_POST['subtitle'] ?? ''),
            trim($_POST['cta_text'] ?? ''),
            trim($_POST['cta_link'] ?? ''),
            trim($_POST['offer'] ?? ''),
            (int) ($_POST['sort_order'] ?? 0),
            isset($_POST['is_active']) ? 1 : 0,
        ];
        if ($id > 0) {
            if ($imagePath) {
                db()->prepare('UPDATE hero_slides SET badge=?,title=?,subtitle=?,cta_text=?,cta_link=?,offer=?,sort_order=?,is_active=?,image_path=? WHERE id=?')->execute([...$fields, $imagePath, $id]);
            } else {
                db()->prepare('UPDATE hero_slides SET badge=?,title=?,subtitle=?,cta_text=?,cta_link=?,offer=?,sort_order=?,is_active=? WHERE id=?')->execute([...$fields, $id]);
            }
        } else {
            db()->prepare('INSERT INTO hero_slides (badge,title,subtitle,cta_text,cta_link,offer,sort_order,is_active,image_path) VALUES (?,?,?,?,?,?,?,?,?)')->execute([...$fields, $imagePath]);
        }
        flash('success', 'Hero slide saved.');
    } elseif ($action === 'delete') {
        db()->prepare('DELETE FROM hero_slides WHERE id = ?')->execute([(int) ($_POST['id'] ?? 0)]);
        flash('success', 'Hero slide deleted.');
    }
    redirect('hero-slides.php');
}

require __DIR__ . '/includes/admin-header.php';
adminFlashBox();
$slides = db()->query('SELECT * FROM hero_slides ORDER BY sort_order ASC, id ASC')->fetchAll();
$editId = (int) ($_GET['edit'] ?? 0);
$editing = null;
foreach ($slides as $s) { if ((int) $s['id'] === $editId) $editing = $s; }
?>
<div class="grid lg:grid-cols-3 gap-6">
  <div class="lg:col-span-2 space-y-4">
    <?php foreach ($slides as $s): ?>
      <div class="bg-white rounded-2xl border border-gray-100 p-5 flex items-center gap-4">
        <?php if ($s['image_path']): ?><img src="../<?= e($s['image_path']) ?>" class="w-20 h-16 object-cover rounded-lg shrink-0" /><?php endif; ?>
        <div class="flex-1 min-w-0">
          <p class="font-semibold text-sm truncate"><?= e($s['title']) ?></p>
          <p class="text-xs text-gray-500 truncate"><?= e($s['badge']) ?> ยท order <?= (int) $s['sort_order'] ?> ยท <?= $s['is_active'] ? 'active' : 'hidden' ?></p>
        </div>
        <a href="?edit=<?= (int) $s['id'] ?>" class="text-primary font-semibold text-sm">Edit</a>
        <form method="post" onsubmit="return confirm('Delete this slide?');">
          <input type="hidden" name="csrf_token" value="<?= e(csrfToken()) ?>" />
          <input type="hidden" name="action" value="delete" />
          <input type="hidden" name="id" value="<?= (int) $s['id'] ?>" />
          <button class="text-red-600 font-semibold text-sm">Delete</button>
        </form>
      </div>
    <?php endforeach; ?>
    <?php if (!$slides): ?><p class="text-sm text-gray-400">No hero slides yet.</p><?php endif; ?>
  </div>
  <div class="bg-white rounded-2xl border border-gray-100 p-6 h-fit">
    <h2 class="font-heading font-semibold mb-4"><?= $editing ? 'Edit Slide' : 'Add Slide' ?></h2>
    <form method="post" enctype="multipart/form-data">
      <input type="hidden" name="csrf_token" value="<?= e(csrfToken()) ?>" />
      <input type="hidden" name="action" value="save" />
      <input type="hidden" name="id" value="<?= (int) ($editing['id'] ?? 0) ?>" />
      <?php inputField('Badge', 'badge', $editing['badge'] ?? '', 'text', false, 'e.g. New: TallyPrime 7.1'); ?>
      <?php inputField('Title', 'title', $editing['title'] ?? '', 'text', true); ?>
      <?php textareaField('Subtitle', 'subtitle', $editing['subtitle'] ?? '', 3); ?>
      <?php inputField('CTA Button Text', 'cta_text', $editing['cta_text'] ?? ''); ?>
      <?php inputField('CTA Button Link', 'cta_link', $editing['cta_link'] ?? ''); ?>
      <?php inputField('Offer Tag (optional)', 'offer', $editing['offer'] ?? ''); ?>
      <label class="block mb-4">
        <span class="block text-sm font-medium text-gray-700 mb-1.5">Slide Image</span>
        <?php if (!empty($editing['image_path'])): ?><img src="../<?= e($editing['image_path']) ?>" class="h-16 mb-2 rounded-lg" /><?php endif; ?>
        <input type="file" name="image" accept="image/*" class="text-sm" />
      </label>
      <?php numberField('Sort Order', 'sort_order', $editing['sort_order'] ?? 0); ?>
      <?php checkboxField('Active', 'is_active', $editing ? !empty($editing['is_active']) : true); ?>
      <button class="btn-primary-brand bg-primary text-white px-5 py-2.5 rounded-lg font-semibold w-full"><?= $editing ? 'Update' : 'Add Slide' ?></button>
      <?php if ($editing): ?><a href="hero-slides.php" class="block text-center text-sm text-gray-500 mt-3">Cancel edit</a><?php endif; ?>
    </form>
  </div>
</div>
<?php require __DIR__ . '/includes/admin-footer.php'; ?>
โ† Back๐Ÿ“ฅ Rawโœ๏ธ Edit๐Ÿ”’ Chmod
โœจ File Manager Magic โœจ