diff --git a/inc/mod/pages.php b/inc/mod/pages.php index 801ad9eb..292d36a2 100644 --- a/inc/mod/pages.php +++ b/inc/mod/pages.php @@ -2236,6 +2236,7 @@ function mod_recent_posts($lim) { error($config['error']['noaccess']); $limit = (is_numeric($lim))? $lim : 25; + $last_time = (isset($_GET['last']) && is_numeric($_GET['last'])) ? $_GET['last'] : 0; $mod_boards = array(); $boards = listBoards(); @@ -2256,37 +2257,29 @@ function mod_recent_posts($lim) { $query .= sprintf('SELECT *, %s AS `board` FROM ``posts_%s`` UNION ALL ', $pdo->quote($board['uri']), $board['uri']); } // Remove the last "UNION ALL" seperator and complete the query - $query = preg_replace('/UNION ALL $/', ') AS `all_posts` ORDER BY `time` DESC LIMIT ' . $limit, $query); - $query = query($query) or error(db_error()); + $query = preg_replace('/UNION ALL $/', ') AS `all_posts` WHERE (`time` < :last_time OR NOT :last_time) ORDER BY `time` DESC LIMIT ' . $limit, $query); + $query = prepare($query); + $query->bindValue(':last_time', $last_time); + $query->execute() or error(db_error($query)); $posts = $query->fetchAll(PDO::FETCH_ASSOC); - $body = '
({% trans 'There are no active posts.' %})
{% else %} - +