summaryrefslogtreecommitdiff
path: root/inc
diff options
context:
space:
mode:
authorMichael Foster <savetheinternet@tinyboard.org>2013-07-16 06:33:37 -0400
committerMichael Foster <savetheinternet@tinyboard.org>2013-07-16 06:33:37 -0400
commitc8f30550af861b95a1f475069ad8d10960a613b2 (patch)
treec0aedcd61603bdf81a54d30e1a2ce554f9363ab6 /inc
parent29b10c88db1ba16210e753e1fcf08d702455a674 (diff)
$config['require_ban_view']: Force users to view the "You are banned" page at least once before letting a ban disappear naturally.
Diffstat (limited to 'inc')
-rw-r--r--inc/config.php3
-rw-r--r--inc/functions.php18
-rw-r--r--inc/mod/ban.php2
3 files changed, 18 insertions, 5 deletions
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());