summaryrefslogtreecommitdiff
path: root/inc/mod/ban.php
diff options
context:
space:
mode:
Diffstat (limited to 'inc/mod/ban.php')
-rw-r--r--inc/mod/ban.php17
1 files changed, 13 insertions, 4 deletions
diff --git a/inc/mod/ban.php b/inc/mod/ban.php
index 9c93d70e..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());
@@ -80,16 +80,25 @@ function ban($mask, $reason, $length, $board) {
modLog('Created a new ' .
($length > 0 ? preg_replace('/^(\d+) (\w+?)s?$/', '$1-$2', until($length)) : 'permanent') .
- ' ban (<small>#' . $pdo->lastInsertId() . '</small>) for ' .
+ ' ban on ' .
+ ($board ? '/' . $board . '/' : 'all boards') .
+ ' for ' .
(filter_var($mask, FILTER_VALIDATE_IP) !== false ? "<a href=\"?/IP/$mask\">$mask</a>" : utf8tohtml($mask)) .
+ ' (<small>#' . $pdo->lastInsertId() . '</small>)' .
' with ' . ($reason ? 'reason: ' . utf8tohtml($reason) . '' : 'no reason'));
}
-function unban($id) {
+function unban($id) {
+ $query = prepare("SELECT `ip` FROM `bans` WHERE `id` = :id");
+ $query->bindValue(':id', $id);
+ $query->execute() or error(db_error($query));
+ $mask = $query->fetchColumn();
+
$query = prepare("DELETE FROM `bans` WHERE `id` = :id");
$query->bindValue(':id', $id);
$query->execute() or error(db_error($query));
- modLog("Removed ban #{$id}");
+ if ($mask)
+ modLog("Removed ban #{$id} for " . (filter_var($mask, FILTER_VALIDATE_IP) !== false ? "<a href=\"?/IP/$mask\">$mask</a>" : utf8tohtml($mask)));
}