public function search($params)
 {
     $query = AccessLogSqlInject::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'db' => \Yii::$app->db1, 'sort' => ['defaultOrder' => ['request_time' => SORT_DESC]]]);
     $this->load($params);
     if (!$this->validate()) {
         return $dataProvider;
     }
     if ($this->request_time) {
         $this->start_date = $this->request_time;
         $this->end_date = date('Y-m-d 00:00:00', strtotime('+1 day', strtotime($this->start_date)));
     }
     $query->andFilterWhere(['source' => $this->source]);
     $query->andFilterWhere(['log_type' => $this->log_type]);
     $query->andFilterWhere(['user_ip' => $this->user_ip]);
     $query->andFilterWhere(['>=', 'request_time', $this->start_date]);
     $query->andFilterWhere(['<', 'request_time', $this->end_date]);
     return $dataProvider;
 }
Ejemplo n.º 2
0
 /**
  * 获得首页要显示的访问情况
  */
 public static function pageAttackEcharts()
 {
     //获得总的攻击信息记录数
     $sqlattack = AccessLogSqlInject::find()->count();
     //获得访问出错的数据
     $query = new Query();
     $dateString = $query->select("count(*) nums,error_status")->from('AccessLogErrorStatus')->groupBy("error_status")->orderBy("nums desc")->all(\Yii::$app->db1);
     if (empty($dateString)) {
         return [];
     }
     $otherCountry = [];
     $otherCountry['categories'][] = '注入';
     //$otherCountry['series']['data'][] = ['url' => Url::toRoute('/nginx/sqlattack'), 'name' => '注入', 'y' => floatval($sqlattack)];
     $otherCountry['series']['data'][] = floatval($sqlattack);
     foreach ($dateString as $oneDate) {
         $otherCountry['categories'][] = $oneDate['error_status'];
         //$otherCountry['series']['data'][] = ['url' => Url::toRoute('/nginx/errorstatus') . '?AccessLogErrorStatusSearch%5Berror_status%5D=' . $oneDate['error_status'], 'name' => $oneDate['error_status'], 'y' => floatval($oneDate['nums'])];
         $otherCountry['series']['data'][] = floatval($oneDate['nums']);
     }
     $otherCountry['series']['name'] = '数量';
     $otherCountry['series']['type'] = 'bar';
     $otherCountry['series']['itemStyle'] = ['normal' => ['label' => ['show' => true, 'position' => 'top']]];
     return $otherCountry;
 }