Files
deskhub/plugin-webseite/preview.php
T
2026-10-16 18:42:18 +00:00

17 lines
699 B
PHP

<?php
declare(strict_types=1);
/** Liefert Vorschaubilder aus dem geschützten Speicher aus. */
require_once __DIR__ . '/inc/lib.php';
site_require_access();
$file = basename((string) ($_GET['file'] ?? ''));
$path = site_storage() . '/previews/' . $file;
$ext = strtolower(pathinfo($file, PATHINFO_EXTENSION));
$types = ['png' => 'image/png', 'jpg' => 'image/jpeg', 'webp' => 'image/webp'];
if ($file === '' || !isset($types[$ext]) || !is_file($path)) { http_response_code(404); exit; }
header('Content-Type: ' . $types[$ext]);
header('Content-Length: ' . filesize($path));
header('Cache-Control: public, max-age=86400');
header('X-Content-Type-Options: nosniff');
readfile($path);