BLACKSITE
:
216.73.216.62
:
147.93.18.13 / vinyasaweddings.com
:
Linux srv667811 6.8.0-134-generic #134-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun 26 18:43:11 UTC 2026 x86_64
:
/
var
/
www
/
vkraft
/
views
/
admin
/
Upload File:
files >> /var/www/vkraft/views/admin/banners-manage.php
<?php include 'views/admin/layout/header.php'; ?> <?php include 'views/admin/layout/Sidebar.php'; ?> <?php require_once __DIR__ . '/../../db.php'; // Handle status update $updated = false; $deleted = false; if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['id'], $_POST['status'])) { $id = $_POST['id']; $status = $_POST['status']; if (in_array($status, ['active', 'inactive'])) { $stmt = $db->prepare("UPDATE banners SET status = ? WHERE id = ?"); if ($stmt->execute([$status, $id])) { $_SESSION['banner_status_updated'] = true; echo "<script>location.href=window.location.href;</script>"; // JS redirect to clear POST exit; } } } if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['delete'], $_POST['id'])) { $id = $_POST['id']; // Get banner file name $stmt = $db->prepare("SELECT image FROM banners WHERE id = ?"); $stmt->execute([$id]); $banner = $stmt->fetch(PDO::FETCH_ASSOC); if ($banner) { $filePath = __DIR__ . '/../../uploads/banners/' . $banner['image']; if (file_exists($filePath)) { unlink($filePath); // delete file } // Delete from DB $stmt = $db->prepare("DELETE FROM banners WHERE id = ?"); if ($stmt->execute([$id])) { $deleted = true; echo "<script>location.href=window.location.href;</script>"; exit; } } } // Fetch all banners $stmt = $db->query("SELECT * FROM banners ORDER BY id DESC"); $banners = $stmt->fetchAll(PDO::FETCH_ASSOC); ?> <main class="main-content"> <div class="container"> <div class="d-flex justify-content-between align-items-center mb-4"> <h1>Manage Banners</h1> <a href="banners-add" class="btn btn-primary"> <i class="fas fa-plus me-2"></i> Add New Banner </a> </div> <?php if ($updated): ?> <div class="alert alert-success fade-alert text-center mx-4">Banner status updated successfully!</div> <?php elseif ($deleted): ?> <div class="alert alert-success fade-alert text-center mx-4">Banner deleted successfully!</div> <?php endif; ?> <div class="card shadow-sm"> <div class="card-body"> <div class="table-responsive"> <table class="table table-hover align-middle"> <thead> <tr> <th width="50">#</th> <th>Banner</th> <th>Title</th> <th>Status</th> <th>Action</th> <!-- <th width="150">Actions</th> --> </tr> </thead> <tbody> <?php if (count($banners) > 0): ?> <?php foreach ($banners as $index => $banner): ?> <tr> <td><?= $index + 1 ?></td> <td> <?php $file = $banner['image']; $extension = strtolower(pathinfo($file, PATHINFO_EXTENSION)); $videoExtensions = ['mp4', 'webm', 'ogg']; if (in_array($extension, $videoExtensions)) { // Show video ?> <video width="150" autoplay muted loop style="border-radius: 5px;"> <source src="<?= BASE_URL ?>/uploads/banners/<?= htmlspecialchars($file) ?>" type="video/<?= $extension ?>"> Your browser does not support the video tag. </video> <?php } else { // Show image ?> <img src="<?= BASE_URL ?>/uploads/banners/<?= htmlspecialchars($file) ?>" alt="Banner Image" class="img-thumbnail" style="width: 150px; height: auto;"> <?php } ?> </td> <td><?= htmlspecialchars($banner['title']) ?></td> <td> <form method="POST" action="" style="margin: 0;"> <input type="hidden" name="id" value="<?= $banner['id'] ?>"> <select name="status" class="form-select form-select-sm" style="width: 120px;" onchange="this.form.submit()"> <option value="active" <?= $banner['status'] === 'active' ? 'selected' : '' ?>> Active</option> <option value="inactive" <?= $banner['status'] === 'inactive' ? 'selected' : '' ?>>Inactive</option> </select> </form> </td> <td> <form method="POST" action="" style="display:inline-block;" onsubmit="return confirm('Are you sure you want to delete this banner?');"> <input type="hidden" name="id" value="<?= $banner['id'] ?>"> <input type="hidden" name="delete" value="1"> <button type="submit" class="btn btn-sm btn-outline-danger"> <i class="fas fa-trash"></i> </button> </form> </td> <!-- <td> <a href="banner-edit.php?id=<?= $banner['id'] ?>" class="btn btn-sm btn-outline-primary me-1"> <i class="fas fa-edit"></i> </a> <a href="delete-banner.php?id=<?= $banner['id'] ?>" onclick="return confirm('Are you sure?')" class="btn btn-sm btn-outline-danger"> <i class="fas fa-trash"></i> </a> </td> --> </tr> <?php endforeach; ?> <?php else: ?> <tr> <td colspan="5" class="text-center">No banners found.</td> </tr> <?php endif; ?> </tbody> </table> </div> <!-- <nav aria-label="Page navigation" class="mt-4"> <ul class="pagination justify-content-center"> <li class="page-item disabled"> <a class="page-link" href="#" tabindex="-1">Previous</a> </li> <li class="page-item active"><a class="page-link" href="#">1</a></li> <li class="page-item"><a class="page-link" href="#">2</a></li> <li class="page-item"><a class="page-link" href="#">3</a></li> <li class="page-item"> <a class="page-link" href="#">Next</a> </li> </ul> </nav> --> </div> </div> </div> </main> <script> setTimeout(() => { const alert = document.querySelector('.fade-alert'); if (alert) { alert.style.transition = 'opacity 0.5s'; alert.style.opacity = 0; setTimeout(() => alert.remove(), 500); } }, 2000); </script> <?php include 'views/admin/layout/footer.php'; ?>