Files
nexus/modules/pihole/pages/asset.php
2026-03-09 01:32:39 +01:00

31 lines
711 B
PHP

<?php
$file = (string)($_GET['file'] ?? '');
$base = realpath(__DIR__ . '/../assets');
$map = [
'pihole.css' => $base . '/pihole.css',
'pihole.js' => $base . '/pihole.js',
];
if (!isset($map[$file])) {
http_response_code(404);
exit('Not found');
}
$path = $map[$file];
if (!$base || !is_file($path) || !str_starts_with($path, $base)) {
http_response_code(404);
exit('Not found');
}
$ext = pathinfo($path, PATHINFO_EXTENSION);
if ($ext === 'css') {
header('Content-Type: text/css; charset=utf-8');
} elseif ($ext === 'js') {
header('Content-Type: application/javascript; charset=utf-8');
} else {
header('Content-Type: application/octet-stream');
}
readfile($path);
exit;