コード例 #1
0
ファイル: Logger.php プロジェクト: NothingToDoCN/ss-panel
 public static function newLog($type, $msg)
 {
     $log = new Log();
     $log->type = $type;
     $log->msg = $msg;
     $log->created_time = time();
     return $log->save();
 }
コード例 #2
0
 /**
  * Creates a new Log model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Log();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
コード例 #3
0
ファイル: GoalController.php プロジェクト: sapozhkov/goal
 public function actionMessage()
 {
     $model = new Log();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect($model->goal->url(['#' => 'log']));
     } else {
         throw new ErrorException('Cannot add message');
     }
 }
コード例 #4
0
ファイル: Source.php プロジェクト: mamontovdmitriy/aaaaa
 public function updateLog()
 {
     $model = Log::findOne($this->id);
     if (!$model) {
         $model = new Log();
         $model->source_id = $this->id;
     }
     $model->updated = date("Y-m-d H:i:s");
     return $model->save();
 }
コード例 #5
0
 public function createLog($data)
 {
     $log = new Log();
     $log->log_name = $data['log_name'];
     $log->log_description = $data['log_description'];
     $log->duration = $data['duration'];
     $log->status = $data['status'];
     $log->retrieved_from = $data['retrieved_from'];
     $log->is_group_log = $data['is_group_log'];
     $log->priority = $data['priority'];
     $log->list_id = $data['list_id'];
     $log->user_id = $this->auth->id();
     $log->save();
 }
コード例 #6
0
 /**
  * Updates an existing Equipment model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param string $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     $model->room_id = $model->location->room_id;
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         //Las siguientes líneas de código almacenan en la tabla Log información de acerca de las actualizaciones en los equipos
         $modelLog = new Log();
         $modelLog->user_id = Yii::$app->user->id;
         $modelLog->date = new \yii\db\Expression('NOW()');
         $modelLog->log_type_id = 3;
         $modelLog->equipment_id = $model->id;
         $modelLog->location_id = $model->location_id;
         $modelLog->equipment_status_id = $model->equipment_status_id;
         $modelLog->save();
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('update', ['model' => $model]);
     }
 }
コード例 #7
0
ファイル: GoalForm.php プロジェクト: sapozhkov/goal
 public function afterSave($insert, $changedAttributes)
 {
     parent::afterSave($insert, $changedAttributes);
     $oLog = new Log();
     $oLog->message = $this->log_message;
     $oLog->goal_id = $this->id;
     $aChanged = [];
     foreach ($changedAttributes as $sName => $sVal) {
         $mNewVal = $this->getAttribute($sName);
         if (is_int($sVal)) {
             $mNewVal = (int) $mNewVal;
         }
         if ($sVal != $this->getAttribute($sName)) {
             $aChanged[$sName] = [$sVal, $mNewVal];
         }
     }
     if (isset($aChanged['updated_at'])) {
         unset($aChanged['updated_at']);
     }
     $oLog->data = json_encode($aChanged);
     $oLog->save();
 }
コード例 #8
0
ファイル: Grab.php プロジェクト: aiyeyun/grab
 function html_str($url)
 {
     /*
     $qihao = $this->grab->find('div[class=mod-aside mod-aside-xssckj]',0)->find('div[class=hd clearfix]',0)->find('em[class=red]',0)->innertext;
     $code1 = $this->grab->find('div[class=mod-aside mod-aside-xssckj]',0)->find('div[class=hd clearfix]',0)->find('ul[id=open_code_list]',0)->find('li[class=ico-ball3]',0)->innertext;
     $code2 = $this->grab->find('div[class=mod-aside mod-aside-xssckj]',0)->find('div[class=hd clearfix]',0)->find('ul[id=open_code_list]',0)->find('li[class=ico-ball3]',1)->innertext;
     $code3 = $this->grab->find('div[class=mod-aside mod-aside-xssckj]',0)->find('div[class=hd clearfix]',0)->find('ul[id=open_code_list]',0)->find('li[class=ico-ball3]',2)->innertext;
     $code4 = $this->grab->find('div[class=mod-aside mod-aside-xssckj]',0)->find('div[class=hd clearfix]',0)->find('ul[id=open_code_list]',0)->find('li[class=ico-ball3]',3)->innertext;
     $code5 = $this->grab->find('div[class=mod-aside mod-aside-xssckj]',0)->find('div[class=hd clearfix]',0)->find('ul[id=open_code_list]',0)->find('li[class=ico-ball3]',4)->innertext;
     $msg = $this->grab->find('div[class=mod-aside mod-aside-xssckj]',0)->find('div[class=hd clearfix]',0)->find('p[class=kj-date]',0)->find('em[class=kj-date-txt]',0)->innertext;
     
     echo $qihao.'<br/>';
     echo $code1.'<br/>';
     echo $code2.'<br/>';
     echo $code3.'<br/>';
     echo $code4.'<br/>';
     echo $code5.'<br/>';
     echo $msg.'<br/>';
     exit;
     */
     $qihao2 = $this->grab->find('div[class=mod-aside mod-aside-xssckj]', 0)->find('div[class=bd]', 0)->find('div[class=kpkjcode]', 0)->find('table', 0)->find('tr', 1)->find('td', 0)->plaintext;
     $code = $this->grab->find('div[class=mod-aside mod-aside-xssckj]', 0)->find('div[class=bd]', 0)->find('div[class=kpkjcode]', 0)->find('table', 0)->find('tr', 1)->find('td', 1)->plaintext;
     if ($code != '--') {
         // == '--' 正在开奖中
         $isKaiJiang = $this->grab->find('div[class=mod-aside mod-aside-xssckj]', 0)->find('div[class=bd]', 0)->find('div[class=kpkjcode]', 0)->find('table', 0)->find('tr', 1)->find('td', 2)->plaintext;
         if ($isKaiJiang != '--' && $isKaiJiang != '开奖中') {
             //能读取到数据
             $sizeProportion = $this->grab->find('div[class=mod-aside mod-aside-xssckj]', 0)->find('div[class=bd]', 0)->find('div[class=kpkjcode]', 0)->find('table', 0)->find('tr', 1)->find('td', 2)->find('span', 0)->plaintext;
             $jioubili = $this->grab->find('div[class=mod-aside mod-aside-xssckj]', 0)->find('div[class=bd]', 0)->find('div[class=kpkjcode]', 0)->find('table', 0)->find('tr', 1)->find('td', 2)->find('span', 1)->plaintext;
             $codeArr = explode(" ", $code);
             list($one, $two, $three, $four, $five) = $codeArr;
             $result = Code::findOne(['qishu' => $qihao2, 'type' => $this->codeType[$url]]);
             if ($result) {
                 $urlName = array_keys($this->urlArr, $url);
                 echo $urlName[0] . ' - [新时时彩] 最新数据已经采集过了<br/>';
                 return;
             }
             $model = new Code();
             $model->qishu = $qihao2;
             $model->one = $one;
             $model->two = $two;
             $model->three = $three;
             $model->four = $four;
             $model->five = $five;
             $model->type = $this->codeType[$url];
             $model->size = $sizeProportion;
             $model->jiou = $jioubili;
             $model->time = time();
             if ($model->validate() && $model->save()) {
                 $urlName = array_keys($this->urlArr, $url);
                 $logModel = new Log();
                 $logModel->type = 1;
                 $logModel->content = $urlName[0] . '.开奖信息抓取成功';
                 $logModel->time = time();
                 $logModel->save();
                 echo $urlName[0] . '.开奖信息抓取成功-[新时时彩]<br/>';
                 $this->find($qihao2, $urlName[0], $codeArr, $model->id);
                 return;
             }
         } else {
             $urlName = array_keys($this->urlArr, $url);
             echo $urlName[0] . '等待开奖...<br/>';
         }
     } else {
         $urlName = array_keys($this->urlArr, $url);
         echo $urlName[0] . ' -[新时时彩] 等待开奖...<br/>';
         return;
     }
 }
