public_banlist: format

This commit is contained in:
Zankaria 2025-07-23 19:56:47 +02:00
parent 938bcd2889
commit 68c0b2ae69

View file

@ -1,7 +1,7 @@
<?php <?php
require 'info.php'; require 'info.php';
function pbanlist_build($action, $settings, $board) { function pbanlist_build($action, $settings, $board) {
// Possible values for $action: // Possible values for $action:
// - all (rebuild everything, initialization) // - all (rebuild everything, initialization)
// - news (news has been updated) // - news (news has been updated)
@ -9,25 +9,27 @@
// - bans (ban list changed) // - bans (ban list changed)
PBanlist::build($action, $settings); PBanlist::build($action, $settings);
} }
// Wrap functions in a class so they don't interfere with normal Tinyboard operations // Wrap functions in a class so they don't interfere with normal Tinyboard operations
class PBanlist { class PBanlist {
public static function build($action, $settings) { public static function build($action, $settings) {
global $config; global $config;
if ($action == 'all') if ($action == 'all') {
file_write($config['dir']['home'] . $settings['file_bans'], PBanlist::homepage($settings)); file_write($config['dir']['home'] . $settings['file_bans'], PBanlist::homepage($settings));
}
if ($action == 'all' || $action == 'bans') if ($action == 'all' || $action == 'bans') {
file_write($config['dir']['home'] . $settings['file_json'], PBanlist::gen_json($settings)); file_write($config['dir']['home'] . $settings['file_json'], PBanlist::gen_json($settings));
} }
}
public static function gen_json($settings) { public static function gen_json($settings) {
ob_start(); \ob_start();
Bans::stream_json(false, true, true, array(), true); Bans::stream_json(false, true, true, [], true);
$out = ob_get_contents(); $out = \ob_get_contents();
ob_end_clean(); \ob_end_clean();
return $out; return $out;
} }
@ -35,23 +37,19 @@
public static function homepage($settings) { public static function homepage($settings) {
global $config; global $config;
return Element('page.html', array( return Element('page.html', [
'config' => $config, 'config' => $config,
'mod' => false, 'mod' => false,
#'hide_dashboard_link' => true,
'title' => _("Ban list"), 'title' => _("Ban list"),
'subtitle' => "", 'subtitle' => "",
'boardlist' => createBoardlist(), 'boardlist' => createBoardlist(),
#'nojavascript' => true, 'body' => Element('mod/ban_list.html', [
'body' => Element('mod/ban_list.html', array(
'mod' => false, 'mod' => false,
'boards' => "[]", 'boards' => "[]",
'token' => false, 'token' => false,
'token_json' => false, 'token_json' => false,
'uri_json' => $config['dir']['home'] . $settings['file_json'], 'uri_json' => $config['dir']['home'] . $settings['file_json'],
)) ])
)); ]);
} }
}; };
?>