Source code of Leftypol imageboard
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.5 KiB

1 year ago
<?php
4 months ago
require_once 'inc/bootstrap.php';
12 months ago
require_once 'templates/themes/overboards/overboards.php';
1 year ago
// Boards that are nsfw
$nsfw_boards = ['b', 'overboard'];
// Boards where posts are not allowed to be created
$readonly_boards = [];
// Allowed boards
12 months ago
$whitelist = ['dead'];
foreach ($config['boards'] as $boards) {
foreach ($boards as $board) {
$whitelist[] = $board;
}
}
foreach ($overboards_config as $board) {
$whitelist[] = $board['uri'];
$readonly_boards[] = $board['uri'];
}
12 months ago
$board_list = listBoards();
// Add objects that are not boards but are treated as such
12 months ago
foreach ($overboards_config as $overboard) {
$board_list[] = $overboard;
}
12 months ago
/**
* Allowed fields for the board object:
* - code<string>: The board code ('b', 'tech', ...)
* - name<string>: The board user-readable name ('Siberia', ...)
* - sfw<boolean>: Is this board sfw?
12 months ago
* - posting_enabled<boolean>: Can new posts be created belonging to this board?
12 months ago
*/
$boards = [];
foreach ($board_list as $board) {
// Skip non-whitelisted boards
if (!in_array($board['uri'], $whitelist)) {
12 months ago
continue;
}
$boards[] = [
'code' => $board['uri'],
'name' => $board['title'],
'sfw' => !in_array($board['uri'], $nsfw_boards),
'posting_enabled' => !in_array($board['uri'], $readonly_boards),
];
}
1 year ago
header('Content-Type: application/json');
echo json_encode([
'captcha' => $config['securimage'],
12 months ago
'flags' => $config['user_flags'],
'boards' => $boards,
1 year ago
]);