DiscuzQ防护批量发帖和批量注册方法
$cip = Thread::where('user_id', $this->actor->id)->where('deleted_at', NULL)->orderBy('created_at', 'desc')->first();;
$cc = Post::where('thread_id', $cip->id)->where('is_first', 1)->first();;
$now = time();
$last = strtotime($cip->created_at);
$d = $now - $last;
if ($d < 30){
throw new Exception('发帖间隔时间太短');
}
$similar_text = $this->lcs->getSimilar($cc->content, $this->data["attributes"]["content"]);
if ($similar_text >= 0.8){
throw new Exception('发帖重复');
}
1.限制批量发帖
文件:
app\Commands\Threa\CreateThread.php
103行的d$this->events = $events;下方增加
2.限制批量会员注册
文件:
\app\Commands\Users\RegisterUser.php
$register_ip = Arr::get($this->data, 'register_ip');
$cip = User::where('register_ip', $register_ip )->whereDate('created_at', date("Y-m-d"))->count();
if ($cip > 1){
throw new DecryptException(trans('user.register_decrypt_code_failed'));
}
在93行下方添加以上代码。
原文地址:http://www.5che2.com/