diff --git a/inc/config.php b/inc/config.php index b2ab7c63..46a81428 100644 --- a/inc/config.php +++ b/inc/config.php @@ -1992,6 +1992,14 @@ // Example: Adding the pre-markup post body to the API as "com_nomarkup". // $config['api']['extra_fields'] = array('body_nomarkup' => 'com_nomarkup'); + // Variables for status.php, used for mobile app API + // Unlisted boards to list. + $config['api']['status']['whitelist'] = []; + // Boards marked as NSFW + $config['api']['status']['nsfw_boards'] = []; + // Boards where posts are not allowed to be created + $config['api']['status']['locked_boards'] = []; + /* * ================== * NNTPChan settings diff --git a/status.php b/status.php new file mode 100644 index 00000000..4deb7c3b --- /dev/null +++ b/status.php @@ -0,0 +1,60 @@ + $overboard) { + $board_list[] = array( + 'uri' => $uri, + 'title' => $config['overboards'][$overboard]['title'] + ); +} + +/** + * Allowed fields for the board object: + * - code: The board code ('b', 'tech', ...) + * - name: The board user-readable name ('Siberia', ...) + * - sfw: Is this board sfw? + * - posting_enabled: 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, +]); \ No newline at end of file