PHP Code:
$getthreads = $DB_site->query("
## GET LATEST THREADS ##
SELECT thread.*, forum.title AS forumtitle
".iif(($vbindex['options'] & VBI_SUBTHREADS) AND $bbuserinfo['userid'], ', NOT ISNULL(subscribethread.subscribethreadid) AS issubscribed')."
FROM ".TABLE_PREFIX."thread AS thread
LEFT JOIN ".TABLE_PREFIX."forum AS forum ON(forum.forumid = thread.forumid)
LEFT JOIN ".TABLE_PREFIX."deletionlog AS deletionlog ON(thread.threadid = deletionlog.primaryid AND type = 'thread')
".iif(($vbindex['options'] & VBI_SUBTHREADS) AND $bbuserinfo['userid'], "
LEFT JOIN " . TABLE_PREFIX . "subscribethread AS subscribethread ON(subscribethread.threadid = thread.threadid AND subscribethread.userid = $bbuserinfo[userid])"
)."
$previewjoin
WHERE open = '1'
AND thread.open <> 10
AND forumid NOT IN (".iif(is_numeric($vbindex[newsfid]), "$vbindex[newsfid],").implode(',', $limitfids).")
AND thread.visible = '1'
AND deletionlog.primaryid IS NULL
$globalignore
$ignorelist
ORDER BY lastpost
DESC LIMIT $vbindex[maxlthreads]");