public function captcha_verify($code = NULL, $id = 0) { header("Content-Type: Application/json; charset=utf-8"); $this->__lib('Captcha'); $c = new Captcha(); echo json_encode(["status" => $c->verify($code, false, $id)]); }
/** * 验证码检测 * @param $captcha * @return bool */ private function Captcha($captcha) { if (empty($captcha)) { return false; } if (hook()->apply('UserRegister_Captcha', false, $captcha)) { return true; } lib()->load('Captcha'); $c = new Captcha(); return $c->verify($captcha, true); }
/** * @param $email * @param $captcha */ public function reset_password($email, $captcha) { lib()->load('Captcha', 'MailTemplate', 'User'); $c = new Captcha(); if (!$c->verify($captcha, true)) { $this->throwMsg(-3); } $user = new User(['user_email' => trim($email)]); if (!in_array($user->getStatus(), [0, 1, 2])) { $this->throwMsg(-4); } $mt = new MailTemplate("reset_password.html"); $mt->setUserInfo($user->getInfo()); $mt->setValues(["reset_password_url" => $this->create_reset_password_url($user)]); $mt->mailSend($user->getName(), $user->getEmail()); }
/** * 登录验证码检测 * @param $code * @return bool */ private function Captcha($code) { lib()->load('Captcha'); $c = new Captcha(); return hook()->apply("UserLogin_Captcha", $c->verify($code, true), $code); }