From d5e42bf5bfe3d9475ab82dbf30bdbe371a55bf1a Mon Sep 17 00:00:00 2001 From: Savetheinternet Date: Sun, 27 Mar 2011 02:55:11 +1100 Subject: [PATCH] Ban list changes --- mod.php | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/mod.php b/mod.php index fd69691a..ab643d16 100644 --- a/mod.php +++ b/mod.php @@ -649,8 +649,21 @@ } elseif(preg_match('/^\/bans$/', $query)) { if($mod['type'] < $config['mod']['view_banlist']) error($config['error']['noaccess']); + if(isset($_POST['unban'])) { + if($mod['type'] < $config['mod']['unban']) error($config['error']['noaccess']); + + foreach($_POST as $post => $value) { + if(preg_match('/^ban_(.+)$/', $post, $m)) { + $m[1] = str_replace('_', '.', $m[1]); + $query = prepare("DELETE FROM `bans` WHERE `ip` = :ip"); + $query->bindValue(':ip', $m[1]); + $query->execute() or error(db_error($query)); + } + } + } + if($mod['type'] >= $config['mod']['view_banexpired']) { - $query = prepare("SELECT * FROM `bans` INNER JOIN `mods` ON `mod` = `id` GROUP BY `ip` ORDER BY `expires` < :time, `set` DESC"); + $query = prepare("SELECT * FROM `bans` INNER JOIN `mods` ON `mod` = `id` GROUP BY `ip` ORDER BY (`expires` IS NOT NULL AND `expires` < :time), `set` DESC"); $query->bindValue(':time', time(), PDO::PARAM_INT); $query->execute() or error(db_error($query)); } else { @@ -664,7 +677,7 @@ $body = '(There are no active bans.)'; } else { $body = '
'; - $body .= ''; + $body .= '
IP addressReasonSetExpiresStaffActions
'; while($ban = $query->fetch()) { $body .= @@ -685,7 +698,7 @@ '">'. $ban['ip'] . '' . // Reason - '' . + '' . // Set '' . @@ -715,12 +728,16 @@ ) . '' . - '' . - ''; } - $body .= '
IP addressReasonSetExpiresStaff
' . $ban['reason'] . '' . ($ban['reason'] ? $ban['reason'] : 'none given') . '' . date($config['post_date'], $ban['set']) . '
'; + $body .= '' . + + ($mod['type'] >= $config['mod']['unban'] ? + '

' + : '') . + + ''; } echo Element('page.html', Array(