diff --git a/include/_topics.php b/include/_topics.php index a6bdccd..8795fd3 100644 --- a/include/_topics.php +++ b/include/_topics.php @@ -1,11 +1,20 @@ prepare('SELECT *, UNIX_TIMESTAMP(`topic_created`) AS `topic_created`, UNIX_TIMESTAMP(`topic_bumped`) AS `topic_bumped`, UNIX_TIMESTAMP(`topic_locked`) AS `topic_locked`, UNIX_TIMESTAMP(`topic_resolved`) AS `topic_resolved`, UNIX_TIMESTAMP(`topic_confirmed`) AS `topic_confirmed` FROM `fmf_topics` WHERE `cat_id` = :category AND `topic_bumped` IS NOT NULL ORDER BY `topic_bumped` DESC'); + $query = 'SELECT *, UNIX_TIMESTAMP(`topic_created`) AS `topic_created`, UNIX_TIMESTAMP(`topic_bumped`) AS `topic_bumped`, UNIX_TIMESTAMP(`topic_locked`) AS `topic_locked`, UNIX_TIMESTAMP(`topic_resolved`) AS `topic_resolved`, UNIX_TIMESTAMP(`topic_confirmed`) AS `topic_confirmed`' + . ' FROM `fmf_topics` WHERE `cat_id` = :category AND `topic_bumped` IS NOT NULL' + . ' ORDER BY '; + + if($variation === 1) + $query .= 'IF(`topic_confirmed` IS NULL, 0, IF(`topic_resolved` IS NULL, -1, 1)), '; + + $query .= '`topic_bumped` DESC'; + + $getTopics = $pdo->prepare($query); $getTopics->bindValue('category', $category); $topics = $getTopics->execute() ? $getTopics->fetchAll(PDO::FETCH_ASSOC) : false; diff --git a/include/_user.php b/include/_user.php index a77868d..618b280 100644 --- a/include/_user.php +++ b/include/_user.php @@ -2,6 +2,7 @@ include_once '_utils.php'; define('FMF_UF_SCROLLBEYOND', 1); +define('FMF_UF_NEWSTYLE', 2); function get_user_id(string $username, string $email): int { global $pdo; @@ -181,6 +182,18 @@ function destroy_session(string $token): void { $delete->execute(); } +function destroy_user_sessions(int $userId): void { + global $pdo; + + $delete = $pdo->prepare('DELETE FROM `fmf_sessions` WHERE `user_id` = :user'); + $delete->bindValue('user', $userId); + $delete->execute(); +} + +function destroy_current_user_sessions(): void { + destroy_user_sessions(current_user_id()); +} + function current_user_id(): int { return session_active() ? $GLOBALS['fmf_user_id'] : 0; } diff --git a/layout/footer.php b/layout/footer.php index 66a54c5..3413c2a 100644 --- a/layout/footer.php +++ b/layout/footer.php @@ -1,4 +1,11 @@ + + +
+