<?php

$ipBlacklist = [
    '154.216.19.204',
];

if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
    $ip = $_SERVER['HTTP_CLIENT_IP'];
} //if user is from the proxy
elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
    $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} //if user is from the remote address
else {
    $ip = $_SERVER['REMOTE_ADDR'];
}

if (in_array($ip, $ipBlacklist)) {
    header("HTTP/1.0 404 Not Found");
    echo "loading . . . ";
    die();
}

define('YII_START_TS', microtime(1));

header('Access-Control-Allow-Origin: *'); //не удалять, фиксит CORS

$hasYiiDebug = isset($_COOKIE['yii_debug']) && $_COOKIE['yii_debug'];

$params = array_merge_recursive(
    require(__DIR__ . '/../config/params.php'),
    require(__DIR__ . '/../config/params.local.php')
);

$debug = in_array($_SERVER['HTTP_HOST'], $params['devHosts']) || $hasYiiDebug;
defined('YII_DEBUG') or define('YII_DEBUG', $debug);
defined('YII_ENV') or define('YII_ENV', 'dev');


require __DIR__ . '/../vendor/autoload.php';
require __DIR__ . '/../vendor/yiisoft/yii2/Yii.php';
require(__DIR__ . '/../config/bootstrap.php');

$config = require __DIR__ . '/../config/web.php';

(new yii\web\Application($config))->run();
