From 5fca7b9e06da64df635a74eb6a688bc62230ea2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=8D=8E=E6=B8=85?= <18691022700@163.com> Date: Tue, 23 Dec 2025 01:59:20 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=91=E9=80=81=E7=9F=AD=E4=BF=A1=20ip?= =?UTF-8?q?=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/api/controller/Sms.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/application/api/controller/Sms.php b/application/api/controller/Sms.php index b67cfad2..ce00582e 100644 --- a/application/api/controller/Sms.php +++ b/application/api/controller/Sms.php @@ -43,11 +43,12 @@ class Sms extends Api //频率控制 $last = db::name('sms')->where(['mobile' => $mobile, 'event' => $event])->order('id', 'DESC')->find(); if ($last && time() - $last['createtime'] < 60) { - return V(0, '发送频繁'); + return V(0, '发送频繁!'); } - $ipSendTotal = db::name('sms')->where(['ip' => $this->request->ip()])->whereTime('createtime', '-1 hours')->count(); + $ip = request()->server('HTTP_X_REAL_IP') ?: request()->server('HTTP_X_FORWARDED_FOR') ?: request()->ip(); + $ipSendTotal = db::name('sms')->where(['ip' => $ip])->whereTime('createtime', '-1 hours')->count(); if ($ipSendTotal >= 7) { - return V(0, '发送频繁'); + return V(0, '发送频繁!!'); } //发送短信 $ret = $this->send_smsbao_msg($mobile, $event);