From 647340091f83b2430a7d918d435d731a46a44626 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=99=E8=BF=B0=E3=80=81=E5=88=AB=E7=A6=BB?= <93301500+xushubieli@users.noreply.github.com> Date: Tue, 11 Feb 2025 10:47:48 +0800 Subject: [PATCH] Update search.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 限制搜索只能中文防止被刷 --- src/apps/search.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/apps/search.php b/src/apps/search.php index 731f17c1..b43071b5 100755 --- a/src/apps/search.php +++ b/src/apps/search.php @@ -54,14 +54,18 @@ if (empty($typeid)) { } } $typeid = intval($typeid); -$keyword = addslashes(cn_substr($keyword,30)); +$keyword = addslashes(cn_substr($keyword, 30)); $typeid = intval($typeid); if ($cfg_notallowstr != '' && preg_match("#".$cfg_notallowstr."#i", $keyword)) { ShowMsg("搜索关键词中存在非法文档,被系统禁止", "-1"); exit(); } if (($keyword != '' && strlen($keyword) < 2) && empty($typeid)) { - ShowMsg('关键词不能小于2个字节', '-1'); + ShowMsg('您输入文字太少了,请重新填写', '-1'); + exit(); +} +if (!preg_match('/^[\x{4e00}-\x{9fa5}]+$/u', $keyword)) { + showMsg('您输入信息不符合,请重新填写', '-1'); exit(); } //检查搜索间隔时间