示例#1
0
文件: pageFunc.go 项目: JGets/reduse
/*
	Reloads the CAPTCHA with the given ID, and returns a .png image representation to be solved
	Parameters:
		ctx:	The context of the http request
		id:		The ID of the captcha to reload and serve
*/
func reloadCaptchaImage(ctx *web.Context, id string) {
	exists := captcha.Reload(id)
	if !exists {
		logger.Println("Error, trying to reload non-existent CAPTCHA")
	}

	serveCaptchaImage(ctx, id)
}
示例#2
0
func reloadCaptcha(writer http.ResponseWriter, request *http.Request) {
	captchaId := request.URL.Query().Get("captchaId")
	result := captcha.Reload(captchaId)
	if result {
		io.WriteString(writer, "success")
	} else {
		io.WriteString(writer, "fail")
	}
}
示例#3
0
// Serve is an adaptation for beegoo for the captcha package
// The code is from the server.go from captcha file
// Credits 	"github.com/dchest/captcha"
func (controller *Captcha) Serve() {
	r := controller.Ctx.Request
	w := controller.Ctx.ResponseWriter

	dir, file := path.Split(r.URL.Path)
	ext := path.Ext(file)
	id := file[:len(file)-len(ext)]
	if ext == "" || id == "" {
		http.NotFound(w, r)
		return
	}
	if r.FormValue("reload") != "" {
		captcha.Reload(id)
	}
	lang := strings.ToLower(r.FormValue("lang"))
	download := path.Base(dir) == "download"
	if controller.serve(w, r, id, ext, lang, download) == captcha.ErrNotFound {
		http.NotFound(w, r)
	}
	// Ignore other errors.
}