2017-05-04 09:11:59 +03:00
|
|
|
<?php
|
|
|
|
/**
|
2017-05-04 10:12:32 +03:00
|
|
|
* Return the latest threads
|
2017-05-04 09:11:59 +03:00
|
|
|
* @return array
|
|
|
|
*/
|
2017-05-04 10:12:32 +03:00
|
|
|
function getLatestActiveThreads()
|
2017-05-04 09:11:59 +03:00
|
|
|
{
|
2017-05-04 09:59:49 +03:00
|
|
|
global $pdo;
|
2017-05-04 09:11:59 +03:00
|
|
|
// This will be the array, where we can save the threads
|
|
|
|
$threads = array();
|
|
|
|
|
2017-05-04 12:19:35 +03:00
|
|
|
$limit = strtotime("1 day ago");
|
|
|
|
if (date("D") === "Mon") {
|
|
|
|
$limit = strtotime("3 days ago");
|
|
|
|
}
|
2017-05-04 09:11:59 +03:00
|
|
|
// Run the Query
|
2017-05-04 15:29:29 +03:00
|
|
|
$query = "SELECT DISTINCT
|
|
|
|
`".MYBB_PREFIX."forums`.`fid`,
|
|
|
|
`".MYBB_PREFIX."forums`.`name` AS `forumname`,
|
2017-05-04 10:12:32 +03:00
|
|
|
`".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`
|
2017-05-04 09:59:49 +03:00
|
|
|
LEFT JOIN `".MYBB_PREFIX."forums` ON `".MYBB_PREFIX.'forums`.`fid` = `'.MYBB_PREFIX.'threads`.`fid`'."
|
2017-05-04 10:12:32 +03:00
|
|
|
WHERE `".MYBB_PREFIX."threads`.`visible` = 1
|
|
|
|
AND `".MYBB_PREFIX."threads`.`lastpost` > :date
|
2017-05-04 09:59:49 +03:00
|
|
|
ORDER BY `".MYBB_PREFIX."threads`.`lastpost` DESC
|
2017-05-04 10:12:32 +03:00
|
|
|
";
|
2017-05-04 09:59:49 +03:00
|
|
|
$query = $pdo->prepare($query);
|
|
|
|
$query->execute([
|
2017-05-04 12:19:35 +03:00
|
|
|
'date' => $limit
|
2017-05-04 09:59:49 +03:00
|
|
|
]);
|
2017-05-04 09:11:59 +03:00
|
|
|
|
|
|
|
return $query->fetchAll();
|
|
|
|
}
|
|
|
|
|