Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

49 строки
2.1KB

  1. <%
  2. '=======================================================================================================================
  3. ' Cloudflare Turnstile (CAPTCHA) server-side verification
  4. '=======================================================================================================================
  5. ' Verifies a Turnstile response token against Cloudflare's siteverify endpoint. Unlike
  6. ' JurisdictionValidator's fail-open behavior (missing reference data shouldn't block orders),
  7. ' this fails CLOSED: a missing token or a failed/unreachable verification call is treated as
  8. ' "not verified" rather than being let through, since the whole point is to block automated
  9. ' submissions.
  10. '=======================================================================================================================
  11. Const TURNSTILE_VERIFY_URL = "https://challenges.cloudflare.com/turnstile/v0/siteverify"
  12. ' Verifies a Turnstile response token (the value of the widget's "cf-turnstile-response"
  13. ' field / the token returned to the data-callback). remoteIp is optional - pass "" to omit it.
  14. Function VerifyTurnstileToken(responseToken, remoteIp)
  15. VerifyTurnstileToken = False
  16. responseToken = Trim(responseToken)
  17. If Len(responseToken) = 0 Then Exit Function
  18. Dim secretKey : secretKey = GetAppSetting("TurnstileSecretKey")
  19. If Len(secretKey) = 0 Then Exit Function
  20. Dim body
  21. body = "secret=" & Server.URLEncode(secretKey) & "&response=" & Server.URLEncode(responseToken)
  22. If Len(remoteIp) > 0 Then body = body & "&remoteip=" & Server.URLEncode(remoteIp)
  23. On Error Resume Next
  24. Dim http : Set http = Server.CreateObject("Msxml2.ServerXMLHTTP")
  25. http.setTimeouts 5000, 5000, 5000, 5000
  26. http.Open "POST", TURNSTILE_VERIFY_URL, False
  27. http.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
  28. http.Send body
  29. If Err.Number = 0 And http.Status = 200 Then
  30. Dim re
  31. Set re = New RegExp
  32. re.Pattern = """success""\s*:\s*true"
  33. re.IgnoreCase = True
  34. VerifyTurnstileToken = re.Test(http.responseText)
  35. End If
  36. Err.Clear
  37. On Error GoTo 0
  38. End Function
  39. %>

Powered by TurnKey Linux.