web/app.php line 66

Open in your IDE?
  1. <?php
  2. error_reporting(E_ALL E_WARNING);
  3. use Symfony\Component\HttpFoundation\Request;
  4. use Dotenv\Dotenv;
  5. use Symfony\Component\Debug\Debug;
  6. require __DIR__.'/../vendor/autoload.php';
  7. if (PHP_VERSION_ID 70000) {
  8.     include_once __DIR__.'/../var/bootstrap.php.cache';
  9. }
  10. // Get the document root
  11. $documentRoot $_SERVER['DOCUMENT_ROOT'];
  12. $pathToEnv    dirname($documentRoot).DIRECTORY_SEPARATOR.'_secrets'.DIRECTORY_SEPARATOR;
  13. // Load the env variables to ensure parameters are set
  14. if (!file_exists($pathToEnv.'.env')) {
  15.     die('Something very wrong happened');
  16.     exit;
  17.     // @todo - make website down or maintainance
  18. }
  19. $dotenv Dotenv::createImmutable($pathToEnv'.env');
  20. $dotenv->load();
  21. $kernel null;
  22. if ($_ENV['IS_MAINTAINANCE_MODE'] == 1) {
  23.     if (strpos($_ENV['BACKEND_ALLOWED_IPS'], $_SERVER['REMOTE_ADDR']) === false) {
  24.         echo require_once 'maintainance.html';
  25.         exit;
  26.     }
  27. }
  28. $currentHost $_SERVER['HTTP_HOST'];
  29. if (in_array($currentHost, ['dev-social.online''dev1-social.online'])) {
  30.     $allowedIps explode(',',$_SERVER['BACKEND_ALLOWED_IPS']);
  31.     if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
  32.         $ip $_SERVER['HTTP_CLIENT_IP'];
  33.     } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
  34.         $ip $_SERVER['HTTP_X_FORWARDED_FOR'];
  35.     } else {
  36.         $ip $_SERVER['REMOTE_ADDR'];
  37.     }
  38.     if(!in_array($ip,$allowedIps)) {
  39.         exit('<h1 style="text-align: center;margin-top: 20%;margin-bottom: 0;">^.^</h1><h1 style="text-align: center;margin-top: 0;">  O  </h1>');
  40.     }
  41. }
  42. if ($_ENV['APP_DEBUG'] == 1) {
  43.     Debug::enable(E_ALL E_WARNING);
  44.     $kernel = new AppKernel('dev'true);
  45. } else {
  46.     $kernel = new AppKernel('prod'false);
  47. }
  48. if (PHP_VERSION_ID 70000) {
  49.     $kernel->loadClassCache();
  50. }
  51. //$kernel = new AppCache($kernel);
  52. // When using the HttpCache, you need to call the method in your front controller instead of relying on the configuration parameter
  53. //Request::enableHttpMethodParameterOverride();
  54. $request  Request::createFromGlobals();
  55. $response $kernel->handle($request);
  56. $response->send();
  57. $kernel->terminate($request$response);