thinkphp3.2.1坑爹的一次性验证码,ajax要2次验证啊!

浏览:2076 发布日期:2016/04/19 分类:功能实现 关键字: 验证码
验证码为什么要加密?加密也就算了,为什么还在一次性失效的前题下加密?
找了半天也没找到解决好的解决方案。最后决定把自带的验证码验证拿出来用于ajax,二次验证照样过。$verify = new \Think\Verify();
            global $seKey;
               $seKey = $verify->seKey;
            function authcode($str){
                $key = substr(md5($GLOBALS['seKey']), 5, 8);
                $str = substr(md5($str), 8, 10);
                return md5($key . $str);
            }
            function check($code, $id = '') {
                $key = authcode($GLOBALS['seKey']).$id;
                // 验证码不能为空
                $secode = session($key);
                if(empty($code) || empty($secode)) {
                    return false;
                }
                if(authcode(strtoupper($code)) == $secode['verify_code']) {
                    return true;
                }
                return false;
            }
            if (check(I('verify'))) {
                $this->success('验证码正确', $_SERVER['HTTP_REFERER']);
            } else {
                $this->error('验证码错误', $_SERVER['HTTP_REFERER']);
            }
Q907999456
http://blog.xuanzeta.com
评论( 相关
后面还有条评论,点击查看>>