[fix] Update captcha api
parent
4f5382bb7c
commit
33c1476ecf
159
config.lua
159
config.lua
|
@ -32,10 +32,11 @@ config_waf_output = "html"
|
|||
config_waf_redirect_url = "/captcha"
|
||||
config_waf_captcha_html=[[
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<title data-sw-translate>Please enter verification code - OneinStack WAF</title>
|
||||
<style> body { font-family: Tahoma, Verdana, Arial, sans-serif; }
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<title data-sw-translate>Please enter verification code - OneinStack WAF</title>
|
||||
<style>
|
||||
body { font-family: Tahoma, Verdana, Arial, sans-serif; }
|
||||
.head_title{margin-top:100px; font-family:"微软雅黑"; font-size:50px; font-weight:lighter;}
|
||||
p{font-family:"微软雅黑"; font-size:16px; font-weight:lighter; color:#666666;}
|
||||
.btn{ float:left;margin-left:15px; margin-top:5px; width:85px; height:30px; background:#56c458;font-family:"微软雅黑"; font-size:16px; color:#FFFFFF; border:0;}
|
||||
|
@ -44,80 +45,96 @@ config_waf_captcha_html=[[
|
|||
.fors{ margin:0 auto;width:500px; height:40px;}
|
||||
.form {width: 500px; margin: 2em auto;}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div align="center">
|
||||
<p><h1 class="head_title" data-sw-translate>Sorry...</h1></p>
|
||||
<p data-sw-translate>Your query looks similar to an automated request from computer software. In order to protect our users, please forgive us for temporarily not processing your request.</p>
|
||||
<p data-sw-translate>To continue accessing the webpage, please enter the characters shown below:</p>
|
||||
<div class="form">
|
||||
<img id="captcha-img" class="yz" src="https://oneinstack.com/restapi/v1/captchas/038fb48d9f8170e9a7c67aee79106a31" alt="Captcha image"><input id="captcha-input" class="inp_s" type="text" name="response" /><input id="captcha-submit" class="btn" type="submit" data-sw-translate value="Submit" />
|
||||
</div>
|
||||
</div>
|
||||
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
|
||||
<script>
|
||||
var url = 'https://oneinstack.com/restapi/v1/captchas'
|
||||
// 获取验证码 hash
|
||||
$.post(url).then((res) => {
|
||||
const {errno, errmsg, data} = JSON.parse(res)
|
||||
if (errno) {
|
||||
return alert(errmsg)
|
||||
}
|
||||
</head>
|
||||
<body>
|
||||
<div align="center">
|
||||
<p>
|
||||
<h1 class="head_title" data-sw-translate>Sorry...</h1>
|
||||
</p>
|
||||
<p data-sw-translate>Your query looks similar to an automated request from computer software. In order to protect
|
||||
our users, please forgive us for temporarily not processing your request.</p>
|
||||
<p data-sw-translate>To continue accessing the webpage, please enter the characters shown below:</p>
|
||||
<div class="form">
|
||||
<img id="captcha-img" class="yz" src="https://oneinstack.com/api/v1/captcha/BrqDr57p3mjj0xAuEQEW.png" alt="Captcha image">
|
||||
<input id="captcha-input" class="inp_s" type="text" name="response" />
|
||||
<input id="captcha-id" class="inp_s" type="hidden" name="response" />
|
||||
<input id="captcha-submit" class="btn" type="submit"
|
||||
data-sw-translate value="Submit" />
|
||||
</div>
|
||||
</div>
|
||||
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
|
||||
<script>
|
||||
let captcha_id = ''
|
||||
var url = 'https://oneinstack.com/api/v1/captcha'
|
||||
var urlimg = 'https://oneinstack.com/api/v1/'
|
||||
// 获取验证码 hash
|
||||
getImg()
|
||||
function getImg() {
|
||||
$.get(url).then((res) => {
|
||||
$('#captcha-img').attr('src', urlimg + '/' + res.data.image_url)
|
||||
$('#captcha-id').val(res.data.captcha_id)
|
||||
})
|
||||
}
|
||||
$('#captcha-img').on('click',function(e) {
|
||||
getImg()
|
||||
})
|
||||
$('#captcha-submit').on('click', function(e) {
|
||||
var data = {
|
||||
captcha_id: $('#captcha-id').val(),
|
||||
captcha_code: document.querySelector('#captcha-input').value,
|
||||
}
|
||||
|
||||
// 更新验证码图片
|
||||
document.querySelector('#captcha-img').src = `${url}/${data}`
|
||||
|
||||
// 提交验证码
|
||||
document.querySelector('#captcha-submit').addEventListener('click', e => {
|
||||
$.post(`${url}/check`, {
|
||||
key: data,
|
||||
code: document.querySelector('#captcha-input').value,
|
||||
}).then(res => {
|
||||
const {errno, errmsg, data} = JSON.parse(res)
|
||||
if (errno) {
|
||||
return location.reload()
|
||||
}
|
||||
|
||||
var targetUrl = new URLSearchParams(location.search).get('continue')
|
||||
targetUrl = atob(targetUrl)
|
||||
location.href = targetUrl
|
||||
})
|
||||
$.ajax({
|
||||
url: `${url}/verify`,
|
||||
type: 'post',
|
||||
dataType: 'json',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify(data),
|
||||
cache: false,
|
||||
success: function(res){
|
||||
var targetUrl = new URLSearchParams(location.search).get('continue')
|
||||
//targetUrl = atob(targetUrl)
|
||||
//location.href = targetUrl
|
||||
},
|
||||
error: function(e) {
|
||||
location.reload()
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
window.SwaggerTranslator = {
|
||||
_words: [],
|
||||
translate: function () {
|
||||
var $this = this;
|
||||
$('[data-sw-translate]').each(function () {
|
||||
$(this).html($this._tryTranslate($(this).html()));
|
||||
$(this).val($this._tryTranslate($(this).val()));
|
||||
$(this).attr('title', $this._tryTranslate($(this).attr('title')));
|
||||
});
|
||||
},
|
||||
})
|
||||
window.SwaggerTranslator = {
|
||||
_words: [],
|
||||
translate: function() {
|
||||
var $this = this;
|
||||
$('[data-sw-translate]').each(function() {
|
||||
$(this).html($this._tryTranslate($(this).html()));
|
||||
$(this).val($this._tryTranslate($(this).val()));
|
||||
$(this).attr('title', $this._tryTranslate($(this).attr('title')));
|
||||
});
|
||||
},
|
||||
|
||||
_tryTranslate: function (word) {
|
||||
return this._words[$.trim(word)] !== undefined ? this._words[$.trim(word)] : word;
|
||||
},
|
||||
_tryTranslate: function(word) {
|
||||
return this._words[$.trim(word)] !== undefined ? this._words[$.trim(word)] : word;
|
||||
},
|
||||
|
||||
learn: function (wordsMap) {
|
||||
this._words = wordsMap;
|
||||
}
|
||||
};
|
||||
learn: function(wordsMap) {
|
||||
this._words = wordsMap;
|
||||
}
|
||||
};
|
||||
|
||||
window.SwaggerTranslator.learn({
|
||||
"Please enter verification code - OneinStack WAF": "输入验证码 - OneinStack防火墙",
|
||||
"Your query looks similar to an automated request from computer software. In order to protect our users, please forgive us for temporarily not processing your request.": "您的查询看起来类似于来自计算机软件的自动请求。为了保护我们的用户,请原谅我们现在暂时不能处理您的请求。",
|
||||
"To continue accessing the webpage, please enter the characters shown below:": "要继续访问网页,请输入下面所示字符:",
|
||||
"Sorry...": "很抱歉...",
|
||||
"Submit": "提交",
|
||||
});
|
||||
window.SwaggerTranslator.learn({
|
||||
"Please enter verification code - OneinStack WAF": "输入验证码 - OneinStack防火墙",
|
||||
"Your query looks similar to an automated request from computer software. In order to protect our users, please forgive us for temporarily not processing your request.": "您的查询看起来类似于来自计算机软件的自动请求。为了保护我们的用户,请原谅我们现在暂时不能处理您的请求。",
|
||||
"To continue accessing the webpage, please enter the characters shown below:": "要继续访问网页,请输入下面所示字符:",
|
||||
"Sorry...": "很抱歉...",
|
||||
"Submit": "提交",
|
||||
});
|
||||
|
||||
$(function () {
|
||||
window.SwaggerTranslator.translate();
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
$(function() {
|
||||
window.SwaggerTranslator.translate();
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
]]
|
||||
config_output_html=[[
|
||||
|
|
Loading…
Reference in New Issue