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

35 lines
986 B
PHP
Raw Normal View History

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();
// Run the Query
2017-05-04 10:12:32 +03:00
$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`
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 10:12:32 +03:00
'date' => strtotime("1 day ago")
2017-05-04 09:59:49 +03:00
]);
2017-05-04 09:11:59 +03:00
return $query->fetchAll();
}