From 34dc31c50e89b38e9489826661edb3f0fffd23ea Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Tue, 16 Jul 2013 01:14:42 -0400 Subject: Remove search section from dashboard as it is currently nonexistent in the latest version. --- templates/mod/dashboard.html | 2 ++ 1 file changed, 2 insertions(+) (limited to 'templates') diff --git a/templates/mod/dashboard.html b/templates/mod/dashboard.html index 2f0b03ad..e54b3cd3 100644 --- a/templates/mod/dashboard.html +++ b/templates/mod/dashboard.html @@ -101,6 +101,7 @@ +{#
{% trans 'Search' %} @@ -115,6 +116,7 @@
+#} {% if config.debug %}
-- 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 'templates') 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 'templates') 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 From aadb57f2a2db9210468f25d7dcd45d561ef6ad54 Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Tue, 16 Jul 2013 08:50:39 -0400 Subject: More ban stuff: Show whether or not user has "seen" a ban yet in the ban list and on IP address pages. Purge useless expired ban records. --- inc/functions.php | 10 ++++++++++ templates/mod/ban_list.html | 8 ++++++++ templates/mod/view_ip.html | 10 ++++++++++ 3 files changed, 28 insertions(+) (limited to 'templates') diff --git a/inc/functions.php b/inc/functions.php index 8d6e0a2d..40a2c1fe 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -654,6 +654,16 @@ function checkBan($board = 0) { displayBan($ban); } + + // I'm not sure where else to put this. It doesn't really matter where; it just needs to be called every now and then to keep the ban list tidy. + purge_bans(); +} + +// No reason to keep expired bans in the database (except those that haven't been viewed yet) +function purge_bans() { + $query = prepare("DELETE FROM `bans` WHERE `expires` IS NOT NULL AND `expires` < :time AND `seen` = 1"); + $query->bindValue(':time', time()); + $query->execute() or error(db_error($query)); } function threadLocked($id) { diff --git a/templates/mod/ban_list.html b/templates/mod/ban_list.html index 2edb9cdf..f8826ade 100644 --- a/templates/mod/ban_list.html +++ b/templates/mod/ban_list.html @@ -10,6 +10,7 @@ {% trans 'Set' %} {% trans 'Duration' %} {% trans 'Expires' %} + {% trans 'Seen' %} {% trans 'Staff' %} {% for ban in bans %} @@ -58,6 +59,13 @@ {% endif %} {% endif %} + + {% if ban.seen %} + {% trans 'Yes' %} + {% else %} + {% trans 'No' %} + {% endif %} + {% if ban.username %} {% if mod|hasPermission(config.mod.view_banstaff) %} diff --git a/templates/mod/view_ip.html b/templates/mod/view_ip.html index 562a0140..e2dad7af 100644 --- a/templates/mod/view_ip.html +++ b/templates/mod/view_ip.html @@ -136,6 +136,16 @@ {% endif %} + + {% trans 'Seen' %} + + {% if ban.seen %} + {% trans 'Yes' %} + {% else %} + {% trans 'No' %} + {% endif %} + + {% trans 'Staff' %} -- cgit v1.3