Sindbad~EG File Manager
<?php
// DeleteFromGallery.php
// CORS headers to allow fetch() to work properly
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Methods: POST");
header("Access-Control-Allow-Headers: Content-Type");
// (The rest of your PHP code goes here)
session_start();
$dbFile = 'ThreeBodyDatabase.db';
$db = new SQLite3($dbFile);
// Get password from URL
$password = $_GET['password'] ?? '';
$showAll = ($password === "God25");
// Fetch simulation documents
if ($showAll) {
$result = $db->query("SELECT * FROM documents ORDER BY date_created DESC");
} else {
$stmt = $db->prepare("SELECT * FROM documents WHERE password = :pw ORDER BY date_created DESC");
$stmt->bindValue(':pw', $password, SQLITE3_TEXT);
$result = $stmt->execute();
}
$documents = [];
while ($row = $result->fetchArray(SQLITE3_ASSOC)) {
$documents[] = $row;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Delete from Gallery</title>
<style>
body {
background-color: #e6f2ff;
font-family: Arial, sans-serif;
margin: 10px;
}
.gallery {
display: flex;
flex-wrap: wrap;
gap: 10px;
}
.thumb-container {
position: relative;
width: 150px;
display: flex;
flex-direction: column;
align-items: center;
background-color: cornsilk;
}
.thumb {
width: 150px;
height: 100px;
object-fit: cover;
}
.caption {
font-size: 0.9em;
color: #333;
text-align: center;
background-color: #e6f2ff;
padding: 2px 4px;
width: 150px;
margin-top: 1px;
box-sizing: border-box;
}
.delete-icon {
position: absolute;
top: 4px;
left: 6px;
font-size: 18px;
cursor: pointer;
background-color: cornsilk;
z-index: 5;
display: none;
}
.thumb-container:hover .delete-icon {
display: block;
}
</style>
<script>
function deleteThumbnail(docId) {
const confirmed = confirm("Are you sure you want to delete this thumbnail?");
if (!confirmed) return;
const form = document.createElement("form");
form.method = "POST";
form.action = "DeleteFromGalleryHelper.php";
const idInput = document.createElement("input");
idInput.type = "hidden";
idInput.name = "DocumentNumber";
idInput.value = docId;
form.appendChild(idInput);
const pwInput = document.createElement("input");
pwInput.type = "hidden";
pwInput.name = "password";
pwInput.value = <?php echo json_encode($password); ?>;
form.appendChild(pwInput);
document.body.appendChild(form);
form.submit();
}
</script>
</head>
<body>
<h1>Private Gallery: Delete Thumbnails</h1>
<div class="gallery">
<?php foreach ($documents as $doc):
$imgSrc = !empty($doc['image_filename']) ? "./images/" . htmlspecialchars($doc['image_filename']) : "placeholder.svg";
$caption = !empty($doc['remark']) ? htmlspecialchars($doc['remark']) : "";
?>
<div class="thumb-container">
<img src="<?php echo $imgSrc; ?>" class="thumb" alt="Thumbnail">
<?php if (!empty($caption)): ?>
<div class="caption"><?php echo $caption; ?></div>
<?php endif; ?>
<div class="delete-icon" onclick="deleteThumbnail(<?php echo $doc['DocumentNumber']; ?>)">🗑️</div>
</div>
<?php endforeach; ?>
</div>
</body>
</html>
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists