qiuwen-rnrs/js.php

151 行
4.5 KiB
PHP

<?php
function regJS()
{
return <<<EOF
<script>
"use strict";
var countdownLength = 60;
var state = { countdown: countdownLength, counter: null };
var buttonAcquire = $("#button_acquirecode");
$("#button_acquirecode").on("click", function () {
var idd = $("#input_idd").val();
var pn = $("#input_phonenumber").val();
if (idd === "" || pn === "") {
alert("手机号不能为空!");
} else {
buttonAcquire.attr("disabled", "true");
$.post(
"./api.php",
{ act: "UserLoginCode", idd: idd, pn: pn },
function (data) {
if (data === "1") {
alert("发送成功!");
} else if (data === "2") {
alert("手机号格式错误!");
} else if (data === "4") {
alert("获取过于频繁,请稍后再试!");
} else if (data === "10") {
alert("我们无法为您提供服务,请联系运营者!");
} else {
alert("网络波动,请稍后再试!");
}
state.counter = setInterval(function () {
buttonAcquire.val(state.countdown-- + "秒后重新发送");
if (state.countdown === 0) {
clearInterval(state.counter);
buttonAcquire.removeAttr("disabled");
var text = "获取验证码";
buttonAcquire.val(text);
state.countdown = countdownLength;
}
}, 1000);
}
);
}
});
</script>
EOF;
}
function updateJS()
{
return <<<EOF
<script>
"use strict";
var countdownLength = 60;
var state = { countdown: countdownLength, counter: null };
var buttonAcquire = $("#button_acquirecode");
$("#button_acquirecode").on("click", function () {
var idd = $("#input_idd").val();
var pn = $("#input_phonenumber").val();
if (idd === "" || pn === "") {
alert("手机号不能为空!");
} else {
buttonAcquire.attr("disabled", "true");
$.post(
"./api.php",
{ act: "UserLoginCode", idd: idd, pn: pn, update: "1" },
function (data) {
if (data === "1") {
alert("发送成功!");
} else if (data === "2") {
alert("手机号格式错误!");
} else if (data === "5") {
alert("参数错误或缺失,请联系技术维护团队!");
} else if (data === "4") {
alert("获取过于频繁,请稍后再试!");
} else if (data === "10") {
alert("我们无法为您提供服务,请联系运营者!");
} else {
alert("网络波动,请稍后再试!");
}
state.counter = setInterval(function () {
buttonAcquire.val(state.countdown-- + "秒后重新发送");
if (state.countdown === 0) {
clearInterval(state.counter);
buttonAcquire.removeAttr("disabled");
var text = "获取验证码";
buttonAcquire.val(text);
state.countdown = countdownLength;
}
}, 1000);
}
);
}
});
</script>
EOF;
}
function verifyJS()
{
return <<<EOF
<script>
"use strict";
var countdownLength = 60;
var state = { countdown: countdownLength, counter: null };
var buttonAcquire = $("#button_acquirecode");
$("#button_acquirecode").on("click", function () {
buttonAcquire.attr("disabled", "true");
var uid = $("input[name=userid]").val();
$.post(
"./api.php",
{ act: "UserVerifyCode", uid: uid },
function (data) {
if (data === "1") {
alert("发送成功!");
} else if (data === "4") {
alert("获取过于频繁,请稍后再试!");
} else if (data === "5") {
alert("参数错误或缺失,请联系技术维护团队!");
} else if (data === "10") {
alert("我们无法为您提供服务,请联系运营者!");
} else {
alert("网络波动,请稍后再试!");
}
state.counter = setInterval(function () {
buttonAcquire.val(state.countdown-- + "秒后重新发送");
if (state.countdown === 0) {
clearInterval(state.counter);
buttonAcquire.removeAttr("disabled");
var text = "获取验证码";
buttonAcquire.val(text);
state.countdown = countdownLength;
}
}, 1000);
}
);
});
</script>
EOF;
}
function matomoJS()
{
$qwUserName = $_SESSION['qwUserName'] ?? '';
echo <<<EOF
<script>(function(b,d,a){var e='&action_name='+b.title;d='&url='+a(d.href);var f=a(b.referrer)?'&urlref='+a(b.referrer):'',c=new URLSearchParams(b.search);u='&uid='+a('$qwUserName');c=new XMLHttpRequest;c.open('post','/api/audit?idsite=7&rec=1&send_image=1'+d+e+f+u+'&rand=1');c.send()})(document,location,encodeURIComponent);</script>
<noscript><img src='/api/audit?idsite=7&rec=1&uid=$qwUserName' width='1' height='1' alt='' /></noscript>
EOF;
}