public/index.php line 44

Open in your IDE?
  1. <?php
  2. use App\Kernel;
  3. use Symfony\Component\Dotenv\Dotenv;
  4. use Symfony\Component\ErrorHandler\Debug;
  5. use Symfony\Component\HttpFoundation\Request;
  6. require dirname(__DIR__).'/vendor/autoload.php';
  7. (new Dotenv())->bootEnv(dirname(__DIR__).'/.env');
  8. if ($_SERVER['APP_DEBUG']) {
  9.     umask(0000);
  10.     Debug::enable();
  11. }
  12. if (php_sapi_name() !== 'cli' && !isset($_GET['auth_disable'])) {
  13.     $user $_SERVER['HTTP_BASIC_AUTH_USERNAME'];
  14.     $pass $_SERVER['HTTP_BASIC_AUTH_PASSWORD'];
  15.     if ($user && $pass) {
  16.         $readUser $_SERVER['PHP_AUTH_USER'] ?? null;
  17.         $readPw $_SERVER['PHP_AUTH_PW'] ?? null;
  18.         if ($user !== $readUser || $pass !== $readPw) {
  19.             header('WWW-Authenticate: Basic realm="My Realm"');
  20.             header('HTTP/1.0 401 Unauthorized');
  21.             echo 'Please, provide correct credentials';
  22.             return;
  23.         }
  24.     }
  25. }
  26. if ($trustedProxies $_SERVER['TRUSTED_PROXIES'] ?? $_ENV['TRUSTED_PROXIES'] ?? []) {
  27.     Request::setTrustedProxies(
  28.         explode(','$trustedProxies),
  29.         Request::HEADER_X_FORWARDED_HOST Request::HEADER_X_FORWARDED_PORT
  30.     );
  31. }
  32. if ($trustedHosts $_SERVER['TRUSTED_HOSTS'] ?? false) {
  33.     Request::setTrustedHosts([$trustedHosts]);
  34. }
  35. $kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
  36. $request Request::createFromGlobals();
  37. $response $kernel->handle($request);
  38. $response->send();
  39. $kernel->terminate($request$response);