Esempio n. 1
0
// 验证码验证
func CaptchaVerify(captchaSolution string, r *http.Request) bool {
	captchaId := r.FormValue("captchaId")
	if !captcha.VerifyString(captchaId, captchaSolution) {
		return false
	}
	return true
}
Esempio n. 2
0
// 验证码验证
func (a *Controller) VerifyCaptcha(captchaSolution string) bool {
	captchaId := a.Form("captchaId")
	if !C.VerifyString(captchaId, captchaSolution) {
		return false
	}
	return true
}
Esempio n. 3
0
func processFormHandler(w http.ResponseWriter, r *http.Request) {
	w.Header().Set("Content-Type", "text/html; charset=utf-8")
	if !captcha.VerifyString(r.FormValue("captchaId"), r.FormValue("captchaSolution")) {
		io.WriteString(w, "Wrong captcha solution! No robots allowed!\n")
	} else {
		io.WriteString(w, "Great job, human! You solved the captcha.\n")
	}
	io.WriteString(w, "<br><a href='/'>Try another one</a>")
}