From 3471f7c6684b12b63626af33ae408fd13544cae9 Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Wed, 18 Sep 2013 08:47:34 +1000 Subject: Optionally show post user was banned for --- inc/bans.php | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'inc/bans.php') 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) { -- cgit v1.3