コード例 #9
0
ファイル: GrabTjSsc.php プロジェクト: aiyeyun/grab
 /**
  * 记录日志
  * @param bool $state      操作状态;
  * @param string $content  操作内容;
  */
 private function setLog($state = true, $content = '')
 {
     $state == true ? $type = 1 : ($type = 2);
     //抓取网页失败 记录日志
     $logModel = new Log();
     $logModel->type = $type;
     $logModel->content = $content;
     $logModel->time = time();
     $logModel->save();
 }
コード例 #10
0
ファイル: Challenge.php プロジェクト: Aksigera/dozor
 public static function checkAnswer($post, $model)
 {
     $answerType = 'Ошибка';
     $answer = $post['Challenge']['answer'];
     if (!empty($answer)) {
         if ($model->is_answer_activate == 0) {
             if ($answer == $model->answer) {
                 $model->is_answer_activate = 1;
                 $answerType = 'Ответ введен верно';
                 $model->save(false);
             } else {
                 $answerType = 'Ответ введен не верно';
             }
         } else {
             $checkSum = (string) (ord($answer[6]) + $answer[7]);
             $answerId = $checkSum[2];
             if (strlen($answer) == 8 && $answer[0] == 'z' && $answer[1] == 'p' && $answerId == $model->id) {
                 $answerType = 'Код введен верно';
                 $model->code_count = $model->code_count + 1;
                 $model->save(false);
             } else {
                 $answerType = 'Код введен не верно';
             }
         }
         $log = new Log();
         $log->time = time();
         $log->text = $answerType;
         $log->challenge_id = $model->id;
         $log->answer = $answer;
         $log->save();
     }
 }
