Пример #1
0
 public function record()
 {
     $operation = $this->controllerName . "/" . $this->actionName;
     $request = new \Phalcon\Http\Request();
     $ip = $request->getClientAddress();
     $members = new \Phalcon_wifi\Common\Models\Members();
     $mid = $members->checkLogin();
     $record = new \Phalcon_wifi\Common\Models\Record();
     $record->operation = $operation;
     $record->loginip = $ip;
     $record->mid = $mid;
     $record->log_time = date("Y-m-d H:i:s");
     $record->save();
 }
Пример #2
0
 public function login($name, $pwd)
 {
     $pwd = md5($pwd);
     $where = "mname = '{$name}' AND mpwd = '{$pwd}' AND del = 'false' AND status = 'true'";
     $user = self::findFirst($where);
     if (!$user) {
         $this->error = "登录失败,请确认后重新登录";
         return false;
     }
     $request = new \Phalcon\Http\Request();
     $user->last_login_time = time();
     $user->last_login_ip = $request->getClientAddress();
     $user->login_counts = $user->login_counts + 1;
     if (!$user->save()) {
         $this->error = "登录失败,请确认后重新登录";
         return false;
     }
     $this->getDI()->get("session")->set("current_user", $user->mid);
     return true;
 }