修复极验的问题

This commit is contained in:
2025-11-28 10:59:58 +08:00
parent 7989c17cde
commit 7f57a4e816
9 changed files with 448 additions and 103 deletions
+28 -83
View File
@@ -116,17 +116,6 @@ $_SESSION['csrf_token'] = $csrf_token;
<script src="<?php echo $cdnpublic?>twitter-bootstrap/3.4.1/js/bootstrap.min.js"></script>
<script src="<?php echo $cdnpublic?>jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
<script src="<?php echo $cdnpublic?>layer/3.1.1/layer.min.js"></script>
<script src="//static.geetest.com/static/tools/gt.js"></script>
<script>
window.appendChildOrg = Element.prototype.appendChild;
Element.prototype.appendChild = function() {
if(arguments[0].tagName == 'SCRIPT'){
arguments[0].setAttribute('referrerpolicy', 'no-referrer');
}
return window.appendChildOrg.apply(this, arguments);
};
</script>
<script src="//static.geetest.com/v4/gt4.js"></script>
<script>
function invokeSettime(obj){
var countdown=60;
@@ -149,54 +138,6 @@ function invokeSettime(obj){
,1000)
}
}
var handlerEmbed = function (captchaObj) {
var sendto;
captchaObj.onReady(function () {
$("#wait").hide();
}).onSuccess(function () {
var result = captchaObj.getValidate();
if (!result) {
return alert('请完成验证');
}
var ii = layer.load(2, {shade:[0.1,'#fff']});
$.ajax({
type : "POST",
url : "ajax.php?act=sendcode",
data : {sendto:sendto, ...result},
dataType : 'json',
success : function(data) {
layer.close(ii);
if(data.code == 0){
new invokeSettime("#sendcode");
layer.msg('发送成功,请注意查收!');
}else{
layer.alert(data.msg);
captchaObj.reset();
}
}
});
}).onError(function(){
layer.msg('验证码加载失败,请刷新页面重试', {icon: 5});
});
$('#sendcode').click(function () {
if ($(this).attr("data-lock") === "true") return;
if($("input[name='verifytype']").val()=='1'){
sendto=$("input[name='phone']").val();
if(sendto==''){layer.alert('手机号码不能为空!');return false;}
if(sendto.length!=11){layer.alert('手机号码不正确!');return false;}
}else{
sendto=$("input[name='email']").val();
if(sendto==''){layer.alert('邮箱不能为空!');return false;}
var reg = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/;
if(!reg.test(sendto)){layer.alert('邮箱格式不正确!');return false;}
}
if(typeof captchaObj.showCaptcha === 'function'){
captchaObj.showCaptcha();
}else{
captchaObj.verify();
}
});
};
$(document).ready(function(){
$("#submit").click(function(){
if ($(this).attr("data-lock") === "true") return;
@@ -246,31 +187,35 @@ $(document).ready(function(){
}
});
});
$.ajax({
url: "ajax.php?act=captcha",
type: "get",
cache: false,
dataType: "json",
success: function (data) {
if(data.version == 1){
initGeetest4({
captchaId: data.gt,
product: 'bind',
protocol: 'https://',
riskType: 'slide',
hideSuccess: true,
}, handlerEmbed);
}else{
initGeetest({
width: '100%',
gt: data.gt,
challenge: data.challenge,
new_captcha: data.new_captcha,
product: "bind",
offline: !data.success
}, handlerEmbed);
}
$('#sendcode').click(function () {
if ($(this).attr("data-lock") === "true") return;
var sendto;
if($("input[name='verifytype']").val()=='1'){
sendto=$("input[name='phone']").val();
if(sendto==''){layer.alert('手机号码不能为空!');return false;}
if(sendto.length!=11){layer.alert('手机号码不正确!');return false;}
}else{
sendto=$("input[name='email']").val();
if(sendto==''){layer.alert('邮箱不能为空!');return false;}
var reg = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/;
if(!reg.test(sendto)){layer.alert('邮箱格式不正确!');return false;}
}
var ii = layer.load(2, {shade:[0.1,'#fff']});
$.ajax({
type : "POST",
url : "ajax.php?act=sendcode",
data : {sendto:sendto},
dataType : 'json',
success : function(data) {
layer.close(ii);
if(data.code == 0){
new invokeSettime("#sendcode");
layer.msg('发送成功,请注意查收!');
}else{
layer.alert(data.msg);
}
}
});
});
<?php if(!empty($conf['zhuce'])){?>
$('#myModal').modal('show');