Files
Thies Mueller bbcfaf32f7 initial commit
2026-04-25 23:00:38 +02:00

118 lines
4.2 KiB
PHP

<?php
$id = '';
$error = '';
$step = 'input';
function sanitizeId($input) {
$input = trim($input);
if (str_ends_with($input, '.jpg')) {
$input = substr($input, 0, -4);
}
return $input;
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if (isset($_POST['confirm_delete_final'])) {
$id = sanitizeId($_POST['id']);
$file = __DIR__ . "/../images/$id.jpg";
if (file_exists($file)) {
rename($file, __DIR__ . "/../images/deleted_$id.jpg");
$step = 'deleted';
} else {
$error = 'Bild nicht gefunden';
$step = 'input';
}
} elseif (isset($_POST['confirm_delete'])) {
$id = sanitizeId($_POST['id']);
$step = 'confirm2';
} else {
$id = sanitizeId($_POST['id']);
if (!preg_match('/^[a-zA-Z0-9]{32}$/', $id)) {
$error = 'Ungültige ID';
} else {
$file = __DIR__ . "/../images/$id.jpg";
if (file_exists($file)) {
$step = 'confirm1';
} else {
$error = 'Bild nicht gefunden oder bereits gelöscht';
}
}
}
}
?>
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Bild löschen</title>
<link href="assets/tailwind.css" rel="stylesheet">
</head>
<body class="bg-gray-900 text-white min-h-screen flex flex-col justify-between">
<div class="flex items-center justify-center flex-grow">
<div class="bg-gray-800 p-6 rounded-xl w-full max-w-md">
<?php if ($step === 'input'): ?>
<h1 class="text-xl mb-4">Bild löschen</h1>
<p class="text-sm mb-4">Die ID ist der hintere Teil des QR-Code Links.</p>
<p class="text-sm mb-4">Wenn du sie nicht hast, schreibe an support@thiesmueller.de</p>
<?php if ($error): ?>
<div class="bg-red-600 p-2 mb-4"><?php echo $error; ?></div>
<?php endif; ?>
<form method="POST">
<input name="id" placeholder="Bild-ID" required class="w-full p-2 bg-gray-700 mb-4">
<button class="bg-blue-600 px-4 py-2 w-full">Weiter</button>
</form>
<?php elseif ($step === 'confirm1'): ?>
<h1 class="text-xl mb-4">Dieses Bild?</h1>
<img src="/images/<?php echo $id; ?>.jpg" class="mb-4">
<form method="POST" class="flex gap-2">
<input type="hidden" name="id" value="<?php echo $id; ?>">
<button name="confirm_delete" class="bg-red-600 px-4 py-2 w-full">Ja löschen</button>
<a href="" class="bg-gray-600 px-4 py-2 w-full text-center">Nein, anderes Bild</a>
</form>
<?php elseif ($step === 'confirm2'): ?>
<h1 class="text-xl mb-4">Sicher? Diese Aktion kann nicht rückgängig gemacht werden!</h1>
<form method="POST" class="flex gap-2">
<input type="hidden" name="id" value="<?php echo $id; ?>">
<button name="confirm_delete_final" class="bg-red-700 px-4 py-2 w-full">Ja, Sicher</button>
<a href="" class="bg-gray-600 px-4 py-2 w-full text-center">Abbrechen</a>
</form>
<?php elseif ($step === 'deleted'): ?>
<h1 class="text-xl">Erfolgreich gelöscht</h1>
<?php endif; ?>
</div>
</div>
<footer class="bg-gray-800 text-gray-400 py-6 mt-10">
<div class="max-w-5xl mx-auto px-4 flex flex-col md:flex-row justify-between items-center gap-4">
<div class="text-sm text-center md:text-left">
© <?php echo date("Y"); ?> Thies Mueller Service Solutions
</div>
<div class="flex flex-wrap justify-center gap-4 text-sm">
<a href="/about.html" class="hover:text-white transition">Über die Fotobox</a>
<a href="/contact.html" class="hover:text-white transition">Kontakt / Anfragen</a>
<a href="/delete/" class="hover:text-white transition">Ich möchte mein Bild löschen lassen</a>
<a href="https://legal.tservic.es" target="_blank" class="hover:text-white transition">Impressum / Datenschutz</a>
<a href="https://thiesmueller.de" target="_blank" class="hover:text-white transition">Thies Mueller Service Solutions</a>
<a href="https://regattatech.de" target="_blank" class="hover:text-white transition">RegattaTech.DE</a>
</div>
</div>
</footer>
</body>
</html>