From 89e6c023dbcbb5b4e59f5d16d651a66c3ef51057 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=8D=8E=E6=B8=85?= <18691022700@163.com> Date: Mon, 11 Aug 2025 18:58:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B8=85=E6=95=B0=E6=8D=AE=20ip=E9=99=90?= =?UTF-8?q?=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/api/controller/Ceshi.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/application/api/controller/Ceshi.php b/application/api/controller/Ceshi.php index a4d49a5..e53d774 100644 --- a/application/api/controller/Ceshi.php +++ b/application/api/controller/Ceshi.php @@ -8,8 +8,10 @@ use think\Log; class Ceshi extends Controller { - //测试 发送各种消息 - + //设置白名单ip访问本类接口 + protected $allowIp = [ + '113.201.181.82' + ]; //发送群组系统消息 public function send_group_system_notification() @@ -150,6 +152,13 @@ class Ceshi extends Controller //清空数据 禁用 慎用 !!!!!! public function clear_data() { + //ip + $ip = request()->ip(); + //白名单 + $white_list = $this -> allowIp; + if (!in_array($ip, $white_list)) { + return V(301, '非法访问!'); + } $i = 0; $res = []; //开启事务