index.php line 84

Open in your IDE?
  1. <?php
  2. @ini_set('memory_limit''-1');
  3. @ini_set('max_execution_time''500');
  4. use Eccube\Kernel;
  5. use Eccube\Service\SystemService;
  6. use Symfony\Component\ErrorHandler\Debug;
  7. use Dotenv\Dotenv;
  8. use Symfony\Component\HttpFoundation\Request;
  9. // システム要件チェック
  10. if (version_compare(PHP_VERSION'7.3.0') < 0) {
  11.     die('Your PHP installation is too old. EC-CUBE requires at least PHP 7.3.0. See the <a href="http://www.ec-cube.net/product/system.php" target="_blank">system requirements</a> page for more information.');
  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.         (Dotenv::createUnsafeMutable(__DIR__))->load();
  25.         if (strpos(getenv('DATABASE_URL'), 'sqlite') !== false && !extension_loaded('pdo_sqlite')) {
  26.             (Dotenv::createUnsafeMutable(__DIR__'.env.install'))->load();
  27.         }
  28.     } else {
  29.         (Dotenv::createUnsafeMutable(__DIR__'.env.install'))->load();
  30.     }
  31. }
  32. error_reporting(E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED);
  33. $env = isset($_SERVER['APP_ENV']) ? $_SERVER['APP_ENV'] : 'dev';
  34. $debug = isset($_SERVER['APP_DEBUG']) ? $_SERVER['APP_DEBUG'] : ('prod' !== $env);
  35. if ($debug) {
  36.     umask(0000);
  37.     Debug::enable();
  38. }
  39. $trustedProxies = isset($_SERVER['TRUSTED_PROXIES']) ? $_SERVER['TRUSTED_PROXIES'] : false;
  40. if ($trustedProxies) {
  41.     Request::setTrustedProxies(explode(','$trustedProxies), Request::HEADER_X_FORWARDED_ALL Request::HEADER_X_FORWARDED_HOST);
  42. }
  43. $trustedHosts = isset($_SERVER['TRUSTED_HOSTS']) ? $_SERVER['TRUSTED_HOSTS'] : false;
  44. if ($trustedHosts) {
  45.     Request::setTrustedHosts(explode(','$trustedHosts));
  46. }
  47. $request Request::createFromGlobals();
  48. $maintenanceFile env('ECCUBE_MAINTENANCE_FILE_PATH'__DIR__.'/.maintenance');
  49. if (file_exists($maintenanceFile)) {
  50.     $pathInfo \rawurldecode($request->getPathInfo());
  51.     $adminPath env('ECCUBE_ADMIN_ROUTE''admin');
  52.     $adminPath '/'.\trim($adminPath'/').'/';
  53.     if (\strpos($pathInfo$adminPath) !== 0) {
  54.         $maintenanceContents file_get_contents($maintenanceFile);
  55.         $maintenanceToken explode(':'$maintenanceContents)[1] ?? null;
  56.         $tokenInCookie $request->cookies->get(SystemService::MAINTENANCE_TOKEN_KEY);
  57.         if ($tokenInCookie === null || $tokenInCookie !== $maintenanceToken) {
  58.             $locale env('ECCUBE_LOCALE');
  59.             $templateCode env('ECCUBE_TEMPLATE_CODE');
  60.             $baseUrl \htmlspecialchars(\rawurldecode($request->getBaseUrl()), ENT_QUOTES);
  61.             header('HTTP/1.1 503 Service Temporarily Unavailable');
  62.             require __DIR__.'/maintenance.php';
  63.             return;
  64.         }
  65.     }
  66. }
  67. $kernel = new Kernel($env$debug);
  68. $response $kernel->handle($request);
  69. $response->send();
  70. $kernel->terminate($request$response);