12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- <?php
- namespace app\common\library\token;
- abstract class Driver
- {
- protected $handler = null;
- protected $options = [];
-
- abstract function set($token, $user_id, $expire = 0);
-
- abstract function get($token);
-
- abstract function check($token, $user_id);
-
- abstract function delete($token);
-
- abstract function clear($user_id);
-
- public function handler()
- {
- return $this->handler;
- }
-
- protected function getEncryptedToken($token)
- {
- $config = \think\Config::get('token');
- return hash_hmac($config['hashalgo'], $token, $config['key']);
- }
-
- protected function getExpiredIn($expiretime)
- {
- return $expiretime ? max(0, $expiretime - time()) : 365 * 86400;
- }
- }
|