This commit is contained in:
czaks 2013-07-31 17:05:53 -04:00
commit dc9df2b9b3

View File

@ -996,7 +996,10 @@ function index($page, $mod=false) {
$query->bindValue(':threads_per_page', $config['threads_per_page'], PDO::PARAM_INT);
$query->execute() or error(db_error($query));
if ($query->rowcount() < 1 && $page > 1)
if ($page == 1 && $query->rowCount() < $config['threads_per_page'])
$board['thread_count'] = $query->rowCount();
if ($query->rowCount() < 1 && $page > 1)
return false;
$threads = array();
@ -1113,10 +1116,13 @@ function getPageButtons($pages, $mod=false) {
function getPages($mod=false) {
global $board, $config;
if (isset($board['thread_count'])) {
$count = $board['thread_count'];
} else {
// Count threads
$query = query(sprintf("SELECT COUNT(`id`) as `num` FROM `posts_%s` WHERE `thread` IS NULL", $board['uri'])) or error(db_error());
$count = current($query->fetch());
$query = query(sprintf("SELECT COUNT(`id`) FROM `posts_%s` WHERE `thread` IS NULL", $board['uri'])) or error(db_error());
$count = $query->fetchColumn();
}
$count = floor(($config['threads_per_page'] + $count - 1) / $config['threads_per_page']);
if ($count < 1) $count = 1;