fixed bad links

This commit is contained in:
Frank Harris 2026-06-15 20:04:55 -05:00
parent b585aec260
commit 7e9a45f014
79 changed files with 2395 additions and 0 deletions

View file

@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
require_once __DIR__ . '/includes/bootstrap.php';
$doc = trim((string)($_GET['doc'] ?? ''));
$file = trim((string)($_GET['file'] ?? ''));
if (!website_is_valid_doc_slug($doc) || !preg_match('/^[a-z0-9._-]+\.(png|jpe?g|webp)$/i', $file)) {
http_response_code(404);
exit;
}
$assetPath = website_doc_path($doc, $file);
if ($assetPath === null || !is_readable($assetPath)) {
http_response_code(404);
exit;
}
$mimeType = match (strtolower(pathinfo($assetPath, PATHINFO_EXTENSION))) {
'png' => 'image/png',
'jpg', 'jpeg' => 'image/jpeg',
'webp' => 'image/webp',
default => 'application/octet-stream',
};
header('Content-Type: ' . $mimeType);
header('Content-Length: ' . (string)filesize($assetPath));
readfile($assetPath);