summaryrefslogtreecommitdiff
path: root/templates/themes/recent
diff options
context:
space:
mode:
authorAppleman1234 <applemansigloo@gmail.com>2022-09-25 13:30:13 +1000
committerAppleman1234 <applemansigloo@gmail.com>2022-09-25 13:30:13 +1000
commit2c69095a1edf7474073451285238659d0f62ce3f (patch)
tree5dee476605402c66dc2853d0836b29f6aedae62b /templates/themes/recent
parente9a61e2fbbd930eaa80d6a5f33420cedc59d748c (diff)
PHP8.1 fixes from Rector
Diffstat (limited to 'templates/themes/recent')
-rw-r--r--templates/themes/recent/info.php74
-rw-r--r--templates/themes/recent/theme.php27
2 files changed, 24 insertions, 77 deletions
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]);
}
};