コード例 #11
0
ファイル: Task.php プロジェクト: sapozhkov/goal
 /**
  * @inheritdoc
  */
 public function afterSave($insert, $changedAttributes)
 {
     parent::afterSave($insert, $changedAttributes);
     // add log record on task creation
     if ($insert) {
         $log = new Log(['data' => json_encode(['add_task' => ['id' => $this->id, 'title' => $this->title]]), 'goal_id' => $this->goal_id]);
         $log->save();
     } elseif (isset($changedAttributes['closed']) and !$changedAttributes['closed'] and $this->closed) {
         // add log record
         $log = new Log(['data' => json_encode(['close_task' => ['id' => $this->id, 'title' => $this->title]]), 'goal_id' => $this->goal_id]);
         $log->save();
         // upd percent if needed
         if ($this->percent and $this->percent > $this->goal->percent) {
             $this->goal->percent = $this->percent;
             $this->goal->save();
         }
     }
 }
コード例 #12
0
ファイル: BaseController.php プロジェクト: vilison/yii2-order
 public function beforeAction($action)
 {
     parent::beforeAction($action);
     $act = $action->id;
     $controller = $action->controller->id;
     $user = Yii::$app->session->get('user');
     $log = new Log();
     $log->url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER["REQUEST_URI"];
     $log->method = Yii::$app->request->method;
     $log->controller = $controller;
     $log->action = $act;
     if ($user != null) {
         $log->uid = $user->id;
     }
     $log->log_time = date('Y-m-d H:i:s');
     $log->save();
     if ($controller == 'site') {
         return true;
     }
     if (Yii::$app->user->isGuest && $act != 'guest-create') {
         $this->redirect('/site/login');
     }
     if ($this->isPermiss($user, $controller, $act)) {
         return true;
     } else {
         throw new MethodNotAllowedHttpException('未被授权!');
     }
 }
