public/index.php line 57

Open in your IDE?
  1. <?php
  2. use App\Kernel;
  3. use Symfony\Component\Debug\Debug;
  4. use Symfony\Component\Dotenv\Dotenv;
  5. use Symfony\Component\HttpFoundation\Request;
  6. require __DIR__.'/../vendor/autoload.php';
  7. // The check is to ensure we don't use .env in production
  8. if (!isset($_SERVER['APP_ENV'])) {
  9.     if (!class_exists(Dotenv::class)) {
  10.         throw new \RuntimeException('APP_ENV environment variable is not defined. You need to define environment variables for configuration or add "symfony/dotenv" as a Composer dependency to load variables from a .env file.');
  11.     }
  12.     (new Dotenv())->load(__DIR__.'/../.env');
  13. }
  14. $env 'dev';//$_SERVER['APP_ENV'] ?? 'dev';
  15. $debug $_SERVER['APP_DEBUG'] ?? ('prod' !== $env);
  16. if (isset($_COOKIE['msdbg'])) {
  17. //    $staticKey = 'bauhaumiau' . date('Y');
  18.     $publicKey __DIR__ '/../app/config/debug_public_key.pem';
  19.     $remoteAddr $_SERVER['REMOTE_ADDR'];
  20.     if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
  21.         $remoteAddr $_SERVER['HTTP_X_FORWARDED_FOR'];
  22.     }
  23. //    $data = $staticKey . $remoteAddr . $staticKey;
  24. //    if (openssl_verify($data, base64_decode($_COOKIE['msdbg']), file_get_contents($publicKey), "sha1WithRSAEncryption")) {
  25. //        $env = 'dev';
  26. //        $_SERVER['APP_ENV']='dev';
  27. //        $_ENV['APP_ENV']='dev';
  28. //        $debug = true;
  29. //    } else {
  30. //        $failedSignature = true;
  31. //    }
  32. }
  33. if ($debug) {
  34.     umask(0000);
  35.     Debug::enable();
  36. }
  37. if ($trustedProxies $_SERVER['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'] ?? false) {
  41.     Request::setTrustedHosts(explode(','$trustedHosts));
  42. }
  43. $kernel = new Kernel($env$debug);
  44. $request Request::createFromGlobals();
  45. $response $kernel->handle($request);
  46. $response->send();
  47. $kernel->terminate($request$response);
  48. if (isset($failedSignature) &&
  49.     (strpos($response->headers->get('Content-Type'), 'text/html') !== FALSE ||
  50.         strpos($response->headers->get('Content-Type'), 'text/plain') !== FALSE)) {
  51.     echo '<!-- msdbg: ' $remoteAddr ' -->';
  52. }