Accounts.php 727 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. namespace app\index\model;
  3. use think\Model;
  4. class Accounts extends Model
  5. {
  6. //用户
  7. function getOneAccount($userName)
  8. {
  9. $res=db('accounts')->where('user_name',$userName)->find();
  10. if(!$res){
  11. return $res;
  12. }
  13. return $res;
  14. }
  15. //检测token
  16. function checktoken($token){
  17. $user = db('accounts')->where('token', $token)->find();
  18. if(!empty($user)){
  19. $time = time()-$user['expire_time'];
  20. if($time<3600){
  21. db('accounts')->where('id', $user['id'])->update(['expire_time' => time()]);
  22. return 1;
  23. }else{
  24. return -1;
  25. }
  26. }
  27. return -1;
  28. }
  29. }