发送短信 ip限制
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user