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_edit.php
<?php // /admin/achv_edit.php — Edit Achievement (MySQLi + Category Master) include 'secure_session.php'; include 'includes/auth.php'; require_once '../config.php'; include 'includes/header.php'; // (enable while testing) // 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 = ''; $id = isset($_GET['id']) && ctype_digit($_GET['id']) ? (int)$_GET['id'] : 0; if ($id <= 0) { http_response_code(400); exit('Invalid ID'); } // ---------- Fetch categories ---------- $catRows = []; $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; // ---------- Load current achievement ---------- $stmt = $conn->prepare("SELECT * FROM achievements WHERE id=?"); $stmt->bind_param("i", $id); $stmt->execute(); $res = $stmt->get_result(); $item = $res->fetch_assoc(); $stmt->close(); if (!$item) { http_response_code(404); exit('Achievement not found'); } // Pre-fill variables $title = $item['title']; $category_id = (int)$item['category_id']; $sub_title = $item['sub_title']; $description = $item['description']; $event_date = $item['event_date']; $external_link = $item['external_link']; $image_path = $item['image_path']; $is_active = (int)$item['is_active']; // ---------- 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'] ?? ''); $is_active = isset($_POST['is_active']) ? 1 : 0; $remove_image = isset($_POST['remove_image']) ? 1 : 0; 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 handling ---- $newImageRel = $image_path; // default keep old $uploadDir = dirname(__DIR__) . '/uploads/achievements/'; // Remove existing image (if ticked) if ($remove_image && $image_path) { $abs = dirname(__DIR__) . '/' . $image_path; if (is_file($abs)) @unlink($abs); $newImageRel = null; } // If new image uploaded, replace it (also remove old file) 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) { if (!is_dir($uploadDir) && !@mkdir($uploadDir, 0775, true)) { $errors[] = 'Failed to create upload folder.'; } elseif (!is_writable($uploadDir)) { $errors[] = 'Upload folder is not writable.'; } else { // delete old file if exists if ($image_path) { $absOld = dirname(__DIR__) . '/' . $image_path; if (is_file($absOld)) @unlink($absOld); } $safe = 'achv_' . date('Ymd_His') . '_' . bin2hex(random_bytes(4)) . '.' . $ext; $dest = $uploadDir . $safe; if (!move_uploaded_file($file['tmp_name'], $dest)) { $errors[] = 'Failed to move uploaded image.'; } else { $newImageRel = 'uploads/achievements/' . $safe; } } } } } // ---- Update in DB ---- if (!$errors) { $stmt = $conn->prepare("UPDATE achievements SET title=?, category_id=?, sub_title=?, description=?, event_date=?, image_path=?, external_link=?, is_active=? WHERE id=?"); if (!$stmt) { $errors[] = 'DB prepare failed: ' . $conn->error; } else { $stmt->bind_param("sisssssii", $title, $category_id, $sub_title, $description, $event_date, $newImageRel, $external_link, $is_active, $id); if ($stmt->execute()) { $success = 'Achievement updated!'; // refresh current vars for form $image_path = $newImageRel; $_SESSION['csrf_token'] = bin2hex(random_bytes(32)); // rotate $csrf = $_SESSION['csrf_token']; } else { $errors[] = 'DB update failed: ' . $stmt->error; } $stmt->close(); } } } ?> <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>Edit Achievement</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <style> body{font-family:system-ui,-apple-system,Segoe UI,Roboto,Arial;background:#f6f7fb;padding:24px;} .card{max-width:900px;margin:0 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;} .nav{margin:0 auto 16px;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;} .thumb{width:100%;max-width:420px;aspect-ratio:16/9;object-fit:cover;border:1px solid #eee;border-radius:12px} .row{grid-column:1 / -1} .switch{display:flex;align-items:center;gap:8px;margin-top:10px} </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 ($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>Edit 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 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 ($category_id===(int)$c['id'])?'selected':''; ?>> <?php echo htmlspecialchars($c['name']); ?> </option> <?php endforeach; ?> </select> <div style="margin-top:6px"> <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" value="<?php echo htmlspecialchars($sub_title); ?>"> </div> <div> <label>Event Date</label> <input type="date" name="event_date" value="<?php echo htmlspecialchars($event_date); ?>"> </div> <div class="row"> <label>Description</label> <textarea name="description"><?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"> <?php if ($image_path): ?> <div style="margin-top:10px"> <img class="thumb" src="../<?php echo htmlspecialchars($image_path); ?>" alt="Current Image"> <div class="switch"> <input type="checkbox" id="remove_image" name="remove_image" value="1"> <label for="remove_image">Remove current image</label> </div> </div> <?php endif; ?> </div> <div> <label>External Link (optional)</label> <input type="url" name="external_link" value="<?php echo htmlspecialchars($external_link); ?>"> <div class="switch"> <input type="checkbox" id="is_active" name="is_active" value="1" <?php echo $is_active? 'checked':''; ?>> <label for="is_active">Active</label> </div> </div> <div class="row"> <button class="btn btn-primary" type="submit">Update</button> </div> </form> </div> </body> </html>
Upload File
Create Folder