Ejemplo n.º 1
0
 public static function addErrorLog($appid, $uri, $err_msg)
 {
     $model_app_logs = new AppLogs();
     $model_app_logs->app_name = $appid;
     $model_app_logs->request_uri = $uri;
     $model_app_logs->content = $err_msg;
     $model_app_logs->ip = UtilHelper::getClientIP();
     $model_app_logs->ua = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : "";
     $model_app_logs->cookies = var_export($_COOKIE, true);
     $model_app_logs->created_time = date("Y-m-d H:i:s");
     $model_app_logs->save(0);
     return true;
 }
Ejemplo n.º 2
0
 public function actionError()
 {
     $type = intval($this->get("type", 0));
     $log_type_mapping = $this->log_type_mapping;
     $p = intval($this->get("p", 1));
     if (!$p) {
         $p = 1;
     }
     $data = [];
     $query = AppLogs::find();
     if (isset($log_type_mapping[$type])) {
         $query->andWhere(['app_name' => $log_type_mapping[$type]]);
     }
     $total_count = $query->count();
     $offset = ($p - 1) * $this->page_size;
     $access_list = $query->orderBy("id desc")->offset($offset)->limit($this->page_size)->all();
     $page_info = DataHelper::ipagination(["total_count" => $total_count, "page_size" => $this->page_size, "page" => $p, "display" => 10]);
     if ($access_list) {
         $idx = 1;
         foreach ($access_list as $_item_access) {
             $data[] = ['idx' => $idx, 'app_name' => $_item_access['app_name'], 'request_uri' => $_item_access['request_uri'], 'content' => mb_strlen($_item_access['content'], "utf-8") > 150 ? DataHelper::encode(mb_substr($_item_access['content'], 0, 150, "utf-8")) : DataHelper::encode($_item_access['content']), 'ua' => $_item_access['ua'], 'ip' => $_item_access['ip'], 'cookies' => DataHelper::encode($_item_access['cookies']), 'created_time' => $_item_access['created_time']];
             $idx++;
         }
     }
     $search_conditions = ['type' => $type];
     return $this->render("error", ["data" => $data, "page_info" => $page_info, 'search_conditions' => $search_conditions, 'log_type_mapping' => $log_type_mapping]);
 }