浏览代码

新增IP发送频繁检测

Karson 1 年之前
父节点
当前提交
940e9a0814
共有 1 个文件被更改,包括 6 次插入0 次删除
  1. 6 0
      application/api/controller/Ems.php

+ 6 - 0
application/api/controller/Ems.php

@@ -37,6 +37,12 @@ class Ems extends Api
         if ($last && time() - $last['createtime'] < 60) {
             $this->error(__('发送频繁'));
         }
+
+        $ipSendTotal = \app\common\model\Ems::where(['ip' => $this->request->ip()])->whereTime('createtime', '-1 hours')->count();
+        if ($ipSendTotal >= 5) {
+            $this->error(__('发送频繁'));
+        }
+
         if ($event) {
             $userinfo = User::getByEmail($email);
             if ($event == 'register' && $userinfo) {