X7ROOT File Manager
Current Path:
/home/u126090504/domains/sketkaranjia.com/public_html/admin
home
/
u126090504
/
domains
/
sketkaranjia.com
/
public_html
/
admin
/
📁
..
📄
achievers.php
(21.44 KB)
📄
achv_cat_manage.php
(7.99 KB)
📄
achv_edit.php
(9.58 KB)
📄
achv_list.php
(8.08 KB)
📄
achv_upload.php
(13.39 KB)
📄
admin-academic-calendar.php
(20.41 KB)
📄
admin-public-disclosure.php
(18.36 KB)
📄
admissions.php
(28.76 KB)
📄
admissions_error.log
(56 KB)
📁
assets
📄
banners.php
(9.78 KB)
📄
branding_settings.php
(5.93 KB)
📄
change_password.php
(3.01 KB)
📄
class_master.php
(4.32 KB)
📄
contacts.php
(3.83 KB)
📄
dashboard.php
(27.76 KB)
📄
downloads.php
(4.91 KB)
📄
edit_faculty.php
(6.85 KB)
📄
events.php
(920 B)
📄
export_franchise.php
(930 B)
📄
faculty.php
(8.36 KB)
📄
fees_list.php
(8.48 KB)
📄
fees_upload.php
(6.19 KB)
📄
forgot_password.php
(5.76 KB)
📄
franchise.php
(7.28 KB)
📄
gallery.php
(3.08 KB)
📄
grievance-update.php
(1003 B)
📄
grievance-view.php
(8.51 KB)
📄
grievances.php
(9.55 KB)
📄
homework_add.php
(5.98 KB)
📄
homework_edit.php
(9.39 KB)
📄
homework_list.php
(2.24 KB)
📁
img
📁
includes
📄
index.php
(82 B)
📄
login.php
(13.47 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)
📄
managing-committee.php
(13.64 KB)
📄
master_menu.php
(5.75 KB)
📄
master_menu_debug.php
(3.73 KB)
📄
new_password.php
(3.9 KB)
📄
non_academic_achievers.php
(21.2 KB)
📄
notice.php
(15.52 KB)
📄
notice_error.log
(38.45 KB)
📄
notices.php
(8.24 KB)
📄
payments.php
(14.96 KB)
📁
phpmailer
📄
popup.php
(14.07 KB)
📄
reset_password.php
(2.27 KB)
📄
section_master.php
(6.59 KB)
📄
sections_by_class.php
(346 B)
📄
secure_session.php
(1000 B)
📄
settings.php
(8.34 KB)
📄
student_photo_update.php
(1.8 KB)
📄
subject_master.php
(6.16 KB)
📄
submit-grievance.php
(4.97 KB)
📄
testimonials.php
(15.15 KB)
📄
update_status.php
(1.66 KB)
📄
upi_settings.php
(1.52 KB)
Editing: admin-public-disclosure.php
<?php /******************************* * admin-public-disclosure.php * Public Disclosures: CRUD + Search (PDF only) *******************************/ include 'secure_session.php'; include 'includes/auth.php'; require_once '../config.php'; // mysqli $conn include 'includes/header.php'; /* ---------- SETTINGS ---------- */ $uploadRelDir = 'uploads/disclosures/'; // relative (stored in DB) $uploadAbsDir = realpath(__DIR__ . '/..') . '/' . $uploadRelDir; // absolute for move $maxSize = 8 * 1024 * 1024; // 8 MB $allowedExt = ['pdf']; // only PDF $success = $error = ''; if (!is_dir($uploadAbsDir)) { @mkdir($uploadAbsDir, 0755, true); } /* ---------- HELPERS ---------- */ function sanitizeFileName($name) { $name = preg_replace('/[^a-zA-Z0-9\.\-_]/', '_', $name); return preg_replace('/\.+/', '.', $name); } function isPdf($tmpPath) { if (!is_file($tmpPath)) return false; $finfo = finfo_open(FILEINFO_MIME_TYPE); $mime = finfo_file($finfo, $tmpPath); finfo_close($finfo); return $mime === 'application/pdf'; } function parse_date_yyyy_mm_dd($in) { $in = trim((string)$in); if ($in === '') return null; if (preg_match('~^\d{2}-\d{2}-\d{4}$~', $in)) { [$d,$m,$y] = explode('-', $in); if (checkdate((int)$m, (int)$d, (int)$y)) return sprintf('%04d-%02d-%02d', $y, $m, $d); } if (preg_match('~^\d{4}-\d{2}-\d{2}$~', $in)) return $in; return null; } /* ---------- ADD ---------- */ if ($_SERVER['REQUEST_METHOD'] === 'POST' && (($_POST['action'] ?? '') === 'add')) { $subject = trim($_POST['subject'] ?? ''); $sort_order = (int)($_POST['sort_order'] ?? 0); $status = (($_POST['status'] ?? 'active') === 'inactive') ? 'inactive' : 'active'; if ($subject === '') $error = "Subject is required."; if (!$error) { if (!isset($_FILES['pdf']) || $_FILES['pdf']['error'] !== UPLOAD_ERR_OK) { $error = "Please choose a PDF file."; } else { $ext = strtolower(pathinfo($_FILES['pdf']['name'], PATHINFO_EXTENSION)); if (!in_array($ext, $allowedExt)) $error = "Only PDF files are allowed."; elseif ($_FILES['pdf']['size'] > $maxSize) $error = "File too large (max 8MB)."; elseif (!isPdf($_FILES['pdf']['tmp_name'])) $error = "Invalid PDF file."; } } if (!$error) { $safeBase = sanitizeFileName(pathinfo($_FILES['pdf']['name'], PATHINFO_FILENAME)); $newName = time() . '_' . bin2hex(random_bytes(4)) . '_' . $safeBase . '.pdf'; if (move_uploaded_file($_FILES['pdf']['tmp_name'], $uploadAbsDir.$newName)) { $fileRel = $uploadRelDir . $newName; $stmt = $conn->prepare("INSERT INTO public_disclosures (subject, file_path, status, sort_order) VALUES (?,?,?,?)"); $stmt->bind_param("sssi", $subject, $fileRel, $status, $sort_order); $stmt->execute(); $success = "✅ Document added."; } else { $error = "Upload failed."; } } } /* ---------- DELETE ---------- */ if (isset($_GET['delete'])) { $id = (int)$_GET['delete']; if ($id > 0) { $stmt = $conn->prepare("SELECT file_path FROM public_disclosures WHERE id=?"); $stmt->bind_param("i", $id); $stmt->execute(); $stmt->bind_result($oldPath); $stmt->fetch(); $stmt->close(); if ($oldPath) { $abs = realpath(__DIR__ . '/..') . '/' . $oldPath; if (is_file($abs)) @unlink($abs); } $del = $conn->prepare("DELETE FROM public_disclosures WHERE id=?"); $del->bind_param("i", $id); $del->execute(); $success = "⚠️ Document deleted."; } } /* ---------- TOGGLE STATUS ---------- */ if (isset($_GET['toggle'])) { $id = (int)$_GET['toggle']; $q = $conn->prepare("UPDATE public_disclosures SET status = IF(status='active','inactive','active') WHERE id=?"); $q->bind_param("i", $id); $q->execute(); $success = "🔁 Status changed."; } /* ---------- UPDATE ---------- */ if ($_SERVER['REQUEST_METHOD'] === 'POST' && (($_POST['action'] ?? '') === 'update')) { $id = (int)($_POST['id'] ?? 0); $subject = trim($_POST['subject'] ?? ''); $sort_order = (int)($_POST['sort_order'] ?? 0); $status = (($_POST['status'] ?? 'active') === 'inactive') ? 'inactive' : 'active'; $replace = isset($_POST['replace_file']); if ($id <= 0) $error = "Invalid record."; if ($subject === '') $error = "Subject is required."; if (!$error) { $stmt = $conn->prepare("SELECT file_path FROM public_disclosures WHERE id=?"); $stmt->bind_param("i", $id); $stmt->execute(); $stmt->bind_result($oldPath); $stmt->fetch(); $stmt->close(); $newRel = $oldPath; if ($replace && isset($_FILES['pdf']) && $_FILES['pdf']['error'] === UPLOAD_ERR_OK) { $ext = strtolower(pathinfo($_FILES['pdf']['name'], PATHINFO_EXTENSION)); if (!in_array($ext, $allowedExt)) $error = "Only PDF files are allowed."; elseif ($_FILES['pdf']['size'] > $maxSize) $error = "File too large (max 8MB)."; elseif (!isPdf($_FILES['pdf']['tmp_name'])) $error = "Invalid PDF file."; else { $safeBase = sanitizeFileName(pathinfo($_FILES['pdf']['name'], PATHINFO_FILENAME)); $newName = time() . '_' . bin2hex(random_bytes(4)) . '_' . $safeBase . '.pdf'; if (move_uploaded_file($_FILES['pdf']['tmp_name'], $uploadAbsDir.$newName)) { $newRel = $uploadRelDir . $newName; if ($oldPath) { $oldAbs = realpath(__DIR__ . '/..') . '/' . $oldPath; if (is_file($oldAbs)) @unlink($oldAbs); } } else { $error = "Upload failed."; } } } } if (!$error) { $up = $conn->prepare("UPDATE public_disclosures SET subject=?, file_path=?, status=?, sort_order=? WHERE id=?"); $up->bind_param("sssii", $subject, $newRel, $status, $sort_order, $id); $up->execute(); $success = "✏️ Changes saved."; } } /* ---------- SEARCH / FILTERS ---------- */ $kw = trim($_GET['q'] ?? ''); // subject keyword $status = trim($_GET['status'] ?? 'all'); // all/active/inactive $fromUi = trim($_GET['from'] ?? ''); // dd-mm-yyyy or yyyy-mm-dd $toUi = trim($_GET['to'] ?? ''); $from = parse_date_yyyy_mm_dd($fromUi); $to = parse_date_yyyy_mm_dd($toUi); $where = []; $params = []; $types = ''; if ($kw !== '') { $where[] = "subject LIKE CONCAT('%',?,'%')"; $params[] = $kw; $types .= 's'; } if ($status === 'active' || $status === 'inactive') { $where[] = "status = ?"; $params[] = $status; $types .= 's'; } if ($from) { $where[] = "DATE(created_at) >= ?"; $params[] = $from; $types .= 's'; } if ($to) { $where[] = "DATE(created_at) <= ?"; $params[] = $to; $types .= 's'; } $whereSql = $where ? ('WHERE ' . implode(' AND ', $where)) : ''; $orderSql = " ORDER BY sort_order ASC, created_at DESC"; $sql_list = "SELECT * FROM public_disclosures $whereSql $orderSql"; $sql_count = "SELECT COUNT(*) FROM public_disclosures"; $sql_count_f= "SELECT COUNT(*) FROM public_disclosures $whereSql"; /* totals */ $totalAll = 0; if ($rs = $conn->query($sql_count)) { $row = $rs->fetch_row(); $totalAll = (int)$row[0]; } if ($where) { $stmtC=$conn->prepare($sql_count_f); if ($types !== '') $stmtC->bind_param($types, ...$params); $stmtC->execute(); $stmtC->bind_result($cnt); $stmtC->fetch(); $stmtC->close(); $totalFiltered = (int)$cnt; $stmtL = $conn->prepare($sql_list); if ($types !== '') $stmtL->bind_param($types, ...$params); $stmtL->execute(); $list = $stmtL->get_result(); } else { $totalFiltered = $totalAll; $list = $conn->query($sql_list); } ?> <style> :root{ --brand:#e0332f; --ink:#202427; --text:#3a3f44; --muted:#6f7780; --line:#eef0f3; --chip:#f6f7f9; --shadow:0 8px 24px rgba(20,28,36,.06); } .page-wrap{ padding:20px 10px 40px; } .page-title{ font-weight:700; color:var(--ink); display:flex; align-items:center; gap:10px; } .page-title .emoji{ width:36px; height:36px; display:grid; place-items:center; border-radius:10px; background:rgba(224,51,47,.08); } .underline{ height:4px; background:linear-gradient(90deg,var(--brand),transparent 50%); border-radius:4px; margin:8px 0 20px; } .chip{ background:var(--chip); border:1px solid var(--line); border-radius:999px; padding:6px 10px; font-weight:600; } .btn-pill{ border-radius:999px!important; padding:.45rem .95rem!important; font-weight:700; } /* Search bar */ .search-bar{ background:#fff; border:1px solid var(--line); border-radius:14px; padding:16px; box-shadow:var(--shadow); margin-bottom:18px; } .search-grid{ display:grid; grid-template-columns: 1.2fr .6fr .6fr .6fr auto; gap:12px; } .search-grid .form-control, .search-grid .custom-select{ border-radius:10px; border:1px solid var(--line); } .search-actions{ display:flex; align-items:center; gap:8px; flex-wrap:wrap; } /* Cards & forms */ .card{ border:1px solid var(--line); border-radius:14px; box-shadow:var(--shadow); } .card-header{ font-weight:800; } label{ font-weight:700; color:var(--text); } .form-control{ border-radius:10px; border:1px solid var(--line); } .muted{ color:var(--muted); font-size:.9rem; } /* 2-column grid */ .two-col .form-grid{ display:grid; grid-template-columns:repeat(2,minmax(260px,1fr)); gap:16px 20px; } .two-col .span-2{ grid-column:1 / -1; } /* table */ .table-wrap{ border:1px solid var(--line); border-radius:14px; overflow:hidden; box-shadow:var(--shadow); } .table thead th{ background:#fafbfc; font-weight:800; } /* modal */ .modal-content{ border-radius:16px; } /* responsive */ @media(max-width:992px){ .search-grid{ grid-template-columns:1fr 1fr; } } @media(max-width:576px){ .search-grid{ grid-template-columns:1fr; } .two-col .form-grid{ grid-template-columns:1fr; } .two-col .span-2{ grid-column:auto; } } </style> <div class="container page-wrap"> <div class="d-flex align-items-center justify-content-between mb-2"> <h3 class="page-title"><span class="emoji">📄</span> Public Disclosures</h3> <span class="chip">Total: <strong><?= (int)$totalFiltered ?></strong></span> </div> <div class="underline"></div> <?php if ($success): ?><div class="alert alert-success"><?= $success ?></div><?php endif; ?> <?php if ($error): ?><div class="alert alert-danger"><?= $error ?></div><?php endif; ?> <!-- SEARCH BAR --> <div class="search-bar"> <form method="GET" class="search-grid" autocomplete="off" novalidate> <input type="text" name="q" value="<?= htmlspecialchars($kw) ?>" class="form-control" placeholder="Search subject..."> <select name="status" class="custom-select"> <option value="all" <?= $status==='all'?'selected':'' ?>>All</option> <option value="active" <?= $status==='active'?'selected':'' ?>>Active</option> <option value="inactive" <?= $status==='inactive'?'selected':'' ?>>Inactive</option> </select> <input type="text" name="from" value="<?= htmlspecialchars($fromUi) ?>" class="form-control" placeholder="From (dd-mm-yyyy)"> <input type="text" name="to" value="<?= htmlspecialchars($toUi) ?>" class="form-control" placeholder="To (dd-mm-yyyy)"> <div class="search-actions"> <button class="btn btn-primary btn-pill" type="submit">Search</button> <a class="btn btn-outline-secondary btn-pill" href="admin-public-disclosure.php">Reset</a> </div> </form> <div class="muted mt-2">Tip: Filter by date range or status to narrow down records.</div> </div> <!-- ADD FORM (2-COLUMN) --> <div class="card mb-4 two-col"> <div class="card-header">➕ Add New Document</div> <div class="card-body"> <form method="POST" enctype="multipart/form-data" autocomplete="off" novalidate> <input type="hidden" name="action" value="add"> <div class="form-grid"> <div> <label>Subject <span class="text-danger">*</span></label> <input type="text" name="subject" class="form-control" required maxlength="200"> </div> <div> <label>Status</label> <select name="status" class="form-control"> <option value="active" selected>Active</option> <option value="inactive">Inactive</option> </select> </div> <div> <label>Sort Order</label> <input type="number" name="sort_order" class="form-control" value="0"> <small class="muted">Lower shows first.</small> </div> <div class="span-2"> <label>PDF File <span class="text-danger">*</span></label> <input type="file" name="pdf" class="form-control" accept="application/pdf,.pdf" required> <small class="muted">Only PDF, max 8MB.</small> </div> </div> <button type="submit" class="btn btn-primary btn-pill mt-3">Upload</button> </form> </div> </div> <!-- LIST --> <div class="table-wrap"> <div class="table-responsive"> <table class="table table-hover text-center align-middle"> <thead> <tr> <th>ID</th> <th class="text-left">Subject</th> <th>File</th> <th>Status</th> <th>Order</th> <th>Actions</th> </tr> </thead> <tbody> <?php $modals = []; if ($list && $list->num_rows): while ($row = $list->fetch_assoc()): $fileUrl = '../' . htmlspecialchars($row['file_path']); ?> <tr> <td><?= (int)$row['id'] ?></td> <td class="text-left" style="min-width:260px;"> <strong><?= htmlspecialchars($row['subject']) ?></strong> <?php if(!empty($row['created_at'])): ?> <div class="muted small">Added: <?= htmlspecialchars($row['created_at']) ?></div> <?php endif; ?> </td> <td> <?php if (!empty($row['file_path'])): ?> <a href="<?= $fileUrl ?>" target="_blank" class="btn btn-sm btn-outline-secondary btn-pill">View</a> <?php else: ?> <span class="text-danger">Missing</span> <?php endif; ?> </td> <!-- ✅ STATUS --> <td> <?php if($row['status']==='active'): ?> <a href="?toggle=<?= (int)$row['id'] ?>" class="btn btn-success btn-sm btn-pill" style="min-width:80px; font-weight:700;"> Active </a> <?php else: ?> <a href="?toggle=<?= (int)$row['id'] ?>" class="btn btn-danger btn-sm btn-pill" style="min-width:80px; font-weight:700;"> Inactive </a> <?php endif; ?> </td> <td><?= (int)$row['sort_order'] ?></td> <td> <button type="button" class="btn btn-info btn-sm btn-pill" data-bs-toggle="modal" data-bs-target="#edit<?= (int)$row['id'] ?>"> Edit </button> <a href="?delete=<?= (int)$row['id'] ?>" class="btn btn-danger btn-sm btn-pill" onclick="return confirm('Delete this document?')">Delete</a> </td> </tr> <?php // ==== Modal stays same ==== ob_start(); ?> <div class="modal fade" id="edit<?= (int)$row['id'] ?>" tabindex="-1" aria-hidden="true"> <div class="modal-dialog modal-lg"> <div class="modal-content two-col"> <form method="POST" enctype="multipart/form-data" autocomplete="off" novalidate> <input type="hidden" name="action" value="update"> <input type="hidden" name="id" value="<?= (int)$row['id'] ?>"> <div class="modal-header"> <h5 class="modal-title">✏️ Edit Document</h5> <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> </div> <div class="modal-body"> <div class="form-grid"> <div> <label>Subject <span class="text-danger">*</span></label> <input type="text" name="subject" class="form-control" value="<?= htmlspecialchars($row['subject']) ?>" required maxlength="200"> </div> <div> <label>Status</label> <select name="status" class="form-control"> <option value="active" <?= $row['status']==='active'?'selected':''; ?>>Active</option> <option value="inactive" <?= $row['status']==='inactive'?'selected':''; ?>>Inactive</option> </select> </div> <div> <label>Sort Order</label> <input type="number" name="sort_order" class="form-control" value="<?= (int)$row['sort_order'] ?>"> </div> <div class="span-2"> <label>Replace PDF (optional)</label> <input type="file" name="pdf" class="form-control" accept="application/pdf,.pdf"> <div class="form-check mt-2"> <input class="form-check-input" type="checkbox" name="replace_file" id="rf<?= (int)$row['id'] ?>"> <label class="form-check-label" for="rf<?= (int)$row['id'] ?>">Yes, replace current file</label> </div> <?php if (!empty($row['file_path'])): ?> <small class="form-text text-muted">Current: <a href="<?= $fileUrl ?>" target="_blank">view</a></small> <?php endif; ?> </div> </div> </div> <div class="modal-footer"> <button type="button" class="btn btn-secondary btn-pill" data-bs-dismiss="modal">Close</button> <button type="submit" class="btn btn-primary btn-pill">Save changes</button> </div> </form> </div> </div> </div> <?php $modals[] = ob_get_clean(); endwhile; else: ?> <tr><td colspan="6">No records found.</td></tr> <?php endif; ?> </tbody> </table> </div> </div> <!-- render all modals here (outside table) --> <?= implode("\n", $modals) ?> </div> <?php include 'includes/footer.php'; ?>
Upload File
Create Folder