summaryrefslogtreecommitdiff
path: root/inc/mod/ban.php
diff options
context:
space:
mode:
authorMichael Save <savetheinternet@tinyboard.org>2012-04-13 09:47:27 +1000
committerMichael Save <savetheinternet@tinyboard.org>2012-04-13 09:47:27 +1000
commit2843ddc4826f250a8af6203cff437929ab807a41 (patch)
treea63d0ce133c97356a809237606e5a13dab349c82 /inc/mod/ban.php
parent78f3ea783394dba14b51b27f7f2db3974ce8b8b3 (diff)
view bans / unban
Diffstat (limited to 'inc/mod/ban.php')
-rw-r--r--inc/mod/ban.php19
1 files changed, 14 insertions, 5 deletions
diff --git a/inc/mod/ban.php b/inc/mod/ban.php
index 236b2b14..33b64975 100644
--- a/inc/mod/ban.php
+++ b/inc/mod/ban.php
@@ -10,7 +10,7 @@ if (realpath($_SERVER['SCRIPT_FILENAME']) == str_replace('\\', '/', __FILE__)) {
}
function parse_time($str) {
- if(empty($str))
+ if (empty($str))
return false;
if (($time = @strtotime($str)) !== false)
@@ -55,16 +55,18 @@ function parse_time($str) {
function ban($mask, $reason, $length, $board) {
global $mod;
- $query = prepare("INSERT INTO `bans` VALUES (NULL, :ip, :mod, UNIX_TIMESTAMP(), :expires, :reason, :board)");
+ $query = prepare("INSERT INTO `bans` VALUES (NULL, :ip, :mod, :time, :expires, :reason, :board)");
$query->bindValue(':ip', $mask);
$query->bindValue(':mod', $mod['id']);
- if ($reason !== '')
+ $query->bindValue(':time', time());
+ if ($reason !== '') {
+ markup($reason);
$query->bindValue(':reason', $reason);
- else
+ } else
$query->bindValue(':reason', null, PDO::PARAM_NULL);
if ($length > 0)
- $query->bindValue(':expires', time() + $length);
+ $query->bindValue(':expires', $length);
else
$query->bindValue(':expires', null, PDO::PARAM_NULL);
@@ -75,3 +77,10 @@ function ban($mask, $reason, $length, $board) {
$query->execute() or error(db_error($query));
}
+
+function unban($id) {
+ $query = prepare("DELETE FROM `bans` WHERE `id` = :id");
+ $query->bindValue(':id', $id);
+ $query->execute() or error(db_error($query));
+}
+