'frameworks-prerelease']); } fixConfig($config, 'frontend'); $application = new yii\web\Application($config); //2025-09-04 scott 限制鏈接數 $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); } } }); });*/ if (getenv('APP_NAME') == 'egogosource' && $_GET['lang'] == 'ZH_CN' && $_GET['switchLang'] == 'ZH_HK') { $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->content) && substr($response->content, 0, 15) == '') { $transliterator = \Transliterator::create('Hans-Hant'); $response->content = $transliterator->transliterate($response->content); } if (!empty($response->data) && substr($response->data, 0, 15) == '') { $transliterator = \Transliterator::create('Hans-Hant'); $response->data = $transliterator->transliterate($response->data); } } }); }); } } // 2020-8-21 - TK: disable yii debug log completely - https://www.yiichina.com/tutorial/1065 Yii::$app->log->targets['debug'] = null; $application->run();