db->createCommand($sql)->queryAll(); // if($_SERVER['REMOTE_ADDR'] == '113.84.211.205'){ // // var_dump(json_last_error_msg()); // var_dump($queryRes); // die(); // } // if($queryRes !== false && $queryRes['pCount'] >= 50) { // echo 'Server is busy!'; // exit; // } $appConfigPath = '/data/app/app_config/' . $appname; if ($appname != false) { $merchantConfig[] = require($appConfigPath . '/common/config/main.php'); $merchantConfig[] = require($appConfigPath . '/common/config/main-local.php'); $merchantConfig[] = require($appConfigPath . '/common/config/email-config.php'); $merchantConfig[] = require($appConfigPath . '/common/config/facebook-config.php'); $merchantConfig[] = require($appConfigPath . '/frontend/config/main.php'); $merchantConfig[] = require($appConfigPath . '/frontend/config/main-local.php'); $merchantConfig[] = file_exists($appConfigPath . '/common/config/esun-config.php') ? require($appConfigPath . '/common/config/esun-config.php') : []; $merchantConfig[] = file_exists($appConfigPath . '/common/config/language-params.php') ? require($appConfigPath . '/common/config/language-params.php') : []; $merchantConfig[] = file_exists($appConfigPath . '/common/config/esunup-config.php') ? require($appConfigPath . '/common/config/esunup-config.php') : []; $merchantConfig[] = file_exists($appConfigPath . '/common/config/seven-config.php') ? require($appConfigPath . '/common/config/seven-config.php') : []; $merchantConfig[] = file_exists($appConfigPath . '/common/config/sms-config.php') ? require($appConfigPath . '/common/config/sms-config.php') : []; $merchantConfig[] = file_exists($appConfigPath . '/common/config/alipayhk-config.php') ? require($appConfigPath . '/common/config/alipayhk-config.php') : []; } foreach ($merchantConfig as $c) { if (is_array($c)) { $config = yii\helpers\ArrayHelper::merge($config, $c); } } if ($prereleaseFrameworks) { $config['vendorPath'] = strtr($config['vendorPath'], ['frameworks-dev' => 'frameworks-prerelease']); } fixConfig($config, 'frontend'); $application = new yii\web\Application($config); $sql = 'select count(*) as pCount from information_schema.processlist where DB=\'' . strtolower($appname) . '_posify_me' . '\' and Command=\'Query\''; $queryRes = Yii::$app->db->createCommand($sql)->queryOne(); if($queryRes !== false && $queryRes['pCount'] > 50) { echo 'Server Busy!'; exit; } //Change the UrlFormat for urlManager to get if a get request is given instead of a path format one. if (isset($_GET['r'])) { Yii::$app->urlManager->enablePrettyUrl = false; } else { // 2019-2-8 - TK: enable ob cache for better performance // 2019-4-18 - TK: it makes ERR_CONTENT_DECODING_FAILED error on chrome...comment out first /*$application->on(yii\web\Application::EVENT_BEFORE_REQUEST, function(yii\base\Event $event) { $event->sender->response->on(yii\web\Response::EVENT_BEFORE_SEND, function($e) { ob_start('ob_gzhandler'); }); $event->sender->response->on(yii\web\Response::EVENT_AFTER_SEND, function($e) { ob_end_flush(); }); });*/ /*$application->on(yii\web\Application::EVENT_BEFORE_REQUEST, function(yii\base\Event $event) { $event->sender->response->on(yii\web\Response::EVENT_BEFORE_SEND, function($e) { $response = $e->sender; if ($response->format === yii\web\Response::FORMAT_HTML) { if (!empty($response->data) && !YII_DEBUG) { //$response->data = compress($response->data); } if (!empty($response->content) && !YII_DEBUG) { //$response->content = compress($response->content); } } }); });*/ } // 2020-8-21 - TK: disable yii debug log completely - https://www.yiichina.com/tutorial/1065 Yii::$app->log->targets['debug'] = null; $application->run();