if (!defined("IN_FUSION")) { die("Access Denied"); }
if (!isset($lastvisited) || !isnum($lastvisited)) { $lastvisited = time(); }
$data = dbarray(dbquery("SELECT tt.thread_lastpost
FROM ".DB_FORUMS." tf
INNER JOIN ".DB_THREADS." tt ON tf.forum_id = tt.forum_id
WHERE ".groupaccess('tf.forum_access')."
ORDER BY tt.thread_lastpost DESC LIMIT 5, 5"));
$timeframe = empty($data['thread_lastpost']) ? 0 : $data['thread_lastpost'];
$result = dbquery(
"SELECT tt.thread_id, tt.thread_subject, tt.thread_views, tt.thread_lastuser, tt.thread_lastpost,
tt.thread_poll, tf.forum_id, tf.forum_name, tf.forum_access, tt.thread_lastpostid, tt.thread_postcount, tu.user_id, tu.user_name
FROM ".DB_THREADS." tt
INNER JOIN ".DB_FORUMS." tf ON tt.forum_id=tf.forum_id
INNER JOIN ".DB_USERS." tu ON tt.thread_lastuser=tu.user_id
WHERE ".groupaccess('tf.forum_access')." AND tt.thread_lastpost >= ".$timeframe."
ORDER BY tt.thread_lastpost DESC LIMIT 0,5"
);
echo "<div style='padding-left: 21px; padding-top: 27px;'>";
echo "<table cellpadding='7' cellspacing='1' width='264' class='forumo'>\n<tr>\n";
echo "</tr>\n";
while ($data = dbarray($result)) {
if ($data['thread_lastpost'] > $lastvisited) {
$thread_match = $data['thread_id']."\|".$data['thread_lastpost']."\|".$data['forum_id'];
if (iMEMBER && preg_match("(^\.{$thread_match}$|\.{$thread_match}\.|\.{$thread_match}$)", $userdata['user_threads'])) {
echo "<img src='".get_image("folder")."' alt='' />";
}
}
if ($data['thread_poll']) {
$thread_poll = "<span class='small' style='font-weight:bold'>[".$locale['global_051']."]</span> ";
} else {
$thread_poll = "";
}
echo "</td>\n";
echo "<td width='100%' class='forumo2' style='background-color:#;filter:alpha(opacity=30);opacity:0.3;' onMouseover=\"this.style.backgroundColor='#000000';\" onMouseout=\"this.style.backgroundColor='';\"><div style='float: left'>".$thread_poll."<a href='".FORUM."viewthread.php?thread_id=".$data['thread_id']."&pid=".$data['thread_lastpostid']."#post_".$data['thread_lastpostid']."' title='".$data['thread_subject']."'>".trimlink($data['thread_subject'], 35)."</a></div> <div style='float: right'>".($data['thread_postcount']-1)."</div></td>\n";
echo "</tr>\n";
}
echo "</table>\n";
echo "</div>";