Files
sermon-notes/public/index.php
Ryan Prather 24a0892160 fix: index
- fixed problem with files not pulling from server correct with MIME types
2025-08-11 13:00:55 -04:00

44 lines
1.8 KiB
PHP

<?php
use App\Kernel;
if (file_exists(__DIR__.$_SERVER['REQUEST_URI']) && is_readable(__DIR__.$_SERVER['REQUEST_URI']) && is_file(__DIR__.$_SERVER['REQUEST_URI'])) {
$header = 'text/html';
if (substr($_SERVER['REQUEST_URI'], -4) == '.css')
$header = 'text/css';
elseif (substr($_SERVER['REQUEST_URI'], -3) == '.js')
$header = 'text/javascript';
elseif (substr($_SERVER['REQUEST_URI'], -4) == '.ico')
$header = 'image/x-icon';
elseif (substr($_SERVER['REQUEST_URI'], -4) == '.png')
$header = 'image/png';
elseif (substr($_SERVER['REQUEST_URI'], -4) == '.jpg')
$header = 'image/jpeg';
elseif (substr($_SERVER['REQUEST_URI'], -4) == '.gif')
$header = 'image/gif';
elseif (substr($_SERVER['REQUEST_URI'], -3) == '.wo' || substr($_SERVER['REQUEST_URI'], -6) == '.woff2')
$header = 'font/woff2';
elseif (substr($_SERVER['REQUEST_URI'], -4) == '.ttf')
$header = 'font/truetype';
elseif (substr($_SERVER['REQUEST_URI'], -4) == '.eot' || substr($_SERVER['REQUEST_URI'], -5) == '.ttf-')
$header = 'application/vnd.ms-fontobject';
elseif (substr($_SERVER['REQUEST_URI'], -4) == '.svg')
$header = 'image/svg+xml';
elseif (substr($_SERVER['REQUEST_URI'], -5) == '.json')
$header = 'application/json';
elseif (substr($_SERVER['REQUEST_URI'], -3) == '.otf')
$header = 'font/opentype';
elseif (substr($_SERVER['REQUEST_URI'], -5) == '.woff')
$header = 'font/woff';
print header("Content-Type: $header; charset=UTF-8");
print file_get_contents(__DIR__.$_SERVER['REQUEST_URI']);
exit;
}
require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
return function (array $context) {
return new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);
};