コード例 #13
0
ファイル: GrabOld.php プロジェクト: aiyeyun/grab
 private function html_str($url)
 {
     $qihao = $this->grab->find('div[class=aside]', 0)->find('h3', 0)->find('em', 0)->plaintext;
     $code = $this->grab->find('div[class=aside]', 0)->find('div[class=mod-aside mod-aside-xssckj]', 0)->find('div[class=bd]', 0)->find('div[class=kpkjcode]', 0)->find('table', 0)->find('tr', 1)->find('td', 1)->plaintext;
     if ($code != '--') {
         $isKaiJiang = $this->grab->find('div[class=aside]', 0)->find('div[class=mod-aside mod-aside-xssckj]', 0)->find('div[class=bd]', 0)->find('div[class=kpkjcode]', 0)->find('table', 0)->find('tr', 1)->find('td', 2)->plaintext;
         if ($isKaiJiang != '--' && $isKaiJiang != '开奖中') {
             //能读取到数据
             $h3_shape = $this->grab->find('div[class=aside]', 0)->find('div[class=mod-aside mod-aside-xssckj]', 0)->find('div[class=bd]', 0)->find('div[class=kpkjcode]', 0)->find('table', 0)->find('tr', 1)->find('td', 2)->find('span', 0)->plaintext;
             $h3_size = $this->grab->find('div[class=aside]', 0)->find('div[class=mod-aside mod-aside-xssckj]', 0)->find('div[class=bd]', 0)->find('div[class=kpkjcode]', 0)->find('table', 0)->find('tr', 1)->find('td', 2)->find('span', 1)->plaintext;
             $h3_jiou = $this->grab->find('div[class=aside]', 0)->find('div[class=mod-aside mod-aside-xssckj]', 0)->find('div[class=bd]', 0)->find('div[class=kpkjcode]', 0)->find('table', 0)->find('tr', 1)->find('td', 2)->find('span', 2)->plaintext;
             $h2_shape = $this->grab->find('div[class=aside]', 0)->find('div[class=mod-aside mod-aside-xssckj]', 0)->find('div[class=bd]', 0)->find('div[class=kpkjcode]', 0)->find('table', 0)->find('tr', 1)->find('td', 3)->find('span', 0)->plaintext;
             $h2_10wei = $this->grab->find('div[class=aside]', 0)->find('div[class=mod-aside mod-aside-xssckj]', 0)->find('div[class=bd]', 0)->find('div[class=kpkjcode]', 0)->find('table', 0)->find('tr', 1)->find('td', 3)->find('span', 1)->plaintext;
             $h2_gewei = $this->grab->find('div[class=aside]', 0)->find('div[class=mod-aside mod-aside-xssckj]', 0)->find('div[class=bd]', 0)->find('div[class=kpkjcode]', 0)->find('table', 0)->find('tr', 1)->find('td', 3)->find('span', 2)->plaintext;
             /*
             echo '开奖期号:'.$qihao;
             echo '<br/>';
             echo '开奖号码:'.$code;
             echo '<br/>';
             echo '<br/>';
             
             echo '后3形态:'.$h3_shape;
             echo '<br/>';
             echo '后3大小比:'.$h3_size;
             echo '<br/>';
             echo '后3奇偶比:'.$h3_jiou;
             echo '<br/>';
             echo '<br/>';
             
             echo '后2形态:'.$h2_shape;
             echo '<br/>';
             echo '后2大小比:'.$h2_10wei;
             echo '<br/>';
             echo '后2奇偶比:'.$h2_gewei;
             */
             $result = Codeold::findOne(['qishu' => $qihao, 'type' => $this->codeType[$url]]);
             if ($result) {
                 $urlName = array_keys($this->urlArr, $url);
                 echo $urlName[0] . ' 最新数据已经采集过了<br/>';
                 return;
             }
             $model = new Codeold();
             $model->qishu = $qihao;
             $model->code = $code;
             $model->after_three_shape = $h3_shape;
             $model->after_three_size = $h3_size;
             $model->after_three_jiou = $h3_jiou;
             $model->after_two_shape = $h2_shape;
             $model->after_two_tens_place = $h2_10wei;
             $model->after_two_the_unit = $h2_gewei;
             $model->type = $this->codeType[$url];
             $model->time = time();
             if ($model->validate() && $model->save()) {
                 $urlName = array_keys($this->urlArr, $url);
                 $logModel = new Log();
                 $logModel->type = 1;
                 $logModel->content = $urlName[0] . '.开奖信息抓取成功';
                 $logModel->time = time();
                 $logModel->save();
                 echo $urlName[0] . '.开奖信息抓取成功<br/>';
                 $this->find($qihao, $urlName[0], $code, $model->id);
                 return;
             }
         } else {
             $urlName = array_keys($this->urlArr, $url);
             echo $urlName[0] . '等待开奖...<br/>';
         }
     } else {
         $urlName = array_keys($this->urlArr, $url);
         echo $urlName[0] . '等待开奖...<br/>';
     }
 }
コード例 #14
0
ファイル: LogMapper.php プロジェクト: blozixdextr/adtw
 public static function reviewed(Log $log)
 {
     $log->review_date = \Carbon\Carbon::now();
     $log->save();
 }