ワイルドカードでBOTをBAN出来るように

このコミットが含まれているのは:
テクニカル諏訪子 2021-07-15 07:10:34 +09:00
コミット 03c75dbf3b
1個のファイルの変更10行の追加0行の削除

ファイルの表示

@ -9,6 +9,16 @@ class Comment {
public function add (Request $r) {
if (!isset($r->submit)) return '';
if ($r->isvideo == 'f') $id = DB::table('blg_content')->select('id')->where('slug', $r->slug)->first()->id;
$banned = DB::table('blg_blacklist')->get();
foreach ($banned as $b) {
$ip = explode('.', getIp());
$ban = explode('.', $b->ipaddress);
if (
($ban[0] == $ip[0] && $ban[1] == $ip[1] && $ban[2] == $ip[2] && $ban[3] == $ip[3]) ||
($ban[0] == $ip[0] && $ban[1] == $ip[1] && $ban[2] == $ip[2] && $ban[3] == '*') ||
($ban[0] == $ip[0] && $ban[1] == $ip[1] && $ban[2] == '*' && $ban[3] == '*')
) return redirect('/bot-trap/');
}
$shadow = DB::table('blg_blacklist')->where('ipaddress', getIp())->first();
if ($shadow && !$shadow->isShadow) return array('status' => '0101FF', 'message' => '失礼しますが、あなたはBANされていましたので、コメントを保存できません。');