<?php
$whichHot = 'Views';
$notIn = '9'; $limit = 10; $orderBy = ($whichHot == 'Views') ? ' t.TOPIC_REPLIES' : ' t.TOPIC_VIEWS';
$notIn = ($notIn) ? 'WHERE f.FORUM_ID NOT IN ('.$notIn.') ' : 'WHERE 1 ';
$timeFrame = $html->get_date() - 86400;
$timeFrame = "AND t.TOPIC_LAST_REPLY_TIME > $timeFrame";
$stuff = '<table cellspacing="0" cellpadding="0" border="0" class="t_standard">';
$stuff .= '<tr><td class="tdheader" width="80%">Topic subject</td><td class="tdheader" width="20%" align="center">'.$whichHot.'</td></tr>';
$query = "
SELECT p.POST_SUBJECT, t.TOPIC_VIEWS, t.TOPIC_REPLIES, t.POST_ID
FROM {$config['TABLE_PREFIX']}TOPICS t,
{$config['TABLE_PREFIX']}POSTS p,
{$config['TABLE_PREFIX']}FORUMS f,
{$config['TABLE_PREFIX']}USERS u
$notIn
$timeFrame
AND t.FORUM_ID = f.FORUM_ID
AND t.TOPIC_IS_APPROVED = 1
AND t.TOPIC_LAST_POST_ID = p.POST_ID
AND t.TOPIC_LAST_POSTER_ID = u.USER_ID
ORDER BY $orderBy DESC, t.TOPIC_LAST_REPLY_TIME DESC
LIMIT $limit
";
$sth = $dbh->do_query($query,__LINE__,__FILE__);
$innerds = '';
$rowNum = 0;
while(list($pSubj,$tViews,$tReplies,$tPostID) = $dbh->fetch_array($sth)) {
$count = ($whichHot == 'Views') ? $tViews : $tReplies;
$lineColor = ($rowNum&1) ? 'alt-topicsubject' : 'topicsubject';
$innerds .= '<tr><td class="'.$lineColor.'"><a href="'.$config['FULL_URL'].'/ubbthreads.php?ubb=showflat&Number='.$tPostID.'">'.$pSubj.'</a></td>';
$innerds .= '<td class="'.$lineColor.'" align="center">'.$count.'</td></tr>';
$rowNum++;
}
if (!innerds) {
$stuff = '[censored] nothing found! :eek:';
} else {
$stuff .= $innerds.'</table>';
}
$body = <<<EOF
$stuff
EOF;
?>