function init() { $this->_initConf(); $this->_initWebObject(); $this->_initEnv(); $this->_initLogger(); $this->requestId = $this->genRequestId(); //do self-define module initial process $mClassName = ucfirst(App::getModule()) . 'Module'; if (class_exists($mClassName)) { $notUsed = new $mClassName(); call_user_func($mClassName . '::initModule'); } else { throw new Exception("initModule class not exists"); } //统计执行时间 $module = App::getModule(); $interface = App::getController() . '_' . App::getAction(); Statis_Client::startTick($module, $interface); App::getTimer()->set('framework init'); }
function send() { $data = $this->_formatResponse(); $this->sendHeaders(); //获取缓冲数据 $ob = ini_get('output_buffering'); if ($ob && strtolower($ob) !== 'off') { $str = ob_get_clean(); //忽略前后空白 $data = trim($str) . $data; } if ($data) { if (EnvConf::$debug) { KC_LOG_DEBUG("[RETURNED DATA]\n\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n" . $data . "\n<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n"); } //统计模块 if (true) { $success = true; $code = 0; $msg = "succ"; $module = App::getModule(); $interface = App::getController() . '_' . App::getAction(); $dataArr = json_decode($data, true); if (isset($dataArr['error_code']) && $dataArr['error_code'] == 0) { $msg = $dataArr['error_msg']; } else { $success = false; $code = isset($dataArr['error_code']) ? $dataArr['error_code'] : -1; $msg = (isset($dataArr['error_msg']) ? $dataArr['error_msg'] : "failed") . " ,requestid:" . $this->app->requestId; $msg .= ', ip:' . App::getClientIp(); } $do_not_report_code = array('100801'); if (!in_array($code, $do_not_report_code)) { Statis_Client::report($module, $interface, $success, $code, $msg); } } //support for return format -- jsonp if ('json' === $this->app->request->of) { $cb = $this->app->request->get('callback', ''); $cb = trim($cb); if (!empty($cb)) { $data = $cb . "({$data})"; } } echo $data; } }