コード例 #1
0
ファイル: LogService.php プロジェクト: lawguangwei/webDB
 public function adminLogin($adminId)
 {
     $log = new LoginLog();
     $log->l_log_id = md5($adminId . date('Y-m-d H:i:s'));
     $log->user_id = $adminId;
     $log->login_date = date('Y-m-d H:i:s');
     $log->login_ip = \Yii::$app->request->userIP;
     $log->ip_address = $this->getIPLoc_QQ(\Yii::$app->request->userIP);
     if ($log->save()) {
         return 'success';
     } else {
         return 'error';
     }
 }
コード例 #2
0
ファイル: TestController.php プロジェクト: lawguangwei/webDB
 public function actionInsertLoginLog()
 {
     $start_time = '2015-08-01 00:00:00';
     $end_time = '2016-03-09 00:00:00';
     for ($i = 1; $i <= 1000; $i++) {
         $date = $this->rand_time($start_time, $end_time);
         $user_name = 'test' . $i;
         $user_email = $user_name . '@qq.com';
         $user = User::findOne(['user_email' => $user_email]);
         $loginLog = new LoginLog();
         $loginLog->l_log_id = md5($user->user_id . $date . $i);
         $loginLog->user_id = $user->user_id;
         $loginLog->login_date = $date;
         $loginLog->login_ip = Yii::$app->request->userIP;
         $loginLog->ip_address = '未能获取';
         $loginLog->save();
     }
     echo rand(1, 1000);
     //echo date('Y-m-d H:i:s');
 }