Enhance status.php
This commit is contained in:
parent
2252634892
commit
1da08a57f7
29
status.php
29
status.php
|
@ -1,14 +1,13 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once 'inc/functions.php';
|
require_once 'inc/functions.php';
|
||||||
|
require_once 'templates/themes/overboards/overboards.php';
|
||||||
|
|
||||||
function endsWith( $haystack, $needle ) {
|
// List of regexes that blacklist boards
|
||||||
$length = strlen( $needle );
|
$blacklist = [
|
||||||
if( !$length ) {
|
'/^.*_archive$/', // b_archive, leftypol_archive, ...
|
||||||
return true;
|
'/^b_.*$/', // b_anime, b_leftypol, ...
|
||||||
}
|
];
|
||||||
return substr( $haystack, -$length ) === $needle;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Boards that are nsfw
|
// Boards that are nsfw
|
||||||
$nsfw_boards = ['b', 'overboard'];
|
$nsfw_boards = ['b', 'overboard'];
|
||||||
|
@ -20,23 +19,25 @@ $readonly_boards = ['overboard', 'sfw', 'alt'];
|
||||||
$board_list = listBoards();
|
$board_list = listBoards();
|
||||||
|
|
||||||
// Add objects that are not boards but are treated as such
|
// Add objects that are not boards but are treated as such
|
||||||
$board_list[] = ['uri' => 'overboard', 'title' => 'Overboard'];
|
foreach ($overboards_config as $overboard) {
|
||||||
$board_list[] = ['uri' => 'sfw', 'title' => 'SFW Overboard'];
|
$board_list[] = $overboard;
|
||||||
$board_list[] = ['uri' => 'alt', 'title' => 'Alternate Overboard'];
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allowed fields for the board object:
|
* Allowed fields for the board object:
|
||||||
* - code<string>: The board code ('b', 'tech', ...)
|
* - code<string>: The board code ('b', 'tech', ...)
|
||||||
* - name<string>: The board user-readable name ('Siberia', ...)
|
* - name<string>: The board user-readable name ('Siberia', ...)
|
||||||
* - description<string>: The board description ('Leftist Politically Incorrect', ...)
|
|
||||||
* - sfw<boolean>: Is this board sfw?
|
* - sfw<boolean>: Is this board sfw?
|
||||||
* - alternate_spoilers<boolean>: Does this board use the alunya spoiler?
|
* - alternate_spoilers<boolean>: Does this board use the alunya spoiler?
|
||||||
|
* - posting_enabled<boolean>: Can new posts be created belonging to this board?
|
||||||
*/
|
*/
|
||||||
$boards = [];
|
$boards = [];
|
||||||
foreach ($board_list as $board) {
|
foreach ($board_list as $board) {
|
||||||
// Skip archives
|
// Skip blacklisted boards
|
||||||
if (endsWith($board['uri'], '_archive')) {
|
foreach ($blacklist as $regex) {
|
||||||
continue;
|
if (preg_match($regex, $board['uri'])) {
|
||||||
|
continue 2; // Skip to the next board
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$boards[] = [
|
$boards[] = [
|
||||||
|
|
Loading…
Reference in New Issue