From 29e71fa3eead4508e243b229ba898117c8b11ff1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20=C5=81abanowski?= Date: Mon, 28 Jul 2014 04:05:47 +0200 Subject: [PATCH] filters: add option to log a message body in ip notes --- inc/filters.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/inc/filters.php b/inc/filters.php index f694d2b1..fd442fd9 100644 --- a/inc/filters.php +++ b/inc/filters.php @@ -9,6 +9,7 @@ defined('TINYBOARD') or exit; class Filter { public $flood_check; private $condition; + private $post; public function __construct(array $arr) { foreach ($arr as $key => $value) @@ -17,6 +18,8 @@ class Filter { public function match(array $post, $condition, $match) { $condition = strtolower($condition); + + $this->post = $post; switch($condition) { case 'custom': @@ -125,8 +128,18 @@ class Filter { $this->expires = isset($this->expires) ? $this->expires : false; $this->reject = isset($this->reject) ? $this->reject : true; $this->all_boards = isset($this->all_boards) ? $this->all_boards : false; + $this->add_note = isset($this->add_note) ? $this->add_note : false; Bans::new_ban($_SERVER['REMOTE_ADDR'], $this->reason, $this->expires, $this->all_boards ? false : $board['uri'], -1); + + if ($this->add_note) { + $query = prepare('INSERT INTO ``ip_notes`` VALUES (NULL, :ip, :mod, :time, :body)'); + $query->bindValue(':ip', $_SERVER['REMOTE_ADDR']); + $query->bindValue(':mod', -1); + $query->bindValue(':time', time()); + $query->bindValue(':body', "Autoban message: ".$this->post['body']); + $query->execute() or error(db_error($query)); + } if ($this->reject) { if (isset($this->message))