Initial commit
This commit is contained in:
commit
2994f7cf6d
16 changed files with 2766 additions and 0 deletions
44
app/static.php
Normal file
44
app/static.php
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
// Serve static files from /app directory
|
||||
$file = $_GET['file'] ?? '';
|
||||
$file = str_replace(['../', '..\\'], '', $file); // Prevent directory traversal
|
||||
|
||||
// Map request paths to actual file paths
|
||||
$basePath = __DIR__ . '/';
|
||||
$customBasePath = dirname(__DIR__) . '/';
|
||||
|
||||
if (str_starts_with($file, 'styles/')) {
|
||||
$filePath = $customBasePath . 'custom/' . $file;
|
||||
} elseif (str_starts_with($file, 'fonts/')) {
|
||||
$filePath = $customBasePath . 'custom/' . $file;
|
||||
} elseif (str_starts_with($file, 'default-styles/')) {
|
||||
$filePath = $basePath . 'default/' . substr($file, 15); // Remove 'default-styles/' prefix
|
||||
} elseif (str_starts_with($file, 'docs-styles/')) {
|
||||
$filePath = $basePath . 'default/docs/styles/' . substr($file, 12); // Remove 'docs-styles/' prefix
|
||||
} else {
|
||||
http_response_code(404);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Check if file exists and is readable
|
||||
if (!file_exists($filePath) || !is_readable($filePath)) {
|
||||
http_response_code(404);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Determine MIME type based on extension
|
||||
$ext = pathinfo($filePath, PATHINFO_EXTENSION);
|
||||
$mimeTypes = [
|
||||
'css' => 'text/css',
|
||||
'js' => 'application/javascript',
|
||||
'woff' => 'font/woff',
|
||||
'woff2' => 'font/woff2',
|
||||
'ttf' => 'font/ttf',
|
||||
'otf' => 'font/otf',
|
||||
'eot' => 'application/vnd.ms-fontobject',
|
||||
'svg' => 'image/svg+xml',
|
||||
];
|
||||
|
||||
$mimeType = $mimeTypes[$ext] ?? (mime_content_type($filePath) ?: 'application/octet-stream');
|
||||
header('Content-Type: ' . $mimeType);
|
||||
readfile($filePath);
|
||||
Loading…
Add table
Add a link
Reference in a new issue