diff --git a/application/admin/controller/Dashboard.php b/application/admin/controller/Dashboard.php index 6d79275e..1cad6b9e 100644 --- a/application/admin/controller/Dashboard.php +++ b/application/admin/controller/Dashboard.php @@ -47,8 +47,8 @@ class Dashboard extends Backend 'totalcategory' => \app\common\model\Category::count(), 'todayusersignup' => User::whereTime('jointime', 'today')->count(), 'todayuserlogin' => User::whereTime('logintime', 'today')->count(), - 'sevendau' => User::whereTime('jointime|logintime', '-7 days')->count(), - 'thirtydau' => User::whereTime('jointime|logintime', '-30 days')->count(), + 'sevendau' => User::whereTime('jointime|logintime|prevtime', '-7 days')->count(), + 'thirtydau' => User::whereTime('jointime|logintime|prevtime', '-30 days')->count(), 'threednu' => User::whereTime('jointime', '-3 days')->count(), 'sevendnu' => User::whereTime('jointime', '-7 days')->count(), 'dbtablenums' => count($dbTableList), diff --git a/application/common/library/token/driver/Mysql.php b/application/common/library/token/driver/Mysql.php index 3859e260..379a1683 100644 --- a/application/common/library/token/driver/Mysql.php +++ b/application/common/library/token/driver/Mysql.php @@ -36,13 +36,19 @@ class Mysql extends Driver } else { $this->handler = \think\Db::name($this->options['table']); } + $time = time(); + $tokentime = cache('tokentime'); + if (!$tokentime || $tokentime < $time - 86400) { + cache('tokentime', $time); + $this->handler->where('expiretime', '<', $time)->where('expiretime', '>', 0)->delete(); + } } /** * 存储Token - * @param string $token Token - * @param int $user_id 会员ID - * @param int $expire 过期时长,0表示无限,单位秒 + * @param string $token Token + * @param int $user_id 会员ID + * @param int $expire 过期时长,0表示无限,单位秒 * @return bool */ public function set($token, $user_id, $expire = null) @@ -50,12 +56,12 @@ class Mysql extends Driver $expiretime = !is_null($expire) && $expire !== 0 ? time() + $expire : 0; $token = $this->getEncryptedToken($token); $this->handler->insert(['token' => $token, 'user_id' => $user_id, 'createtime' => time(), 'expiretime' => $expiretime]); - return TRUE; + return true; } /** * 获取Token内的信息 - * @param string $token + * @param string $token * @return array */ public function get($token) @@ -77,8 +83,8 @@ class Mysql extends Driver /** * 判断Token是否可用 - * @param string $token Token - * @param int $user_id 会员ID + * @param string $token Token + * @param int $user_id 会员ID * @return boolean */ public function check($token, $user_id) @@ -89,7 +95,7 @@ class Mysql extends Driver /** * 删除Token - * @param string $token + * @param string $token * @return boolean */ public function delete($token) @@ -100,7 +106,7 @@ class Mysql extends Driver /** * 删除指定用户的所有Token - * @param int $user_id + * @param int $user_id * @return boolean */ public function clear($user_id)