Exemplo n.º 1
0
 public function dologout()
 {
     //更新用户日志表
     LogModel::where('serial', Session::get('user.serial'))->update(['logoutTime' => time()]);
     //去除session
     Session::forget('user');
     return redirect(DOMAIN . 'login');
 }
Exemplo n.º 2
0
 public function dologout()
 {
     //更新用户日志表
     $logoutTime = time();
     LogModel::where('serial', Session::get('admin.serial'))->update(['logoutTime' => $logoutTime]);
     //去除session
     Session::forget('admin');
     return Redirect(DOMAIN . 'admin/login');
 }
Exemplo n.º 3
0
 public function __construct()
 {
     parent::__construct();
     $this->userid = \Session::has('user.uid') ? \Session::get('user.uid') : redirect('/login');
     $userSpace = \App\Models\UserParamsModel::where('uid', $this->userid)->first();
     $this->user = \App\Models\UserModel::find($this->userid);
     $userlog = \App\Models\Admin\LogModel::where('uid', $this->userid)->orderBy('id', 'asc')->get();
     //注册的记录
     $this->user->spaceTopBgImg = $userSpace->getPicUrl();
     $this->user->userlog = $userlog;
 }
Exemplo n.º 4
0
 public function users()
 {
     $users_all = UserModel::all();
     $users_week = LogModel::where('loginTime', '>', time() - 3600 * 24 * 7)->distinct('uid')->get();
     $users_hour = LogModel::where('loginTime', '>', time() - 3600)->distinct('uid')->get();
     //最新注册用户
     $datas = UserModel::where('isauth', '>', 0)->where('created_at', '>', time() - 3600 * 24 * 7)->orderBy('id', 'desc')->paginate($this->limit);
     if (!count($datas)) {
         $datas = UserModel::where('isauth', '>', 0)->orderBy('id', 'desc')->paginate($this->limit);
     }
     return array('datas' => $datas, 'all' => count($users_all), 'week' => count($users_week), 'hour' => count($users_hour));
 }
Exemplo n.º 5
0
 public function doregist()
 {
     //查看同ip是否已有3个注册,满3个则限制
     if (count(UserModel::where('ip', Tools::getIp())->get()) == 3) {
         echo "<script>alert('此用户已经注册过,不要重复注册!');history.go(-1);</script>";
         exit;
     }
     //查看是否有此用户
     if (UserModel::where('username', Input::get('username'))->first()) {
         echo "<script>alert('此用户已经注册!');history.go(-1);</script>";
         exit;
     }
     //        //验证密码正确否
     //        if (!(Hash::check(Input::get('password'),$userModel->password))) {
     //            echo "<script>alert('密码错误!');history.go(-1);</script>";exit;
     //        }
     //查看2次密码输入是否一致
     if (Input::get('password') != Input::get('password2')) {
         echo "<script>alert('2次密码输入不一致!');history.go(-1);</script>";
         exit;
     }
     //验证码验证
     $rules = [];
     $messages = ['captcha.required' => '请输入验证码', 'captcha.captcha' => '验证码错误,请重试'];
     $validator = Validator::make(Input::all(), $rules, $messages);
     if ($validator->fails()) {
         echo "<script>alert('验证码错误!');history.go(-1);</script>";
         exit;
     }
     //数据写入用户表
     $data = ['username' => Input::get('username'), 'password' => Hash::make(Input::get('password')), 'ip' => Tools::getIp(), 'email' => Input::get('email'), 'created_at' => time(), 'lastLogin' => time()];
     UserModel::create($data);
     //加入session
     $userinfo = UserModel::where('username', Input::get('username'))->first();
     $userInfo = ['uid' => $userinfo->id, 'username' => Input::get('username'), 'email' => Input::get('email')];
     Session::put('user', $userInfo);
     //登陆加入用户日志表
     $serial = date('YmdHis', time()) . rand(0, 10000);
     $ip = \App\Tools::getIp();
     $ipaddress = \App\Tools::getCityByIp($ip);
     $userlog = ['uid' => $userinfo->id, 'uname' => Input::get('username'), 'genre' => 1, 'serial' => $serial, 'ip' => $ip, 'ipaddress' => $ipaddress, 'action' => $_SERVER['REQUEST_URI'], 'loginTime' => time(), 'created_at' => $userinfo->created_at];
     \App\Models\Admin\LogModel::create($userlog);
     return redirect(DOMAIN . 'regist/success');
 }
Exemplo n.º 6
0
 public function query()
 {
     $datas = LogModel::where('genre', 1)->orderBy('id', 'desc')->paginate($this->limit);
     $datas->limit = $this->limit;
     return $datas;
 }