<?php
if(version_compare(PHP_VERSION,'5.4.0','<'))  die('require PHP > 5.4.0 !');
defined('ROOT_PATH') or define('ROOT_PATH', dirname(dirname(__FILE__)).'/');
if(!file_exists(ROOT_PATH.'data/install.lock')){
	header("Location:../install/index.php");exit;
}
defined('YII_DEBUG') or define('YII_DEBUG', true);
// defined('YII_ENV') or define('YII_ENV', 'dev');
defined('YII_ENV') or define('YII_ENV', 'prod');

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

$config = yii\helpers\ArrayHelper::merge(
    require(__DIR__ . '/../protected/common/config/main.php'),
    require(__DIR__ . '/../protected/common/config/db.php'),
    require(__DIR__ . '/../protected/backend/config/main.php'),
    require(__DIR__ . '/../protected/backend/config/main-local.php'),
    require(__DIR__ . '/../protected/frontend/config/route-rule.php')
);
$config['components']['urlManagerFrontend'] = $config['components']['urlManager'];
unset($config['components']['urlManager']);
$config['components']['urlManagerFrontend']['class'] = 'yii\web\urlManager';
$config['components']['urlManagerFrontend']['baseUrl'] = $config['params']['sitedir'];
$config['components']['urlManagerFrontend']['enablePrettyUrl'] = true;
$config['components']['urlManagerFrontend']['showScriptName'] = false;
defined('UPLOAD_PATH') or define('UPLOAD_PATH',ROOT_PATH.'data/upload/');
defined('RUNTIME_PATH') or define('RUNTIME_PATH',ROOT_PATH.'runtime/');
defined('COMMON_CONF_PATH') or define('COMMON_CONF_PATH', ROOT_PATH.'protected/common/config/');
defined('FRONTEND_CONF_PATH') or define('FRONTEND_CONF_PATH', ROOT_PATH.'protected/frontend/config/');

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