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: achv_upload.php
<?php // /admin/achv_upload.php — Safe (MySQLi + Category Master) + layout + universal sidebar fix include 'secure_session.php'; include 'includes/auth.php'; require_once '../config.php'; include 'includes/header.php'; // (Optional Debug) // ini_set('display_errors', 1); error_reporting(E_ALL); if (empty($_SESSION['csrf_token'])) $_SESSION['csrf_token'] = bin2hex(random_bytes(32)); $csrf = $_SESSION['csrf_token']; $errors = []; $success = ''; $dbWarn = ''; // ===== Fetch active categories ===== $catRows = []; try { $cres = $conn->query("SELECT id, name FROM achievement_categories WHERE is_active=1 ORDER BY display_order ASC, name ASC"); while ($c = $cres->fetch_assoc()) $catRows[] = $c; } catch (Throwable $e) { $dbWarn = 'Category load failed: ' . $e->getMessage() . ' — Did you create table `achievement_categories`?'; } // ===== Handle POST ===== if ($_SERVER['REQUEST_METHOD'] === 'POST') { if (!isset($_POST['csrf']) || !hash_equals($_SESSION['csrf_token'], $_POST['csrf'])) { $errors[] = 'Invalid form token. Please reload and try again.'; } $title = trim($_POST['title'] ?? ''); $category_id = (int)($_POST['category_id'] ?? 0); $sub_title = trim($_POST['sub_title'] ?? ''); $description = trim($_POST['description'] ?? ''); $event_date = trim($_POST['event_date'] ?? ''); $external_link = trim($_POST['external_link'] ?? ''); if ($title === '') $errors[] = 'Title is required.'; if ($category_id <= 0) $errors[] = 'Please select a category.'; if ($event_date !== '' && !preg_match('/^\d{4}-\d{2}-\d{2}$/', $event_date)) $errors[] = 'Date must be YYYY-MM-DD.'; // Image (optional) $imgRel = null; if (isset($_FILES['image']) && $_FILES['image']['error'] !== UPLOAD_ERR_NO_FILE) { if ($_FILES['image']['error'] !== UPLOAD_ERR_OK) { $errors[] = 'Image upload error.'; } else { $file = $_FILES['image']; if ($file['size'] > 5 * 1024 * 1024) $errors[] = 'Image too large (max 5MB).'; $ext = strtolower(pathinfo($file['name'], PATHINFO_EXTENSION)); if (!in_array($ext, ['jpg','jpeg','png','webp'], true)) $errors[] = 'Only JPG/PNG/WEBP allowed.'; if (class_exists('finfo')) { $f = new finfo(FILEINFO_MIME_TYPE); $mime = $f->file($file['tmp_name']); if ($mime && !in_array($mime, ['image/jpeg','image/png','image/webp'], true)) $errors[] = 'Invalid image format.'; } if (!$errors) { $dir = dirname(__DIR__) . '/uploads/achievements/'; if (!is_dir($dir) && !@mkdir($dir, 0775, true)) { $errors[] = 'Failed to create upload folder.'; } elseif (!is_writable($dir)) { $errors[] = 'Upload folder is not writable.'; } else { $safe = 'achv_' . date('Ymd_His') . '_' . bin2hex(random_bytes(4)) . '.' . $ext; $dest = $dir . $safe; if (!move_uploaded_file($file['tmp_name'], $dest)) { $errors[] = 'Failed to move uploaded image.'; } else { $imgRel = 'uploads/achievements/' . $safe; } } } } } if (!$errors) { try { $stmt = $conn->prepare("INSERT INTO achievements (title, category_id, sub_title, description, event_date, image_path, external_link, is_active, display_order) VALUES (?, ?, ?, ?, ?, ?, ?, 1, 0)"); $stmt->bind_param("sisssss", $title, $category_id, $sub_title, $description, $event_date, $imgRel, $external_link); $stmt->execute(); $stmt->close(); $success = 'Achievement added successfully!'; $_SESSION['csrf_token'] = bin2hex(random_bytes(32)); $csrf = $_SESSION['csrf_token']; $title = $sub_title = $description = $event_date = $external_link = ''; $category_id = 0; } catch (Throwable $e) { $errors[] = 'DB insert failed: ' . $e->getMessage() . ' — Is table `achievements` present with column `category_id` (INT NOT NULL)?'; } } } ?> <style> /* ===== Layout fix: remove top gap ===== */ body{ font-family:system-ui,-apple-system,Segoe UI,Roboto,Arial; background:#f6f7fb; padding:0; /* no global padding */ margin:0; } /* ===== Keep sidebar on top for clicks ===== */ .sidebar, .main-sidebar, .left-sidebar, aside.sidebar, aside.main-sidebar { position: relative; z-index: 3000 !important; } .content, .content-wrapper, .site-main, .app-content, .page-content { position: relative; z-index: 1; } /* Prevent any overlay from blocking sidebar clicks */ .content-overlay, .page-overlay, .header-shadow { pointer-events: none; } /* ===== Generic submenu visibility ===== */ .sidebar ul ul, .main-sidebar ul ul, .left-sidebar ul ul, .nav-sidebar .nav-treeview { display: none; } /* When LI has .open/mm-active, show submenu */ .sidebar li.open > ul, .main-sidebar li.open > ul, .left-sidebar li.open > ul, .nav-sidebar li.mm-active > .nav-treeview { display: block; } /* MetisMenu helpers */ .mm-collapse { display: none; } .mm-show { display: block; } /* ===== Page UI ===== */ .card{max-width:900px;margin:24px auto;background:#fff;border-radius:16px;box-shadow:0 10px 30px rgba(0,0,0,.08);padding:24px;} h1{margin:0 0 16px;} .grid{display:grid;grid-template-columns:1fr 1fr;gap:14px;} label{font-weight:600;} input[type="text"],input[type="date"],input[type="url"],select,textarea{width:100%;padding:12px 14px;border:1px solid #e3e3e8;border-radius:12px;} textarea{min-height:120px} .btn{padding:10px 18px;border-radius:12px;border:0;cursor:pointer;font-weight:700;} .btn-primary{background:#ea0000;color:#fff;} .alert{padding:12px 14px;border-radius:12px;margin:0 auto 12px;max-width:900px} .alert-ok{background:#e8fff1;color:#177a3f;border:1px solid #c8f2d8;} .alert-err{background:#ffe8e8;color:#8a1f1f;border:1px solid #ffd2d2;} .alert-warn{background:#fff6d5;color:#7a5a00;border:1px solid #ffe7a3;} .nav{margin:16px auto;max-width:900px;display:flex;gap:10px;} .nav a{padding:8px 12px;text-decoration:none;border-radius:12px;background:#fff;border:1px solid #eee;color:#222;} .hint{font-size:12px;margin-top:6px} </style> </head> <body> <div class="nav"> <a href="achv_upload.php">Add</a> <a href="achv_list.php">Manage</a> <a href="achv_cat_manage.php">Categories</a> </div> <?php if ($dbWarn): ?> <div class="alert alert-warn"><?php echo htmlspecialchars($dbWarn); ?></div> <div class="alert alert-warn" style="max-width:900px;margin:-8px auto 12px;"> <pre style="white-space:pre-wrap;margin:0;"> -- Run these if not created: CREATE TABLE IF NOT EXISTS achievement_categories ( id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(120) NOT NULL UNIQUE, slug VARCHAR(140) DEFAULT NULL, is_active TINYINT(1) NOT NULL DEFAULT 1, display_order INT NOT NULL DEFAULT 0, created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; CREATE TABLE IF NOT EXISTS achievements ( id INT AUTO_INCREMENT PRIMARY KEY, title VARCHAR(255) NOT NULL, category_id INT NOT NULL, sub_title VARCHAR(255) DEFAULT NULL, description TEXT DEFAULT NULL, event_date DATE DEFAULT NULL, image_path VARCHAR(255) DEFAULT NULL, external_link VARCHAR(255) DEFAULT NULL, is_active TINYINT(1) NOT NULL DEFAULT 1, display_order INT NOT NULL DEFAULT 0, created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, CONSTRAINT fk_achv_cat FOREIGN KEY (category_id) REFERENCES achievement_categories(id) ON DELETE RESTRICT ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; </pre> </div> <?php endif; ?> <?php if ($success): ?> <div class="alert alert-ok"><?php echo htmlspecialchars($success); ?></div> <?php endif; ?> <?php if ($errors): ?> <div class="alert alert-err"><?php echo implode('<br>', array_map('htmlspecialchars', $errors)); ?></div> <?php endif; ?> <div class="card"> <h1>Add Achievement</h1> <form method="post" enctype="multipart/form-data" class="grid" novalidate> <input type="hidden" name="csrf" value="<?php echo htmlspecialchars($csrf); ?>"> <div> <label>Title *</label> <input type="text" name="title" required placeholder="e.g., State Level Science Award" value="<?php echo htmlspecialchars($title ?? ''); ?>"> </div> <div> <label>Category *</label> <select name="category_id" required> <option value="">-- Select --</option> <?php foreach ($catRows as $c): ?> <option value="<?php echo (int)$c['id']; ?>" <?php echo (isset($category_id) && (int)$category_id === (int)$c['id']) ? 'selected' : ''; ?>> <?php echo htmlspecialchars($c['name']); ?> </option> <?php endforeach; ?> </select> <div class="hint"> <a href="achv_cat_manage.php" target="_blank" style="text-decoration:underline;color:#0b5ed7">+ Manage Categories</a> </div> </div> <div> <label>Sub Title / Position</label> <input type="text" name="sub_title" placeholder="e.g., 1st Prize, 2024 Batch, etc." value="<?php echo htmlspecialchars($sub_title ?? ''); ?>"> </div> <div> <label>Event Date</label> <input type="date" name="event_date" placeholder="YYYY-MM-DD" value="<?php echo htmlspecialchars($event_date ?? ''); ?>"> </div> <div style="grid-column:1 / -1"> <label>Description</label> <textarea name="description" placeholder="Short details..."><?php echo htmlspecialchars($description ?? ''); ?></textarea> </div> <div> <label>Image (JPG/PNG/WEBP, max 5MB)</label> <input type="file" name="image" accept=".jpg,.jpeg,.png,.webp"> </div> <div> <label>External Link (optional)</label> <input type="url" name="external_link" placeholder="https://..." value="<?php echo htmlspecialchars($external_link ?? ''); ?>"> </div> <div style="grid-column:1 / -1"> <button class="btn btn-primary" type="submit">Save</button> </div> </form> </div> <!-- ===== Universal Sidebar Expand Fix (works with AdminLTE/MetisMenu/custom) ===== --> <script> (function () { // Utility: find direct child UL (submenu) function findSubmenu(li, toggle){ // 1) nextElementSibling (most themes place UL next to <a>) let ul = toggle.nextElementSibling; if (ul && ul.tagName === 'UL') return ul; // 2) AdminLTE: .nav-treeview ul = li.querySelector(':scope > ul.nav-treeview'); if (ul) return ul; // 3) Plain UL ul = li.querySelector(':scope > ul'); if (ul) return ul; // 4) MetisMenu collapse container ul = li.querySelector(':scope > .mm-collapse, :scope > ul.mm-collapse'); return ul || null; } function closeSiblings(li){ const parent = li.parentElement; if (!parent) return; Array.from(parent.children).forEach(function (sib) { if (sib === li) return; sib.classList.remove('open','mm-active','menu-open'); const sUL = findSubmenu(sib, sib.querySelector(':scope > a, :scope > .menu-toggle') || {}); if (sUL){ sUL.style.display = 'none'; sUL.classList.remove('mm-show','show'); } }); } function toggleSubmenu(li, ul){ // Toggle classes for common themes li.classList.toggle('open'); li.classList.toggle('mm-active'); li.classList.toggle('menu-open'); // AdminLTE const nowOpen = li.classList.contains('open') || li.classList.contains('mm-active') || li.classList.contains('menu-open'); if (ul){ if (nowOpen){ ul.style.display = 'block'; ul.classList.add('mm-show','show'); } else { ul.style.display = 'none'; ul.classList.remove('mm-show','show'); } } } document.addEventListener('click', function (e) { // Anchor/button that controls submenu inside any sidebar const toggle = e.target.closest( '.sidebar li > a, .sidebar .menu-toggle,' + '.main-sidebar li > a, .main-sidebar .menu-toggle,' + '.left-sidebar li > a, .left-sidebar .menu-toggle,' + 'aside.sidebar li > a, aside.main-sidebar li > a,' + '.nav-sidebar > li > a' // AdminLTE ); if (!toggle) return; // ensure inside a sidebar const sidebar = toggle.closest('.sidebar, .main-sidebar, .left-sidebar, aside.sidebar, aside.main-sidebar, .nav-sidebar'); if (!sidebar) return; const li = toggle.closest('li'); if (!li) return; // pick submenu const ul = findSubmenu(li, toggle); // if no submenu -> allow navigation if (!ul) return; // prevent navigation, toggle it e.preventDefault(); e.stopPropagation(); // Accordion behavior closeSiblings(li); // Toggle toggleSubmenu(li, ul); }); // Ensure active menus are visible on load window.addEventListener('DOMContentLoaded', function (){ document.querySelectorAll( '.sidebar li.open > ul, .main-sidebar li.open > ul, .left-sidebar li.open > ul,' + '.nav-sidebar li.menu-open > .nav-treeview, .metismenu li.mm-active > .mm-collapse' ).forEach(function(ul){ ul.style.display = 'block'; ul.classList.add('mm-show','show'); }); }); })(); </script> <?php // /admin/achv_upload.php — Safe (MySQLi + Category Master) + layout + universal sidebar fix include 'includes/footer.php';
Upload File
Create Folder