<?php
$baseDir = realpath(__DIR__ . '/../');
$file = $_GET['file'] ?? '';

$path = realpath($baseDir . '/' . $file);
if (!$path || strpos($path, $baseDir) !== 0 || !file_exists($path)) {
    http_response_code(404);
    exit;
}

$ext = strtolower(pathinfo($path, PATHINFO_EXTENSION));
$mime = [
  'js'=>'application/javascript','css'=>'text/css',
  'png'=>'image/png','jpg'=>'image/jpeg','jpeg'=>'image/jpeg'
];

header('Content-Type: '.$mime[$ext] ?? 'application/octet-stream');
header('Cache-Control: no-store');
readfile($path);
