/** * catch server side errors and return json encoded exception * @return void */ function extDirectShutdownFunction() { $data = \CB\Cache::get('ExtDirectData'); $error = error_get_last(); if (in_array($error['type'], array(1, 4))) { $data['type'] = 'exception'; $data['result'] = array('success' => false); $data['msg'] = 'Internal server error.'; if (\CB\IS_DEBUG_HOST) { $data['msg'] = $error['message']; $data['where'] = print_r(debug_backtrace(false), true); } //notify admin if (!(php_sapi_name() == "cli")) { @mail(Config::get('ADMIN_EMAIL'), 'Remote router error on ' . Config::get('core_url'), var_export($data, true), 'From: ' . Config::get('SENDER_EMAIL') . "\r\n"); } echo Util\jsonEncode($data); } if (\CB\User::isLoged()) { \CB\User::updateLastActionTime(); } }