Display banned post contents if reason does not contain cp

This commit is contained in:
Michael Walker 2016-02-11 15:21:54 +00:00
parent cc62a579bc
commit 9f00630b40
2 changed files with 10 additions and 2 deletions

View File

@ -149,7 +149,7 @@ class Bans {
return $ban_list;
}
static public function stream_json($out = false, $filter_ips = false, $filter_staff = false, $board_access = false, $hide_message = false) {
static public function stream_json($out = false, $filter_ips = false, $filter_staff = false, $board_access = false, $hide_regexes = []) {
$query = query("SELECT ``bans``.*, `username` FROM ``bans``
LEFT JOIN ``mods`` ON ``mods``.`id` = `creator`
ORDER BY `created` DESC") or error(db_error());
@ -164,6 +164,14 @@ class Bans {
foreach ($bans as &$ban) {
$ban['mask'] = self::range_to_string(array($ban['ipstart'], $ban['ipend']));
$hide_message = false;
foreach ($hide_regexes as $regex) {
if(preg_match($regex, $ban['reason'])) {
$hide_message = true;
break;
}
}
if ($ban['post'] && !$hide_message) {
$post = json_decode($ban['post']);
$ban['message'] = $post->body;

View File

@ -25,7 +25,7 @@
public static function gen_json($settings) {
ob_start();
Bans::stream_json(false, true, true, array(), true);
Bans::stream_json(false, true, true, array(), array("/\bcp\b/i"));
$out = ob_get_contents();
ob_end_clean();
return $out;