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: manage_photos.php
<?php include 'secure_session.php'; // 🔐 Always first (session security) include 'includes/auth.php'; // ✅ Your authentication check require_once '../config.php'; // ✅ DB connection $success = $error = ""; // ✅ Manual Center Crop + Resize to exactly 1080x1080 px function resizeTo1080($source, $destination, $quality = 80) { if (!function_exists('imagecreatefromjpeg')) { return copy($source, $destination); // fallback if GD missing } $info = getimagesize($source); $mime = $info['mime']; switch ($mime) { case 'image/jpeg': $image = imagecreatefromjpeg($source); break; case 'image/png': $image = imagecreatefrompng($source); break; case 'image/gif': $image = imagecreatefromgif($source); break; default: return false; } $width = imagesx($image); $height = imagesy($image); // Smallest side for square crop $smallestSide = min($width, $height); $x = max(0, ($width - $smallestSide) / 2); $y = max(0, ($height - $smallestSide) / 2); // Crop manually $croppedImage = imagecreatetruecolor($smallestSide, $smallestSide); imagecopy($croppedImage, $image, 0, 0, $x, $y, $smallestSide, $smallestSide); // Resize to 1080x1080 $newImage = imagecreatetruecolor(1080, 1080); imagecopyresampled($newImage, $croppedImage, 0, 0, 0, 0, 1080, 1080, $smallestSide, $smallestSide); // Save if ($mime == 'image/png') { imagepng($newImage, $destination, 6); } elseif ($mime == 'image/gif') { imagegif($newImage, $destination); } else { imagejpeg($newImage, $destination, $quality); } imagedestroy($image); imagedestroy($croppedImage); imagedestroy($newImage); return true; } // ✅ Upload Handler if (isset($_POST['upload'])) { $album_id = $_POST['album_id']; foreach ($_FILES['photos']['name'] as $key => $name) { if ($_FILES['photos']['error'][$key] == 0) { $size = $_FILES['photos']['size'][$key]; // Reject >1.5MB if ($size > 1572864) { echo "<p style='color:red;'>❌ {$name} skipped (larger than 1.5 MB)</p>"; continue; } $fileName = time() . "_" . basename($name); $tmpName = $_FILES['photos']['tmp_name'][$key]; $target = "../uploads/gallery/" . $fileName; $quality = 80; if (resizeTo1080($tmpName, $target, $quality)) { // Compress loop until ≤600KB while (filesize($target) > 600 * 1024 && $quality > 30) { $quality -= 5; resizeTo1080($tmpName, $target, $quality); } $conn->query("INSERT INTO photos (album_id, filename) VALUES ('$album_id', '$fileName')"); echo "<p style='color:green;'>✅ {$name} cropped & uploaded (1080×1080)</p>"; } else { echo "<p style='color:red;'>❌ {$name} failed</p>"; } } } } // ✅ Delete Handler if (isset($_GET['delete'])) { $id = intval($_GET['delete']); $photo = $conn->query("SELECT filename FROM photos WHERE id=$id")->fetch_assoc(); if ($photo) { $filePath = "../uploads/gallery/" . $photo['filename']; if (file_exists($filePath)) unlink($filePath); } $conn->query("DELETE FROM photos WHERE id=$id"); } ?> <!DOCTYPE html> <html> <head> <title>Manage Photos</title> <link rel="stylesheet" href="../css/bootstrap.min.css"> </head> <body class="container mt-4"> <!-- Header Section with Buttons --> <div class="d-flex justify-content-between align-items-center mb-4"> <h2>Manage Photos</h2> <div> <a href="manage_albums.php" class="btn btn-primary">➕ Create Album</a> <a href="dashboard.php" class="btn btn-dark">⬅ Go to Dashboard</a> </div> </div> <!-- Upload Form --> <form method="post" enctype="multipart/form-data" class="mb-4"> <div class="form-group"> <label>Select Album</label> <select name="album_id" class="form-control" required> <option value="">-- Choose Album --</option> <?php $albums = $conn->query("SELECT * FROM albums ORDER BY name ASC"); while ($a = $albums->fetch_assoc()) { echo "<option value='{$a['id']}'>{$a['name']}</option>"; } ?> </select> </div> <div class="form-group"> <label>Choose Photos (Multiple Allowed)</label> <input type="file" name="photos[]" class="form-control" multiple required> <small class="form-text text-muted"> Each photo will be center-cropped to 1080×1080 px, compressed ≤600KB. Max allowed file size: 1.5MB. </small> </div> <button type="submit" name="upload" class="btn btn-success">Upload Photos</button> </form> <!-- Photo List --> <h3>All Photos</h3> <div class="row"> <?php $res = $conn->query("SELECT p.*, a.name AS album FROM photos p JOIN albums a ON p.album_id=a.id ORDER BY p.uploaded_at DESC"); while ($row = $res->fetch_assoc()) { echo "<div class='col-md-3 mb-3 text-center'> <img src='../uploads/gallery/{$row['filename']}' class='img-fluid rounded mb-2'> <p><b>{$row['album']}</b></p> <a href='?delete={$row['id']}' class='btn btn-danger btn-sm' onclick='return confirm(\"Delete this photo?\")'>Delete</a> </div>"; } ?> </div> </body> </html>
Upload File
Create Folder