示例#1
0
文件: tplfunc.go 项目: webx-top/webx
// 验证码验证
func CaptchaVerify(captchaSolution string, r *http.Request) bool {
	captchaId := r.FormValue("captchaId")
	if !captcha.VerifyString(captchaId, captchaSolution) {
		return false
	}
	return true
}
示例#2
0
// 验证码验证
func (a *Controller) VerifyCaptcha(captchaSolution string) bool {
	captchaId := a.Form("captchaId")
	if !C.VerifyString(captchaId, captchaSolution) {
		return false
	}
	return true
}
示例#3
0
文件: main.go 项目: webx-top/webx
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>")
}