index.php line 131

Open in your IDE?
  1. <?php
  2. error_reporting(E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED);
  3. use Eccube\Kernel;
  4. use Symfony\Component\Debug\Debug;
  5. use Dotenv\Dotenv;
  6. use Symfony\Component\HttpFoundation\Request;
  7. header("Access-Control-Allow-Headers: X-API-KEY, Origin, X-Requested-With, Content-Type, Accept, Access-Control-Request-Method");
  8. header("Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, DELETE");
  9. header("Allow: GET, POST, OPTIONS, PUT, DELETE");
  10. // システム要件チェック
  11. if (version_compare(PHP_VERSION'7.1.3') < 0) {
  12.     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.');
  13. }
  14. $autoload __DIR__.'/vendor/autoload.php';
  15. if (!file_exists($autoload) && !is_readable($autoload)) {
  16.     die('Composer is not installed.');
  17. }
  18. require $autoload;
  19. // The check is to ensure we don't use .env in production   
  20. if (!isset($_SERVER['APP_ENV'])) {
  21.     if (!class_exists(Dotenv::class)) {
  22.         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.');
  23.     }
  24.     if (file_exists(__DIR__.'/.env')) {
  25.         (new Dotenv(__DIR__))->overload();
  26.         if (strpos(getenv('DATABASE_URL'), 'sqlite') !== false && !extension_loaded('pdo_sqlite')) {
  27.             (new Dotenv(__DIR__'.env.install'))->overload();
  28.         }
  29.     } else {
  30.         (new Dotenv(__DIR__'.env.install'))->overload();
  31.     }
  32. }
  33. $env = isset($_SERVER['APP_ENV']) ? $_SERVER['APP_ENV'] : 'dev';
  34. $debug = isset($_SERVER['APP_DEBUG']) ? $_SERVER['APP_DEBUG'] : ('prod' !== $env);
  35. if ($env === 'dev') {
  36.     header('X-Robots-Tag: noindex');
  37. }
  38. if ($debug) {
  39.     umask(0000);
  40.     Debug::enable();
  41. }
  42. // アフィリエイト用
  43. $abm filter_input(INPUT_GET"abm");
  44. if($abm){
  45.     if($debug){
  46.         setcookie('afbcookie'$abmtime() + 776000"/""xs564860.xsrv.jp");
  47.     }else{
  48.         setcookie('afbcookie'$abmtime() + 776000"/""kyogokupro.com"truetrue);
  49.     }
  50. }
  51. $deny_file __DIR__ "/.denyip";
  52. if(file_exists($deny_file)){
  53.     $ip $_SERVER['REMOTE_ADDR'];
  54.     $deny_ips file_get_contents(__DIR__ "/.denyip");
  55.     $deny_ip explode("\n"$deny_ips);
  56.     if(in_array($ip$deny_ip)){
  57.         header("HTTP/1.1 404 Not Found");
  58.         exit;
  59.     }
  60. }
  61. # とりあえずIPBlockは解除(2023-09-15)
  62. if(false && in_array($_SERVER["REQUEST_URI"],[
  63.     "/cart",
  64.     "/mypage/",
  65.     "/mypage/gmo_card_edit",
  66.     "/mypage/eccube_payment_lite/credit_card",
  67.     ])){
  68.     $allow_file __DIR__ "/.allowip";
  69.     if(file_exists($allow_file)){
  70.         $block = new \Customize\Service\IpBlock($allow_file);
  71.         if( $block->is_allow() == false){
  72.             header("HTTP/1.1 404 Not Found");
  73.             exit;
  74.         }
  75.     }
  76. }
  77. $deny_path = ["/&id1""/&id1="];
  78. foreach($deny_path as $dp){
  79.     if(preg_match('/^'preg_quote($dp,'/') . '.*/'$_SERVER["REQUEST_URI"])){
  80.         header("HTTP/1.1 404 Not Found");
  81.         exit;
  82.     }
  83. }
  84. $trustedProxies = isset($_SERVER['TRUSTED_PROXIES']) ? $_SERVER['TRUSTED_PROXIES'] : false;
  85. if ($trustedProxies) {
  86.     Request::setTrustedProxies(explode(','$trustedProxies), Request::HEADER_X_FORWARDED_ALL Request::HEADER_X_FORWARDED_HOST);
  87. }
  88. $trustedHosts = isset($_SERVER['TRUSTED_HOSTS']) ? $_SERVER['TRUSTED_HOSTS'] : false;
  89. if ($trustedHosts) {
  90.     Request::setTrustedHosts(explode(','$trustedHosts));
  91. }
  92. $request Request::createFromGlobals();
  93. $maintenanceFile env('ECCUBE_MAINTENANCE_FILE_PATH'__DIR__.'/.maintenance');
  94. if (file_exists($maintenanceFile)) {
  95.     $pathInfo = \rawurldecode($request->getPathInfo());
  96.     $adminPath env('ECCUBE_ADMIN_ROUTE''admin');
  97.     $adminPath '/'.\trim($adminPath'/').'/';
  98.     if (\strpos($pathInfo$adminPath) !== 0) {
  99.         $locale env('ECCUBE_LOCALE');
  100.         $templateCode env('ECCUBE_TEMPLATE_CODE');
  101.         $baseUrl = \htmlspecialchars(\rawurldecode($request->getBaseUrl()), ENT_QUOTES);
  102.         header('HTTP/1.1 503 Service Temporarily Unavailable');
  103.         require __DIR__.'/maintenance.php';
  104.         return;
  105.     }
  106. }
  107. $kernel = new Kernel($env$debug);
  108. $response $kernel->handle($request);
  109. $response->send();
  110. $kernel->terminate($request$response);