60 lines
1.7 KiB
PHP
60 lines
1.7 KiB
PHP
|
<?php
|
||
|
|
||
|
require_once 'inc/bootstrap.php';
|
||
|
|
||
|
// Boards that are nsfw
|
||
|
$nsfw_boards = $config['api']['status']['nsfw_boards'];
|
||
|
// Boards where posts are not allowed to be created
|
||
|
$readonly_boards = $config['api']['status']['locked_boards'];
|
||
|
|
||
|
// Allowed boards
|
||
|
$whitelist = $config['api']['status']['whitelist'];
|
||
|
foreach ($config['boards'] as $boards) {
|
||
|
foreach ($boards as $board) {
|
||
|
$whitelist[] = $board;
|
||
|
}
|
||
|
}
|
||
|
foreach (array_keys($config['overboards']) as $board_uri) {
|
||
|
$whitelist[] = $board_uri;
|
||
|
$readonly_boards[] = $board_uri;
|
||
|
}
|
||
|
|
||
|
$board_list = listBoards();
|
||
|
|
||
|
// Add objects that are not boards but are treated as such
|
||
|
foreach (array_keys($config['overboards']) as $uri => $overboard) {
|
||
|
$board_list[] = array(
|
||
|
'uri' => $uri,
|
||
|
'title' => $config['overboards'][$overboard]['title']
|
||
|
);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 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?
|
||
|
* - posting_enabled<boolean>: Can new posts be created belonging to this board?
|
||
|
*/
|
||
|
$boards = [];
|
||
|
foreach ($board_list as $board) {
|
||
|
// Skip non-whitelisted boards
|
||
|
if (!in_array($board['uri'], $whitelist)) {
|
||
|
continue;
|
||
|
}
|
||
|
|
||
|
$boards[] = [
|
||
|
'code' => $board['uri'],
|
||
|
'name' => $board['title'],
|
||
|
'sfw' => !in_array($board['uri'], $nsfw_boards),
|
||
|
'posting_enabled' => !in_array($board['uri'], $readonly_boards),
|
||
|
];
|
||
|
}
|
||
|
|
||
|
header('Content-Type: application/json');
|
||
|
echo json_encode([
|
||
|
'captcha' => $config['captcha']['enabled'],
|
||
|
'recaptcha' => $config['recaptcha'],
|
||
|
'flags' => $config['user_flags'],
|
||
|
'boards' => $boards,
|
||
|
]);
|