MCPcopy Create free account
hub / github.com/GoEdgeLab/EdgeNode / showSlideForm

Method showSlideForm

internal/waf/captcha_validator.go:556–714  ·  view source on GitHub ↗
(actionConfig *CaptchaAction, req requests.Request, writer http.ResponseWriter)

Source from the content-addressed store, hash-verified

554}
555
556func (this *CaptchaValidator) showSlideForm(actionConfig *CaptchaAction, req requests.Request, writer http.ResponseWriter) {
557 var lang = actionConfig.Lang
558 if len(lang) == 0 {
559 var acceptLanguage = req.WAFRaw().Header.Get("Accept-Language")
560 if len(acceptLanguage) > 0 {
561 langIndex := strings.Index(acceptLanguage, ",")
562 if langIndex > 0 {
563 lang = acceptLanguage[:langIndex]
564 }
565 }
566 }
567 if len(lang) == 0 {
568 lang = "en-US"
569 }
570
571 var msgTitle string
572 var msgPrompt string
573 var msgRequestId string
574
575 switch lang {
576 case "zh-CN":
577 msgTitle = "身份验证"
578 msgPrompt = "滑动上面方块到右侧解锁"
579 msgRequestId = "请求ID"
580 case "zh-TW":
581 msgTitle = "身份驗證"
582 msgPrompt = "滑動上面方塊到右側解鎖"
583 msgRequestId = "請求ID"
584 default:
585 msgTitle = "Verify Yourself"
586 msgPrompt = "Slide to Unlock"
587 msgRequestId = "Request ID"
588 }
589
590 var msgCss = ""
591 var requestIdBox = `<address>` + msgRequestId + `: ` + req.Format("${requestId}") + `</address>`
592 var msgFooter = ""
593
594 // 默认设置
595 if actionConfig.OneClickUIIsOn {
596 if len(actionConfig.OneClickUIPrompt) > 0 {
597 msgPrompt = actionConfig.OneClickUIPrompt
598 }
599 if len(actionConfig.OneClickUITitle) > 0 {
600 msgTitle = actionConfig.OneClickUITitle
601 }
602 if len(actionConfig.OneClickUICss) > 0 {
603 msgCss = actionConfig.OneClickUICss
604 }
605 if !actionConfig.OneClickUIShowRequestId {
606 requestIdBox = ""
607 }
608 if len(actionConfig.OneClickUIFooter) > 0 {
609 msgFooter = actionConfig.OneClickUIFooter
610 }
611 }
612
613 var captchaId = stringutil.Md5(req.WAFRemoteIP() + "@" + stringutil.Rand(32))

Callers 1

showMethod · 0.95

Calls 12

NowFunction · 0.92
UnixMethod · 0.80
WAFRawMethod · 0.65
FormatMethod · 0.65
WAFRemoteIPMethod · 0.65
WriteMethod · 0.65
WriteHeaderMethod · 0.65
GetMethod · 0.45
StringMethod · 0.45
HeaderMethod · 0.45
SetMethod · 0.45

Tested by

no test coverage detected