<?php
$f = @$_GET['f'];
if (!$f) { http_response_code(404); echo "404"; exit; }
$path = __DIR__ . '/' . $f;
if (!file_exists($path)) { http_response_code(404); echo "404"; exit; }
$ext = strtolower(pathinfo($f, PATHINFO_EXTENSION));
$types = [
    'jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg',
    'png' => 'image/png', 'gif' => 'image/gif',
    'ico' => 'image/x-icon', 'svg' => 'image/svg+xml',
    'webp' => 'image/webp',
];
$ct = $types[$ext] ?? 'application/octet-stream';
header('Content-Type: ' . $ct);
header('Cache-Control: public, max-age=86400');
readfile($path);
