forked from leftypol/leftypol
Merge pull request 'Finish the work of the previous PR' (#107) from ip-note-queries-refactor-2 into config
Reviewed-on: leftypol/leftypol#107
This commit is contained in:
commit
77ae0b101e
2 changed files with 34 additions and 35 deletions
|
@ -4,6 +4,9 @@
|
||||||
* Copyright (c) 2010-2013 Tinyboard Development Group
|
* Copyright (c) 2010-2013 Tinyboard Development Group
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Vichan\Context;
|
||||||
|
use Vichan\Data\IpNoteQueries;
|
||||||
|
|
||||||
defined('TINYBOARD') or exit;
|
defined('TINYBOARD') or exit;
|
||||||
|
|
||||||
class Filter {
|
class Filter {
|
||||||
|
@ -136,17 +139,13 @@ class Filter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function action() {
|
public function action(Context $ctx) {
|
||||||
global $board;
|
global $board;
|
||||||
|
|
||||||
$this->add_note = isset($this->add_note) ? $this->add_note : false;
|
$this->add_note = isset($this->add_note) ? $this->add_note : false;
|
||||||
if ($this->add_note) {
|
if ($this->add_note) {
|
||||||
$query = prepare('INSERT INTO ``ip_notes`` VALUES (NULL, :ip, :mod, :time, :body)');
|
$note_queries = $ctx->get(IpNoteQueries::class);
|
||||||
$query->bindValue(':ip', $_SERVER['REMOTE_ADDR']);
|
$note_queries->add($_SERVER['REMOTE_ADDR'], -1, 'Autoban message: ' . $this->post['body']);
|
||||||
$query->bindValue(':mod', -1);
|
|
||||||
$query->bindValue(':time', time());
|
|
||||||
$query->bindValue(':body', "Autoban message: ".$this->post['body']);
|
|
||||||
$query->execute() or error(db_error($query));
|
|
||||||
}
|
}
|
||||||
if (isset ($this->action)) switch($this->action) {
|
if (isset ($this->action)) switch($this->action) {
|
||||||
case 'reject':
|
case 'reject':
|
||||||
|
@ -214,7 +213,7 @@ function purge_flood_table() {
|
||||||
query("DELETE FROM ``flood`` WHERE `time` < $time") or error(db_error());
|
query("DELETE FROM ``flood`` WHERE `time` < $time") or error(db_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
function do_filters(array $post) {
|
function do_filters(Context $ctx, array $post) {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
if (!isset($config['filters']) || empty($config['filters']))
|
if (!isset($config['filters']) || empty($config['filters']))
|
||||||
|
@ -237,7 +236,7 @@ function do_filters(array $post) {
|
||||||
$filter = new Filter($filter_array);
|
$filter = new Filter($filter_array);
|
||||||
$filter->flood_check = $flood_check;
|
$filter->flood_check = $flood_check;
|
||||||
if ($filter->check($post)) {
|
if ($filter->check($post)) {
|
||||||
$filter->action();
|
$filter->action($ctx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
4
post.php
4
post.php
|
@ -1315,7 +1315,7 @@ function handle_post(Context $ctx)
|
||||||
|
|
||||||
if (!hasPermission($config['mod']['bypass_filters'], $board['uri']) && !$dropped_post) {
|
if (!hasPermission($config['mod']['bypass_filters'], $board['uri']) && !$dropped_post) {
|
||||||
require_once 'inc/filters.php';
|
require_once 'inc/filters.php';
|
||||||
do_filters($post);
|
do_filters($ctx, $post);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($post['has_file']) {
|
if ($post['has_file']) {
|
||||||
|
@ -1631,7 +1631,7 @@ function handle_post(Context $ctx)
|
||||||
|
|
||||||
// Do filters again if OCRing
|
// Do filters again if OCRing
|
||||||
if ($config['tesseract_ocr'] && !hasPermission($config['mod']['bypass_filters'], $board['uri']) && !$dropped_post) {
|
if ($config['tesseract_ocr'] && !hasPermission($config['mod']['bypass_filters'], $board['uri']) && !$dropped_post) {
|
||||||
do_filters($post);
|
do_filters($ctx, $post);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hasPermission($config['mod']['postunoriginal'], $board['uri']) && $config['robot_enable'] && checkRobot($post['body_nomarkup']) && !$dropped_post) {
|
if (!hasPermission($config['mod']['postunoriginal'], $board['uri']) && $config['robot_enable'] && checkRobot($post['body_nomarkup']) && !$dropped_post) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue