/**
* 获取图片验证码
* @Author Dadong2g
* @date 2022-04-12
* @return [type]
*/
function get_img_captcha() {
$builder = new Gregwar\Captcha\CaptchaBuilder(4);
$builder->build();
$cache = $builder->getPhrase();
ZB_Cookie::set('img_captcha_code', ZB_Code::enstr($cache));
return $builder->inline();
}
function is_img_captcha($string = '') {
$cache = ZB_Cookie::get('img_captcha_code');
$cache = ZB_Code::destr($cache);
// Checking that the posted phrase match the phrase stored in the session
$is_captcha = Gregwar\Captcha\PhraseBuilder::comparePhrases($cache, $string);
ZB_Cookie::set('img_captcha_code', '');
if (empty($cache) || empty($string)) {
return false;
}
return (bool) $is_captcha;
}