コード例 #1
0
 public function actionExport($AS, $zero = false)
 {
     $myAS = intval(escapeshellcmd($AS));
     if ($myAS <= 0) {
         exit("Error you need to provide the AS number for the routes to be published\neg. php cron.php cron 65001\n\n");
     }
     Yii::import('application.modules.abuser.models.*');
     $criteria = new CDbCriteria();
     $criteria->condition = 'abuserIncidents.counter>=occurrence';
     $criteria->order = "abuserIncidents.counter DESC";
     $AT = AbuserTrigger::model()->with('abuserIncidents')->findAll($criteria);
     foreach ($AT as $trigger) {
         foreach ($trigger->abuserIncidents as $incident) {
             $ret = shell_exec(sprintf("/usr/sbin/bgpctl network add %s/32 community %d:%d", $incident->ipstr, $myAS, $incident->trigger_id, $incident->counter));
             $incident->zero($zero);
             // log operation
         }
     }
 }
コード例 #2
0
 public function actionAbuser($email, $interval = 1, $zero = false)
 {
     date_default_timezone_set('UTC');
     $criteria = new CDbCriteria();
     $criteria->condition = '(abuserIncidents.last_occurrence between NOW()-interval :interval minute and NOW() and abuserIncidents.counter>=occurrence) /*OR abuserIncidents.counter>occurrence*/';
     $criteria->params = array(':interval' => intval($interval));
     $criteria->order = "abuserIncidents.counter DESC";
     $AT = AbuserTrigger::model()->with('abuserIncidents')->findAll($criteria);
     if (!$AT) {
         exit;
     }
     $message = $this->render('abuser_report', array('model' => $AT));
     $this->email_report($email, $message);
     if ($zero !== false) {
         foreach ($AT as $a) {
             foreach ($a->abuserIncidents as $b) {
                 $b->zero(true);
             }
         }
     }
     // mail latest abuser incidents
 }
コード例 #3
0
 public function actionUpload()
 {
     $model = new BackupUpload();
     $form = new CForm('application.models.uploadForm', $model);
     if ($form->submitted('submit') && $form->validate()) {
         $form->model->backup = CUploadedFile::getInstance($form->model, 'backup');
         $fc = file_get_contents($form->model->backup->tempName);
         $xml = new SimpleXMLElement($fc, LIBXML_NOCDATA);
         foreach ($xml->record as $record) {
             foreach ((array) $record->attributes() as $val) {
                 if (AbuserTrigger::model()->findByAttributes($val) === null) {
                     $tr = new AbuserTrigger();
                     $tr->attributes = $val;
                     if ($tr->validate()) {
                         $tr->save();
                     }
                 }
             }
         }
         Yii::app()->user->setFlash('success', 'File Uploaded');
         $this->redirect(array('upload'));
     }
     $this->render('upload', array('form' => $form));
 }