22 lines
977 B
PHP
22 lines
977 B
PHP
<?php
|
|
declare(strict_types=1);
|
|
/** Liefert Vorschaubilder aus dem geschützten Speicher aus. */
|
|
require_once __DIR__ . '/inc/lib.php';
|
|
// DeskHub kommt mit dem Zugangsschlüssel; die Verwaltung (angemeldeter Administrator) sieht die Bilder in ihrer Übersicht
|
|
if (!site_access_ok()) {
|
|
session_name('plugin_site_admin');
|
|
session_start(['read_and_close' => true]);
|
|
if (empty($_SESSION['admin'])) 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);
|