CaptchaModel.class.php 684 B

123456789101112131415161718192021222324
  1. <?php
  2. namespace Api\Model;
  3. use Api\Model\BaseModel;
  4. /**
  5. *
  6. * @author star7th
  7. */
  8. class CaptchaModel extends BaseModel {
  9. public function check($captcha_id , $captcha, $none =''){
  10. $time = time() ;
  11. $captcha_id = intval($captcha_id) ;
  12. $captcha_array = $this->where(" captcha_id = '$captcha_id' and expire_time > $time ")->find();
  13. if ($captcha_array['captcha'] && $captcha_array['captcha'] == $captcha) {
  14. //检查完就设置该验证码过期
  15. $this->where(" captcha_id = '$captcha_id'")->save(array("expire_time"=>0));
  16. return true ;
  17. }else{
  18. //删除掉所有过期的二维码
  19. //$this->where(" expire_time < '$time' ")->delete();
  20. }
  21. return false;
  22. }
  23. }