コード例 #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
ファイル: main.go プロジェクト: thbourlove/ecaptcha
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
ファイル: captcha.go プロジェクト: cristian-sima/Wisply
// 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.
}