public_banlist: format

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

View file

@ -1,57 +1,55 @@
<?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)
// - boards (board list changed) // - boards (board list changed)
// - 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
class PBanlist {
public static function build($action, $settings) {
global $config;
if ($action == 'all') {
file_write($config['dir']['home'] . $settings['file_bans'], PBanlist::homepage($settings));
}
if ($action == 'all' || $action == 'bans') {
file_write($config['dir']['home'] . $settings['file_json'], PBanlist::gen_json($settings));
}
} }
// Wrap functions in a class so they don't interfere with normal Tinyboard operations public static function gen_json($settings) {
class PBanlist { \ob_start();
public static function build($action, $settings) { Bans::stream_json(false, true, true, [], true);
global $config; $out = \ob_get_contents();
\ob_end_clean();
if ($action == 'all') return $out;
file_write($config['dir']['home'] . $settings['file_bans'], PBanlist::homepage($settings)); }
if ($action == 'all' || $action == 'bans')
file_write($config['dir']['home'] . $settings['file_json'], PBanlist::gen_json($settings));
}
public static function gen_json($settings) { // Build homepage
ob_start(); public static function homepage($settings) {
Bans::stream_json(false, true, true, array(), true); global $config;
$out = ob_get_contents();
ob_end_clean();
return $out;
}
// Build homepage
public static function homepage($settings) {
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'],
)) ])
)); ]);
} }
}; };
?>