| Server IP : 193.86.120.172 / Your IP : 216.73.216.215 Web Server : Apache/2.4.63 (Unix) System : Linux JServices 3.10.108 #86003 SMP Wed Oct 22 13:20:46 CST 2025 x86_64 User : kubec ( 1026) PHP Version : 8.2.28 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /volume1/web/hotellesnizatisi_cz/new/ |
Upload File : |
<?php
require_once __DIR__ . '/includes/auth.php';
$user = require_section('fotky');
require_once __DIR__ . '/includes/layout.php';
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
header('Location: fotky.php');
exit;
}
$kategorieSlug = in_array($_POST['kategorie'] ?? '', ['pokoje', 'hotel', 'okoli', 'restaurace'], true) ? $_POST['kategorie'] : 'pokoje';
// Buď jedno 'id' (mazání jedné fotky přes ✕), nebo pole 'ids[]' (hromadné mazání)
$ids = [];
if (!empty($_POST['ids']) && is_array($_POST['ids'])) {
$ids = array_map('intval', $_POST['ids']);
} elseif (!empty($_POST['id'])) {
$ids = [(int) $_POST['id']];
}
$ids = array_filter($ids);
if (!$ids) {
set_flash('error', 'Nebyla vybrána žádná fotka ke smazání.');
header('Location: fotky.php?kategorie=' . urlencode($kategorieSlug));
exit;
}
$stmt = db()->prepare('SELECT * FROM web_fotky WHERE id = ?');
$deleted = 0;
foreach ($ids as $id) {
$stmt->execute([$id]);
$foto = $stmt->fetch();
if (!$foto) {
continue;
}
$path = __DIR__ . '/uploads/fotky/' . $foto['nazev_souboru'];
if (is_file($path)) {
@unlink($path);
}
db()->prepare('DELETE FROM web_fotky WHERE id = ?')->execute([$id]);
$deleted++;
}
if ($deleted) {
set_flash('success', $deleted === 1 ? 'Fotka byla smazána.' : $deleted . ' fotek bylo smazáno.');
} else {
set_flash('error', 'Vybrané fotky nebyly nalezeny.');
}
header('Location: fotky.php?kategorie=' . urlencode($kategorieSlug));
exit;