diff options
| author | Appleman1234 <applemansigloo@gmail.com> | 2022-09-25 13:30:13 +1000 |
|---|---|---|
| committer | Appleman1234 <applemansigloo@gmail.com> | 2022-09-25 13:30:13 +1000 |
| commit | 2c69095a1edf7474073451285238659d0f62ce3f (patch) | |
| tree | 5dee476605402c66dc2853d0836b29f6aedae62b /templates | |
| parent | e9a61e2fbbd930eaa80d6a5f33420cedc59d748c (diff) | |
PHP8.1 fixes from Rector
Diffstat (limited to 'templates')
51 files changed, 346 insertions, 1302 deletions
diff --git a/templates/themes/basic/info.php b/templates/themes/basic/info.php index 0b8ba98b..982010ef 100644 --- a/templates/themes/basic/info.php +++ b/templates/themes/basic/info.php @@ -1,44 +1,22 @@ <?php - $theme = Array(); + $theme = []; // Theme name - $theme['name'] = 'Basic'; + $theme['name'] = \Basic::class; // Description (you can use Tinyboard markup here) $theme['description'] = 'Extremely basic news listing for the homepage. Enabling boardlinks is recommended for this theme.'; $theme['version'] = 'v0.9.1'; // Theme configuration - $theme['config'] = Array(); + $theme['config'] = []; - $theme['config'][] = Array( - 'title' => 'Site title', - 'name' => 'title', - 'type' => 'text' - ); + $theme['config'][] = ['title' => 'Site title', 'name' => 'title', 'type' => 'text']; - $theme['config'][] = Array( - 'title' => 'Slogan', - 'name' => 'subtitle', - 'type' => 'text', - 'comment' => '(optional)' - ); + $theme['config'][] = ['title' => 'Slogan', 'name' => 'subtitle', 'type' => 'text', 'comment' => '(optional)']; - $theme['config'][] = Array( - 'title' => 'File', - 'name' => 'file', - 'type' => 'text', - 'default' => $config['file_index'], - 'comment' => '(eg. "index.html")' - ); + $theme['config'][] = ['title' => 'File', 'name' => 'file', 'type' => 'text', 'default' => $config['file_index'], 'comment' => '(eg. "index.html")']; - $theme['config'][] = Array( - 'title' => '# of recent entries', - 'name' => 'no_recent', - 'type' => 'text', - 'default' => 0, - 'size' => 3, - 'comment' => '(number of recent news entries to display; "0" is infinite)' - ); + $theme['config'][] = ['title' => '# of recent entries', 'name' => 'no_recent', 'type' => 'text', 'default' => 0, 'size' => 3, 'comment' => '(number of recent news entries to display; "0" is infinite)']; // Unique function name for building everything $theme['build_function'] = 'basic_build'; @@ -47,7 +25,7 @@ if (!function_exists('build_install')) { function build_install($settings) { if (!is_numeric($settings['no_recent']) || $settings['no_recent'] < 0) - return Array(false, '<strong>' . utf8tohtml($settings['no_recent']) . '</strong> is not a non-negative integer.'); + return [false, '<strong>' . utf8tohtml($settings['no_recent']) . '</strong> is not a non-negative integer.']; } } diff --git a/templates/themes/basic/theme.php b/templates/themes/basic/theme.php index 6ba09ce6..4d79d73f 100644 --- a/templates/themes/basic/theme.php +++ b/templates/themes/basic/theme.php @@ -28,12 +28,7 @@ $query = query("SELECT * FROM ``news`` ORDER BY `time` DESC" . ($settings['no_recent'] ? ' LIMIT ' . $settings['no_recent'] : '')) or error(db_error()); $news = $query->fetchAll(PDO::FETCH_ASSOC); - return Element('themes/basic/index.html', Array( - 'settings' => $settings, - 'config' => $config, - 'boardlist' => createBoardlist(), - 'news' => $news - )); + return Element('themes/basic/index.html', ['settings' => $settings, 'config' => $config, 'boardlist' => createBoardlist(), 'news' => $news]); } }; diff --git a/templates/themes/calendar/calendarpost.php b/templates/themes/calendar/calendarpost.php index 5293a881..ac2c1a72 100644 --- a/templates/themes/calendar/calendarpost.php +++ b/templates/themes/calendar/calendarpost.php @@ -51,7 +51,7 @@ $method = $_SERVER['REQUEST_METHOD']; } elseif ($method == 'GET') { // Method is GET $query = query("SELECT * FROM calendar_events ORDER BY id") or error(db_error()); - echo json_encode($query->fetchAll(PDO::FETCH_ASSOC)); + echo json_encode($query->fetchAll(PDO::FETCH_ASSOC), JSON_THROW_ON_ERROR); } ?> diff --git a/templates/themes/calendar/info.php b/templates/themes/calendar/info.php index 0687a26d..6d770601 100644 --- a/templates/themes/calendar/info.php +++ b/templates/themes/calendar/info.php @@ -1,35 +1,20 @@ <?php - $theme = Array(); + $theme = []; // Theme name - $theme['name'] = 'Calendar'; + $theme['name'] = \Calendar::class; // Description (you can use Tinyboard markup here) $theme['description'] = 'Calendar theme.'; $theme['version'] = 'v0.0.1'; // Theme configuration - $theme['config'] = Array(); + $theme['config'] = []; - $theme['config'][] = Array( - 'title' => 'Site title', - 'name' => 'title', - 'type' => 'text' - ); + $theme['config'][] = ['title' => 'Site title', 'name' => 'title', 'type' => 'text']; - $theme['config'][] = Array( - 'title' => 'Slogan', - 'name' => 'subtitle', - 'type' => 'text', - 'comment' => '(optional)' - ); + $theme['config'][] = ['title' => 'Slogan', 'name' => 'subtitle', 'type' => 'text', 'comment' => '(optional)']; - $theme['config'][] = Array( - 'title' => 'File', - 'name' => 'file', - 'type' => 'text', - 'default' => $config['file_index'], - 'comment' => '(eg. "index.html")' - ); + $theme['config'][] = ['title' => 'File', 'name' => 'file', 'type' => 'text', 'default' => $config['file_index'], 'comment' => '(eg. "index.html")']; // Unique function name for building everything $theme['build_function'] = 'calendar_build'; diff --git a/templates/themes/calendar/theme.php b/templates/themes/calendar/theme.php index 8e9d32db..b39729ed 100644 --- a/templates/themes/calendar/theme.php +++ b/templates/themes/calendar/theme.php @@ -24,11 +24,7 @@ public static function htmlpage($settings) { global $config; - return Element('themes/calendar/calendar.html', Array( - 'settings' => $settings, - 'config' => $config, - 'boardlist' => createBoardlist() - )); + return Element('themes/calendar/calendar.html', ['settings' => $settings, 'config' => $config, 'boardlist' => createBoardlist()]); } public static function phppage($settings) { global $config; diff --git a/templates/themes/catalog/info.php b/templates/themes/catalog/info.php index bc0e7eb5..cf0d42ab 100644 --- a/templates/themes/catalog/info.php +++ b/templates/themes/catalog/info.php @@ -1,96 +1,37 @@ <?php - $theme = array(); + $theme = []; // Theme name - $theme['name'] = 'Catalog'; + $theme['name'] = \Catalog::class; // Description (you can use Tinyboard markup here) $theme['description'] = 'Show a post catalog.'; $theme['version'] = 'v0.2.1'; // Theme configuration - $theme['config'] = Array(); + $theme['config'] = []; - $theme['config'][] = Array( - 'title' => 'Title', - 'name' => 'title', - 'type' => 'text', - 'default' => 'Catalog' - ); + $theme['config'][] = ['title' => 'Title', 'name' => 'title', 'type' => 'text', 'default' => \Catalog::class]; $__boards = listBoards(); - $__default_boards = Array(); + $__default_boards = []; foreach ($__boards as $__board) $__default_boards[] = $__board['uri']; - $theme['config'][] = Array( - 'title' => 'Included boards', - 'name' => 'boards', - 'type' => 'text', - 'comment' => '(space seperated)', - 'default' => implode(' ', $__default_boards) - ); + $theme['config'][] = ['title' => 'Included boards', 'name' => 'boards', 'type' => 'text', 'comment' => '(space seperated)', 'default' => implode(' ', $__default_boards)]; - $theme['config'][] = Array( - 'title' => 'Update on new posts', - 'name' => 'update_on_posts', - 'type' => 'checkbox', - 'default' => false, - 'comment' => 'Without this checked, the catalog only updates on new threads.' - ); + $theme['config'][] = ['title' => 'Update on new posts', 'name' => 'update_on_posts', 'type' => 'checkbox', 'default' => false, 'comment' => 'Without this checked, the catalog only updates on new threads.']; - $theme['config'][] = Array( - 'title' => 'Enable Ukko catalog', - 'name' => 'enable_ukko', - 'type' => 'checkbox', - 'default' => false, - 'comment' => 'Enable catalog for the Ukko theme. This requires the Ukko theme to be enabled.' - ); + $theme['config'][] = ['title' => 'Enable Ukko catalog', 'name' => 'enable_ukko', 'type' => 'checkbox', 'default' => false, 'comment' => 'Enable catalog for the Ukko theme. This requires the Ukko theme to be enabled.']; - $theme['config'][] = Array( - 'title' => 'Enable Ukko2 catalog', - 'name' => 'enable_ukko2', - 'type' => 'checkbox', - 'default' => false, - 'comment' => 'Enable catalog for the Ukko2 theme. This requires the Ukko2 theme to be enabled.' - ); + $theme['config'][] = ['title' => 'Enable Ukko2 catalog', 'name' => 'enable_ukko2', 'type' => 'checkbox', 'default' => false, 'comment' => 'Enable catalog for the Ukko2 theme. This requires the Ukko2 theme to be enabled.']; - $theme['config'][] = Array( - 'title' => 'Enable Ukko3 catalog', - 'name' => 'enable_ukko3', - 'type' => 'checkbox', - 'default' => false, - 'comment' => 'Enable catalog for the Ukko theme. This requires the Ukko3 theme to be enabled.' - ); - $theme['config'][] = Array( - 'title' => 'Enable Ukko4 catalog', - 'name' => 'enable_ukko4', - 'type' => 'checkbox', - 'default' => false, - 'comment' => 'Enable catalog for the Ukko theme. This requires the Ukko4 theme to be enabled.' - ); + $theme['config'][] = ['title' => 'Enable Ukko3 catalog', 'name' => 'enable_ukko3', 'type' => 'checkbox', 'default' => false, 'comment' => 'Enable catalog for the Ukko theme. This requires the Ukko3 theme to be enabled.']; + $theme['config'][] = ['title' => 'Enable Ukko4 catalog', 'name' => 'enable_ukko4', 'type' => 'checkbox', 'default' => false, 'comment' => 'Enable catalog for the Ukko theme. This requires the Ukko4 theme to be enabled.']; - $theme['config'][] = Array( - 'title' => 'Enable Rand catalog', - 'name' => 'enable_rand', - 'type' => 'checkbox', - 'default' => false, - 'comment' => 'Enable catalog for the Rand theme. This requires the Rand theme to be enabled.' - ); - $theme['config'][] = Array( - 'title' => 'Use tooltipster', - 'name' => 'use_tooltipster', - 'type' => 'checkbox', - 'default' => true, - 'comment' => 'Check this if you wish to show a nice tooltip with info about the thread on mouse over.' - ); + $theme['config'][] = ['title' => 'Enable Rand catalog', 'name' => 'enable_rand', 'type' => 'checkbox', 'default' => false, 'comment' => 'Enable catalog for the Rand theme. This requires the Rand theme to be enabled.']; + $theme['config'][] = ['title' => 'Use tooltipster', 'name' => 'use_tooltipster', 'type' => 'checkbox', 'default' => true, 'comment' => 'Check this if you wish to show a nice tooltip with info about the thread on mouse over.']; - $theme['config'][] = Array( - 'title' => 'Base URL', - 'name' => 'base_url', - 'type' => 'text', - 'default' => 'http://test.com', - 'comment' => '(eg. "http://test.com")' - ); + $theme['config'][] = ['title' => 'Base URL', 'name' => 'base_url', 'type' => 'text', 'default' => 'http://test.com', 'comment' => '(eg. "http://test.com")']; // Unique function name for building everything $theme['build_function'] = 'catalog_build'; diff --git a/templates/themes/catalog/theme.php b/templates/themes/catalog/theme.php index 1b55d56e..f4c59681 100644 --- a/templates/themes/catalog/theme.php +++ b/templates/themes/catalog/theme.php @@ -5,7 +5,7 @@ global $config; $b = new Catalog($settings); - $boards = explode(' ', $settings['boards']); + $boards = explode(' ', (string) $settings['boards']); // Possible values for $action: // - all (rebuild everything, initialization) @@ -17,7 +17,7 @@ foreach ($boards as $board) { $b = new Catalog($settings); - $action = generation_strategy("sb_catalog", array($board)); + $action = generation_strategy("sb_catalog", [$board]); if ($action == 'delete') { file_unlink($config['dir']['home'] . $board . '/catalog.html'); file_unlink($config['dir']['home'] . $board . '/index.rss'); @@ -30,7 +30,7 @@ || $action == 'sticky' || ($action == 'lock' && in_array($board, $boards))) { $b = new Catalog($settings); - $action = generation_strategy("sb_catalog", array($board)); + $action = generation_strategy("sb_catalog", [$board]); if ($action == 'delete') { file_unlink($config['dir']['home'] . $board . '/catalog.html'); file_unlink($config['dir']['home'] . $board . '/index.rss'); @@ -82,13 +82,12 @@ // Wrap functions in a class so they don't interfere with normal Tinyboard operations class Catalog { - private $settings; // Cache for threads from boards that have already been processed - private $threadsCache = array(); + private array $threadsCache = []; - public function __construct($settings) { - $this->settings = $settings; - } + public function __construct(private $settings) + { + } /** * Build and save the HTML of the catalog for the Ukko theme @@ -97,10 +96,10 @@ global $config; $ukkoSettings = themeSettings('ukko'); - $queries = array(); - $threads = array(); + $queries = []; + $threads = []; - $exclusions = explode(' ', $ukkoSettings['exclude']); + $exclusions = explode(' ', (string) $ukkoSettings['exclude']); $boards = array_diff(listBoards(true), $exclusions); foreach ($boards as $b) { @@ -119,9 +118,7 @@ } // Sort in bump order - usort($threads, function($a, $b) { - return strcmp($b['bump'], $a['bump']); - }); + usort($threads, fn($a, $b) => strcmp((string) $b['bump'], (string) $a['bump'])); // Generate data for the template $recent_posts = $this->generateRecentPosts($threads); @@ -134,10 +131,10 @@ public function buildUkko2() { global $config; $ukkoSettings = themeSettings('ukko2'); - $queries = array(); - $threads = array(); + $queries = []; + $threads = []; - $inclusions = explode(' ', $ukkoSettings['include']); + $inclusions = explode(' ', (string) $ukkoSettings['include']); $boards = array_intersect(listBoards(true), $inclusions); foreach ($boards as $b) { @@ -156,9 +153,7 @@ } // Sort in bump order - usort($threads, function($a, $b) { - return strcmp($b['bump'], $a['bump']); - }); + usort($threads, fn($a, $b) => strcmp((string) $b['bump'], (string) $a['bump'])); // Generate data for the template $recent_posts = $this->generateRecentPosts($threads); @@ -173,10 +168,10 @@ global $config; $ukkoSettings = themeSettings('ukko3'); - $queries = array(); - $threads = array(); + $queries = []; + $threads = []; - $inclusions = explode(' ', $ukkoSettings['include']); + $inclusions = explode(' ', (string) $ukkoSettings['include']); $boards = array_intersect(listBoards(true), $inclusions); foreach ($boards as $b) { @@ -195,9 +190,7 @@ } // Sort in bump order - usort($threads, function($a, $b) { - return strcmp($b['bump'], $a['bump']); - }); + usort($threads, fn($a, $b) => strcmp((string) $b['bump'], (string) $a['bump'])); // Generate data for the template $recent_posts = $this->generateRecentPosts($threads); @@ -212,10 +205,10 @@ global $config; $ukkoSettings = themeSettings('ukko4'); - $queries = array(); - $threads = array(); + $queries = []; + $threads = []; - $exclusions = explode(' ', $ukkoSettings['exclude']); + $exclusions = explode(' ', (string) $ukkoSettings['exclude']); $boards = array_diff(listBoards(true), $exclusions); foreach ($boards as $b) { @@ -234,9 +227,7 @@ } // Sort in bump order - usort($threads, function($a, $b) { - return strcmp($b['bump'], $a['bump']); - }); + usort($threads, fn($a, $b) => strcmp((string) $b['bump'], (string) $a['bump'])); // Generate data for the template $recent_posts = $this->generateRecentPosts($threads); @@ -250,10 +241,10 @@ global $config; $randSettings = themeSettings('rand'); - $queries = array(); - $threads = array(); + $queries = []; + $threads = []; - $exclusions = explode(' ', $randSettings['exclude']); + $exclusions = explode(' ', (string) $randSettings['exclude']); $boards = array_diff(listBoards(true), $exclusions); foreach ($boards as $b) { @@ -272,9 +263,7 @@ } // Sort in bump order - usort($threads, function($a, $b) { - return strcmp($b['bump'], $a['bump']); - }); + usort($threads, fn($a, $b) => strcmp((string) $b['bump'], (string) $a['bump'])); // Generate data for the template $recent_posts = $this->generateRecentPosts($threads); @@ -321,7 +310,7 @@ private function generateRecentPosts($threads) { global $config, $board; - $posts = array(); + $posts = []; foreach ($threads as $post) { if ($board['uri'] !== $post['board']) { openBoard($post['board']); @@ -330,16 +319,16 @@ $post['link'] = $config['root'] . $board['dir'] . $config['dir']['res'] . link_for($post); $post['board_name'] = $board['name']; - if ($post['embed'] && preg_match('/^https?:\/\/(\w+\.)?(?:youtube\.com\/watch\?v=|youtu\.be\/)([a-zA-Z0-9\-_]{10,11})(&.+)?$/i', $post['embed'], $matches)) { + if ($post['embed'] && preg_match('/^https?:\/\/(\w+\.)?(?:youtube\.com\/watch\?v=|youtu\.be\/)([a-zA-Z0-9\-_]{10,11})(&.+)?$/i', (string) $post['embed'], $matches)) { $post['youtube'] = $matches[2]; } if (isset($post['files']) && $post['files']) { - $files = json_decode($post['files']); + $files = json_decode((string) $post['files'], null, 512, JSON_THROW_ON_ERROR); if ($files[0]) { if ($files[0]->file == 'deleted') { - if (count($files) > 1) { + if ((is_countable($files) ? count($files) : 0) > 1) { foreach ($files as $file) { if (($file == $files[0]) || ($file->file == 'deleted')) continue; @@ -378,8 +367,7 @@ $board_link = $config['root'] . $board['dir']; } - $required_scripts = array('js/jquery.min.js', 'js/jquery.mixitup.min.js', - 'js/catalog.js'); + $required_scripts = ['js/jquery.min.js', 'js/jquery.mixitup.min.js', 'js/catalog.js']; // Include scripts that haven't been yet included foreach($required_scripts as $i => $s) { @@ -387,22 +375,8 @@ $config['additional_javascript'][] = $s; } - file_write($config['dir']['home'] . $board_name . '/catalog.html', Element('themes/catalog/catalog.html', Array( - 'settings' => $this->settings, - 'config' => $config, - 'boardlist' => createBoardlist(), - 'recent_images' => array(), - 'recent_posts' => $recent_posts, - 'stats' => array(), - 'board' => $board_name, - 'link' => $board_link - ))); + file_write($config['dir']['home'] . $board_name . '/catalog.html', Element('themes/catalog/catalog.html', ['settings' => $this->settings, 'config' => $config, 'boardlist' => createBoardlist(), 'recent_images' => [], 'recent_posts' => $recent_posts, 'stats' => [], 'board' => $board_name, 'link' => $board_link])); - file_write($config['dir']['home'] . $board_name . '/index.rss', Element('themes/catalog/index.rss', Array( - 'settings' => $this->settings, - 'config' => $config, - 'recent_posts' => $recent_posts, - 'board' => $board - ))); + file_write($config['dir']['home'] . $board_name . '/index.rss', Element('themes/catalog/index.rss', ['settings' => $this->settings, 'config' => $config, 'recent_posts' => $recent_posts, 'board' => $board])); } } diff --git a/templates/themes/categories-uboachan/info.php b/templates/themes/categories-uboachan/info.php index 3ef9871f..99177e8f 100644 --- a/templates/themes/categories-uboachan/info.php +++ b/templates/themes/categories-uboachan/info.php @@ -1,5 +1,5 @@ <?php - $theme = Array(); + $theme = []; // Theme name $theme['name'] = 'Categories-Uboachan'; @@ -11,19 +11,11 @@ Requires $config[\'boards\'] and $config[\'categories\'].'; $theme['version'] = 'v0.2.1'; // Theme configuration - $theme['config'] = Array(); + $theme['config'] = []; - $theme['config'][] = Array( - 'title' => 'Title', - 'name' => 'title', - 'type' => 'text' - ); + $theme['config'][] = ['title' => 'Title', 'name' => 'title', 'type' => 'text']; - $theme['config'][] = Array( - 'title' => 'Slogan', - 'name' => 'subtitle', - 'type' => 'text' - ); + $theme['config'][] = ['title' => 'Slogan', 'name' => 'subtitle', 'type' => 'text']; // Unique function name for building everything $theme['build_function'] = 'categories_build'; @@ -34,8 +26,8 @@ Requires $config[\'boards\'] and $config[\'categories\'].'; global $config; if(!isset($config['boards']) || !isset($config['categories'])) { - return Array(false, '<h2>Prerequisites not met!</h2>' . - 'This theme requires $config[\'boards\'] and $config[\'categories\'] to be set.'); + return [false, '<h2>Prerequisites not met!</h2>' . + 'This theme requires $config[\'boards\'] and $config[\'categories\'] to be set.']; } } } diff --git a/templates/themes/categories-uboachan/theme.php b/templates/themes/categories-uboachan/theme.php index 296e0d06..3c735ec4 100644 --- a/templates/themes/categories-uboachan/theme.php +++ b/templates/themes/categories-uboachan/theme.php @@ -105,7 +105,7 @@ openBoard($post['board']); $body .= '<strong>' . $board['name'] . '</strong>: <a href="' . - $config['root'] . $board['dir'] . $config['dir']['res'] . ($post['thread']?$post['thread']:$post['id']) . '.html#' . $post['id'] . + $config['root'] . $board['dir'] . $config['dir']['res'] . ($post['thread'] ?: $post['id']) . '.html#' . $post['id'] . '">'; $snip = pm_snippet($post['body'], 95); if($snip === "<em></em>") @@ -136,10 +136,7 @@ : '' ) . - ($news['subject'] ? - $news['subject'] - : - '<em>no subject</em>' + ($news['subject'] ?: '<em>no subject</em>' ) . ' — by ' . $news['name'] . @@ -190,7 +187,7 @@ '<li><a href="javascript:changeStyleForAll(\'YB\');">[YB]</a> <a href="javascript:changeStyleForAll(\'Y\');">[Y]</a> <a href="javascript:changeStyleForAll(\'U\');">[U]</a> <a href="javascript:changeStyleForAll(\'UG\');">[UG]</a> <a href="javascript:changeStyleForAll(\'RZ\');">[RZ]</a></li>'. '</ul></fieldset>'; - for($cat = 0; $cat < count($config['categories']); $cat++) { + for($cat = 0; $cat < (is_countable($config['categories']) ? count($config['categories']) : 0); $cat++) { $body .= '<fieldset><legend class="category">' . $config['categories'][$cat] . '</legend><ul>'; foreach($config['boards'][$cat] as &$board) { diff --git a/templates/themes/categories/info.php b/templates/themes/categories/info.php index 62d8f6bb..003d30a5 100644 --- a/templates/themes/categories/info.php +++ b/templates/themes/categories/info.php @@ -1,8 +1,8 @@ <?php - $theme = Array(); + $theme = []; // Theme name - $theme['name'] = 'Categories'; + $theme['name'] = \Categories::class; // Description (you can use Tinyboard markup here) $theme['description'] = 'Group-ordered, category-aware modification of the Frameset theme, with removable sidebar frame. @@ -11,44 +11,17 @@ Requires $config[\'categories\'].'; $theme['version'] = 'v0.3'; // Theme configuration - $theme['config'] = Array(); + $theme['config'] = []; - $theme['config'][] = Array( - 'title' => 'Site title', - 'name' => 'title', - 'type' => 'text' - ); + $theme['config'][] = ['title' => 'Site title', 'name' => 'title', 'type' => 'text']; - $theme['config'][] = Array( - 'title' => 'Slogan', - 'name' => 'subtitle', - 'type' => 'text', - 'comment' => '(optional)' - ); + $theme['config'][] = ['title' => 'Slogan', 'name' => 'subtitle', 'type' => 'text', 'comment' => '(optional)']; - $theme['config'][] = Array( - 'title' => 'Main HTML file', - 'name' => 'file_main', - 'type' => 'text', - 'default' => $config['file_index'], - 'comment' => '(eg. "index.html")' - ); + $theme['config'][] = ['title' => 'Main HTML file', 'name' => 'file_main', 'type' => 'text', 'default' => $config['file_index'], 'comment' => '(eg. "index.html")']; - $theme['config'][] = Array( - 'title' => 'Sidebar file', - 'name' => 'file_sidebar', - 'type' => 'text', - 'default' => 'sidebar.html', - 'comment' => '(eg. "sidebar.html")' - ); + $theme['config'][] = ['title' => 'Sidebar file', 'name' => 'file_sidebar', 'type' => 'text', 'default' => 'sidebar.html', 'comment' => '(eg. "sidebar.html")']; - $theme['config'][] = Array( - 'title' => 'News file', - 'name' => 'file_news', - 'type' => 'text', - 'default' => 'news.html', - 'comment' => '(eg. "news.html")' - ); + $theme['config'][] = ['title' => 'News file', 'name' => 'file_news', 'type' => 'text', 'default' => 'news.html', 'comment' => '(eg. "news.html")']; // Unique function name for building everything $theme['build_function'] = 'categories_build'; @@ -59,8 +32,8 @@ Requires $config[\'categories\'].'; global $config; if (!isset($config['categories'])) { - return Array(false, '<h2>Prerequisites not met!</h2>' . - 'This theme requires $config[\'boards\'] and $config[\'categories\'] to be set.'); + return [false, '<h2>Prerequisites not met!</h2>' . + 'This theme requires $config[\'boards\'] and $config[\'categories\'] to be set.']; } } } diff --git a/templates/themes/categories/theme.php b/templates/themes/categories/theme.php index 1ccfe451..d76fd7fc 100644 --- a/templates/themes/categories/theme.php +++ b/templates/themes/categories/theme.php @@ -29,7 +29,7 @@ public static function homepage($settings) { global $config; - return Element('themes/categories/frames.html', Array('config' => $config, 'settings' => $settings)); + return Element('themes/categories/frames.html', ['config' => $config, 'settings' => $settings]); } // Build news page @@ -39,12 +39,7 @@ $query = query("SELECT * FROM ``news`` ORDER BY `time` DESC") or error(db_error()); $news = $query->fetchAll(PDO::FETCH_ASSOC); - return Element('themes/categories/news.html', Array( - 'settings' => $settings, - 'config' => $config, - 'news' => $news, - 'boardlist' => createBoardlist(false) - )); + return Element('themes/categories/news.html', ['settings' => $settings, 'config' => $config, 'news' => $news, 'boardlist' => createBoardlist(false)]); } // Build sidebar @@ -58,15 +53,11 @@ $title = boardTitle($board); if (!$title) $title = $board; // board doesn't exist, but for some reason you want to display it anyway - $board = Array('title' => $title, 'uri' => sprintf($config['board_path'], $board)); + $board = ['title' => $title, 'uri' => sprintf($config['board_path'], $board)]; } } - return Element('themes/categories/sidebar.html', Array( - 'settings' => $settings, - 'config' => $config, - 'categories' => $categories - )); + return Element('themes/categories/sidebar.html', ['settings' => $settings, 'config' => $config, 'categories' => $categories]); } }; diff --git a/templates/themes/donate/donate.html b/templates/themes/donate/donate.html index 955beaab..592b5a64 100644 --- a/templates/themes/donate/donate.html +++ b/templates/themes/donate/donate.html @@ -25,7 +25,7 @@ <h2>Thanks for donating</h2> <p>The server costs {{ settings.monthlyamount }} per month. If you buy stickers we get about 45-55% of whatever you spend. Historical donation records to the former owner are ForeverN2Dust is the top donator, giving about $3000. FOOFDOOF is #2 with $1000 and lots of cheap Chinese shit. Please specify what you'd like your money to go towards. If you don't want to buy stickers, but want to donate something else please either ask in /q/ or contact the Lainchan administration on IRC at #lainchan on Lainchan IRC at irc.lainchan.org or Freenode. </p> - <p>Stickermule shutdown their stickermarket place ages ago. So stickers are no longer avaliable for purchase. Lainstore is being slowly worked on but isn't finished yet. + <p>Stickermule shutdown their stickermarket place ages ago. So stickers are no longer avaliable for purcahse. Lainstore is being slowly worked on but isn't finished yet. </p> <p> <a href="/stickers.html">To view the sticker gallery click here </a> diff --git a/templates/themes/donate/info.php b/templates/themes/donate/info.php index ecb53154..6f5b725e 100644 --- a/templates/themes/donate/info.php +++ b/templates/themes/donate/info.php @@ -1,81 +1,4 @@ <?php -$theme = array( - 'name' => 'Donate', - 'description' => 'le wales face', - 'version' => 'v9001', - - 'config' => array( - array('title' => 'Page title', - 'name' => 'title', - 'type' => 'text'), - - array('title' => 'Slogan', - 'name' => 'subtitle', - 'type' => 'text', - 'comment' => '(optional)'), - - array('title' => 'File', - 'name' => 'file', - 'type' => 'text', - 'default' => 'donate.html'), - - array('title' => 'Monthly Amount', - 'name' => 'monthlyamount', - 'type' => 'text', - 'default' => '$0'), - - - array('title' => 'Current Sticker Amount', - 'name' => 'stickeramount', - 'type' => 'text', - 'default' => '$0'), - - array('title' => 'Current Other Donations Amount', - 'name' => 'otheramount', - 'type' => 'text', - 'default' => '$0'), - - array('title' => 'Current Bitcoin Amount', - 'name' => 'bitcoinamount', - 'type' => 'text', - 'default' => '0 BTC'), - - array('title' => 'Current Progress', - 'name' => 'currentprogress', - 'type' => 'text', - 'default' => '$0'), - - array('title' => 'Progress Bar CSS class', - 'name' => 'progressbarcssclass', - 'type' => 'text', - 'default' => 'progress-bar green glow'), - - - array('title' => 'Progress Bar CSS width', - 'name' => 'progressbarcsswidth', - 'type' => 'text', - 'default' => '15%'), - - array('title' => 'Progress Bar CSS left', - 'name' => 'progressbarcssleft', - 'type' => 'text', - 'default' => '51'), - - array('title' => 'Progress Bar Text CSS left', - 'name' => 'progressbartextcssleft', - 'type' => 'text', - 'default' => '195'), - - array('title' => 'Bitcoin receiving address', - 'name' => 'bitcoinreceivingaddress', - 'type' => 'text', - 'default' => 'nothing'), - - array('title' => 'Bitcoin receiving QR code ', - 'name' => 'bitcoinreceivingqrcode', - 'type' => 'text', - 'default' => 'nothing'), - ), - 'build_function' => 'donate_build'); +$theme = ['name' => 'Donate', 'description' => 'le wales face', 'version' => 'v9001', 'config' => [['title' => 'Page title', 'name' => 'title', 'type' => 'text'], ['title' => 'Slogan', 'name' => 'subtitle', 'type' => 'text', 'comment' => '(optional)'], ['title' => 'File', 'name' => 'file', 'type' => 'text', 'default' => 'donate.html'], ['title' => 'Monthly Amount', 'name' => 'monthlyamount', 'type' => 'text', 'default' => '$0'], ['title' => 'Current Sticker Amount', 'name' => 'stickeramount', 'type' => 'text', 'default' => '$0'], ['title' => 'Current Other Donations Amount', 'name' => 'otheramount', 'type' => 'text', 'default' => '$0'], ['title' => 'Current Bitcoin Amount', 'name' => 'bitcoinamount', 'type' => 'text', 'default' => '0 BTC'], ['title' => 'Current Progress', 'name' => 'currentprogress', 'type' => 'text', 'default' => '$0'], ['title' => 'Progress Bar CSS class', 'name' => 'progressbarcssclass', 'type' => 'text', 'default' => 'progress-bar green glow'], ['title' => 'Progress Bar CSS width', 'name' => 'progressbarcsswidth', 'type' => 'text', 'default' => '15%'], ['title' => 'Progress Bar CSS left', 'name' => 'progressbarcssleft', 'type' => 'text', 'default' => '51'], ['title' => 'Progress Bar Text CSS left', 'name' => 'progressbartextcssleft', 'type' => 'text', 'default' => '195'], ['title' => 'Bitcoin receiving address', 'name' => 'bitcoinreceivingaddress', 'type' => 'text', 'default' => 'nothing'], ['title' => 'Bitcoin receiving QR code ', 'name' => 'bitcoinreceivingqrcode', 'type' => 'text', 'default' => 'nothing']], 'build_function' => 'donate_build']; ?> diff --git a/templates/themes/donate/theme.php b/templates/themes/donate/theme.php index 736519a8..23acdb81 100644 --- a/templates/themes/donate/theme.php +++ b/templates/themes/donate/theme.php @@ -19,9 +19,7 @@ class donate { global $config; return Element('themes/donate/donate.html', - array('settings' => $settings, - 'config' => $config, - 'boardlist' => createBoardlist())); + ['settings' => $settings, 'config' => $config, 'boardlist' => createBoardlist()]); } } diff --git a/templates/themes/faq/info.php b/templates/themes/faq/info.php index c81d52ab..019eff88 100644 --- a/templates/themes/faq/info.php +++ b/templates/themes/faq/info.php @@ -1,35 +1,20 @@ <?php - $theme = Array(); + $theme = []; // Theme name - $theme['name'] = 'FAQ'; + $theme['name'] = \FAQ::class; // Description (you can use Tinyboard markup here) $theme['description'] = 'FAQ because Lainons have questions'; $theme['version'] = 'v0.0.1'; // Theme configuration - $theme['config'] = Array(); + $theme['config'] = []; - $theme['config'][] = Array( - 'title' => 'Site title', - 'name' => 'title', - 'type' => 'text' - ); + $theme['config'][] = ['title' => 'Site title', 'name' => 'title', 'type' => 'text']; - $theme['config'][] = Array( - 'title' => 'Slogan', - 'name' => 'subtitle', - 'type' => 'text', - 'comment' => '(optional)' - ); + $theme['config'][] = ['title' => 'Slogan', 'name' => 'subtitle', 'type' => 'text', 'comment' => '(optional)']; - $theme['config'][] = Array( - 'title' => 'File', - 'name' => 'file', - 'type' => 'text', - 'default' => "faq.html", - 'comment' => '(eg. "faq.html")' - ); + $theme['config'][] = ['title' => 'File', 'name' => 'file', 'type' => 'text', 'default' => "faq.html", 'comment' => '(eg. "faq.html")']; // Unique function name for building everything diff --git a/templates/themes/faq/theme.php b/templates/themes/faq/theme.php index 28db35a2..18421482 100644 --- a/templates/themes/faq/theme.php +++ b/templates/themes/faq/theme.php @@ -22,11 +22,7 @@ // Build FAQ page public static function homepage($settings) { global $config; - return Element('themes/faq/index.html', Array( - 'settings' => $settings, - 'config' => $config, - 'boardlist' => createBoardlist(), - )); + return Element('themes/faq/index.html', ['settings' => $settings, 'config' => $config, 'boardlist' => createBoardlist()]); } }; diff --git a/templates/themes/frameset/info.php b/templates/themes/frameset/info.php index 8cff78a9..f19ea010 100644 --- a/templates/themes/frameset/info.php +++ b/templates/themes/frameset/info.php @@ -1,8 +1,8 @@ <?php - $theme = Array(); + $theme = []; // Theme name - $theme['name'] = 'Frameset'; + $theme['name'] = \Frameset::class; // Description (you can use Tinyboard markup here) $theme['description'] = 'Use a basic frameset layout, with a list of boards and pages on a sidebar to the left of the page. @@ -11,44 +11,17 @@ Users never have to leave the homepage; they can do all their browsing from the $theme['version'] = 'v0.1'; // Theme configuration - $theme['config'] = Array(); + $theme['config'] = []; - $theme['config'][] = Array( - 'title' => 'Site title', - 'name' => 'title', - 'type' => 'text' - ); + $theme['config'][] = ['title' => 'Site title', 'name' => 'title', 'type' => 'text']; - $theme['config'][] = Array( - 'title' => 'Slogan', - 'name' => 'subtitle', - 'type' => 'text', - 'comment' => '(optional)' - ); + $theme['config'][] = ['title' => 'Slogan', 'name' => 'subtitle', 'type' => 'text', 'comment' => '(optional)']; - $theme['config'][] = Array( - 'title' => 'Main HTML file', - 'name' => 'file_main', - 'type' => 'text', - 'default' => $config['file_index'], - 'comment' => '(eg. "index.html")' - ); + $theme['config'][] = ['title' => 'Main HTML file', 'name' => 'file_main', 'type' => 'text', 'default' => $config['file_index'], 'comment' => '(eg. "index.html")']; - $theme['config'][] = Array( - 'title' => 'Sidebar file', - 'name' => 'file_sidebar', - 'type' => 'text', - 'default' => 'sidebar.html', - 'comment' => '(eg. "sidebar.html")' - ); + $theme['config'][] = ['title' => 'Sidebar file', 'name' => 'file_sidebar', 'type' => 'text', 'default' => 'sidebar.html', 'comment' => '(eg. "sidebar.html")']; - $theme['config'][] = Array( - 'title' => 'News file', - 'name' => 'file_news', - 'type' => 'text', - 'default' => 'news.html', - 'comment' => '(eg. "news.html")' - ); + $theme['config'][] = ['title' => 'News file', 'name' => 'file_news', 'type' => 'text', 'default' => 'news.html', 'comment' => '(eg. "news.html")']; // Unique function name for building everything $theme['build_function'] = 'frameset_build'; diff --git a/templates/themes/frameset/theme.php b/templates/themes/frameset/theme.php index ffab0538..996ee64e 100644 --- a/templates/themes/frameset/theme.php +++ b/templates/themes/frameset/theme.php @@ -29,7 +29,7 @@ public static function homepage($settings) { global $config; - return Element('themes/frameset/frames.html', Array('config' => $config, 'settings' => $settings)); + return Element('themes/frameset/frames.html', ['config' => $config, 'settings' => $settings]); } // Build news page @@ -39,22 +39,14 @@ $query = query("SELECT * FROM ``news`` ORDER BY `time` DESC") or error(db_error()); $news = $query->fetchAll(PDO::FETCH_ASSOC); - return Element('themes/frameset/news.html', Array( - 'settings' => $settings, - 'config' => $config, - 'news' => $news - )); + return Element('themes/frameset/news.html', ['settings' => $settings, 'config' => $config, 'news' => $news]); } // Build sidebar public static function sidebar($settings) { global $config, $board; - return Element('themes/frameset/sidebar.html', Array( - 'settings' => $settings, - 'config' => $config, - 'boards' => listBoards() - )); + return Element('themes/frameset/sidebar.html', ['settings' => $settings, 'config' => $config, 'boards' => listBoards()]); } }; diff --git a/templates/themes/irc/info.php b/templates/themes/irc/info.php index 8ca3be0a..2c46f3c0 100644 --- a/templates/themes/irc/info.php +++ b/templates/themes/irc/info.php @@ -1,38 +1,3 @@ <?php -$theme = array( - 'name' => 'IRC', - 'description' => 'Display a link to the lainchan irc', - 'version' => 'v1', - - 'config' => array( - array('title' => 'Page title', - 'name' => 'title', - 'type' => 'text'), - - array('title' => 'Slogan', - 'name' => 'subtitle', - 'type' => 'text', - 'comment' => '(optional)'), - - array('title' => 'File', - 'name' => 'file', - 'type' => 'text', - 'default' => 'irc.html'), - - array('title' => 'Channel', - 'name' => 'channel', - 'type' => 'text', - 'default' => 'general'), - - array('title' => 'Server', - 'name' => 'server', - 'type' => 'text', - 'default' => 'irc.lainchan.org'), - - array('title' => 'Port', - 'name' => 'port', - 'type' => 'text', - 'default' => '6697')), - - 'build_function' => 'irc_build'); +$theme = ['name' => 'IRC', 'description' => 'Display a link to the lainchan irc', 'version' => 'v1', 'config' => [['title' => 'Page title', 'name' => 'title', 'type' => 'text'], ['title' => 'Slogan', 'name' => 'subtitle', 'type' => 'text', 'comment' => '(optional)'], ['title' => 'File', 'name' => 'file', 'type' => 'text', 'default' => 'irc.html'], ['title' => 'Channel', 'name' => 'channel', 'type' => 'text', 'default' => 'general'], ['title' => 'Server', 'name' => 'server', 'type' => 'text', 'default' => 'irc.lainchan.org'], ['title' => 'Port', 'name' => 'port', 'type' => 'text', 'default' => '6697']], 'build_function' => 'irc_build']; ?> diff --git a/templates/themes/irc/theme.php b/templates/themes/irc/theme.php index c9b45c33..fd98a122 100644 --- a/templates/themes/irc/theme.php +++ b/templates/themes/irc/theme.php @@ -18,9 +18,7 @@ class irc { global $config; return Element('themes/irc/irc.html', - array('settings' => $settings, - 'config' => $config, - 'boardlist' => createBoardlist())); + ['settings' => $settings, 'config' => $config, 'boardlist' => createBoardlist()]); } } diff --git a/templates/themes/public_banlist/info.php b/templates/themes/public_banlist/info.php index 006ac38e..6f928d9a 100644 --- a/templates/themes/public_banlist/info.php +++ b/templates/themes/public_banlist/info.php @@ -1,5 +1,5 @@ <?php - $theme = Array(); + $theme = []; // Theme name $theme['name'] = 'Public Banlist'; @@ -10,23 +10,11 @@ copies the banlist interface from moderation panel.'; $theme['version'] = 'v0.1'; // Theme configuration - $theme['config'] = Array(); + $theme['config'] = []; - $theme['config'][] = Array( - 'title' => 'JSON feed file', - 'name' => 'file_json', - 'type' => 'text', - 'default' => 'bans.json', - 'comment' => '(eg. "bans.json")' - ); + $theme['config'][] = ['title' => 'JSON feed file', 'name' => 'file_json', 'type' => 'text', 'default' => 'bans.json', 'comment' => '(eg. "bans.json")']; - $theme['config'][] = Array( - 'title' => 'Main HTML file', - 'name' => 'file_bans', - 'type' => 'text', - 'default' => 'bans.html', - 'comment' => '(eg. "bans.html")' - ); + $theme['config'][] = ['title' => 'Main HTML file', 'name' => 'file_bans', 'type' => 'text', 'default' => 'bans.html', 'comment' => '(eg. "bans.html")']; // Unique function name for building everything $theme['build_function'] = 'pbanlist_build'; diff --git a/templates/themes/public_banlist/theme.php b/templates/themes/public_banlist/theme.php index d56a6481..3b27d764 100644 --- a/templates/themes/public_banlist/theme.php +++ b/templates/themes/public_banlist/theme.php @@ -25,7 +25,7 @@ public static function gen_json($settings) { ob_start(); - Bans::stream_json(false, true, true, array(), array("/\bcp\b/i", "/porn/i")); + Bans::stream_json(false, true, true, [], ["/\bcp\b/i", "/porn/i"]); $out = ob_get_contents(); ob_end_clean(); return $out; @@ -35,22 +35,16 @@ public static function homepage($settings) { global $config; - return Element('page.html', array( - 'config' => $config, - 'mod' => false, - #'hide_dashboard_link' => true, - 'title' => _("Ban list"), - 'subtitle' => "", - 'boardlist' => createBoardlist(), - #'nojavascript' => true, - 'body' => Element('mod/ban_list.html', array( - 'mod' => false, - 'boards' => "[]", - 'token' => false, - 'token_json' => false, - 'uri_json' => $config['dir']['home'] . $settings['file_json'], - )) - )); + return Element('page.html', [ + 'config' => $config, + 'mod' => false, + #'hide_dashboard_link' => true, + 'title' => _("Ban list"), + 'subtitle' => "", + 'boardlist' => createBoardlist(), + #'nojavascript' => true, + 'body' => Element('mod/ban_list.html', ['mod' => false, 'boards' => "[]", 'token' => false, 'token_json' => false, 'uri_json' => $config['dir']['home'] . $settings['file_json']]), + ]); } }; diff --git a/templates/themes/radio/info.php b/templates/themes/radio/info.php index 70be5c59..3432616d 100644 --- a/templates/themes/radio/info.php +++ b/templates/themes/radio/info.php @@ -1,58 +1,3 @@ <?php -$theme = array( - 'name' => 'Radio', - 'description' => 'Display a link to the lainchan radio', - 'version' => 'v1', - - 'config' => array( - array('title' => 'Page title', - 'name' => 'title', - 'type' => 'text'), - - array('title' => 'Slogan', - 'name' => 'subtitle', - 'type' => 'text', - 'comment' => '(optional)'), - - array('title' => 'File', - 'name' => 'file', - 'type' => 'text', - 'default' => 'radio.html'), - - array('title' => 'HTTP Prefix', - 'name' => 'httpprefix', - 'type' => 'text', - 'default' => ''), - - array('title' => 'Radio Status URL', - 'name' => 'radiostatus', - 'type' => 'text', - 'default' => '/radio_assets/status.xsl'), - - array('title' => 'Radio Prefix', - 'name' => 'radioprefix', - 'type' => 'text', - 'default' => ''), - - array('title' => 'Filelist Prefix', - 'name' => 'filelistprefix', - 'type' => 'text', - 'default' => ''), - - array('title' => 'Channels', - 'name' => 'channels', - 'type' => 'text', - 'default' => 'everything cyberia swing'), - - array('title' => 'Default Channel', - 'name' => 'defaultchannel', - 'type' => 'text', - 'default' => 'everything'), - - array('title' => 'formats', - 'name' => 'formats', - 'type' => 'text', - 'default' => 'mp3 ogg'), - ), - 'build_function' => 'radio_build'); +$theme = ['name' => 'Radio', 'description' => 'Display a link to the lainchan radio', 'version' => 'v1', 'config' => [['title' => 'Page title', 'name' => 'title', 'type' => 'text'], ['title' => 'Slogan', 'name' => 'subtitle', 'type' => 'text', 'comment' => '(optional)'], ['title' => 'File', 'name' => 'file', 'type' => 'text', 'default' => 'radio.html'], ['title' => 'HTTP Prefix', 'name' => 'httpprefix', 'type' => 'text', 'default' => ''], ['title' => 'Radio Status URL', 'name' => 'radiostatus', 'type' => 'text', 'default' => '/radio_assets/status.xsl'], ['title' => 'Radio Prefix', 'name' => 'radioprefix', 'type' => 'text', 'default' => ''], ['title' => 'Filelist Prefix', 'name' => 'filelistprefix', 'type' => 'text', 'default' => ''], ['title' => 'Channels', 'name' => 'channels', 'type' => 'text', 'default' => 'everything cyberia swing'], ['title' => 'Default Channel', 'name' => 'defaultchannel', 'type' => 'text', 'default' => 'everything'], ['title' => 'formats', 'name' => 'formats', 'type' => 'text', 'default' => 'mp3 ogg']], 'build_function' => 'radio_build']; ?> diff --git a/templates/themes/radio/theme.php b/templates/themes/radio/theme.php index e1244e6f..fafb51a0 100644 --- a/templates/themes/radio/theme.php +++ b/templates/themes/radio/theme.php @@ -18,9 +18,7 @@ class radio { global $config; return Element('themes/radio/radio.html', - array('settings' => $settings, - 'config' => $config, - 'boardlist' => createBoardlist())); + ['settings' => $settings, 'config' => $config, 'boardlist' => createBoardlist()]); } } diff --git a/templates/themes/rand/info.php b/templates/themes/rand/info.php index c226e2e4..833c0c78 100644 --- a/templates/themes/rand/info.php +++ b/templates/themes/rand/info.php @@ -1,5 +1,5 @@ <?php - $theme = array(); + $theme = []; // Theme name $theme['name'] = 'Random Overboard'; @@ -8,39 +8,13 @@ $theme['version'] = 'v0.2'; // Theme configuration - $theme['config'] = array(); + $theme['config'] = []; - $theme['config'][] = array( - 'title' => 'Board name', - 'name' => 'title', - 'type' => 'text', - 'default' => 'Random' - ); - $theme['config'][] = array( - 'title' => 'Board URI', - 'name' => 'uri', - 'type' => 'text', - 'default' => '.', - 'comment' => '(rand for example)' - ); - $theme['config'][] = array( - 'title' => 'Subtitle', - 'name' => 'subtitle', - 'type' => 'text', - 'comment' => '(%s = thread limit. for example "%s freshly bumped threads")' - ); - $theme['config'][] = array( - 'title' => 'Excluded boards', - 'name' => 'exclude', - 'type' => 'text', - 'comment' => '(space seperated)' - ); - $theme['config'][] = array( - 'title' => 'Number of threads', - 'name' => 'thread_limit', - 'type' => 'text', - 'default' => '15', - ); + $theme['config'][] = ['title' => 'Board name', 'name' => 'title', 'type' => 'text', 'default' => 'Random']; + $theme['config'][] = ['title' => 'Board URI', 'name' => 'uri', 'type' => 'text', 'default' => '.', 'comment' => '(rand for example)']; + $theme['config'][] = ['title' => 'Subtitle', 'name' => 'subtitle', 'type' => 'text', 'comment' => '(%s = thread limit. for example "%s freshly bumped threads")']; + $theme['config'][] = ['title' => 'Excluded boards', 'name' => 'exclude', 'type' => 'text', 'comment' => '(space seperated)']; + $theme['config'][] = ['title' => 'Number of threads', 'name' => 'thread_limit', 'type' => 'text', 'default' => '15']; // Unique function name for building everything $theme['build_function'] = 'rand_build'; $theme['install_callback'] = 'rand_install'; diff --git a/templates/themes/rand/theme.php b/templates/themes/rand/theme.php index e3814c4e..14a78b59 100644 --- a/templates/themes/rand/theme.php +++ b/templates/themes/rand/theme.php @@ -6,7 +6,7 @@ $rand->settings = $settings; file_write($settings['uri'] . '/index.html', $rand->build()); - file_write($settings['uri'] . '/rand.js', Element('themes/rand/rand.js', array())); + file_write($settings['uri'] . '/rand.js', Element('themes/rand/rand.js', [])); } class rand { @@ -16,17 +16,12 @@ $boards = listBoards(); $body = ''; - $overflow = array(); - $board = array( - 'dir' => $this->settings['uri'] . "/", - 'url' => $this->settings['uri'], - 'name' => $this->settings['title'], - 'title' => sprintf($this->settings['subtitle'], $this->settings['thread_limit']) - ); + $overflow = []; + $board = ['dir' => $this->settings['uri'] . "/", 'url' => $this->settings['uri'], 'name' => $this->settings['title'], 'title' => sprintf($this->settings['subtitle'], $this->settings['thread_limit'])]; $query = ''; foreach($boards as &$_board) { - if(in_array($_board['uri'], explode(' ', $this->settings['exclude']))) + if(in_array($_board['uri'], explode(' ', (string) $this->settings['exclude']))) continue; $query .= sprintf("SELECT *, '%s' AS `board` FROM ``posts_%s`` WHERE `thread` IS NULL UNION ALL ", $_board['uri'], $_board['uri']); } @@ -34,7 +29,7 @@ $query = query($query) or error(db_error()); $count = 0; - $threads = array(); + $threads = []; while($post = $query->fetch()) { if(!isset($threads[$post['board']])) { @@ -81,23 +76,16 @@ if(floor($threads[$post['board']] / $config['threads_per_page']) > 0) { $page = floor($threads[$post['board']] / $config['threads_per_page']) + 1; } - $overflow[] = array('id' => $post['id'], 'board' => $post['board'], 'page' => $page . '.html'); + $overflow[] = ['id' => $post['id'], 'board' => $post['board'], 'page' => $page . '.html']; } $count += 1; } - $body .= '<script> var overflow = ' . json_encode($overflow) . '</script>'; + $body .= '<script> var overflow = ' . json_encode($overflow, JSON_THROW_ON_ERROR) . '</script>'; $body .= '<script type="text/javascript" src="/'.$this->settings['uri'].'/rand.js"></script>'; - return Element('index.html', array( - 'config' => $config, - 'board' => $board, - 'no_post_form' => true, - 'body' => $body, - 'mod' => $mod, - 'boardlist' => createBoardlist($mod), - )); + return Element('index.html', ['config' => $config, 'board' => $board, 'no_post_form' => true, 'body' => $body, 'mod' => $mod, 'boardlist' => createBoardlist($mod)]); } }; diff --git a/templates/themes/recent/info.php b/templates/themes/recent/info.php index bea3513c..188f9dfe 100644 --- a/templates/themes/recent/info.php +++ b/templates/themes/recent/info.php @@ -1,76 +1,30 @@ <?php - $theme = Array(); + $theme = []; // Theme name - $theme['name'] = 'RecentPosts'; + $theme['name'] = \RecentPosts::class; // Description (you can use Tinyboard markup here) $theme['description'] = 'Show recent posts and images, like 4chan.'; $theme['version'] = 'v1.0'; // Theme configuration - $theme['config'] = Array(); + $theme['config'] = []; - $theme['config'][] = Array( - 'title' => 'Title', - 'name' => 'title', - 'type' => 'text', - 'default' => 'Recent Posts' - ); + $theme['config'][] = ['title' => 'Title', 'name' => 'title', 'type' => 'text', 'default' => 'Recent Posts']; - $theme['config'][] = Array( - 'title' => 'Excluded boards', - 'name' => 'exclude', - 'type' => 'text', - 'comment' => '(space seperated)' - ); + $theme['config'][] = ['title' => 'Excluded boards', 'name' => 'exclude', 'type' => 'text', 'comment' => '(space seperated)']; - $theme['config'][] = Array( - 'title' => '# of recent images', - 'name' => 'limit_images', - 'type' => 'text', - 'default' => '3', - 'comment' => '(maximum images to display)' - ); + $theme['config'][] = ['title' => '# of recent images', 'name' => 'limit_images', 'type' => 'text', 'default' => '3', 'comment' => '(maximum images to display)']; - $theme['config'][] = Array( - 'title' => '# of recent posts', - 'name' => 'limit_posts', - 'type' => 'text', - 'default' => '30', - 'comment' => '(maximum posts to display)' - ); + $theme['config'][] = ['title' => '# of recent posts', 'name' => 'limit_posts', 'type' => 'text', 'default' => '30', 'comment' => '(maximum posts to display)']; - $theme['config'][] = Array( - 'title' => 'HTML file', - 'name' => 'html', - 'type' => 'text', - 'default' => 'recent.html', - 'comment' => '(eg. "recent.html")' - ); + $theme['config'][] = ['title' => 'HTML file', 'name' => 'html', 'type' => 'text', 'default' => 'recent.html', 'comment' => '(eg. "recent.html")']; - $theme['config'][] = Array( - 'title' => 'CSS file', - 'name' => 'css', - 'type' => 'text', - 'default' => 'recent.css', - 'comment' => '(eg. "recent.css")' - ); + $theme['config'][] = ['title' => 'CSS file', 'name' => 'css', 'type' => 'text', 'default' => 'recent.css', 'comment' => '(eg. "recent.css")']; - $theme['config'][] = Array( - 'title' => 'CSS stylesheet name', - 'name' => 'basecss', - 'type' => 'text', - 'default' => 'recent.css', - 'comment' => '(eg. "recent.css" - see templates/themes/recent for details)' - ); + $theme['config'][] = ['title' => 'CSS stylesheet name', 'name' => 'basecss', 'type' => 'text', 'default' => 'recent.css', 'comment' => '(eg. "recent.css" - see templates/themes/recent for details)']; - $theme['config'][] = Array( - 'title' => '# of recent news', - 'name' => 'limit_news', - 'type' => 'text', - 'default' => '1', - 'comment' => '(maximum news to display)' - ); + $theme['config'][] = ['title' => '# of recent news', 'name' => 'limit_news', 'type' => 'text', 'default' => '1', 'comment' => '(maximum news to display)']; // Unique function name for building everything $theme['build_function'] = 'recentposts_build'; $theme['install_callback'] = 'recentposts_install'; @@ -78,11 +32,11 @@ if (!function_exists('recentposts_install')) { function recentposts_install($settings) { if (!is_numeric($settings['limit_news']) || $settings['limit_news'] < 0) - return Array(false, '<strong>' . utf8tohtml($settings['limit_news']) . '</strong> is not a non-negative integer.'); + return [false, '<strong>' . utf8tohtml($settings['limit_news']) . '</strong> is not a non-negative integer.']; if (!is_numeric($settings['limit_images']) || $settings['limit_images'] < 0) - return Array(false, '<strong>' . utf8tohtml($settings['limit_images']) . '</strong> is not a non-negative integer.'); + return [false, '<strong>' . utf8tohtml($settings['limit_images']) . '</strong> is not a non-negative integer.']; if (!is_numeric($settings['limit_posts']) || $settings['limit_posts'] < 0) - return Array(false, '<strong>' . utf8tohtml($settings['limit_posts']) . '</strong> is not a non-negative integer.'); + return [false, '<strong>' . utf8tohtml($settings['limit_posts']) . '</strong> is not a non-negative integer.']; } } diff --git a/templates/themes/recent/theme.php b/templates/themes/recent/theme.php index ecc3adfb..e51061db 100644 --- a/templates/themes/recent/theme.php +++ b/templates/themes/recent/theme.php @@ -22,10 +22,10 @@ copy('templates/themes/recent/' . $settings['basecss'], $config['dir']['home'] . "stylesheets/" . $settings['css']); } - $this->excluded = explode(' ', $settings['exclude']); + $this->excluded = explode(' ', (string) $settings['exclude']); if ($action == 'all' || $action == 'post' || $action == 'post-thread' || $action == 'post-delete') { - $action = generation_strategy('sb_recent', array()); + $action = generation_strategy('sb_recent', []); if ($action == 'delete') { file_unlink($config['dir']['home'] . $settings['html']); } @@ -37,11 +37,12 @@ // Build news page public function homepage($settings) { - global $config, $board; + $files = []; + global $config, $board; - $recent_images = Array(); - $recent_posts = Array(); - $stats = Array(); + $recent_images = []; + $recent_posts = []; + $stats = []; $boards = listBoards(); @@ -63,7 +64,7 @@ openBoard($post['board']); if (isset($post['files'])) - $files = json_decode($post['files']); + $files = json_decode((string) $post['files'], null, 512, JSON_THROW_ON_ERROR); if ($files[0]->file == 'deleted' || $files[0]->thumb == 'file') continue; @@ -145,22 +146,14 @@ $files = $query->fetchAll(); $stats['active_content'] = 0; foreach ($files as &$file) { - preg_match_all('/"size":([0-9]*)/', $file[0], $matches); + preg_match_all('/"size":([0-9]*)/', (string) $file[0], $matches); $stats['active_content'] += array_sum($matches[1]); } $query = query("SELECT * FROM ``news`` ORDER BY `time` DESC" . ($settings['limit_news'] ? ' LIMIT ' . $settings['limit_news'] : '')) or error(db_error()); $recent_news = $query->fetchAll(PDO::FETCH_ASSOC); - return Element('themes/recent/recent.html', Array( - 'settings' => $settings, - 'config' => $config, - 'boardlist' => createBoardlist(), - 'recent_images' => $recent_images, - 'recent_posts' => $recent_posts, - 'stats' => $stats, - 'recent_news' => $recent_news, - )); + return Element('themes/recent/recent.html', ['settings' => $settings, 'config' => $config, 'boardlist' => createBoardlist(), 'recent_images' => $recent_images, 'recent_posts' => $recent_posts, 'stats' => $stats, 'recent_news' => $recent_news]); } }; diff --git a/templates/themes/rss/info.php b/templates/themes/rss/info.php index 4da43bf0..62832341 100755 --- a/templates/themes/rss/info.php +++ b/templates/themes/rss/info.php @@ -1,5 +1,5 @@ <?php - $theme = Array(); + $theme = []; // Theme name $theme['name'] = 'RSS'; @@ -8,59 +8,21 @@ $theme['version'] = 'v0.1'; // Theme configuration - $theme['config'] = Array(); + $theme['config'] = []; - $theme['config'][] = Array( - 'title' => 'Title', - 'name' => 'title', - 'type' => 'text', - 'default' => 'Recent Posts RSS' - ); + $theme['config'][] = ['title' => 'Title', 'name' => 'title', 'type' => 'text', 'default' => 'Recent Posts RSS']; - $theme['config'][] = Array( - 'title' => 'Excluded boards', - 'name' => 'exclude', - 'type' => 'text', - 'comment' => '(space seperated)' - ); + $theme['config'][] = ['title' => 'Excluded boards', 'name' => 'exclude', 'type' => 'text', 'comment' => '(space seperated)']; - $theme['config'][] = Array( - 'title' => '# of recent posts', - 'name' => 'limit_posts', - 'type' => 'text', - 'default' => '30', - 'comment' => '(maximum posts to display)' - ); + $theme['config'][] = ['title' => '# of recent posts', 'name' => 'limit_posts', 'type' => 'text', 'default' => '30', 'comment' => '(maximum posts to display)']; - $theme['config'][] = Array( - 'title' => 'XML file', - 'name' => 'xml', - 'type' => 'text', - 'default' => 'recent.xml', - 'comment' => '(eg. "recent.xml")' - ); + $theme['config'][] = ['title' => 'XML file', 'name' => 'xml', 'type' => 'text', 'default' => 'recent.xml', 'comment' => '(eg. "recent.xml")']; - $theme['config'][] = Array( - 'title' => 'Base URL', - 'name' => 'base_url', - 'type' => 'text', - 'default' => 'http://test.com', - 'comment' => '(eg. "http://test.com")' - ); + $theme['config'][] = ['title' => 'Base URL', 'name' => 'base_url', 'type' => 'text', 'default' => 'http://test.com', 'comment' => '(eg. "http://test.com")']; - $theme['config'][] = Array( - 'title' => 'Show Threads Only', - 'name' => 'show_threads_only', - 'type' => 'text', - 'default' => 'false', - ); + $theme['config'][] = ['title' => 'Show Threads Only', 'name' => 'show_threads_only', 'type' => 'text', 'default' => 'false']; - $theme['config'][] = Array( - 'title' => 'Enable Per Board', - 'name' => 'enable_per_board', - 'type' => 'text', - 'default' => 'false', - ); + $theme['config'][] = ['title' => 'Enable Per Board', 'name' => 'enable_per_board', 'type' => 'text', 'default' => 'false']; // Unique function name for building everything $theme['build_function'] = 'rss_recentposts_build'; @@ -69,7 +31,7 @@ if (!function_exists('rss_recentposts_install')) { function rss_recentposts_install($settings) { if (!is_numeric($settings['limit_posts']) || $settings['limit_posts'] < 0) - return Array(false, '<strong>' . utf8tohtml($settings['limit_posts']) . '</strong> is not a non-negative integer.'); + return [false, '<strong>' . utf8tohtml($settings['limit_posts']) . '</strong> is not a non-negative integer.']; } } diff --git a/templates/themes/rss/theme.php b/templates/themes/rss/theme.php index 4b0c86a5..9549559d 100755 --- a/templates/themes/rss/theme.php +++ b/templates/themes/rss/theme.php @@ -19,7 +19,7 @@ global $config, $_theme,$board; - $this->excluded = explode(' ', $settings['exclude']); + $this->excluded = explode(' ', (string) $settings['exclude']); if ($settings['show_threads_only'] == 'true'){ if ($action == 'all' || $action == 'post-thread' || $action == 'post-delete') file_write($config['dir']['home'] . $settings['xml'], $this->site_rsspage($settings)); @@ -68,7 +68,7 @@ public function site_rsspage($settings) { global $config, $board; - $recent_posts = Array(); + $recent_posts = []; $boards = listBoards(); @@ -89,7 +89,7 @@ while ($post = $query->fetch(PDO::FETCH_ASSOC)) { openBoard($post['board']); - $post['link'] = $config['root'] . $board['dir'] . $config['dir']['res'] . sprintf($config['file_page'], ($post['thread'] ? $post['thread'] : $post['id'])) . '#' . $post['id']; + $post['link'] = $config['root'] . $board['dir'] . $config['dir']['res'] . sprintf($config['file_page'], ($post['thread'] ?: $post['id'])) . '#' . $post['id']; $post['snippet'] = pm_snippet($post['body'], 30); $post['board_name'] = $board['name']; @@ -97,18 +97,14 @@ } - return Element('themes/rss/rss.xml', Array( - 'settings' => $settings, - 'config' => $config, - 'recent_posts' => $recent_posts, - )); + return Element('themes/rss/rss.xml', ['settings' => $settings, 'config' => $config, 'recent_posts' => $recent_posts]); } // Build news page public function board_rsspage($settings,$_board) { global $config, $board; - $recent_posts = Array(); + $recent_posts = []; $query = ''; if ($settings['show_threads_only'] == 'true'){ @@ -123,7 +119,7 @@ while ($post = $query->fetch(PDO::FETCH_ASSOC)) { openBoard($post['board']); - $post['link'] = $config['root'] . $board['dir'] . $config['dir']['res'] . sprintf($config['file_page'], ($post['thread'] ? $post['thread'] : $post['id'])) . '#' . $post['id']; + $post['link'] = $config['root'] . $board['dir'] . $config['dir']['res'] . sprintf($config['file_page'], ($post['thread'] ?: $post['id'])) . '#' . $post['id']; $post['snippet'] = pm_snippet($post['body'], 30); $post['board_name'] = $board['name']; @@ -131,18 +127,14 @@ } - return Element('themes/rss/rss.xml', Array( - 'settings' => $settings, - 'config' => $config, - 'recent_posts' => $recent_posts, - )); + return Element('themes/rss/rss.xml', ['settings' => $settings, 'config' => $config, 'recent_posts' => $recent_posts]); } // Build news page public function overboard_rsspage($settings,$overboard) { global $config, $board; - $recent_posts = Array(); + $recent_posts = []; $boards = listBoards(); @@ -178,7 +170,7 @@ while ($post = $query->fetch(PDO::FETCH_ASSOC)) { openBoard($post['board']); - $post['link'] = $config['root'] . $post['board'] . $config['dir']['res'] . sprintf($config['file_page'], ($post['thread'] ? $post['thread'] : $post['id'])) . '#' . $post['id']; + $post['link'] = $config['root'] . $post['board'] . $config['dir']['res'] . sprintf($config['file_page'], ($post['thread'] ?: $post['id'])) . '#' . $post['id']; $post['snippet'] = pm_snippet($post['body'], 30); $post['board_name'] = $post['board']; @@ -186,11 +178,7 @@ } - return Element('themes/rss/rss.xml', Array( - 'settings' => $settings, - 'config' => $config, - 'recent_posts' => $recent_posts, - )); + return Element('themes/rss/rss.xml', ['settings' => $settings, 'config' => $config, 'recent_posts' => $recent_posts]); } }; diff --git a/templates/themes/rules/info.php b/templates/themes/rules/info.php index 7faaedc6..31f42d79 100755 --- a/templates/themes/rules/info.php +++ b/templates/themes/rules/info.php @@ -1,23 +1,3 @@ <?php -$theme = array( - 'name' => 'Rules', - 'description' => 'Display the lainchan rules', - 'version' => 'v1', - - 'config' => array( - array('title' => 'Page title', - 'name' => 'title', - 'type' => 'text'), - - array('title' => 'Slogan', - 'name' => 'subtitle', - 'type' => 'text', - 'comment' => '(optional)'), - - array('title' => 'File', - 'name' => 'file', - 'type' => 'text', - 'default' => 'rules.html')), - - 'build_function' => 'rules_build'); +$theme = ['name' => 'Rules', 'description' => 'Display the lainchan rules', 'version' => 'v1', 'config' => [['title' => 'Page title', 'name' => 'title', 'type' => 'text'], ['title' => 'Slogan', 'name' => 'subtitle', 'type' => 'text', 'comment' => '(optional)'], ['title' => 'File', 'name' => 'file', 'type' => 'text', 'default' => 'rules.html']], 'build_function' => 'rules_build']; ?>
\ No newline at end of file diff --git a/templates/themes/rules/theme.php b/templates/themes/rules/theme.php index fc50437f..457f4067 100755 --- a/templates/themes/rules/theme.php +++ b/templates/themes/rules/theme.php @@ -19,10 +19,8 @@ class rules { global $config; return Element('themes/rules/rules.html', - array('settings' => $settings, - 'config' => $config, - 'boardlist' => createBoardlist())); + ['settings' => $settings, 'config' => $config, 'boardlist' => createBoardlist()]); } } -?>
\ No newline at end of file +?> diff --git a/templates/themes/semirand/info.php b/templates/themes/semirand/info.php index 8590a205..ddf4c08d 100644 --- a/templates/themes/semirand/info.php +++ b/templates/themes/semirand/info.php @@ -1,64 +1,18 @@ <?php // Basic theme properties - $theme = array( - 'name' => 'Mixed All/Random Overboard', - // Description (you can use Tinyboard markup here) - 'description' => 'Board with threads from all boards with most recently bumped and random ones intermixed', - 'version' => 'v0.1', - // Unique function name for building and installing whatever's necessary - 'build_function' => 'semirand_build', - 'install_callback' => 'semirand_install', - ); + $theme = [ + 'name' => 'Mixed All/Random Overboard', + // Description (you can use Tinyboard markup here) + 'description' => 'Board with threads from all boards with most recently bumped and random ones intermixed', + 'version' => 'v0.1', + // Unique function name for building and installing whatever's necessary + 'build_function' => 'semirand_build', + 'install_callback' => 'semirand_install', + ]; // Theme configuration - $theme['config'] = array( - array( - 'title' => 'Board name', - 'name' => 'title', - 'type' => 'text', - 'default' => 'Semirandom', - ), - array( - 'title' => 'Board URI', - 'name' => 'uri', - 'type' => 'text', - 'default' => '.', - 'comment' => '("mixed", for example)', - ), - array( - 'title' => 'Subtitle', - 'name' => 'subtitle', - 'type' => 'text', - 'comment' => '(%s = thread limit, for example "%s coolest threads")', - ), - array( - 'title' => 'Excluded boards', - 'name' => 'exclude', - 'type' => 'text', - 'comment' => '(space seperated)', - ), - array( - 'title' => 'Number of threads', - 'name' => 'thread_limit', - 'type' => 'text', - 'default' => '15', - ), - array( - 'title' => 'Random threads', - 'name' => 'random_count', - 'comment' => '(number of consecutive random threads)', - 'type' => 'text', - 'default' => '1', - ), - array( - 'title' => 'Bumped threads', - 'name' => 'recent_count', - 'comment' => '(number of consecutive recent threads)', - 'type' => 'text', - 'default' => '1', - ), - ); + $theme['config'] = [['title' => 'Board name', 'name' => 'title', 'type' => 'text', 'default' => 'Semirandom'], ['title' => 'Board URI', 'name' => 'uri', 'type' => 'text', 'default' => '.', 'comment' => '("mixed", for example)'], ['title' => 'Subtitle', 'name' => 'subtitle', 'type' => 'text', 'comment' => '(%s = thread limit, for example "%s coolest threads")'], ['title' => 'Excluded boards', 'name' => 'exclude', 'type' => 'text', 'comment' => '(space seperated)'], ['title' => 'Number of threads', 'name' => 'thread_limit', 'type' => 'text', 'default' => '15'], ['title' => 'Random threads', 'name' => 'random_count', 'comment' => '(number of consecutive random threads)', 'type' => 'text', 'default' => '1'], ['title' => 'Bumped threads', 'name' => 'recent_count', 'comment' => '(number of consecutive recent threads)', 'type' => 'text', 'default' => '1']]; if (!function_exists('semirand_install')) { function semirand_install($settings) { diff --git a/templates/themes/semirand/theme.php b/templates/themes/semirand/theme.php index e8d3e56c..ba93f87a 100644 --- a/templates/themes/semirand/theme.php +++ b/templates/themes/semirand/theme.php @@ -23,7 +23,7 @@ // Copy the generated board HTML to its place file_write($settings['uri'] . '/index.html', $semirand->build()); file_write($settings['uri'] . '/semirand.js', - Element('themes/semirand/semirand.js', array())); + Element('themes/semirand/semirand.js', [])); } } @@ -48,7 +48,7 @@ error('Invalid configuration parameters.', true); } - $settings['exclude'] = explode(' ', $settings['exclude']); + $settings['exclude'] = explode(' ', (string) $settings['exclude']); $settings['thread_limit'] = intval($settings['thread_limit']); $settings['random_count'] = intval($settings['random_count']); $settings['recent_count'] = intval($settings['recent_count']); @@ -101,10 +101,10 @@ private function shuffleThreads($threads) { $random_count = $this->settings['random_count']; $recent_count = $this->settings['recent_count']; - $total = count($threads); + $total = is_countable($threads) ? count($threads) : 0; // Storage for threads that will be randomly interspersed - $shuffled = array(); + $shuffled = []; // Ratio of bumped / all threads $topRatio = $recent_count / ($recent_count + $random_count); @@ -148,9 +148,7 @@ } // Count the number of omitted image replies - $omitted_img_count = count(array_filter($replies, function($p) { - return $p['files'] !== ''; - })); + $omitted_img_count = count(array_filter($replies, fn($p) => $p['files'] !== '')); // Set the corresponding omitted numbers on the thread if (!empty($replies)) { @@ -178,16 +176,16 @@ global $config; $html = ''; - $overflow = array(); + $overflow = []; // Fetch threads from all boards and chomp the first 'n' posts, depending // on the setting $threads = $this->shuffleThreads($this->fetchThreads()); - $total_count = count($threads); + $total_count = is_countable($threads) ? count($threads) : 0; // Top threads displayed on load $top_threads = array_splice($threads, 0, $this->settings['thread_limit']); // Number of processed threads by board - $counts = array(); + $counts = []; // Output threads up to the specified limit foreach ($top_threads as $post) { @@ -212,30 +210,14 @@ if ($board_page > 0) { $page = $board_page + 1; } - $overflow[] = array( - 'id' => $post['id'], - 'board' => $post['board'], - 'page' => $page . '.html' - ); + $overflow[] = ['id' => $post['id'], 'board' => $post['board'], 'page' => $page . '.html']; } - $html .= '<script>var ukko_overflow = ' . json_encode($overflow) . '</script>'; + $html .= '<script>var ukko_overflow = ' . json_encode($overflow, JSON_THROW_ON_ERROR) . '</script>'; $html .= '<script type="text/javascript" src="/'.$this->settings['uri'].'/semirand.js"></script>'; - return Element('index.html', array( - 'config' => $config, - 'board' => array( - 'dir' => $this->settings['uri'] . "/", - 'url' => $this->settings['uri'], - 'title' => $this->settings['title'], - 'subtitle' => str_replace('%s', $this->settings['thread_limit'], - strval(min($this->settings['subtitle'], $total_count))), - ), - 'no_post_form' => true, - 'body' => $html, - 'mod' => $mod, - 'boardlist' => createBoardlist($mod), - )); + return Element('index.html', ['config' => $config, 'board' => ['dir' => $this->settings['uri'] . "/", 'url' => $this->settings['uri'], 'title' => $this->settings['title'], 'subtitle' => str_replace('%s', $this->settings['thread_limit'], + strval(min($this->settings['subtitle'], $total_count)))], 'no_post_form' => true, 'body' => $html, 'mod' => $mod, 'boardlist' => createBoardlist($mod)]); } }; diff --git a/templates/themes/sitemap/info.php b/templates/themes/sitemap/info.php index 0ea2ba9d..058bed4d 100644 --- a/templates/themes/sitemap/info.php +++ b/templates/themes/sitemap/info.php @@ -1,5 +1,5 @@ <?php - $theme = Array(); + $theme = []; // Theme name $theme['name'] = 'Sitemap Generator'; @@ -8,55 +8,21 @@ $theme['version'] = 'v1.0'; // Theme configuration - $theme['config'] = Array(); + $theme['config'] = []; - $theme['config'][] = Array( - 'title' => 'Sitemap Path', - 'name' => 'path', - 'type' => 'text', - 'default' => 'sitemap.xml', - 'size' => '20' - ); + $theme['config'][] = ['title' => 'Sitemap Path', 'name' => 'path', 'type' => 'text', 'default' => 'sitemap.xml', 'size' => '20']; - $theme['config'][] = Array( - 'title' => 'URL prefix', - 'name' => 'url', - 'type' => 'text', - 'comment' => '(with trailing slash)', - 'default' => (isset($_SERVER['HTTP_HOST']) ? 'http://' . $_SERVER['HTTP_HOST'] . $config['root'] : ''), - 'size' => '20' - ); + $theme['config'][] = ['title' => 'URL prefix', 'name' => 'url', 'type' => 'text', 'comment' => '(with trailing slash)', 'default' => (isset($_SERVER['HTTP_HOST']) ? 'http://' . $_SERVER['HTTP_HOST'] . $config['root'] : ''), 'size' => '20']; - $theme['config'][] = Array( - 'title' => 'Thread change frequency', - 'name' => 'changefreq', - 'type' => 'text', - 'comment' => '(eg. "hourly", "daily", etc.)', - 'default' => 'hourly', - 'size' => '20' - ); + $theme['config'][] = ['title' => 'Thread change frequency', 'name' => 'changefreq', 'type' => 'text', 'comment' => '(eg. "hourly", "daily", etc.)', 'default' => 'hourly', 'size' => '20']; - $theme['config'][] = Array( - 'title' => 'Minimum time between regenerating', - 'name' => 'regen_time', - 'type' => 'text', - 'comment' => '(in seconds)', - 'default' => '0', - 'size' => '8' - ); + $theme['config'][] = ['title' => 'Minimum time between regenerating', 'name' => 'regen_time', 'type' => 'text', 'comment' => '(in seconds)', 'default' => '0', 'size' => '8']; $__boards = listBoards(); - $__default_boards = Array(); + $__default_boards = []; foreach ($__boards as $__board) $__default_boards[] = $__board['uri']; - $theme['config'][] = Array( - 'title' => 'Boards', - 'name' => 'boards', - 'type' => 'text', - 'comment' => '(boards to include; space seperated)', - 'size' => 24, - 'default' => implode(' ', $__default_boards) - ); + $theme['config'][] = ['title' => 'Boards', 'name' => 'boards', 'type' => 'text', 'comment' => '(boards to include; space seperated)', 'size' => 24, 'default' => implode(' ', $__default_boards)]; $theme['build_function'] = 'sitemap_build'; diff --git a/templates/themes/sitemap/theme.php b/templates/themes/sitemap/theme.php index 6bc035bb..a04b9f7c 100644 --- a/templates/themes/sitemap/theme.php +++ b/templates/themes/sitemap/theme.php @@ -23,26 +23,21 @@ } } - $action = generation_strategy('sb_sitemap', array()); + $action = generation_strategy('sb_sitemap', []); if ($action == 'delete') { file_unlink($settings['path']); } elseif ($action == 'rebuild') { - $boards = explode(' ', $settings['boards']); + $boards = explode(' ', (string) $settings['boards']); - $threads = array(); + $threads = []; foreach ($boards as $board) { $query = query(sprintf("SELECT `id`, `id` AS `thread_id`, `slug`, (SELECT `time` FROM ``posts_%s`` WHERE `thread` = `thread_id` OR `id` = `thread_id` ORDER BY `time` DESC LIMIT 1) AS `lastmod` FROM ``posts_%s`` WHERE `thread` IS NULL", $board, $board)) or error(db_error()); $threads[$board] = $query->fetchAll(PDO::FETCH_ASSOC); } - file_write($settings['path'], Element('themes/sitemap/sitemap.xml', Array( - 'settings' => $settings, - 'config' => $config, - 'threads' => $threads, - 'boards' => $boards, - ))); + file_write($settings['path'], Element('themes/sitemap/sitemap.xml', ['settings' => $settings, 'config' => $config, 'threads' => $threads, 'boards' => $boards])); } } diff --git a/templates/themes/staffapplication/info.php b/templates/themes/staffapplication/info.php index a8093093..64915b38 100644 --- a/templates/themes/staffapplication/info.php +++ b/templates/themes/staffapplication/info.php @@ -1,35 +1,20 @@ <?php - $theme = Array(); + $theme = []; // Theme name - $theme['name'] = 'StaffApplication'; + $theme['name'] = \StaffApplication::class; // Description (you can use Tinyboard markup here) $theme['description'] = 'Staff Application theme.'; $theme['version'] = 'v0.0.1'; // Theme configuration - $theme['config'] = Array(); + $theme['config'] = []; - $theme['config'][] = Array( - 'title' => 'Site title', - 'name' => 'title', - 'type' => 'text' - ); + $theme['config'][] = ['title' => 'Site title', 'name' => 'title', 'type' => 'text']; - $theme['config'][] = Array( - 'title' => 'Slogan', - 'name' => 'subtitle', - 'type' => 'text', - 'comment' => '(optional)' - ); + $theme['config'][] = ['title' => 'Slogan', 'name' => 'subtitle', 'type' => 'text', 'comment' => '(optional)']; - $theme['config'][] = Array( - 'title' => 'File', - 'name' => 'file', - 'type' => 'text', - 'default' => $config['file_index'], - 'comment' => '(eg. "index.html")' - ); + $theme['config'][] = ['title' => 'File', 'name' => 'file', 'type' => 'text', 'default' => $config['file_index'], 'comment' => '(eg. "index.html")']; // Unique function name for building everything $theme['build_function'] = 'staffapplication_build'; diff --git a/templates/themes/staffapplication/staffapplicationpost.php b/templates/themes/staffapplication/staffapplicationpost.php index 0e1b14ca..4d850cc2 100644 --- a/templates/themes/staffapplication/staffapplicationpost.php +++ b/templates/themes/staffapplication/staffapplicationpost.php @@ -43,12 +43,6 @@ $displaymessage = "<p style=\"text-align:center;\">ANTISPAM NOT SET</p>\r\n"; } $displaymessage .= '<span style="text-align:center; display: block;" >[ <a href="https://lainchan.org/"> Return Home </a> ]</span>'; -echo Element('page.html', array( - 'index' => $config['root'], - 'title' => _('Staff Application'), - 'config' => $config, - 'boardlist' => createBoardlist(isset($mod) ? $mod : false), - 'body' => $displaymessage, - ) +echo Element('page.html', ['index' => $config['root'], 'title' => _('Staff Application'), 'config' => $config, 'boardlist' => createBoardlist($mod ?? false), 'body' => $displaymessage] ); ?> diff --git a/templates/themes/staffapplication/theme.php b/templates/themes/staffapplication/theme.php index a827a7f8..e94e09b7 100644 --- a/templates/themes/staffapplication/theme.php +++ b/templates/themes/staffapplication/theme.php @@ -24,11 +24,7 @@ public static function htmlpage($settings) { global $config; - return Element('themes/staffapplication/staffapplication.html', Array( - 'settings' => $settings, - 'config' => $config, - 'boardlist' => createBoardlist() - )); + return Element('themes/staffapplication/staffapplication.html', ['settings' => $settings, 'config' => $config, 'boardlist' => createBoardlist()]); } public static function phppage($settings) { global $config; diff --git a/templates/themes/stream/info.php b/templates/themes/stream/info.php index d522032d..b0f67492 100644 --- a/templates/themes/stream/info.php +++ b/templates/themes/stream/info.php @@ -1,92 +1,32 @@ <?php - $theme = Array(); + $theme = []; // Theme name - $theme['name'] = 'Stream'; + $theme['name'] = \Stream::class; // Description (you can use Tinyboard markup here) $theme['description'] = 'Stream page'; $theme['version'] = 'v0.9.1'; // Theme configuration - $theme['config'] = Array(); + $theme['config'] = []; - $theme['config'][] = Array( - 'title' => 'Site title', - 'name' => 'title', - 'type' => 'text' - ); + $theme['config'][] = ['title' => 'Site title', 'name' => 'title', 'type' => 'text']; - $theme['config'][] = Array( - 'title' => 'Slogan', - 'name' => 'subtitle', - 'type' => 'text', - 'comment' => '(optional)' - ); + $theme['config'][] = ['title' => 'Slogan', 'name' => 'subtitle', 'type' => 'text', 'comment' => '(optional)']; - $theme['config'][] = Array( - 'title' => 'File', - 'name' => 'file', - 'type' => 'text', - 'default' => 'stream.html', - 'comment' => '(eg. "stream.html")' - ); - $theme['config'][] = Array( - 'title' => 'OGV stream URL', - 'name' => 'ogvurl', - 'type' => 'text', - 'default' => 'https://lainchan.org/icecast/lainstream.ogg' - ); - $theme['config'][] = Array( - 'title' => 'RTMP stream URL', - 'name' => 'rtmpurl', - 'type' => 'text', - 'default' => 'rtmp://lainchan.org/show/stream' - ); - $theme['config'][] = Array( - 'title' => 'RTMP Video.JS stream URL', - 'name' => 'rtmpvideojsurl', - 'type' => 'text', - 'default' => 'rtmp://lainchan.org/show/&stream' - ); + $theme['config'][] = ['title' => 'File', 'name' => 'file', 'type' => 'text', 'default' => 'stream.html', 'comment' => '(eg. "stream.html")']; + $theme['config'][] = ['title' => 'OGV stream URL', 'name' => 'ogvurl', 'type' => 'text', 'default' => 'https://lainchan.org/icecast/lainstream.ogg']; + $theme['config'][] = ['title' => 'RTMP stream URL', 'name' => 'rtmpurl', 'type' => 'text', 'default' => 'rtmp://lainchan.org/show/stream']; + $theme['config'][] = ['title' => 'RTMP Video.JS stream URL', 'name' => 'rtmpvideojsurl', 'type' => 'text', 'default' => 'rtmp://lainchan.org/show/&stream']; - $theme['config'][] = Array( - 'title' => 'RTMP HLS stream URL', - 'name' => 'hlsurl', - 'type' => 'text', - 'default' => 'https://lainchan.org:8080/hls/stream.m3u8' - ); + $theme['config'][] = ['title' => 'RTMP HLS stream URL', 'name' => 'hlsurl', 'type' => 'text', 'default' => 'https://lainchan.org:8080/hls/stream.m3u8']; - $theme['config'][] = Array( - 'title' => 'OGV Status URL', - 'name' => 'ogvstatus', - 'type' => 'text', - 'default' => '/radio_assets/status.xsl' - ); + $theme['config'][] = ['title' => 'OGV Status URL', 'name' => 'ogvstatus', 'type' => 'text', 'default' => '/radio_assets/status.xsl']; - $theme['config'][] = Array( - 'title' => 'RTMP Status URL', - 'name' => 'rtmpstatus', - 'type' => 'text', - 'default' => '/live/status?app=live&name=stream' - ); - $theme['config'][] = Array( - 'title' => 'RTMP Viewers URL', - 'name' => 'rtmpviewers', - 'type' => 'text', - 'default' => '/live/subs?app=live&name=stream' - ); - $theme['config'][] = Array( - 'title' => 'Formats', - 'name' => 'formats', - 'type' => 'text', - 'default' => 'hls ogg rtmp' - ); - $theme['config'][] = Array( - 'title' => 'Default Format', - 'name' => 'defaultformat', - 'type' => 'text', - 'default' => 'hls ogg rtmp' - ); + $theme['config'][] = ['title' => 'RTMP Status URL', 'name' => 'rtmpstatus', 'type' => 'text', 'default' => '/live/status?app=live&name=stream']; + $theme['config'][] = ['title' => 'RTMP Viewers URL', 'name' => 'rtmpviewers', 'type' => 'text', 'default' => '/live/subs?app=live&name=stream']; + $theme['config'][] = ['title' => 'Formats', 'name' => 'formats', 'type' => 'text', 'default' => 'hls ogg rtmp']; + $theme['config'][] = ['title' => 'Default Format', 'name' => 'defaultformat', 'type' => 'text', 'default' => 'hls ogg rtmp']; // Unique function name for building everything diff --git a/templates/themes/stream/theme.php b/templates/themes/stream/theme.php index 6d11a0dc..d37ceca9 100644 --- a/templates/themes/stream/theme.php +++ b/templates/themes/stream/theme.php @@ -23,11 +23,7 @@ global $config; - return Element('themes/stream/stream.html', Array( - 'settings' => $settings, - 'config' => $config, - 'boardlist' => createBoardlist(), - )); + return Element('themes/stream/stream.html', ['settings' => $settings, 'config' => $config, 'boardlist' => createBoardlist()]); } }; diff --git a/templates/themes/ukko/info.php b/templates/themes/ukko/info.php index 9a0a53e6..f9b27520 100644 --- a/templates/themes/ukko/info.php +++ b/templates/themes/ukko/info.php @@ -1,5 +1,5 @@ <?php - $theme = array(); + $theme = []; // Theme name $theme['name'] = 'Overboard (Ukko)'; @@ -8,39 +8,13 @@ $theme['version'] = 'v0.2'; // Theme configuration - $theme['config'] = array(); + $theme['config'] = []; - $theme['config'][] = array( - 'title' => 'Board name', - 'name' => 'title', - 'type' => 'text', - 'default' => 'Ukko' - ); - $theme['config'][] = array( - 'title' => 'Board URI', - 'name' => 'uri', - 'type' => 'text', - 'default' => '*', - 'comment' => '(ukko for example)' - ); - $theme['config'][] = array( - 'title' => 'Subtitle', - 'name' => 'subtitle', - 'type' => 'text', - 'comment' => '(%s = thread limit. for example "%s freshly bumped threads")' - ); - $theme['config'][] = array( - 'title' => 'Excluded boards', - 'name' => 'exclude', - 'type' => 'text', - 'comment' => '(space seperated)' - ); - $theme['config'][] = array( - 'title' => 'Number of threads', - 'name' => 'thread_limit', - 'type' => 'text', - 'default' => '15', - ); + $theme['config'][] = ['title' => 'Board name', 'name' => 'title', 'type' => 'text', 'default' => 'Ukko']; + $theme['config'][] = ['title' => 'Board URI', 'name' => 'uri', 'type' => 'text', 'default' => '*', 'comment' => '(ukko for example)']; + $theme['config'][] = ['title' => 'Subtitle', 'name' => 'subtitle', 'type' => 'text', 'comment' => '(%s = thread limit. for example "%s freshly bumped threads")']; + $theme['config'][] = ['title' => 'Excluded boards', 'name' => 'exclude', 'type' => 'text', 'comment' => '(space seperated)']; + $theme['config'][] = ['title' => 'Number of threads', 'name' => 'thread_limit', 'type' => 'text', 'default' => '15']; // Unique function name for building everything $theme['build_function'] = 'ukko_build'; $theme['install_callback'] = 'ukko_install'; @@ -49,7 +23,7 @@ function ukko_install($settings) { if (!file_exists($settings['uri'])) @mkdir($settings['uri'], 0777) or error("Couldn't create " . $settings['uri'] . ". Check permissions.", true); - file_write($settings['uri'] . '/ukko.js', Element('themes/ukko/ukko.js', array())); + file_write($settings['uri'] . '/ukko.js', Element('themes/ukko/ukko.js', [])); } } diff --git a/templates/themes/ukko/theme.php b/templates/themes/ukko/theme.php index d08b6769..4b729514 100644 --- a/templates/themes/ukko/theme.php +++ b/templates/themes/ukko/theme.php @@ -11,7 +11,7 @@ return; } - $action = generation_strategy('sb_ukko', array()); + $action = generation_strategy('sb_ukko', []); if ($action == 'delete') { file_unlink($settings['uri'] . '/index.html'); @@ -32,23 +32,18 @@ class ukko { public $settings; public function build($mod = false) { - global $config; + $apithreads = null; + global $config; $boards = listBoards(); $body = ''; - $overflow = array(); - $board = array( - 'dir' => $this->settings['uri'] . "/", - 'url' => $this->settings['uri'], - 'uri' => $this->settings['uri'], - 'name' => $this->settings['title'], - 'title' => sprintf($this->settings['subtitle'], $this->settings['thread_limit']) - ); + $overflow = []; + $board = ['dir' => $this->settings['uri'] . "/", 'url' => $this->settings['uri'], 'uri' => $this->settings['uri'], 'name' => $this->settings['title'], 'title' => sprintf($this->settings['subtitle'], $this->settings['thread_limit'])]; - $boardsforukko = array(); + $boardsforukko = []; $query = ''; foreach($boards as &$_board) { - if(in_array($_board['uri'], explode(' ', $this->settings['exclude']))) + if(in_array($_board['uri'], explode(' ', (string) $this->settings['exclude']))) continue; $query .= sprintf("SELECT *, '%s' AS `board` FROM ``posts_%s`` WHERE `thread` IS NULL UNION ALL ", $_board['uri'], $_board['uri']); array_push($boardsforukko,$_board); @@ -57,9 +52,9 @@ $query = query($query) or error(db_error()); $count = 0; - $threads = array(); + $threads = []; if ($config['api']['enabled']) { - $apithreads = array(); + $apithreads = []; } while($post = $query->fetch()) { @@ -110,13 +105,13 @@ if(floor($threads[$post['board']] / $config['threads_per_page']) > 0) { $page = floor($threads[$post['board']] / $config['threads_per_page']) + 1; } - $overflow[] = array('id' => $post['id'], 'board' => $post['board'], 'page' => $page . '.html'); + $overflow[] = ['id' => $post['id'], 'board' => $post['board'], 'page' => $page . '.html']; } $count += 1; } - $body .= '<script> var overflow = ' . json_encode($overflow) . '</script>'; + $body .= '<script> var overflow = ' . json_encode($overflow, JSON_THROW_ON_ERROR) . '</script>'; $body .= '<script type="text/javascript" src="/'.$this->settings['uri'].'/ukko.js"></script>'; // json api @@ -124,18 +119,18 @@ require_once __DIR__. '/../../../inc/api.php'; $api = new Api(); $jsonFilename = $board['dir'] . '0.json'; - $json = json_encode($api->translatePage($apithreads)); + $json = json_encode($api->translatePage($apithreads), JSON_THROW_ON_ERROR); file_write($jsonFilename, $json); - $catalog = array(); + $catalog = []; $catalog[0] = $apithreads; - $json = json_encode($api->translateCatalog($catalog)); + $json = json_encode($api->translateCatalog($catalog), JSON_THROW_ON_ERROR); $jsonFilename = $board['dir'] . 'catalog.json'; file_write($jsonFilename, $json); - $json = json_encode($api->translateCatalog($catalog, true)); + $json = json_encode($api->translateCatalog($catalog, true), JSON_THROW_ON_ERROR); $jsonFilename = $board['dir'] . 'threads.json'; file_write($jsonFilename, $json); } @@ -145,15 +140,7 @@ } $antibot->reset(); - return Element('index.html', array( - 'config' => $config, - 'board' => $board, - 'no_post_form' => $config['overboard_post_form'] ? false : true, - 'body' => $body, - 'mod' => $mod, - 'boardlist' => createBoardlist($mod), - 'boards' => $boardsforukko, - 'antibot' => $antibot ) + return Element('index.html', ['config' => $config, 'board' => $board, 'no_post_form' => $config['overboard_post_form'] ? false : true, 'body' => $body, 'mod' => $mod, 'boardlist' => createBoardlist($mod), 'boards' => $boardsforukko, 'antibot' => $antibot] ); } diff --git a/templates/themes/ukko2/info.php b/templates/themes/ukko2/info.php index f7094697..24904c91 100644 --- a/templates/themes/ukko2/info.php +++ b/templates/themes/ukko2/info.php @@ -1,5 +1,5 @@ <?php - $theme = array(); + $theme = []; // Theme name $theme['name'] = 'Overboard (Ukko2)'; @@ -8,39 +8,13 @@ $theme['version'] = 'v0.2'; // Theme configuration - $theme['config'] = array(); + $theme['config'] = []; - $theme['config'][] = array( - 'title' => 'Board name', - 'name' => 'title', - 'type' => 'text', - 'default' => 'Ukko' - ); - $theme['config'][] = array( - 'title' => 'Board URI', - 'name' => 'uri', - 'type' => 'text', - 'default' => '*', - 'comment' => '(ukko for example)' - ); - $theme['config'][] = array( - 'title' => 'Subtitle', - 'name' => 'subtitle', - 'type' => 'text', - 'comment' => '(%s = thread limit. for example "%s freshly bumped threads")' - ); - $theme['config'][] = array( - 'title' => 'included boards', - 'name' => 'include', - 'type' => 'text', - 'comment' => '(space seperated)' - ); - $theme['config'][] = array( - 'title' => 'Number of threads', - 'name' => 'thread_limit', - 'type' => 'text', - 'default' => '15', - ); + $theme['config'][] = ['title' => 'Board name', 'name' => 'title', 'type' => 'text', 'default' => 'Ukko']; + $theme['config'][] = ['title' => 'Board URI', 'name' => 'uri', 'type' => 'text', 'default' => '*', 'comment' => '(ukko for example)']; + $theme['config'][] = ['title' => 'Subtitle', 'name' => 'subtitle', 'type' => 'text', 'comment' => '(%s = thread limit. for example "%s freshly bumped threads")']; + $theme['config'][] = ['title' => 'included boards', 'name' => 'include', 'type' => 'text', 'comment' => '(space seperated)']; + $theme['config'][] = ['title' => 'Number of threads', 'name' => 'thread_limit', 'type' => 'text', 'default' => '15']; // Unique function name for building everything $theme['build_function'] = 'ukko2_build'; $theme['install_callback'] = 'ukko2_install'; @@ -49,7 +23,7 @@ function ukko2_install($settings) { if (!file_exists($settings['uri'])) @mkdir($settings['uri'], 0777) or error("Couldn't create " . $settings['uri'] . ". Check permissions.", true); - file_write($settings['uri'] . '/ukko.js', Element('themes/ukko/ukko.js', array())); + file_write($settings['uri'] . '/ukko.js', Element('themes/ukko/ukko.js', [])); } } diff --git a/templates/themes/ukko2/theme.php b/templates/themes/ukko2/theme.php index c34b5b89..629ab4e1 100644 --- a/templates/themes/ukko2/theme.php +++ b/templates/themes/ukko2/theme.php @@ -11,7 +11,7 @@ return; } - $action = generation_strategy('sb_ukko', array()); + $action = generation_strategy('sb_ukko', []); if ($action == 'delete') { file_unlink($settings['uri'] . '/index.html'); @@ -32,22 +32,17 @@ class ukko2 { public $settings; public function build($mod = false) { - global $config; + $apithreads = null; + global $config; $boards = listBoards(); $body = ''; - $overflow = array(); - $board = array( - 'dir' => $this->settings['uri'] . "/", - 'url' => $this->settings['uri'], - 'uri' => $this->settings['uri'], - 'name' => $this->settings['title'], - 'title' => sprintf($this->settings['subtitle'], $this->settings['thread_limit']) - ); - $boardsforukko2 = array(); + $overflow = []; + $board = ['dir' => $this->settings['uri'] . "/", 'url' => $this->settings['uri'], 'uri' => $this->settings['uri'], 'name' => $this->settings['title'], 'title' => sprintf($this->settings['subtitle'], $this->settings['thread_limit'])]; + $boardsforukko2 = []; $query = ''; foreach($boards as &$_board) { - if(in_array($_board['uri'], explode(' ', $this->settings['include']))){ + if(in_array($_board['uri'], explode(' ', (string) $this->settings['include']))){ $query .= sprintf("SELECT *, '%s' AS `board` FROM ``posts_%s`` WHERE `thread` IS NULL UNION ALL ", $_board['uri'], $_board['uri']); array_push($boardsforukko2,$_board); } @@ -56,9 +51,9 @@ $query = query($query) or error(db_error()); $count = 0; - $threads = array(); + $threads = []; if ($config['api']['enabled']) { - $apithreads = array(); + $apithreads = []; } while($post = $query->fetch()) { @@ -109,13 +104,13 @@ if(floor($threads[$post['board']] / $config['threads_per_page']) > 0) { $page = floor($threads[$post['board']] / $config['threads_per_page']) + 1; } - $overflow[] = array('id' => $post['id'], 'board' => $post['board'], 'page' => $page . '.html'); + $overflow[] = ['id' => $post['id'], 'board' => $post['board'], 'page' => $page . '.html']; } $count += 1; } - $body .= '<script> var overflow = ' . json_encode($overflow) . '</script>'; + $body .= '<script> var overflow = ' . json_encode($overflow, JSON_THROW_ON_ERROR) . '</script>'; $body .= '<script type="text/javascript" src="/'.$this->settings['uri'].'/ukko.js"></script>'; // json api @@ -123,18 +118,18 @@ require_once __DIR__. '/../../../inc/api.php'; $api = new Api(); $jsonFilename = $board['dir'] . '0.json'; - $json = json_encode($api->translatePage($apithreads)); + $json = json_encode($api->translatePage($apithreads), JSON_THROW_ON_ERROR); file_write($jsonFilename, $json); - $catalog = array(); + $catalog = []; $catalog[0] = $apithreads; - $json = json_encode($api->translateCatalog($catalog)); + $json = json_encode($api->translateCatalog($catalog), JSON_THROW_ON_ERROR); $jsonFilename = $board['dir'] . 'catalog.json'; file_write($jsonFilename, $json); - $json = json_encode($api->translateCatalog($catalog, true)); + $json = json_encode($api->translateCatalog($catalog, true), JSON_THROW_ON_ERROR); $jsonFilename = $board['dir'] . 'threads.json'; file_write($jsonFilename, $json); } @@ -144,15 +139,7 @@ } $antibot->reset(); - return Element('index.html', array( - 'config' => $config, - 'board' => $board, - 'no_post_form' => $config['overboard_post_form'] ? false : true, - 'body' => $body, - 'mod' => $mod, - 'boardlist' => createBoardlist($mod), - 'boards' => $boardsforukko2, - 'antibot' => $antibot ) + return Element('index.html', ['config' => $config, 'board' => $board, 'no_post_form' => $config['overboard_post_form'] ? false : true, 'body' => $body, 'mod' => $mod, 'boardlist' => createBoardlist($mod), 'boards' => $boardsforukko2, 'antibot' => $antibot] ); } diff --git a/templates/themes/ukko3/info.php b/templates/themes/ukko3/info.php index 375995f4..463331f9 100644 --- a/templates/themes/ukko3/info.php +++ b/templates/themes/ukko3/info.php @@ -1,5 +1,5 @@ <?php - $theme = array(); + $theme = []; // Theme name $theme['name'] = 'Overboard (Ukko3)'; @@ -8,39 +8,13 @@ $theme['version'] = 'v0.2'; // Theme configuration - $theme['config'] = array(); + $theme['config'] = []; - $theme['config'][] = array( - 'title' => 'Board name', - 'name' => 'title', - 'type' => 'text', - 'default' => 'Ukko' - ); - $theme['config'][] = array( - 'title' => 'Board URI', - 'name' => 'uri', - 'type' => 'text', - 'default' => '*', - 'comment' => '(ukko for example)' - ); - $theme['config'][] = array( - 'title' => 'Subtitle', - 'name' => 'subtitle', - 'type' => 'text', - 'comment' => '(%s = thread limit. for example "%s freshly bumped threads")' - ); - $theme['config'][] = array( - 'title' => 'included boards', - 'name' => 'include', - 'type' => 'text', - 'comment' => '(space seperated)' - ); - $theme['config'][] = array( - 'title' => 'Number of threads', - 'name' => 'thread_limit', - 'type' => 'text', - 'default' => '15', - ); + $theme['config'][] = ['title' => 'Board name', 'name' => 'title', 'type' => 'text', 'default' => 'Ukko']; + $theme['config'][] = ['title' => 'Board URI', 'name' => 'uri', 'type' => 'text', 'default' => '*', 'comment' => '(ukko for example)']; + $theme['config'][] = ['title' => 'Subtitle', 'name' => 'subtitle', 'type' => 'text', 'comment' => '(%s = thread limit. for example "%s freshly bumped threads")']; + $theme['config'][] = ['title' => 'included boards', 'name' => 'include', 'type' => 'text', 'comment' => '(space seperated)']; + $theme['config'][] = ['title' => 'Number of threads', 'name' => 'thread_limit', 'type' => 'text', 'default' => '15']; // Unique function name for building everything $theme['build_function'] = 'ukko3_build'; $theme['install_callback'] = 'ukko3_install'; @@ -49,7 +23,7 @@ function ukko3_install($settings) { if (!file_exists($settings['uri'])) @mkdir($settings['uri'], 0777) or error("Couldn't create " . $settings['uri'] . ". Check permissions.", true); - file_write($settings['uri'] . '/ukko.js', Element('themes/ukko/ukko.js', array())); + file_write($settings['uri'] . '/ukko.js', Element('themes/ukko/ukko.js', [])); } } diff --git a/templates/themes/ukko3/theme.php b/templates/themes/ukko3/theme.php index c33b8521..eabe3998 100644 --- a/templates/themes/ukko3/theme.php +++ b/templates/themes/ukko3/theme.php @@ -11,7 +11,7 @@ return; } - $action = generation_strategy('sb_ukko', array()); + $action = generation_strategy('sb_ukko', []); if ($action == 'delete') { file_unlink($settings['uri'] . '/index.html'); @@ -32,23 +32,18 @@ class ukko3 { public $settings; public function build($mod = false) { - global $config; + $apithreads = null; + global $config; $boards = listBoards(); $body = ''; - $overflow = array(); - $board = array( - 'dir' => $this->settings['uri'] . "/", - 'url' => $this->settings['uri'], - 'uri' => $this->settings['uri'], - 'name' => $this->settings['title'], - 'title' => sprintf($this->settings['subtitle'], $this->settings['thread_limit']) - ); + $overflow = []; + $board = ['dir' => $this->settings['uri'] . "/", 'url' => $this->settings['uri'], 'uri' => $this->settings['uri'], 'name' => $this->settings['title'], 'title' => sprintf($this->settings['subtitle'], $this->settings['thread_limit'])]; - $boardsforukko3 = array(); + $boardsforukko3 = []; $query = ''; foreach($boards as &$_board) { - if(in_array($_board['uri'], explode(' ', $this->settings['include']))){ + if(in_array($_board['uri'], explode(' ', (string) $this->settings['include']))){ $query .= sprintf("SELECT *, '%s' AS `board` FROM ``posts_%s`` WHERE `thread` IS NULL UNION ALL ", $_board['uri'], $_board['uri']); array_push($boardsforukko3,$_board); } @@ -57,9 +52,9 @@ $query = query($query) or error(db_error()); $count = 0; - $threads = array(); + $threads = []; if ($config['api']['enabled']) { - $apithreads = array(); + $apithreads = []; } while($post = $query->fetch()) { @@ -110,13 +105,13 @@ if(floor($threads[$post['board']] / $config['threads_per_page']) > 0) { $page = floor($threads[$post['board']] / $config['threads_per_page']) + 1; } - $overflow[] = array('id' => $post['id'], 'board' => $post['board'], 'page' => $page . '.html'); + $overflow[] = ['id' => $post['id'], 'board' => $post['board'], 'page' => $page . '.html']; } $count += 1; } - $body .= '<script> var overflow = ' . json_encode($overflow) . '</script>'; + $body .= '<script> var overflow = ' . json_encode($overflow, JSON_THROW_ON_ERROR) . '</script>'; $body .= '<script type="text/javascript" src="/'.$this->settings['uri'].'/ukko.js"></script>'; // json api @@ -124,18 +119,18 @@ require_once __DIR__. '/../../../inc/api.php'; $api = new Api(); $jsonFilename = $board['dir'] . '0.json'; - $json = json_encode($api->translatePage($apithreads)); + $json = json_encode($api->translatePage($apithreads), JSON_THROW_ON_ERROR); file_write($jsonFilename, $json); - $catalog = array(); + $catalog = []; $catalog[0] = $apithreads; - $json = json_encode($api->translateCatalog($catalog)); + $json = json_encode($api->translateCatalog($catalog), JSON_THROW_ON_ERROR); $jsonFilename = $board['dir'] . 'catalog.json'; file_write($jsonFilename, $json); - $json = json_encode($api->translateCatalog($catalog, true)); + $json = json_encode($api->translateCatalog($catalog, true), JSON_THROW_ON_ERROR); $jsonFilename = $board['dir'] . 'threads.json'; file_write($jsonFilename, $json); } @@ -145,15 +140,7 @@ } $antibot->reset(); - return Element('index.html', array( - 'config' => $config, - 'board' => $board, - 'no_post_form' => $config['overboard_post_form'] ? false : true, - 'body' => $body, - 'mod' => $mod, - 'boardlist' => createBoardlist($mod), - 'boards' => $boardsforukko3, - 'antibot' => $antibot ) + return Element('index.html', ['config' => $config, 'board' => $board, 'no_post_form' => $config['overboard_post_form'] ? false : true, 'body' => $body, 'mod' => $mod, 'boardlist' => createBoardlist($mod), 'boards' => $boardsforukko3, 'antibot' => $antibot] ); } diff --git a/templates/themes/ukko4/info.php b/templates/themes/ukko4/info.php index dbbf6da8..0e797026 100644 --- a/templates/themes/ukko4/info.php +++ b/templates/themes/ukko4/info.php @@ -1,5 +1,5 @@ <?php - $theme = array(); + $theme = []; // Theme name $theme['name'] = 'Overboard (Ukko) 4'; @@ -8,39 +8,13 @@ $theme['version'] = 'v0.2'; // Theme configuration - $theme['config'] = array(); + $theme['config'] = []; - $theme['config'][] = array( - 'title' => 'Board name', - 'name' => 'title', - 'type' => 'text', - 'default' => 'Ukko' - ); - $theme['config'][] = array( - 'title' => 'Board URI', - 'name' => 'uri', - 'type' => 'text', - 'default' => '*', - 'comment' => '(ukko for example)' - ); - $theme['config'][] = array( - 'title' => 'Subtitle', - 'name' => 'subtitle', - 'type' => 'text', - 'comment' => '(%s = thread limit. for example "%s freshly bumped threads")' - ); - $theme['config'][] = array( - 'title' => 'Excluded boards', - 'name' => 'exclude', - 'type' => 'text', - 'comment' => '(space seperated)' - ); - $theme['config'][] = array( - 'title' => 'Number of threads', - 'name' => 'thread_limit', - 'type' => 'text', - 'default' => '15', - ); + $theme['config'][] = ['title' => 'Board name', 'name' => 'title', 'type' => 'text', 'default' => 'Ukko']; + $theme['config'][] = ['title' => 'Board URI', 'name' => 'uri', 'type' => 'text', 'default' => '*', 'comment' => '(ukko for example)']; + $theme['config'][] = ['title' => 'Subtitle', 'name' => 'subtitle', 'type' => 'text', 'comment' => '(%s = thread limit. for example "%s freshly bumped threads")']; + $theme['config'][] = ['title' => 'Excluded boards', 'name' => 'exclude', 'type' => 'text', 'comment' => '(space seperated)']; + $theme['config'][] = ['title' => 'Number of threads', 'name' => 'thread_limit', 'type' => 'text', 'default' => '15']; // Unique function name for building everything $theme['build_function'] = 'ukko4_build'; $theme['install_callback'] = 'ukko4_install'; @@ -49,7 +23,7 @@ function ukko4_install($settings) { if (!file_exists($settings['uri'])) @mkdir($settings['uri'], 0777) or error("Couldn't create " . $settings['uri'] . ". Check permissions.", true); - file_write($settings['uri'] . '/ukko.js', Element('themes/ukko/ukko.js', array())); + file_write($settings['uri'] . '/ukko.js', Element('themes/ukko/ukko.js', [])); } } diff --git a/templates/themes/ukko4/theme.php b/templates/themes/ukko4/theme.php index 4511483e..d58d8653 100644 --- a/templates/themes/ukko4/theme.php +++ b/templates/themes/ukko4/theme.php @@ -11,7 +11,7 @@ return; } - $action = generation_strategy('sb_ukko', array()); + $action = generation_strategy('sb_ukko', []); if ($action == 'delete') { file_unlink($settings['uri'] . '/index.html'); @@ -32,23 +32,18 @@ class ukko4 { public $settings; public function build($mod = false) { - global $config; + $apithreads = null; + global $config; $boards = listBoards(); $body = ''; - $overflow = array(); - $board = array( - 'dir' => $this->settings['uri'] . "/", - 'url' => $this->settings['uri'], - 'uri' => $this->settings['uri'], - 'name' => $this->settings['title'], - 'title' => sprintf($this->settings['subtitle'], $this->settings['thread_limit']) - ); + $overflow = []; + $board = ['dir' => $this->settings['uri'] . "/", 'url' => $this->settings['uri'], 'uri' => $this->settings['uri'], 'name' => $this->settings['title'], 'title' => sprintf($this->settings['subtitle'], $this->settings['thread_limit'])]; - $boardsforukko = array(); + $boardsforukko = []; $query = ''; foreach($boards as &$_board) { - if(in_array($_board['uri'], explode(' ', $this->settings['exclude']))) + if(in_array($_board['uri'], explode(' ', (string) $this->settings['exclude']))) continue; $query .= sprintf("SELECT *, '%s' AS `board` FROM ``posts_%s`` WHERE `thread` IS NULL UNION ALL ", $_board['uri'], $_board['uri']); array_push($boardsforukko,$_board); @@ -57,9 +52,9 @@ $query = query($query) or error(db_error()); $count = 0; - $threads = array(); + $threads = []; if ($config['api']['enabled']) { - $apithreads = array(); + $apithreads = []; } while($post = $query->fetch()) { @@ -110,13 +105,13 @@ if(floor($threads[$post['board']] / $config['threads_per_page']) > 0) { $page = floor($threads[$post['board']] / $config['threads_per_page']) + 1; } - $overflow[] = array('id' => $post['id'], 'board' => $post['board'], 'page' => $page . '.html'); + $overflow[] = ['id' => $post['id'], 'board' => $post['board'], 'page' => $page . '.html']; } $count += 1; } - $body .= '<script> var overflow = ' . json_encode($overflow) . '</script>'; + $body .= '<script> var overflow = ' . json_encode($overflow, JSON_THROW_ON_ERROR) . '</script>'; $body .= '<script type="text/javascript" src="/'.$this->settings['uri'].'/ukko.js"></script>'; // json api @@ -124,18 +119,18 @@ require_once __DIR__. '/../../../inc/api.php'; $api = new Api(); $jsonFilename = $board['dir'] . '0.json'; - $json = json_encode($api->translatePage($apithreads)); + $json = json_encode($api->translatePage($apithreads), JSON_THROW_ON_ERROR); file_write($jsonFilename, $json); - $catalog = array(); + $catalog = []; $catalog[0] = $apithreads; - $json = json_encode($api->translateCatalog($catalog)); + $json = json_encode($api->translateCatalog($catalog), JSON_THROW_ON_ERROR); $jsonFilename = $board['dir'] . 'catalog.json'; file_write($jsonFilename, $json); - $json = json_encode($api->translateCatalog($catalog, true)); + $json = json_encode($api->translateCatalog($catalog, true), JSON_THROW_ON_ERROR); $jsonFilename = $board['dir'] . 'threads.json'; file_write($jsonFilename, $json); } @@ -145,15 +140,7 @@ } $antibot->reset(); - return Element('index.html', array( - 'config' => $config, - 'board' => $board, - 'no_post_form' => $config['overboard_post_form'] ? false : true, - 'body' => $body, - 'mod' => $mod, - 'boardlist' => createBoardlist($mod), - 'boards' => $boardsforukko, - 'antibot' => $antibot ) + return Element('index.html', ['config' => $config, 'board' => $board, 'no_post_form' => $config['overboard_post_form'] ? false : true, 'body' => $body, 'mod' => $mod, 'boardlist' => createBoardlist($mod), 'boards' => $boardsforukko, 'antibot' => $antibot] ); } diff --git a/templates/themes/zine/info.php b/templates/themes/zine/info.php index d7dabef5..a0fad880 100644 --- a/templates/themes/zine/info.php +++ b/templates/themes/zine/info.php @@ -1,23 +1,3 @@ <?php -$theme = array( - 'name' => 'Zine', - 'description' => 'sex on digital paper', - 'version' => 'v9001', - - 'config' => array( - array('title' => 'Page title', - 'name' => 'title', - 'type' => 'text'), - - array('title' => 'Slogan', - 'name' => 'subtitle', - 'type' => 'text', - 'comment' => '(optional)'), - - array('title' => 'File', - 'name' => 'file', - 'type' => 'text', - 'default' => 'zine/index.html')), - - 'build_function' => 'zine_build'); +$theme = ['name' => 'Zine', 'description' => 'sex on digital paper', 'version' => 'v9001', 'config' => [['title' => 'Page title', 'name' => 'title', 'type' => 'text'], ['title' => 'Slogan', 'name' => 'subtitle', 'type' => 'text', 'comment' => '(optional)'], ['title' => 'File', 'name' => 'file', 'type' => 'text', 'default' => 'zine/index.html']], 'build_function' => 'zine_build']; ?> diff --git a/templates/themes/zine/theme.php b/templates/themes/zine/theme.php index 78cb780c..fdeffc64 100644 --- a/templates/themes/zine/theme.php +++ b/templates/themes/zine/theme.php @@ -19,9 +19,7 @@ class zine { global $config; return Element('themes/zine/zine.html', - array('settings' => $settings, - 'config' => $config, - 'boardlist' => createBoardlist())); + ['settings' => $settings, 'config' => $config, 'boardlist' => createBoardlist()]); } } |
