This repository has been archived on 2024-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
mybb-digest/activethreads.php

39 lines
1.1 KiB
PHP

<?php
/**
* Return the latest threads
* @return array
*/
function getLatestActiveThreads()
{
global $pdo;
// This will be the array, where we can save the threads
$threads = array();
$limit = strtotime("1 day ago");
if (date("D") === "Mon") {
$limit = strtotime("3 days ago");
}
// Run the Query
$query = "SELECT `".MYBB_PREFIX."forums`.`name` AS `forumname`,
`".MYBB_PREFIX."threads`.`subject`,
`".MYBB_PREFIX."threads`.`lastpost`,
`".MYBB_PREFIX."threads`.`username`,
`".MYBB_PREFIX."threads`.`dateline`,
`".MYBB_PREFIX."threads`.`lastposter`,
`".MYBB_PREFIX."threads`.`lastpost`,
`".MYBB_PREFIX."threads`.`replies`
FROM `".MYBB_PREFIX."threads`
LEFT JOIN `".MYBB_PREFIX."forums` ON `".MYBB_PREFIX.'forums`.`fid` = `'.MYBB_PREFIX.'threads`.`fid`'."
WHERE `".MYBB_PREFIX."threads`.`visible` = 1
AND `".MYBB_PREFIX."threads`.`lastpost` > :date
ORDER BY `".MYBB_PREFIX."threads`.`lastpost` DESC
";
$query = $pdo->prepare($query);
$query->execute([
'date' => $limit
]);
return $query->fetchAll();
}