From 64ae123739c39567447bfc16fc95deb556786671 Mon Sep 17 00:00:00 2001 From: Michael Save Date: Sat, 16 Mar 2013 18:27:24 +1100 Subject: Mod log in ?/IP (ie. ban history) --- inc/config.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'inc/config.php') diff --git a/inc/config.php b/inc/config.php index cedf3e06..8d37e601 100644 --- a/inc/config.php +++ b/inc/config.php @@ -986,6 +986,9 @@ $config['mod']['createusers'] = ADMIN; // View the moderation log $config['mod']['modlog'] = ADMIN; + // View relevant moderation log entries on IP address pages (ie. ban history, etc.) + // Warning: Can be pretty resource exhaustive if your mod logs are huge. + $config['mod']['modlog_ip'] = MOD; // Create a PM (viewing mod usernames) $config['mod']['create_pm'] = JANITOR; // Read any PM, sent to or from anybody -- cgit v1.3 From bb54605eb7ef65c5e415aba7bcc94eed928e185e Mon Sep 17 00:00:00 2001 From: Fredrick Date: Wed, 20 Mar 2013 07:46:48 -0400 Subject: Fix per-board name not being used --- inc/config.php | 4 ++-- inc/mod/pages.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'inc/config.php') diff --git a/inc/config.php b/inc/config.php index 8d37e601..8eed50fa 100644 --- a/inc/config.php +++ b/inc/config.php @@ -858,8 +858,8 @@ $config['mod']['shadow_mesage'] = 'Moved to %s.'; // Capcode to use when posting the above message. $config['mod']['shadow_capcode'] = 'Mod'; - // Name to use when posting the above message. - $config['mod']['shadow_name'] = $config['anonymous']; + // Name to use when posting the above message. If false, the default board name will be used. If something else, that will be used. + $config['mod']['shadow_name'] = false; // Wait indefinitely when rebuilding everything $config['mod']['rebuild_timelimit'] = 0; diff --git a/inc/mod/pages.php b/inc/mod/pages.php index db51324a..5d736a1a 100644 --- a/inc/mod/pages.php +++ b/inc/mod/pages.php @@ -912,7 +912,7 @@ function mod_move($originBoard, $postID) { 'mod' => true, 'subject' => '', 'email' => '', - 'name' => $config['mod']['shadow_name'], + 'name' => (!$config['mod']['shadow_name'] ? $config['anonymous'] : $config['mod']['shadow_name']), 'capcode' => $config['mod']['shadow_capcode'], 'trip' => '', 'password' => '', -- cgit v1.3 From 83401b3a68b4031b4e3c33230acf0d99df7e45fe Mon Sep 17 00:00:00 2001 From: undido Date: Tue, 16 Apr 2013 19:14:51 -0300 Subject: update config.php config for unban limit Adding config and error for unban list when a user tries to unban more users than they are allowed too. --- inc/config.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'inc/config.php') diff --git a/inc/config.php b/inc/config.php index 8eed50fa..900d540a 100644 --- a/inc/config.php +++ b/inc/config.php @@ -686,6 +686,7 @@ $config['error']['captcha'] = _('You seem to have mistyped the verification.'); // Moderator errors + $config['error']['toomanyunban'] = _('You are only allowed to unban %s users at a time. You tried to unban %u users.'); $config['error']['invalid'] = _('Invalid username and/or password.'); $config['error']['notamod'] = _('You are not a mod…'); $config['error']['invalidafter'] = _('Invalid username and/or password. Your user may have been deleted or changed.'); @@ -768,6 +769,9 @@ * Mod settings * ==================== */ + + // Limit how many bans can be removed via the ban list. (Set too -1 to remove limit.) + $config['mod']['unban_limit'] = 5; // Whether or not to lock moderator sessions to the IP address that was logged in with. $config['mod']['lock_ip'] = true; -- cgit v1.3 From 3eda5b054361f7312b40a14728b76841c01628d2 Mon Sep 17 00:00:00 2001 From: Macil Tech Date: Tue, 18 Jun 2013 12:21:41 -0500 Subject: Adds image_hard_limit and reply_hard_limit options. Also reworks the numPosts() function and uses it elsewhere too. --- inc/config.php | 7 +++++++ inc/functions.php | 19 ++++++++++--------- post.php | 20 ++++++++++++++------ 3 files changed, 31 insertions(+), 15 deletions(-) (limited to 'inc/config.php') diff --git a/inc/config.php b/inc/config.php index cedf3e06..93a2fde2 100644 --- a/inc/config.php +++ b/inc/config.php @@ -311,6 +311,11 @@ // Reply limit (stops bumping thread when this is reached) $config['reply_limit'] = 250; + // Image hard limit (stops allowing new image replies when this is reached if not zero) + $config['image_hard_limit'] = 0; + // Reply hard limit (stops allowing new replies when this is reached if not zero) + $config['reply_hard_limit'] = 0; + // Strip repeating characters when making hashes $config['robot_enable'] = false; $config['robot_strip_repeating'] = true; @@ -659,6 +664,8 @@ $config['error']['noboard'] = _('Invalid board!'); $config['error']['nonexistant'] = _('Thread specified does not exist.'); $config['error']['locked'] = _('Thread locked. You may not reply at this time.'); + $config['error']['reply_hard_limit'] = _('Thread has reached its maximum reply limit.'); + $config['error']['image_hard_limit'] = _('Thread has reached its maximum image limit.'); $config['error']['nopost'] = _('You didn\'t make a post.'); $config['error']['flood'] = _('Flood detected; Post discarded.'); $config['error']['spam'] = _('Your request looks automated; Post discarded.'); diff --git a/inc/functions.php b/inc/functions.php index 16b16901..b8dab90b 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -986,12 +986,8 @@ function index($page, $mod=false) { $replies = array_reverse($posts->fetchAll(PDO::FETCH_ASSOC)); if (count($replies) == ($th['sticky'] ? $config['threads_preview_sticky'] : $config['threads_preview'])) { - $count = prepare(sprintf("SELECT COUNT(`id`) as `num` FROM `posts_%s` WHERE `thread` = :thread UNION ALL SELECT COUNT(`id`) FROM `posts_%s` WHERE `file` IS NOT NULL AND `thread` = :thread", $board['uri'], $board['uri'])); - $count->bindValue(':thread', $th['id'], PDO::PARAM_INT); - $count->execute() or error(db_error($count)); - $count = $count->fetchAll(PDO::FETCH_COLUMN); - - $omitted = array('post_count' => $count[0], 'image_count' => $count[1]); + $count = numPosts($th['id']); + $omitted = array('post_count' => $count['replies'], 'image_count' => $count['images']); } else { $omitted = false; } @@ -1134,14 +1130,19 @@ function checkRobot($body) { return false; } +// Returns an associative array with 'replies' and 'images' keys function numPosts($id) { global $board; - $query = prepare(sprintf("SELECT COUNT(*) as `count` FROM `posts_%s` WHERE `thread` = :thread", $board['uri'])); + $query = prepare(sprintf("SELECT COUNT(*) as `num` FROM `posts_%s` WHERE `thread` = :thread UNION ALL SELECT COUNT(*) FROM `posts_%s` WHERE `file` IS NOT NULL AND `thread` = :thread", $board['uri'], $board['uri'])); $query->bindValue(':thread', $id, PDO::PARAM_INT); $query->execute() or error(db_error($query)); - $result = $query->fetch(); - return $result['count']; + $num_posts = $query->fetch(); + $num_posts = $num_posts['num']; + $num_images = $query->fetch(); + $num_images = $num_images['num']; + + return array('replies' => $num_posts, 'images' => $num_images); } function muteTime() { diff --git a/post.php b/post.php index c5e68578..f236e929 100644 --- a/post.php +++ b/post.php @@ -302,13 +302,21 @@ if (isset($_POST['delete'])) { } } - // Check if thread is locked - // but allow mods to post - if (!$post['op'] && !hasPermission($config['mod']['postinlocked'], $board['uri'])) { - if ($thread['locked']) + if (!$post['op']) { + // Check if thread is locked + // but allow mods to post + if ($thread['locked'] && !hasPermission($config['mod']['postinlocked'], $board['uri'])) error($config['error']['locked']); + + $numposts = numPosts($post['thread']); + + if ($config['reply_hard_limit'] != 0 && $config['reply_hard_limit'] <= $numposts['replies']) + error($config['error']['reply_hard_limit']); + + if ($post['has_file'] && $config['image_hard_limit'] != 0 && $config['image_hard_limit'] <= $numposts['images']) + error($config['error']['image_hard_limit']); } - + if ($post['has_file']) { $size = $_FILES['file']['size']; if ($size > $config['max_filesize']) @@ -636,7 +644,7 @@ if (isset($_POST['delete'])) { buildThread($post['op'] ? $id : $post['thread']); - if (!$post['op'] && strtolower($post['email']) != 'sage' && !$thread['sage'] && ($config['reply_limit'] == 0 || numPosts($post['thread']) < $config['reply_limit'])) { + if (!$post['op'] && strtolower($post['email']) != 'sage' && !$thread['sage'] && ($config['reply_limit'] == 0 || $numposts['replies']+1 < $config['reply_limit'])) { bumpThread($post['thread']); } -- cgit v1.3 From 7302fc57a8f83c6fe40f9c751259d9c616ebdaec Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Tue, 16 Jul 2013 02:32:44 -0400 Subject: Automatically dismiss all reports regarding a thread after it is locked. --- inc/config.php | 3 +++ inc/mod/pages.php | 7 +++++++ 2 files changed, 10 insertions(+) (limited to 'inc/config.php') diff --git a/inc/config.php b/inc/config.php index da9309e8..83b98c2b 100644 --- a/inc/config.php +++ b/inc/config.php @@ -881,6 +881,9 @@ // Edit raw HTML in posts by default $config['mod']['raw_html_default'] = false; + // Automatically dismiss all reports regarding a thread when it is locked + $config['mod']['dismiss_reports_on_lock'] = true; + // Probably best not to change these: if (!defined('JANITOR')) { define('JANITOR', 0, true); diff --git a/inc/mod/pages.php b/inc/mod/pages.php index 899f2611..3f823d3d 100644 --- a/inc/mod/pages.php +++ b/inc/mod/pages.php @@ -738,6 +738,13 @@ function mod_lock($board, $unlock, $post) { buildIndex(); } + if ($config['mod']['dismiss_reports_on_lock']) { + $query = prepare('DELETE FROM `reports` WHERE `board` = :board AND `post` = :id'); + $query->bindValue(':board', $board); + $query->bindValue(':id', $post); + $query->execute() or error(db_error($query)); + } + header('Location: ?/' . sprintf($config['board_path'], $board) . $config['file_index'], true, $config['redirect_http']); if ($unlock) -- cgit v1.3 From 29b10c88db1ba16210e753e1fcf08d702455a674 Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Tue, 16 Jul 2013 02:48:20 -0400 Subject: Outputting thread subject in header/title (issue #122) --- inc/config.php | 3 +++ inc/functions.php | 5 +++-- templates/index.html | 2 +- templates/thread.html | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) (limited to 'inc/config.php') diff --git a/inc/config.php b/inc/config.php index 83b98c2b..ed4a31f1 100644 --- a/inc/config.php +++ b/inc/config.php @@ -527,6 +527,9 @@ // Number of characters in the poster ID (maximum is 40) $config['poster_id_length'] = 5; + // Show thread subject in page title? + $config['thread_subject_in_title'] = false; + // Page footer $config['footer'][] = 'All trademarks, copyrights, comments, and images on this page are owned by and are the responsibility of their respective parties.'; diff --git a/inc/functions.php b/inc/functions.php index 67019e0a..4b0e56d8 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -1537,8 +1537,9 @@ function buildThread($id, $return=false, $mod=false) { error($config['error']['nonexistant']); $body = Element('thread.html', array( - 'board'=>$board, - 'body'=>$thread->build(), + 'board' => $board, + 'thread' => $thread, + 'body' => $thread->build(), 'config' => $config, 'id' => $id, 'mod' => $mod, diff --git a/templates/index.html b/templates/index.html index 112756d1..9b25e1be 100644 --- a/templates/index.html +++ b/templates/index.html @@ -4,7 +4,7 @@ {% if config.url_favicon %}{% endif %} - {{ board.url }} - {{ board.name }} + {{ board.url }} - {{ board.title|e }} {% if config.meta_keywords %}{% endif %} {% if config.default_stylesheet.1 != '' %}{% endif %} diff --git a/templates/thread.html b/templates/thread.html index 5442166f..aea8abb5 100644 --- a/templates/thread.html +++ b/templates/thread.html @@ -4,7 +4,7 @@ {% if config.url_favicon %}{% endif %} - {{ board.url }} - {{ board.name }} + {{ board.url }} - {% if config.thread_subject_in_title and thread.subject %}{{ thread.subject }}{% else %}{{ board.title|e }}{% endif %} {% if config.meta_keywords %}{% endif %} {% if config.default_stylesheet.1 != '' %}{% endif %} -- cgit v1.3 From c8f30550af861b95a1f475069ad8d10960a613b2 Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Tue, 16 Jul 2013 06:33:37 -0400 Subject: $config['require_ban_view']: Force users to view the "You are banned" page at least once before letting a ban disappear naturally. --- inc/config.php | 3 +++ inc/functions.php | 18 ++++++++++++++---- inc/mod/ban.php | 2 +- install.php | 4 +++- install.sql | 1 + templates/banned.html | 16 +++++++++++++--- 6 files changed, 35 insertions(+), 9 deletions(-) (limited to 'inc/config.php') diff --git a/inc/config.php b/inc/config.php index ed4a31f1..b7f6d220 100644 --- a/inc/config.php +++ b/inc/config.php @@ -366,6 +366,9 @@ // When true, a blank password will be used for files (not usable for deletion). $config['field_disable_password'] = false; + // Require users to see the ban page at least once for a ban even if it has since expired? + $config['require_ban_view'] = false; + /* * ==================== * Markup settings diff --git a/inc/functions.php b/inc/functions.php index 4b0e56d8..8d6e0a2d 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -579,6 +579,12 @@ function ago($timestamp) { function displayBan($ban) { global $config; + if (!$ban['seen']) { + $query = prepare("UPDATE `bans` SET `seen` = 1 WHERE `id` = :id"); + $query->bindValue(':id', $ban['id'], PDO::PARAM_INT); + $query->execute() or error(db_error($query)); + } + $ban['ip'] = $_SERVER['REMOTE_ADDR']; // Show banned page and exit @@ -605,12 +611,12 @@ function checkBan($board = 0) { if (event('check-ban', $board)) return true; - $query = prepare("SELECT `set`, `expires`, `reason`, `board`, `bans`.`id` FROM `bans` WHERE (`board` IS NULL OR `board` = :board) AND `ip` = :ip ORDER BY `expires` IS NULL DESC, `expires` DESC, `expires` DESC LIMIT 1"); + $query = prepare("SELECT `set`, `expires`, `reason`, `board`, `seen`, `bans`.`id` FROM `bans` WHERE (`board` IS NULL OR `board` = :board) AND `ip` = :ip ORDER BY `expires` IS NULL DESC, `expires` DESC, `expires` DESC LIMIT 1"); $query->bindValue(':ip', $_SERVER['REMOTE_ADDR']); $query->bindValue(':board', $board); $query->execute() or error(db_error($query)); if ($query->rowCount() < 1 && $config['ban_range']) { - $query = prepare("SELECT `set`, `expires`, `reason`, `board`, `bans`.`id` FROM `bans` WHERE (`board` IS NULL OR `board` = :board) AND :ip LIKE REPLACE(REPLACE(`ip`, '%', '!%'), '*', '%') ESCAPE '!' ORDER BY `expires` IS NULL DESC, `expires` DESC LIMIT 1"); + $query = prepare("SELECT `set`, `expires`, `reason`, `board`, `seen`, `bans`.`id` FROM `bans` WHERE (`board` IS NULL OR `board` = :board) AND :ip LIKE REPLACE(REPLACE(`ip`, '%', '!%'), '*', '%') ESCAPE '!' ORDER BY `expires` IS NULL DESC, `expires` DESC LIMIT 1"); $query->bindValue(':ip', $_SERVER['REMOTE_ADDR']); $query->bindValue(':board', $board); $query->execute() or error(db_error($query)); @@ -618,7 +624,7 @@ function checkBan($board = 0) { if ($query->rowCount() < 1 && $config['ban_cidr'] && !isIPv6()) { // my most insane SQL query yet - $query = prepare("SELECT `set`, `expires`, `reason`, `board`, `bans`.`id` FROM `bans` WHERE (`board` IS NULL OR `board` = :board) + $query = prepare("SELECT `set`, `expires`, `reason`, `board`, `seen`, `bans`.`id` FROM `bans` WHERE (`board` IS NULL OR `board` = :board) AND ( `ip` REGEXP '^(\[0-9]+\.\[0-9]+\.\[0-9]+\.\[0-9]+\)\/(\[0-9]+)$' AND @@ -635,10 +641,14 @@ function checkBan($board = 0) { if ($ban = $query->fetch()) { if ($ban['expires'] && $ban['expires'] < time()) { // Ban expired - $query = prepare("DELETE FROM `bans` WHERE `id` = :id LIMIT 1"); + $query = prepare("DELETE FROM `bans` WHERE `id` = :id"); $query->bindValue(':id', $ban['id'], PDO::PARAM_INT); $query->execute() or error(db_error($query)); + if ($config['require_ban_view'] && !$ban['seen']) { + displayBan($ban); + } + return; } diff --git a/inc/mod/ban.php b/inc/mod/ban.php index 30234157..cfc2636f 100644 --- a/inc/mod/ban.php +++ b/inc/mod/ban.php @@ -56,7 +56,7 @@ function parse_time($str) { function ban($mask, $reason, $length, $board) { global $mod, $pdo; - $query = prepare("INSERT INTO `bans` VALUES (NULL, :ip, :mod, :time, :expires, :reason, :board)"); + $query = prepare("INSERT INTO `bans` VALUES (NULL, :ip, :mod, :time, :expires, :reason, :board, 0)"); $query->bindValue(':ip', $mask); $query->bindValue(':mod', $mod['id']); $query->bindValue(':time', time()); diff --git a/install.php b/install.php index 1447c723..71d1c910 100644 --- a/install.php +++ b/install.php @@ -1,7 +1,7 @@ -

{% trans %}You are banned! ;_;{% endtrans %}

+ {% if ban.expires and time() >= ban.expires %} +

{% trans %}You were banned! ;_;{% endtrans %}

+ {% else %} +

{% trans %}You are banned! ;_;{% endtrans %}

+ {% endif %}

- {% trans %}You have been banned from{% endtrans %} + {% if ban.expires and time() >= ban.expires %} + {% trans %}You were banned from{% endtrans %} + {% else %} + {% trans %}You have been banned from{% endtrans %} + {% endif %} {% if ban.board %} {{ config.board_abbreviation|sprintf(ban.board) }} {% else %} @@ -23,7 +31,9 @@

{% trans %}Your ban was filed on{% endtrans %} {{ ban.set|date(config.ban_date) }} {% trans %}and{% endtrans %} - {% if ban.expires %} + {% if ban.expires and time() >= ban.expires %} + {% trans %} has since expired. Refresh the page to continue.{% endtrans %} + {% elseif ban.expires %} {% trans %}expires{% endtrans %} {{ ban.expires|until }} {% trans %}from now, which is on{% endtrans %} {{ ban.expires|date(config.ban_date) }} -- cgit v1.3