index.php line 82

Open in your IDE?
  1. <?php
  2. use Eccube\Kernel;
  3. use Symfony\Component\Debug\Debug;
  4. use Dotenv\Dotenv;
  5. use Symfony\Component\HttpFoundation\Request;
  6. // システム要件チェック
  7. if (version_compare(PHP_VERSION'7.1.3') < 0) {
  8.     die('Your PHP installation is too old. EC-CUBE requires at least PHP 7.1.3. See the <a href="http://www.ec-cube.net/product/system.php" target="_blank">system requirements</a> page for more information.');
  9. }
  10. if(isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') {
  11.     $_SERVER['HTTPS'] = 'on';
  12. }
  13. $autoload __DIR__.'/vendor/autoload.php';
  14. if (!file_exists($autoload) && !is_readable($autoload)) {
  15.     die('Composer is not installed.');
  16. }
  17. require $autoload;
  18. // The check is to ensure we don't use .env in production
  19. if (!isset($_SERVER['APP_ENV'])) {
  20.     if (!class_exists(Dotenv::class)) {
  21.         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.');
  22.     }
  23.     if (file_exists(__DIR__.'/.env')) {
  24.         (new Dotenv(__DIR__))->overload();
  25.         if (strpos(getenv('DATABASE_URL'), 'sqlite') !== false && !extension_loaded('pdo_sqlite')) {
  26.             (new Dotenv(__DIR__'.env.install'))->overload();
  27.         }
  28.     } else {
  29.         (new Dotenv(__DIR__'.env.install'))->overload();
  30.     }
  31. }
  32. $env = isset($_SERVER['APP_ENV']) ? $_SERVER['APP_ENV'] : 'dev';
  33. $debug = isset($_SERVER['APP_DEBUG']) ? $_SERVER['APP_DEBUG'] : ('prod' !== $env);
  34. if ($debug) {
  35.     umask(0000);
  36.     Debug::enable();
  37. }
  38. $trustedProxies = isset($_SERVER['TRUSTED_PROXIES']) ? $_SERVER['TRUSTED_PROXIES'] : false;
  39. if ($trustedProxies) {
  40.     Request::setTrustedProxies(explode(','$trustedProxies), Request::HEADER_X_FORWARDED_ALL Request::HEADER_X_FORWARDED_HOST);
  41. }
  42. $trustedHosts = isset($_SERVER['TRUSTED_HOSTS']) ? $_SERVER['TRUSTED_HOSTS'] : false;
  43. if ($trustedHosts) {
  44.     Request::setTrustedHosts(explode(','$trustedHosts));
  45. }
  46. $request Request::createFromGlobals();
  47. $maintenanceFile env('ECCUBE_MAINTENANCE_FILE_PATH'__DIR__.'/.maintenance');
  48. if (file_exists($maintenanceFile)) {
  49.     $pathInfo = \rawurldecode($request->getPathInfo());
  50.     $adminPath env('ECCUBE_ADMIN_ROUTE''admin');
  51.     $adminPath '/'.\trim($adminPath'/').'/';
  52.     if (\strpos($pathInfo$adminPath) !== 0) {
  53.         $locale env('ECCUBE_LOCALE');
  54.         $templateCode env('ECCUBE_TEMPLATE_CODE');
  55.         $baseUrl = \htmlspecialchars(\rawurldecode($request->getBaseUrl()), ENT_QUOTES);
  56.         header('HTTP/1.1 503 Service Temporarily Unavailable');
  57.         require __DIR__.'/maintenance.php';
  58.         return;
  59.     }
  60. }
  61. $kernel = new Kernel($env$debug);
  62. $response $kernel->handle($request);
  63. $response->send();
  64. $kernel->terminate($request$response);