Files
server_torii/config_example/error_page/CAPTCHA.html
Roi Feng eaec9574b2 Revert "feat: CAPTCHA session ID"
This reverts commit 12c7473e
2025-02-25 13:07:47 -05:00

102 lines
3.0 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CAPTCHA - ⛩Server Torii</title>
<style>
body {
font-family: Arial, sans-serif;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
background-color: #f9f9f9;
}
.container {
text-align: left;
max-width: 600px;
}
.icon svg {
width: 60px;
height: 60px;
stroke: #333;
}
.message {
font-size: 24px;
font-weight: bold;
color: #333;
}
.description {
margin-top: 10px;
color: #666;
}
.toriiVerifyBox {
margin-top: 10px;
color: #666;
}
.footer {
margin-top: 30px;
font-size: 12px;
color: #999;
}
.footer a {
color: red;
text-decoration: none;
}
</style>
<script src="https://js.hcaptcha.com/1/api.js" async defer></script>
<script>
function onSubmit(token) {
let reqBody = "h-captcha-response=" + token;
let httpRequest = new XMLHttpRequest();
httpRequest.open("POST", "/torii/captcha", true);
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.\n"
+ "您未能通过人机验证,请刷新页面后重试。");
window.location.reload();
break;
default:
alert("Unexpected error occurred, please refresh the page and try again.\n"
+ "发生了意料之外的错误,请刷新页面后重试。");
window.location.reload();
}
}
}
}
function checkCaptchaRender() {
const captchaDiv = document.querySelector(".h-captcha");
if (captchaDiv && captchaDiv.children.length > 0) {
} else {
document.getElementById("toriiVerifyBox").innerHTML = "Loading CAPTCHA failed, please check your internet connection and try again.<br>"
+ "加载人机验证失败,请检查尝试更换网络环境后重试。";
}
}
setTimeout(checkCaptchaRender, 5000);
</script>
</head>
<body>
<div class="container">
<div class="message">Checking that you are not a robot</div>
<div class="message">请完成人机验证</div>
<div class="toriiVerifyBox" id="toriiVerifyBox"><div class="h-captcha" data-sitekey="" data-callback="onSubmit"></div></div>
<div class="footer">
DDoS Protection Powered by <a href="https://github.com/Rayzggz/server_torii">Server Torii</a>
</div>
</div>
</body>
</html>