diff --git a/inc/functions.php b/inc/functions.php index 3a624ff1..3e9fffd0 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -1322,7 +1322,7 @@ function index($page, $mod=false, $brief = false) { $body = ''; $offset = round($page*$config['threads_per_page']-$config['threads_per_page']); - $query = prepare(sprintf("SELECT * FROM ``posts_%s`` WHERE `thread` IS NULL ORDER BY `sticky` DESC, `bump` DESC LIMIT :offset,:threads_per_page", $board['uri'])); + $query = prepare(sprintf("SELECT *,'%s' as board FROM ``posts_%s`` WHERE `thread` IS NULL ORDER BY `sticky` DESC, `bump` DESC LIMIT :offset,:threads_per_page", $board['uri'], $board['uri'])); $query->bindValue(':offset', $offset, PDO::PARAM_INT); $query->bindValue(':threads_per_page', $config['threads_per_page'], PDO::PARAM_INT); $query->execute() or error(db_error($query)); @@ -2292,7 +2292,7 @@ function buildThread($id, $return = false, $mod = false) { $action = generation_strategy('sb_thread', array($board['uri'], $id)); if ($action == 'rebuild' || $return || $mod) { - $query = prepare(sprintf("SELECT * FROM ``posts_%s`` WHERE (`thread` IS NULL AND `id` = :id) OR `thread` = :id ORDER BY `thread`,`id`", $board['uri'])); + $query = prepare(sprintf("SELECT *,'%s' as board FROM ``posts_%s`` WHERE (`thread` IS NULL AND `id` = :id) OR `thread` = :id ORDER BY `thread`,`id`", $board['uri'],$board['uri'])); $query->bindValue(':id', $id, PDO::PARAM_INT); $query->execute() or error(db_error($query)); diff --git a/templates/themes/catalog/catalog.html b/templates/themes/catalog/catalog.html index a932278d..e39debee 100644 --- a/templates/themes/catalog/catalog.html +++ b/templates/themes/catalog/catalog.html @@ -48,7 +48,7 @@
{% for post in recent_posts %}
- R: {{ post.reply_count }} / I: {{ post.image_count }}{% if post.sticky %} (sticky){% endif %}{% if post.locked %}  {% endif %} + R: {{ post.replies }} / I: {{ post.images }}{% if post.sticky %} (sticky){% endif %}{% if post.locked %}  {% endif %} {% if post.subject %}

diff --git a/templates/themes/catalog/theme.php b/templates/themes/catalog/theme.php index c986aeb5..e2275338 100644 --- a/templates/themes/catalog/theme.php +++ b/templates/themes/catalog/theme.php @@ -337,8 +337,8 @@ private function buildThreadsQuery($board) { $sql = "SELECT *, `id` AS `thread_id`, " . - "(SELECT COUNT(`id`) FROM ``posts_$board`` WHERE `thread` = `thread_id`) AS `reply_count`, " . - "(SELECT SUM(`num_files`) FROM ``posts_$board`` WHERE `thread` = `thread_id` AND `num_files` IS NOT NULL) AS `image_count`, " . + "(SELECT COUNT(`id`) FROM ``posts_$board`` WHERE `thread` = `thread_id`) AS `replies`, " . + "(SELECT SUM(`num_files`) FROM ``posts_$board`` WHERE `thread` = `thread_id` AND `num_files` IS NOT NULL) AS `images`, " . "'$board' AS `board` FROM ``posts_$board`` WHERE `thread` IS NULL"; return $sql; @@ -445,8 +445,8 @@ $post['file'] = $config['root'] . $config['image_deleted']; } - if (empty($post['image_count'])) - $post['image_count'] = 0; + if (empty($post['images'])) + $post['images'] = 0; $post['pubdate'] = date('r', $post['time']); $posts[] = $post;