This commit is contained in:
杜恒 2021-05-08 12:54:26 +08:00
parent 270301f770
commit 873e96f793
6 changed files with 26 additions and 5 deletions

View File

@ -359,9 +359,18 @@ document.addEventListener('DOMContentLoaded', () => {
const parent = $('.joe_comment__respond-form').attr('data-coid'); const parent = $('.joe_comment__respond-form').attr('data-coid');
const author = $(".joe_comment__respond-form .head input[name='author']").val(); const author = $(".joe_comment__respond-form .head input[name='author']").val();
const mail = $(".joe_comment__respond-form .head input[name='mail']").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(); let text = $(".joe_comment__respond-form .body textarea[name='text']").val();
if (author.trim() === '') return Qmsg.info('请输入昵称!'); if (author.trim() === '') return Qmsg.info('请输入昵称!');
if (!/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/.test(mail)) return Qmsg.info('请输入正确的邮箱!'); if (!/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/.test(mail)) return Qmsg.info('请输入正确的邮箱!');
/* -- 验证码前端校验 -- */
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 === 'text' && text.trim() === '') return Qmsg.info('请输入评论内容!');
if (type === 'draw') { if (type === 'draw') {
const txt = $('#joe_comment_draw')[0].toDataURL('image/webp', 0.1); const txt = $('#joe_comment_draw')[0].toDataURL('image/webp', 0.1);
@ -373,7 +382,7 @@ document.addEventListener('DOMContentLoaded', () => {
$.ajax({ $.ajax({
url, url,
type: 'POST', type: 'POST',
data: { author, mail, text, parent }, data: { author, mail, text, parent, num1, num2, sum },
dataType: 'text', dataType: 'text',
success(res) { success(res) {
let arr = [], let arr = [],

File diff suppressed because one or more lines are too long

View File

@ -6,6 +6,12 @@ class Intercept
{ {
public static function message($comment) 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 (preg_match('/\{!\{(.*)\}!\}/', $comment['text'], $matches)) { if (preg_match('/\{!\{(.*)\}!\}/', $comment['text'], $matches)) {
/* 如果判断是否有双引号,如果有双引号,则禁止评论 */ /* 如果判断是否有双引号,如果有双引号,则禁止评论 */

View File

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

View File

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

View File

@ -26,7 +26,13 @@
<input type="text" value="<?php $this->user->hasLogin() ? $this->user->mail() : $this->remember('mail') ?>" autocomplete="off" name="mail" placeholder="请输入邮箱..." /> <input type="text" value="<?php $this->user->hasLogin() ? $this->user->mail() : $this->remember('mail') ?>" autocomplete="off" name="mail" placeholder="请输入邮箱..." />
</div> </div>
<div class="list"> <div class="list">
<input type="text" value="<?php $this->remember('url'); ?>" autocomplete="off" name="url" placeholder="(选填)请输入网址..." /> <?php
$num1 = rand(1, 10);
$num2 = rand(1, 10);
?>
<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>
</div> </div>
<div class="body"> <div class="body">