From ce9431ba34e6f4212ac264827d9bbcac38bb0665 Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Thu, 18 Jul 2013 10:17:19 -0400 Subject: [PATCH 1/6] Update filters to work with new ban table --- inc/filters.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/filters.php b/inc/filters.php index 0b5eb3c1..524d37cf 100644 --- a/inc/filters.php +++ b/inc/filters.php @@ -81,7 +81,7 @@ class Filter { else $all_boards = false; - $query = prepare("INSERT INTO `bans` VALUES (NULL, :ip, :mod, :set, :expires, :reason, :board)"); + $query = prepare("INSERT INTO `bans` VALUES (NULL, :ip, :mod, :set, :expires, :reason, :board, 0)"); $query->bindValue(':ip', $_SERVER['REMOTE_ADDR']); $query->bindValue(':mod', -1); $query->bindValue(':set', time()); From 25ca144d0cf08a4bc82c6d8b5c2038a0423a78d0 Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Thu, 18 Jul 2013 11:28:35 -0400 Subject: [PATCH 2/6] Bugfix: .DS_Store fix --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 78e3c38a..73c05be2 100644 --- a/.gitignore +++ b/.gitignore @@ -14,7 +14,7 @@ /templates/cache # other stuff -.DS_Store? +.DS_Store thumbs.db Icon? Thumbs.db From f5d378fab5eca1147923bbc268cc7ea1e864041c Mon Sep 17 00:00:00 2001 From: copypaste Date: Thu, 18 Jul 2013 11:30:00 -0400 Subject: [PATCH 3/6] Catalog theme --- templates/themes/catalog/catalog.css | 38 +++++++++++++++++ templates/themes/catalog/info.php | 42 ++++++++++++++++++ templates/themes/catalog/theme.php | 64 ++++++++++++++++++++++++++++ 3 files changed, 144 insertions(+) create mode 100644 templates/themes/catalog/catalog.css create mode 100644 templates/themes/catalog/info.php create mode 100644 templates/themes/catalog/theme.php diff --git a/templates/themes/catalog/catalog.css b/templates/themes/catalog/catalog.css new file mode 100644 index 00000000..048dd656 --- /dev/null +++ b/templates/themes/catalog/catalog.css @@ -0,0 +1,38 @@ +img { + float:none!important; + margin: auto; + margin-bottom: 12px; + max-height: 150px; + max-width: 200px; + box-shadow: 0 0 4px rgba(0, 0, 0, 0.55); + border: 2px solid rgba(153, 153, 153, 0); +} + +/* +img:hover { + border: 2px solid rgba(153, 153, 153, 0.27); +} +*/ + +div.thread { + display: inline-block; + vertical-align: top; + margin-bottom:25px; + margin-left: 20px; + margin-right: 15px; + text-align:center; + font-weight:normal; + width:205px; + overflow:hidden; + position: relative; + font-size:11px; + padding: 15px; + background: rgba(182, 182, 182, 0.12); + border: 2px solid rgba(111, 111, 111, 0.34); + max-height:300px; +} + +div.thread:hover { + background: #D6DAF0; + border-color: #B7C5D9; +} \ No newline at end of file diff --git a/templates/themes/catalog/info.php b/templates/themes/catalog/info.php new file mode 100644 index 00000000..1b9831ae --- /dev/null +++ b/templates/themes/catalog/info.php @@ -0,0 +1,42 @@ + 'Title', + 'name' => 'title', + 'type' => 'text', + 'default' => 'Catalog' + ); + + $__boards = listBoards(); + $__default_boards = Array(); + 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'][] = Array( + 'title' => 'CSS file', + 'name' => 'css', + 'type' => 'text', + 'default' => 'catalog.css', + 'comment' => '(eg. "catalog.css")' + ); + + // 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 new file mode 100644 index 00000000..356933ba --- /dev/null +++ b/templates/themes/catalog/theme.php @@ -0,0 +1,64 @@ +build($action, $settings); + } + + // Wrap functions in a class so they don't interfere with normal Tinyboard operations + class Catalog { + public function build($action, $settings) { + global $config, $_theme; + + if ($action == 'all') { + copy('templates/themes/catalog/catalog.css', $config['dir']['home'] . $settings['css']); + } + + $boards = explode(' ', $settings['boards']); + foreach ($boards as $board) { + if ($action == 'all' || $action == 'post') + file_write($config['dir']['home'] . $board . '/catalog.html', $this->homepage($settings, $board)); + } + + } + + public function homepage($settings, $board_name) { + global $config, $board; + + $recent_images = array(); + $recent_posts = array(); + $stats = array(); + + $query = query(sprintf("SELECT *, `id` AS `thread_id`, (SELECT COUNT(*) FROM `posts_%s` WHERE `thread` = `thread_id`) AS `reply_count`, '%s' AS `board` FROM `posts_%s` WHERE `thread` IS NULL ORDER BY `bump` DESC", $board_name, $board_name, $board_name)) or error(db_error()); + + while ($post = $query->fetch()) { + openBoard($post['board']); + + $post['link'] = $config['root'] . $board['dir'] . $config['dir']['res'] . sprintf($config['file_page'], ($post['thread'] ? $post['thread'] : $post['id'])); + $post['board_name'] = $board['name']; + $post['file'] = $config['uri_thumb'] . $post['thumb']; + $recent_posts[] = $post; + } + + + return Element('themes/catalog/catalog.html', Array( + 'settings' => $settings, + 'config' => $config, + 'boardlist' => createBoardlist(), + 'recent_images' => $recent_images, + 'recent_posts' => $recent_posts, + 'stats' => $stats, + 'board' => $board_name, + 'link' => $config['root'] . $board['dir'] + )); + } + }; + +?> From 461d98b9457f90a6ff87534081f760572301e6f9 Mon Sep 17 00:00:00 2001 From: copypaste Date: Thu, 18 Jul 2013 11:34:04 -0400 Subject: [PATCH 4/6] Catalog theme --- templates/themes/catalog/catalog.html | 35 +++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 templates/themes/catalog/catalog.html diff --git a/templates/themes/catalog/catalog.html b/templates/themes/catalog/catalog.html new file mode 100644 index 00000000..501117a8 --- /dev/null +++ b/templates/themes/catalog/catalog.html @@ -0,0 +1,35 @@ +{% filter remove_whitespace %} + + + + + {{ settings.title }} + + + {% if config.url_favicon %}{% endif %} + + + {{ boardlist.top }} +
+

{{ settings.title }} (/{{ board }}/)

+
{{ settings.subtitle }}
+
+ + + +
+

Powered by Tinyboard {{ config.version }} | Tinyboard Copyright © 2010-2013 Tinyboard Development Group

+ + +{% endfilter %} From de4b5b396246ee5c3cb8687cfef3647c844a3b54 Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Thu, 18 Jul 2013 11:40:21 -0400 Subject: [PATCH 5/6] Quick catalog theme bugfix --- templates/themes/catalog/catalog.html | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/templates/themes/catalog/catalog.html b/templates/themes/catalog/catalog.html index 501117a8..7fcae04e 100644 --- a/templates/themes/catalog/catalog.html +++ b/templates/themes/catalog/catalog.html @@ -16,16 +16,17 @@
From e4bd9a6886af2a812ccc909d8ad957df1bdc5d2b Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Thu, 18 Jul 2013 12:06:26 -0400 Subject: [PATCH 6/6] Themes edit: Split "post" into two seperate actions: "post" (replies) and "post-thread". And add a $board variable. --- inc/functions.php | 8 ++--- post.php | 6 +++- templates/themes/basic/theme.php | 2 +- templates/themes/catalog/theme.php | 50 ++++++++++++--------------- templates/themes/categories/theme.php | 2 +- templates/themes/frameset/theme.php | 2 +- templates/themes/recent/theme.php | 5 +-- templates/themes/rrdtool/theme.php | 2 +- templates/themes/sitemap/theme.php | 6 +++- 9 files changed, 44 insertions(+), 39 deletions(-) diff --git a/inc/functions.php b/inc/functions.php index 40a2c1fe..af810f31 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -239,12 +239,12 @@ function create_antibot($board, $thread = null) { return _create_antibot($board, $thread); } -function rebuildThemes($action) { +function rebuildThemes($action, $board = false) { // List themes $query = query("SELECT `theme` FROM `theme_settings` WHERE `name` IS NULL AND `value` IS NULL") or error(db_error()); while ($theme = $query->fetch()) { - rebuildTheme($theme['theme'], $action); + rebuildTheme($theme['theme'], $action, $board); } } @@ -261,7 +261,7 @@ function loadThemeConfig($_theme) { return $theme; } -function rebuildTheme($theme, $action) { +function rebuildTheme($theme, $action, $board = false) { global $config, $_theme; $_theme = $theme; @@ -270,7 +270,7 @@ function rebuildTheme($theme, $action) { if (file_exists($config['dir']['themes'] . '/' . $_theme . '/theme.php')) { require_once $config['dir']['themes'] . '/' . $_theme . '/theme.php'; - $theme['build_function']($action, themeSettings($_theme)); + $theme['build_function']($action, themeSettings($_theme), $board); } } diff --git a/post.php b/post.php index 3d718786..97fb263d 100644 --- a/post.php +++ b/post.php @@ -677,7 +677,11 @@ if (isset($_POST['delete'])) { _syslog(LOG_INFO, 'New post: /' . $board['dir'] . $config['dir']['res'] . sprintf($config['file_page'], $post['op'] ? $id : $post['thread']) . (!$post['op'] ? '#' . $id : '')); - rebuildThemes('post'); + if ($post['op']) + rebuildThemes('post-thread', $board['uri']); + else + rebuildThemes('post', $board['uri']); + header('Location: ' . $redirect, true, $config['redirect_http']); } else { if (!file_exists($config['has_installed'])) { diff --git a/templates/themes/basic/theme.php b/templates/themes/basic/theme.php index 806a331a..7ba0d1e7 100644 --- a/templates/themes/basic/theme.php +++ b/templates/themes/basic/theme.php @@ -1,7 +1,7 @@ build($action, $settings); - } - - // Wrap functions in a class so they don't interfere with normal Tinyboard operations - class Catalog { - public function build($action, $settings) { - global $config, $_theme; - - if ($action == 'all') { - copy('templates/themes/catalog/catalog.css', $config['dir']['home'] . $settings['css']); - } + $boards = explode(' ', $settings['boards']); + + if ($action == 'all') { + copy('templates/themes/catalog/catalog.css', $config['dir']['home'] . $settings['css']); - $boards = explode(' ', $settings['boards']); foreach ($boards as $board) { - if ($action == 'all' || $action == 'post') - file_write($config['dir']['home'] . $board . '/catalog.html', $this->homepage($settings, $board)); + $b = new Catalog(); + $b->build($settings, $board); } - + } elseif ($action == 'post-thread' && in_array($board, $boards)) { + $b = new Catalog(); + $b->build($settings, $board); } - - public function homepage($settings, $board_name) { + } + + // Wrap functions in a class so they don't interfere with normal Tinyboard operations + class Catalog { + public function build($settings, $board_name) { global $config, $board; + openBoard($board_name); + $recent_images = array(); $recent_posts = array(); $stats = array(); @@ -39,16 +40,13 @@ $query = query(sprintf("SELECT *, `id` AS `thread_id`, (SELECT COUNT(*) FROM `posts_%s` WHERE `thread` = `thread_id`) AS `reply_count`, '%s' AS `board` FROM `posts_%s` WHERE `thread` IS NULL ORDER BY `bump` DESC", $board_name, $board_name, $board_name)) or error(db_error()); while ($post = $query->fetch()) { - openBoard($post['board']); - $post['link'] = $config['root'] . $board['dir'] . $config['dir']['res'] . sprintf($config['file_page'], ($post['thread'] ? $post['thread'] : $post['id'])); $post['board_name'] = $board['name']; $post['file'] = $config['uri_thumb'] . $post['thumb']; $recent_posts[] = $post; } - - return Element('themes/catalog/catalog.html', Array( + file_write($config['dir']['home'] . $board_name . '/catalog.html', Element('themes/catalog/catalog.html', Array( 'settings' => $settings, 'config' => $config, 'boardlist' => createBoardlist(), @@ -57,8 +55,6 @@ 'stats' => $stats, 'board' => $board_name, 'link' => $config['root'] . $board['dir'] - )); + ))); } }; - -?> diff --git a/templates/themes/categories/theme.php b/templates/themes/categories/theme.php index 11fcbbaf..7d468d0d 100644 --- a/templates/themes/categories/theme.php +++ b/templates/themes/categories/theme.php @@ -1,7 +1,7 @@ build($action, $settings); @@ -23,7 +24,7 @@ $this->excluded = explode(' ', $settings['exclude']); - if ($action == 'all' || $action == 'post') + if ($action == 'all' || $action == 'post' || $action == 'post-thread') file_write($config['dir']['home'] . $settings['html'], $this->homepage($settings)); } diff --git a/templates/themes/rrdtool/theme.php b/templates/themes/rrdtool/theme.php index eed2ac9a..68fc1850 100644 --- a/templates/themes/rrdtool/theme.php +++ b/templates/themes/rrdtool/theme.php @@ -1,7 +1,7 @@