public/index.php line 54

Open in your IDE?
  1. <?php
  2. ini_set("log_errors"1);
  3. ini_set("error_log"__DIR__."/../var/log/php-error.log");
  4. putenv('LC_ALL=pl_PL');
  5. setlocale(LC_ALL'pl_PL');
  6. use App\Kernel;
  7. use Symfony\Component\Debug\Debug;
  8. use Symfony\Component\HttpFoundation\Request;
  9. require dirname(__DIR__).'/config/bootstrap.php';
  10. if (in_array($_SERVER['HTTP_X_REAL_IP']?:null, ['85.14.122.42''93.105.223.55','127.0.0.1''::1'], true)) {
  11.     $_SERVER['APP_ENV'] = 'dev';
  12.     $_SERVER['APP_DEBUG'] = 1;
  13. }
  14. if ($_SERVER['APP_DEBUG']) {
  15.     ini_set('memory_limit''2G');
  16.     error_reporting(E_ALL);
  17.     ini_set('display_errors'1);
  18.     umask(0000);
  19.     Debug::enable();
  20. }
  21. if($_SERVER['SERVER_NAME'] === 'api.autopunkt.pl') {
  22.     if (empty($_SERVER['HTTPS']) || $_SERVER['HTTPS'] === "off") {
  23.         $location 'https://' $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
  24.         header('HTTP/1.1 301 Moved Permanently');
  25.         header('Location: ' $location);
  26.         exit;
  27.     }
  28. }
  29. else {
  30.     $_SERVER['HTTPS'] = 'on';
  31.     $_SERVER['SERVER_PORT'] = 443;
  32.     $_SERVER['REQUEST_SCHEME'] = 'https';
  33.     $_SERVER['SCRIPT_URI'] = str_replace('http','https',$_SERVER['SCRIPT_URI']);
  34. }
  35. if ($trustedProxies $_SERVER['TRUSTED_PROXIES'] ?? $_ENV['TRUSTED_PROXIES'] ?? false) {
  36.     Request::setTrustedProxies(explode(','$trustedProxies), Request::HEADER_X_FORWARDED_ALL Request::HEADER_X_FORWARDED_HOST);
  37. }
  38. if ($trustedHosts $_SERVER['TRUSTED_HOSTS'] ?? $_ENV['TRUSTED_HOSTS'] ?? false) {
  39.     Request::setTrustedHosts([$trustedHosts]);
  40. }
  41. $kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
  42. $request Request::createFromGlobals();
  43. $response $kernel->handle($request);
  44. $response->send();
  45. $kernel->terminate($request$response);