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 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()); diff --git a/inc/functions.php b/inc/functions.php index 84241983..fe1e254c 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -240,12 +240,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); } } @@ -262,7 +262,7 @@ function loadThemeConfig($_theme) { return $theme; } -function rebuildTheme($theme, $action) { +function rebuildTheme($theme, $action, $board = false) { global $config, $_theme; $_theme = $theme; @@ -271,7 +271,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 aa897340..2825b40b 100644 --- a/post.php +++ b/post.php @@ -685,8 +685,13 @@ 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['mod']) header('X-Associated-Content: "' . $redirect . '"'); + + 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 @@ + + + + {{ 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 %} 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..e585cf17 --- /dev/null +++ b/templates/themes/catalog/theme.php @@ -0,0 +1,60 @@ +build($settings, $board); + } + } elseif ($action == 'post-thread' && in_array($board, $boards)) { + $b = new Catalog(); + $b->build($settings, $board); + } + } + + // 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(); + + $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()) { + $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; + } + + file_write($config['dir']['home'] . $board_name . '/catalog.html', 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'] + ))); + } + }; 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 @@