This commit is contained in:
haoouba 2021-05-16 22:10:36 +08:00
parent e2c5b31754
commit cd27486b67
6 changed files with 16 additions and 16 deletions

View File

@ -328,17 +328,12 @@ document.addEventListener('DOMContentLoaded', () => {
const parent = $('.joe_comment__respond-form').attr('data-coid');
const author = $(".joe_comment__respond-form .head input[name='author']").val();
const mail = $(".joe_comment__respond-form .head input[name='mail']").val();
/* -- 验证码 -- */
const num1 = $(".joe_comment__respond-form .head input[name='num1']").val();
const num2 = $(".joe_comment__respond-form .head input[name='num2']").val();
const sum = $(".joe_comment__respond-form .head input[name='sum']").val();
/* -- 验证码 -- */
let text = $(".joe_comment__respond-form .body textarea[name='text']").val();
if (author.trim() === '') return Qmsg.info('请输入昵称!');
if (!/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/.test(mail)) return Qmsg.info('请输入正确的邮箱!');
/* -- 验证码前端校验 -- */
const sum = $(".joe_comment__respond-form .head input[name='sum']").val();
if (sum.trim() === '') return Qmsg.info('请输入计算结果!');
if (Number(num1) + Number(num2) !== Number(sum)) return Qmsg.info('计算结果有误,请检查!');
/* -- 验证码前端校验 -- */
if (type === 'text' && text.trim() === '') return Qmsg.info('请输入评论内容!');
if (type === 'draw') {
@ -351,7 +346,7 @@ document.addEventListener('DOMContentLoaded', () => {
$.ajax({
url,
type: 'POST',
data: { author, mail, text, parent, num1, num2, sum },
data: { author, mail, text, parent, sum },
dataType: 'text',
success(res) {
let arr = [],
@ -367,6 +362,11 @@ document.addEventListener('DOMContentLoaded', () => {
} else {
window.location.reload();
}
},
error() {
isSubmit = false
$('.joe_comment__respond-form .foot .submit button').html('发表评论');
Qmsg.warning('发送失败!请刷新重试!')
}
});
});

File diff suppressed because one or more lines are too long

View File

@ -10,10 +10,10 @@ class Intercept
public static function message($comment)
{
/* 校验验证码是否正确 */
$num1 = (int)Typecho_Request::getInstance()->num1;
$num2 = (int)Typecho_Request::getInstance()->num2;
$sum = (int)Typecho_Request::getInstance()->sum;
if ($num1 + $num2 !== $sum) throw new Typecho_Widget_Exception('计算结果有误,请检查!', 403);
if (!$sum) throw new Typecho_Widget_Exception('请输入计算结果!', 403);
session_start();
if ($sum !== $_SESSION['commentCode']) throw new Typecho_Widget_Exception('计算结果有误,请检查!', 403);
/* 用户输入内容画图模式 */
if (preg_match('/\{!\{(.*)\}!\}/', $comment['text'], $matches)) {

View File

@ -2,7 +2,7 @@
/* 获取主题当前版本号 */
function _getVersion()
{
return "6.9.4";
return "6.9.5";
};
/* 判断是否是手机 */

View File

@ -1,6 +1,6 @@
{
"name": "typecho-joe-next",
"version": "6.9.4",
"version": "6.9.5",
"description": "A Theme Of Typecho",
"main": "index.php",
"keywords": [

View File

@ -27,11 +27,11 @@
</div>
<div class="list">
<?php
session_start();
$num1 = rand(1, 10);
$num2 = rand(1, 10);
$_SESSION['commentCode'] = $num1 + $num2;
?>
<input type="hidden" name="num1" value="<?php echo $num1 ?>">
<input type="hidden" name="num2" value="<?php echo $num2 ?>">
<input type="text" autocomplete="off" name="sum" placeholder="计算:<?php echo $num1 ?> + <?php echo $num2 ?> = ?" />
</div>
</div>
@ -63,7 +63,7 @@
<div class="owo joe_owo__contain"></div>
<div class="submit">
<span class="cancle joe_comment__cancle">取消</span>
<button type="submit">评论</button>
<button type="submit">评论</button>
</div>
</div>
</form>