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);