From d46c40652cf0710c75d7cc1d929ed9f2aa106411 Mon Sep 17 00:00:00 2001 From: Savetheinternet Date: Sun, 2 Jan 2011 01:43:25 +1100 Subject: [PATCH] Bans expire --- inc/functions.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/inc/functions.php b/inc/functions.php index 70520334..30effd17 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -77,6 +77,14 @@ $query->execute() or error(db_error($query)); if($ban = $query->fetch()) { + if($ban['expires'] && $ban['expires'] < time()) { + // Ban expired + $query = prepare("DELETE FROM `bans` WHERE `ip` = :ip AND `expires` = :expires LIMIT 1"); + $query->bindValue(':ip', $_SERVER['REMOTE_ADDR']); + $query->bindValue(':expires', $ban['expires'], PDO::PARAM_INT); + $query->execute() or error(db_error($query)); + return; + } $body = '

You are banned! ;_;

You have been banned ' . @@ -94,7 +102,7 @@ 'expires on ' . formatDate($ban['expires']) . ', which is ' . until($ban['expires']) . ' from now' - : 'does not expire' ) . + : 'will not expire' ) . '.

Your IP address is ' . $_SERVER['REMOTE_ADDR'] . '.

';