summaryrefslogtreecommitdiff
path: root/inc/bans.php
diff options
context:
space:
mode:
authorMichael Foster <savetheinternet@tinyboard.org>2013-09-18 08:47:34 +1000
committerMichael Foster <savetheinternet@tinyboard.org>2013-09-18 08:47:34 +1000
commit3471f7c6684b12b63626af33ae408fd13544cae9 (patch)
tree4536ea053a5c01548d6de1c43c1e5a7699f65050 /inc/bans.php
parent803f0c8ce1487ea791824197de9d1ee140127838 (diff)
Optionally show post user was banned for
Diffstat (limited to 'inc/bans.php')
-rw-r--r--inc/bans.php20
1 files changed, 14 insertions, 6 deletions
diff --git a/inc/bans.php b/inc/bans.php
index 652d42cc..853332a0 100644
--- a/inc/bans.php
+++ b/inc/bans.php
@@ -33,7 +33,7 @@ class Bans {
return array(inet_pton($range[0]), inet_pton($range[1]));
}
- private static function parse_time($str) {
+ public static function parse_time($str) {
if (empty($str))
return false;
@@ -141,6 +141,8 @@ class Bans {
$query->bindValue(':id', $ban['id'], PDO::PARAM_INT);
$query->execute() or error(db_error($query));
} else {
+ if ($ban['post'])
+ $ban['post'] = json_decode($ban['post'], true);
$ban['mask'] = self::range_to_string(array($ban['ipstart'], $ban['ipend']));
$ban_list[] = $ban;
}
@@ -197,8 +199,8 @@ class Bans {
return true;
}
- static public function new_ban($mask, $reason, $length = false, $board = false, $mod_id = false) {
- global $mod, $pdo;
+ static public function new_ban($mask, $reason, $length = false, $ban_board = false, $mod_id = false, $post = false) {
+ global $mod, $pdo, $board;
if ($mod_id === false) {
$mod_id = isset($mod['id']) ? $mod['id'] : -1;
@@ -207,7 +209,7 @@ class Bans {
$range = self::parse_range($mask);
$mask = self::range_to_string($range);
- $query = prepare("INSERT INTO ``bans`` VALUES (NULL, :ipstart, :ipend, :time, :expires, :board, :mod, :reason, 0, NULL)");
+ $query = prepare("INSERT INTO ``bans`` VALUES (NULL, :ipstart, :ipend, :time, :expires, :board, :mod, :reason, 0, :post)");
$query->bindValue(':ipstart', $range[0]);
if ($range[1] !== false && $range[1] != $range[0])
@@ -236,11 +238,17 @@ class Bans {
$query->bindValue(':expires', null, PDO::PARAM_NULL);
}
- if ($board)
- $query->bindValue(':board', $board);
+ if ($ban_board)
+ $query->bindValue(':board', $ban_board);
else
$query->bindValue(':board', null, PDO::PARAM_NULL);
+ if ($post) {
+ $post['board'] = $board['uri'];
+ $query->bindValue(':post', json_encode($post));
+ } else
+ $query->bindValue(':post', null, PDO::PARAM_NULL);
+
$query->execute() or error(db_error($query));
if (isset($mod['id']) && $mod['id'] == $mod_id) {