From 3a48cbc7905859a4994856ccdcaf73b3575455d9 Mon Sep 17 00:00:00 2001 From: czaks Date: Thu, 9 Oct 2014 03:10:47 +0200 Subject: [PATCH] 8chan: allow users to opt out of public ban system --- inc/bans.php | 17 +++++++++++++++-- inc/instance-config.php | 5 ++++- templates/mod/settings.html | 3 ++- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/inc/bans.php b/inc/bans.php index 87e62774..99cd9442 100644 --- a/inc/bans.php +++ b/inc/bans.php @@ -155,14 +155,27 @@ class Bans { } static public function stream_json($out = false, $filter_ips = false, $filter_staff = false, $board_access = false) { - global $config; + global $config, $pdo; + + + if ($board_access && $board_access[0] == '*') $board_access = false; + + $query_addition = ""; + if ($board_access !== FALSE) { + $query_addition .= "WHERE `public_bans` OR `public_bans` IS NULL"; + } + if ($board_access) { + $boards = implode(", ", array_map(array($pdo, "quote"), $board_access)); + $query_addition .= " OR `board` IN (".$boards.")"; + } $query = query("SELECT ``bans``.*, `username`, `type` FROM ``bans`` LEFT JOIN ``mods`` ON ``mods``.`id` = `creator` + LEFT JOIN ``boards`` ON ``boards``.`uri` = ``bans``.`board` + $query_addition ORDER BY `created` DESC") or error(db_error()); $bans = $query->fetchAll(PDO::FETCH_ASSOC); - if ($board_access && $board_access[0] == '*') $board_access = false; $out ? fputs($out, "[") : print("["); diff --git a/inc/instance-config.php b/inc/instance-config.php index c928b0d9..cebf00c8 100644 --- a/inc/instance-config.php +++ b/inc/instance-config.php @@ -311,11 +311,12 @@ OEKAKI; if (!(strlen($subtitle) < 200)) error('Invalid subtitle'); - $query = prepare('UPDATE ``boards`` SET `title` = :title, `subtitle` = :subtitle, `indexed` = :indexed WHERE `uri` = :uri'); + $query = prepare('UPDATE ``boards`` SET `title` = :title, `subtitle` = :subtitle, `indexed` = :indexed, `public_bans` = :public_bans WHERE `uri` = :uri'); $query->bindValue(':title', $title); $query->bindValue(':subtitle', $subtitle); $query->bindValue(':uri', $b); $query->bindValue(':indexed', !isset($_POST['meta_noindex'])); + $query->bindValue(':public_bans', isset($_POST['public_bans'])); $query->execute() or error(db_error($query)); @@ -367,6 +368,8 @@ EOT; openBoard($b); + rebuildThemes('bans'); + if ($config['cache']['enabled']) cache::delete('board_' . $board['uri']); cache::delete('all_boards'); diff --git a/templates/mod/settings.html b/templates/mod/settings.html index 38a5b168..caa12b1a 100644 --- a/templates/mod/settings.html +++ b/templates/mod/settings.html @@ -32,7 +32,8 @@ Poster ID's Display SAGE! after saged posts Automatically convert ... to … - No index
Hide from boards index
and do not index in search engines
+ No index
Hide from boards index
and do not index in search engines
+ Public bans
Displays your bans for the public [code] tags Oekaki Format math between $$