forked from h5bp/server-configs-nginx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathv3.html
49 lines (46 loc) · 1.45 KB
/
v3.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<!DOCTYPE html>
<html lang="en">
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Please complete the captcha</title>
<script src="https://www.recaptcha.net/recaptcha/api.js"></script>
<style type="text/css">
div {
text-align: center;
}
</style>
<script>
function onSubmit(token) {
let reqBody = "g-recaptcha-response=" + token;
let httpRequest = new XMLHttpRequest();
httpRequest.open("POST", "/captcha");
httpRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
httpRequest.send(reqBody);
httpRequest.onreadystatechange = () => {
if (httpRequest.readyState == 4 && httpRequest.status == 200) {
let text = httpRequest.responseText;
switch (text) {
case "good":
window.location.reload();
break;
case "bad":
alert("Bad CAPTCHA. Please refresh the page and try again.");
break;
default:
alert("An unexpected error has occurred. Please refresh the page and try again.");
}
}
}
}
</script>
</head>
<body>
<h1>Please complete the captcha.</h1>
<div>
<button class="g-recaptcha" data-sitekey="6Lc4HyQjAAAAAHOhY02kZ6LV6EGfWBhuOCtRJ9Df"
data-callback='onSubmit' style="font-size:25px" data-action='submit'>Click to Proceed</button>
</div>
</body>
</html>