summaryrefslogtreecommitdiff
path: root/inc/mod/ban.php
diff options
context:
space:
mode:
authorMichael Save <savetheinternet@tinyboard.org>2012-04-16 16:40:24 +1000
committerMichael Save <savetheinternet@tinyboard.org>2012-04-16 16:40:24 +1000
commitad55a634bf3f9301489f5371942c73940361a24c (patch)
tree3d6120b26158942bade96f8d96cbc4c668e21eed /inc/mod/ban.php
parentfb3e8191328c12bc1ab5bce8a3aef58582ee1a64 (diff)
various improvements
Diffstat (limited to 'inc/mod/ban.php')
-rw-r--r--inc/mod/ban.php41
1 files changed, 23 insertions, 18 deletions
diff --git a/inc/mod/ban.php b/inc/mod/ban.php
index 8d86cbcd..e7110edf 100644
--- a/inc/mod/ban.php
+++ b/inc/mod/ban.php
@@ -16,44 +16,45 @@ function parse_time($str) {
if (($time = @strtotime($str)) !== false)
return $time;
- if (!preg_match('/^((\d+)\s*ye?a?r?s?)?\s*+((\d+)\s*mon?t?h?s?)?\s*((\d+)\s*we?e?k?s?)?\s*((\d+)\s*da?y?s?)?((\d+)\s*ho?u?r?s?)?\s*((\d+)\s*mi?n?u?t?e?s?)?\s*+((\d+)\s*se?c?o?n?d?s?)?$/', $str, $matches))
+ if (!preg_match('/^((\d+)\s?ye?a?r?s?)?\s?+((\d+)\s?mon?t?h?s?)?\s?+((\d+)\s?we?e?k?s?)?\s?+((\d+)\s?da?y?s?)?((\d+)\s?ho?u?r?s?)?\s?+((\d+)\s?mi?n?u?t?e?s?)?\s?+((\d+)\s?se?c?o?n?d?s?)?$/', $str, $matches))
return false;
- $expire = time();
- if (isset($m[2])) {
+ $expire = 0;
+
+ if (isset($matches[2])) {
// Years
- $expire += $m[2]*60*60*24*365;
+ $expire += $matches[2]*60*60*24*365;
}
- if (isset($m[4])) {
+ if (isset($matches[4])) {
// Months
- $expire += $m[4]*60*60*24*30;
+ $expire += $matches[4]*60*60*24*30;
}
- if (isset($m[6])) {
+ if (isset($matches[6])) {
// Weeks
- $expire += $m[6]*60*60*24*7;
+ $expire += $matches[6]*60*60*24*7;
}
- if (isset($m[8])) {
+ if (isset($matches[8])) {
// Days
- $expire += $m[8]*60*60*24;
+ $expire += $matches[8]*60*60*24;
}
- if (isset($m[10])) {
+ if (isset($matches[10])) {
// Hours
- $expire += $m[10]*60*60;
+ $expire += $matches[10]*60*60;
}
- if (isset($m[12])) {
+ if (isset($matches[12])) {
// Minutes
- $expire += $m[12]*60;
+ $expire += $matches[12]*60;
}
- if (isset($m[14])) {
+ if (isset($matches[14])) {
// Seconds
- $expire += $m[14];
+ $expire += $matches[14];
}
- return $expire;
+ return time() + $expire;
}
function ban($mask, $reason, $length, $board) {
- global $mod;
+ global $mod, $pdo;
// TODO: permissions
@@ -78,6 +79,8 @@ function ban($mask, $reason, $length, $board) {
$query->bindValue(':board', null, PDO::PARAM_NULL);
$query->execute() or error(db_error($query));
+
+ modLog('Created a new ban (<small>#' . $pdo->lastInsertId() . '</small>) for <strong>' . utf8tohtml($mask) . '</strong> with ' . ($reason ? 'reason: <small>' . $reason . '</small>' : 'no reason'));
}
function unban($id) {
@@ -86,5 +89,7 @@ function unban($id) {
$query = prepare("DELETE FROM `bans` WHERE `id` = :id");
$query->bindValue(':id', $id);
$query->execute() or error(db_error($query));
+
+ modLog("Removed ban #{$id}");
}