X7ROOT File Manager
Current Path:
/home/u126090504/domains/oceanicabeachresort.com/public_html/admin
home
/
u126090504
/
domains
/
oceanicabeachresort.com
/
public_html
/
admin
/
📁
..
📁
assets
📄
banners.php
(9.78 KB)
📄
booking-dashboard.php
(4.93 KB)
📄
booking_status_update.php
(6.14 KB)
📄
booking_view.php
(4.04 KB)
📄
branding_settings.php
(5.93 KB)
📄
change_password.php
(3.01 KB)
📄
contacts.php
(3.83 KB)
📄
dashboard.php
(5.64 KB)
📁
dompdf
📄
downloads.php
(4.91 KB)
📄
forgot_password.php
(5.76 KB)
📄
gallery.php
(3.08 KB)
📁
img
📁
includes
📄
index.php
(82 B)
📁
invoices
📄
login.php
(13.47 KB)
📄
logo.png
(19.29 KB)
📄
logout.php
(102 B)
📄
manage_albums.php
(10.82 KB)
📄
manage_media.php
(11.77 KB)
📄
manage_photos.php
(6.35 KB)
📄
manage_videos.php
(18.38 KB)
📄
new_password.php
(3.9 KB)
📄
notice.php
(15.52 KB)
📄
notice_error.log
(38.45 KB)
📄
notices.php
(8.24 KB)
📄
payments.php
(14.96 KB)
📄
pdf_bill_template.php
(30.69 KB)
📁
phpmailer
📄
popup.php
(14.07 KB)
📄
reset_password.php
(2.27 KB)
📄
secure_session.php
(1000 B)
📄
settings.php
(8.34 KB)
📄
test.php
(239 B)
📄
test_pdf.php
(1.58 KB)
📄
testimonials.php
(15.15 KB)
📁
tmp
📄
update_status.php
(1.66 KB)
📄
upi_settings.php
(1.52 KB)
Editing: downloads.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 $success = $error = ""; $allowedTypes = ['pdf','doc','docx','jpg','jpeg','png']; $maxSize = 5 * 1024 * 1024; $success = $error = ""; // ✅ Add Download if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['add_download'])) { $subject = trim($_POST['subject']); $file = ''; if (!empty($_FILES['dfile']['name'])) { $targetDir = __DIR__ . "/../uploads/downloads/"; if (!is_dir($targetDir)) mkdir($targetDir, 0755, true); $ext = strtolower(pathinfo($_FILES['dfile']['name'], PATHINFO_EXTENSION)); if (!in_array($ext, $allowedTypes)) { $error = "❌ Only PDF, DOC, DOCX, JPG, PNG allowed."; } elseif ($_FILES['dfile']['size'] > $maxSize) { $error = "❌ File too large (max 5MB)."; } else { $safeName = time() . "_" . bin2hex(random_bytes(5)) . "." . $ext; $targetFile = $targetDir . $safeName; if (move_uploaded_file($_FILES['dfile']['tmp_name'], $targetFile)) { $file = $safeName; } } } if (!$error && $file) { $stmt = $conn->prepare("INSERT INTO downloads (subject, file_name) VALUES (?, ?)"); $stmt->bind_param("ss", $subject, $file); $stmt->execute(); $success = "✅ File uploaded successfully."; } } // ✅ Delete Download if (isset($_GET['delete'])) { $id = intval($_GET['delete']); $stmt = $conn->prepare("SELECT file_name FROM downloads WHERE id=?"); $stmt->bind_param("i", $id); $stmt->execute(); $stmt->bind_result($oldFile); $stmt->fetch(); $stmt->close(); if ($oldFile && file_exists(__DIR__."/../uploads/downloads/".$oldFile)) { unlink(__DIR__."/../uploads/downloads/".$oldFile); } $stmt = $conn->prepare("DELETE FROM downloads WHERE id=?"); $stmt->bind_param("i", $id); $stmt->execute(); $success = "⚠️ File deleted."; } ?> <div class="container mt-4"> <h3>📂 Manage Downloads</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 Download --> <div class="card mb-4"> <div class="card-header">➕ Add New Download</div> <div class="card-body"> <form method="POST" enctype="multipart/form-data"> <div class="form-group"><label>Subject</label><input type="text" name="subject" class="form-control" required></div> <div class="form-group"><label>File</label><input type="file" name="dfile" class="form-control" required></div> <button type="submit" name="add_download" class="btn btn-primary">Upload</button> </form> </div> </div> <!-- List Downloads --> <div class="table-responsive"> <table class="table table-bordered text-center"> <thead class="thead-dark"> <tr><th>ID</th><th>Subject</th><th>File</th><th>Action</th></tr> </thead> <tbody> <?php $res = $conn->query("SELECT * FROM downloads ORDER BY id DESC"); if ($res->num_rows > 0) { while ($row = $res->fetch_assoc()) { $fileUrl = "../uploads/downloads/" . htmlspecialchars($row['file_name']); $ext = strtolower(pathinfo($row['file_name'], PATHINFO_EXTENSION)); // ✅ Icon logic (same as frontend) if ($ext === "pdf") { $icon = "<img src='../images/pd.png' alt='PDF' style='height:40px;'>"; } elseif ($ext === "doc" || $ext === "docx") { $icon = "<img src='../images/doc.png' alt='DOC' style='height:40px;'>"; } elseif (in_array($ext, ["jpg","jpeg","png"])) { $icon = "<img src='{$fileUrl}' alt='Image' style='height:40px;border-radius:5px;'>"; } else { $icon = "<img src='../images/file.png' alt='File' style='height:40px;'>"; } echo "<tr> <td>{$row['id']}</td> <td>".htmlspecialchars($row['subject'])."</td> <td><a href='{$fileUrl}' target='_blank' download>{$icon}</a></td> <td> <a href='?delete={$row['id']}' class='btn btn-danger btn-sm' onclick='return confirm(\"Delete this file?\")'>Delete</a> </td> </tr>"; } } else { echo "<tr><td colspan='4'>No Records Found</td></tr>"; } ?> </tbody> </table> </div> </div> <?php include 'includes/footer.php'; ?>
Upload File
Create Folder