if (!defined("IN_FUSION")) { header("Location:../../index.php"); exit; }
global $lastvisited;
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 ".($settings['numofthreads']-1).", ".$settings['numofthreads']));
$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,6 ");
if (dbrows($result)) {
$i = 0;
echo "<table cellpadding='0' cellspacing='0' width='80%'>\n<tr>\n";
while ($data = dbarray($result)) {
$row_color = ($i % 2 == 0 ? "tbl" : "tbl");
echo "<tr>\n<td class='".$row_color."'>";
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'])) {
}
}
if ($data['thread_poll']) {
$thread_poll = "<span class='font-size:20px' style='font-weight:bold'>[".$locale['global_051']."]</span> ";
} else {
$thread_poll = "";
}
echo "</td>\n";
echo "<td width='100%' class='".$row_color."'>".$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'], 46)."</a>\n</td>\n";
echo "<td width='200px' class='".$row_color."' style='text-align:center;white-space:nowrap'>".$data['thread_views']."</td>\n";
echo "<td width='200px' class='".$row_color."' style='text-align:center;white-space:nowrap'>".($data['thread_postcount']-1)."</td>\n";
echo "<td width='1%' class='".$row_color."' style='text-align:center;white-space:nowrap'><a href='".BASEDIR."profile.php?lookup=".$data['thread_lastuser']."'>".$data['user_name']."</a>\n</td>\n";
echo "</tr>\n";
$i++;
}
echo "</table>\n";
echo "</div>\n";
}