|
@@ -23,7 +23,7 @@ var TextCharacters = []rune("ACDEFGHJKLMNPQRSTUVWXY2456789")
|
|
|
|
|
|
// 初始化字体文件
|
|
// 初始化字体文件
|
|
func InitCaptcha() {
|
|
func InitCaptcha() {
|
|
- err := SetFontPath("./fonts/")
|
|
|
|
|
|
+ err := SetFontPath("app.yhyue.com/moapp/jybase/gocaptcha/fonts/")
|
|
if err != nil {
|
|
if err != nil {
|
|
log.Println(err)
|
|
log.Println(err)
|
|
}
|
|
}
|
|
@@ -51,7 +51,7 @@ func RandLightColor(n int) color.RGBA {
|
|
return color.RGBA{R: uint8(red), G: uint8(green), B: uint8(blue), A: a}
|
|
return color.RGBA{R: uint8(red), G: uint8(green), B: uint8(blue), A: a}
|
|
}
|
|
}
|
|
|
|
|
|
-func Get(sess *httpsession.Session, checkCode string, w http.ResponseWriter, r *http.Request) (err error) {
|
|
|
|
|
|
+func Get(sess *httpsession.Session, checkCode string, w http.ResponseWriter, r *http.Request) {
|
|
code := RandText(4)
|
|
code := RandText(4)
|
|
log.Println(code)
|
|
log.Println(code)
|
|
cacheKey := fmt.Sprintf("captcha_times_%s", sess.Id())
|
|
cacheKey := fmt.Sprintf("captcha_times_%s", sess.Id())
|
|
@@ -93,17 +93,16 @@ func Get(sess *httpsession.Session, checkCode string, w http.ResponseWriter, r *
|
|
DrawText(NewTwistTextDrawer(66, 18, 0.04), code).
|
|
DrawText(NewTwistTextDrawer(66, 18, 0.04), code).
|
|
DrawBlur(NewGaussianBlur(), 2, 0.44)
|
|
DrawBlur(NewGaussianBlur(), 2, 0.44)
|
|
}
|
|
}
|
|
|
|
+ if captchaImage.Error != nil {
|
|
|
|
+ log.Println(captchaImage.Error)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
if times == 0 {
|
|
if times == 0 {
|
|
ttl = 24 * 60 * 60
|
|
ttl = 24 * 60 * 60
|
|
}
|
|
}
|
|
//计次
|
|
//计次
|
|
times++
|
|
times++
|
|
redis.Put("other", cacheKey, times, int(ttl))
|
|
redis.Put("other", cacheKey, times, int(ttl))
|
|
- if captchaImage.Error != nil {
|
|
|
|
- log.Println(captchaImage.Error)
|
|
|
|
- err = captchaImage.Error
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
sess.Set(checkCode, code)
|
|
sess.Set(checkCode, code)
|
|
- return captchaImage.Encode(w, ImageFormatJpeg)
|
|
|
|
|
|
+ _ = captchaImage.Encode(w, ImageFormatJpeg)
|
|
}
|
|
}
|