public function actionReset($id) { $model = $this->loadModel($id); $model->counter = 0; if ($model->save()) { foreach ($model->AE as $ae) { $s = Syslog::model()->findByPk($ae->archive_id); if ($s) { $s->delete(); } } $this->redirect(array('view', 'id' => $model->id)); } }
/** * Creates a new model . * * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionFromsyslog($syslog_id) { $entry = Syslog::model()->findByPk($syslog_id); $model = new Whitelist(); $model->host = $entry->hostip; $model->facility = $entry->facility; $model->level = $entry->level; $model->program = $entry->program; $model->pattern = addcslashes($entry->msg, '\\'); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Whitelist'])) { $model->attributes = $_POST['Whitelist']; if ($model->save()) { $this->redirect(array('/syslog/logs/admin')); } } $this->render('create', array('model' => $model)); }
/** * Creates a new model based on a specific message from Syslog. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionFromsyslog($syslog_id) { $entry = Syslog::model()->findByPk($syslog_id); $model = new AbuserTrigger(); $model->facility = $entry->facility; $model->severity = $entry->level; $model->program = $entry->program; $model->msg = addcslashes($entry->msg, '\\'); $model->pattern = '/^(.*?)/'; $model->grouping = 1; $model->capture = 1; $model->occurrence = 1; $model->priority = 1; // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['AbuserTrigger'])) { $model->attributes = $_POST['AbuserTrigger']; if ($model->save()) { $this->redirect(array('/syslog/logs/admin')); } } $this->render('create', array('model' => $model)); }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * * @param * integer the ID of the model to be loaded */ public function loadModel($id) { $model = Syslog::model ()->findByPk ( $id ); if ($model === null) throw new CHttpException ( 404, 'The requested page does not exist.' ); return $model; }
/** * Retrieves a list of models based on the current search/filter conditions. * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions. */ public function search() { // Warning: Please modify the following code to remove attributes that // should not be searched. $criteria = new CDbCriteria(); $criteria->compare('id', $this->id, true); $criteria->compare('host', $this->host, true); $criteria->compare('inet_ntoa(host)', $this->hostip, true); $criteria->compare('facility', $this->facility); $criteria->compare('priority', $this->priority); $criteria->compare('level', $this->level); $criteria->compare('program', $this->program, true); $criteria->compare('pid', $this->pid, true); $criteria->compare('tag', $this->tag, true); $criteria->compare('msg', $this->msg, true); $criteria->compare('received_ts', $this->received_ts, true); $criteria->compare('created_at', $this->created_at, true); if (Yii::app()->user->getState('pageSize', Yii::app()->params['defaultPageSize']) == 0) { $pagination = false; } else { $pagination = array('pageSize' => Yii::app()->user->getState('pageSize', Yii::app()->params['defaultPageSize'])); } if ($this->acknowledge !== false) { Syslog::model()->deleteAll($criteria->condition, $criteria->params); $this->unsetAttributes(); return new CActiveDataProvider($this, array('sort' => array('defaultOrder' => 'received_ts DESC', 'attributes' => array('hostip' => array('asc' => 'inet_ntoa(host)', 'desc' => 'inet_ntoa(host) DESC'), '*')), 'pagination' => $pagination)); } return new CActiveDataProvider($this, array('criteria' => $criteria, 'sort' => array('defaultOrder' => 'received_ts DESC', 'attributes' => array('hostip' => array('asc' => 'inet_ntoa(host)', 'desc' => 'inet_ntoa(host) DESC'), '*')), 'pagination' => $pagination)); }