public/index.php line 56

Open in your IDE?
  1. <?php
  2. use App\Kernel;
  3. use Symfony\Component\HttpFoundation\Request;
  4. require dirname(__DIR__).'/config/bootstrap.php';
  5. function sendJpgHeaders(string $path)
  6. {
  7.     header('Content-type: '.mime_content_type($path));
  8.     $modifiedDate gmdate('D, d M Y H:i:s'filemtime($path));
  9.     if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
  10.         if (strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) >= filemtime($path)) {
  11.             // send the last mod time of the file back
  12.             $code 304;
  13.             // header('Last-Modified: ' . $modifiedDate . ' GMT', true, $code);
  14.         }
  15.     } else {
  16.         // header('Last-Modified: ' . $modifiedDate);
  17.         // header('Cache-Control: must-revalidate');
  18.     }
  19. }
  20. if (isset($_SERVER['REQUEST_URI']) && === strpos($_SERVER['REQUEST_URI'], '/categoryimages/media')) {
  21.     header('Access-Control-Allow-Origin: *');
  22.     $path $_ENV['APP_PATH_NFS_CATEGORIES'].substr($_SERVER['REQUEST_URI'], 21);
  23.     if ($pos strpos($path'?')) {
  24.         $path substr($path0$pos);
  25.     }
  26.     if (is_file($path)) {
  27.         sendJpgHeaders($path);
  28.         return readfile($path);
  29.     }
  30.     echo $path.' does not exist';
  31.     exit;
  32. }
  33. if ($_SERVER['APP_DEBUG']) {
  34.     umask(0000);
  35.     Symfony\Component\ErrorHandler\Debug::enable();
  36. }
  37. if ($trustedProxies $_SERVER['TRUSTED_PROXIES'] ?? $_ENV['TRUSTED_PROXIES'] ?? false) {
  38.     Request::setTrustedProxies(explode(','$trustedProxies), Request::HEADER_X_FORWARDED_ALL Request::HEADER_X_FORWARDED_HOST);
  39. }
  40. if ($trustedHosts $_SERVER['TRUSTED_HOSTS'] ?? $_ENV['TRUSTED_HOSTS'] ?? false) {
  41.     Request::setTrustedHosts([$trustedHosts]);
  42. }
  43. $kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
  44. $request Request::createFromGlobals();
  45. $response $kernel->handle($request);
  46. $response->send();
  47. $kernel->terminate($request$response);