thers $globalignore "); while ($thissticky = $db->fetch_array($stickies)) { $stickycount++; if ($thissticky['lastpost'] >= $lastread AND $thissticky['open'] <> 10) { $newthreads++; } $stickyids .= ",$thissticky[threadid]"; } $db->free_result($stickies); unset($thissticky, $stickies); } $limitlower = ($pagenumber - 1) * $perpage; $limitupper = ($pagenumber) * $perpage; if ($limitupper > $totalthreads) { $limitupper = $totalthreads; if ($limitlower > $totalthreads) { $limitlower = ($totalthreads - $perpage) - 1; } } if ($limitlower < 0) { $limitlower = 0; } if ($foruminfo['allowratings']) { $vbulletin->options['showvotes'] = intval($vbulletin->options['showvotes']); $votequery = " IF(votenum >= " . $vbulletin->options['showvotes'] . ", votenum, 0) AS votenum, IF(votenum >= " . $vbulletin->options['showvotes'] . " AND votenum > 0, votetotal / votenum, 0) AS voteavg, "; } else { $votequery = ''; } if ($vbulletin->options['threadpreview'] > 0) { $previewfield = "post.pagetext AS preview,"; $previewjoin = "LEFT JOIN " . TABLE_PREFIX . "post AS post ON(post.postid = thread.firstpostid)"; } else { $previewfield = ''; $previewjoin = ''; } if ($vbulletin->userinfo['userid'] AND in_coventry($vbulletin->userinfo['userid'], true)) { $tachyjoin = " LEFT JOIN " . TABLE_PREFIX . "tachythreadpost AS tachythreadpost ON (tachythreadpost.threadid = thread.threadid AND tachythreadpost.userid = " . $vbulletin->userinfo['userid'] . ") LEFT JOIN " . TABLE_PREFIX . "tachythreadcounter AS tachythreadcounter ON (tachythreadcounter.threadid = thread.threadid AND tachythreadcounter.userid = " . $vbulletin->userinfo['userid'] . ") "; $tachy_columns = " IF(tachythreadpost.userid IS NULL, thread.lastpost, tachythreadpost.lastpost) AS lastpost, IF(tachythreadpost.userid IS NULL, thread.lastposter, tachythreadpost.lastposter) AS lastposter, IF(tachythreadpost.userid IS NULL, thread.lastpostid, tachythreadpost.lastpostid) AS lastpostid, IF(tachythreadcounter.userid IS NULL, thread.replycount, thread.replycount + tachythreadcounter.replycount) AS replycount, IF(views<=IF(tachythreadcounter.userid IS NULL, thread.replycount, thread.replycount + tachythreadcounter.replycount), IF(tachythreadcounter.userid IS NULL, thread.replycount, thread.replycount + tachythreadcounter.replycount)+1, views) AS views "; } else { $tachyjoin = ''; $tachy_columns = 'thread.lastpost, thread.lastposter, thread.lastpostid, replycount, IF(views<=replycount, replycount+1, views) AS views'; } $hook_query_fields = $hook_query_joins = $hook_query_where = ''; ($hook = vBulletinHook::fetch_hook('forumdisplay_query_threadid')) ? eval($hook) : false; $getthreadids = $db->query_read_slave(" SELECT " . iif($sortfield == 'voteavg', $votequery) . " thread.threadid, $tachy_columns $hook_query_fields FROM " . TABLE_PREFIX . "thread AS thread $tachyjoin $hook_query_joins WHERE forumid = $foruminfo[forumid] AND sticky = 0 $prefix_filter $visiblethreads $globalignore $limitothers $datecut $hook_query_where ORDER BY sticky DESC, $sqlsortfield $sqlsortorder" . (!empty($sqlsortfield2) ? ", $sqlsortfield2 $sqlsortorder" : '') . " LIMIT $limitlower, $perpage "); $ids = ''; while ($thread = $db->fetch_array($getthreadids)) { $ids .= ',' . $thread['threadid']; } $ids .= $stickyids; $db->free_result($getthreadids); unset ($thread, $getthreadids); $hook_query_fields = $hook_query_joins = $hook_query_where = ''; ($hook = vBulletinHook::fetch_hook('forumdisplay_query')) ? eval($hook) : false; $threads = $db->query_read_slave(" SELECT $votequery $previewfield thread.threadid, thread.title AS threadtitle, thread.forumid, pollid, open, postusername, postuserid, thread.iconid AS threadiconid, thread.dateline, notes, thread.visible, sticky, votetotal, thread.attach, $tachy_columns, thread.prefixid, thread.taglist, hiddencount, deletedcount " . (($vbulletin->options['threadsubscribed'] AND $vbulletin->userinfo['userid']) ? ", NOT ISNULL(subscribethread.subscribethreadid) AS issubscribed" : "") . " " . ($deljoin ? ", deletionlog.userid AS del_userid, deletionlog.username AS del_username, deletionlog.reason AS del_reason" : "") . " " . (($vbulletin->options['threadmarking'] AND $vbulletin->userinfo['userid']) ? ", threadread.readtime AS threadread" : "") . " " . ($redirectjoin ? ", threadredirect.expires" : "") . " $hook_query_fields FROM " . TABLE_PREFIX . "thread AS thread $deljoin " . (($vbulletin->options['threadsubscribed'] AND $vbulletin->userinfo['userid']) ? " LEFT JOIN " . TABLE_PREFIX . "subscribethread AS subscribethread ON(subscribethread.threadid = thread.threadid AND subscribethread.userid = " . $vbulletin->userinfo['userid'] . " AND canview = 1)" : "") . " " . (($vbulletin->options['threadmarking'] AND $vbulletin->userinfo['userid']) ? " LEFT JOIN " . TABLE_PREFIX . "threadread AS threadread ON (threadread.threadid = thread.threadid AND threadread.userid = " . $vbulletin->userinfo['userid'] . ")" : "") . " $previewjoin $tachyjoin $redirectjoin $hook_query_joins WHERE thread.threadid IN (0$ids) $hook_query_where ORDER BY sticky DESC, $sqlsortfield $sqlsortorder" . (!empty($sqlsortfield2) ? ", $sqlsortfield2 $sqlsortorder" : '') . " "); unset($limitothers, $delthreadlimit, $deljoin, $datecut, $votequery, $sqlsortfield, $sqlsortorder, $threadids, $sqlsortfield2); // Get Dot Threads $dotthreads = fetch_dot_threads_array($ids); if ($vbulletin->options['showdots'] AND $vbulletin->userinfo['userid']) { $show['dotthreads'] = true; } else { $show['dotthreads'] = false; } unset($ids); // prepare sort things for column header row: $sorturl = 'forumdisplay.php?' . $vbulletin->session->vars['sessionurl'] . "f=$forumid&daysprune=$daysprune"; $oppositesort = iif($vbulletin->GPC['sortorder'] == 'asc', 'desc', 'asc'); if ($totalthreads > 0 OR $stickyids) { if ($totalthreads > 0) { $limitlower++; } // check to see if there are any threads to display. If there are, do so, otherwise, show message if ($vbulletin->options['threadpreview'] > 0) { // Get Buddy List $buddy = array(); if (trim($vbulletin->userinfo['buddylist'])) { $buddylist = preg_split('/( )+/', trim($vbulletin->userinfo['buddylist']), -1, PREG_SPLIT_NO_EMPTY); foreach ($buddylist AS $buddyuserid) { $buddy["$buddyuserid"] = 1; } } DEVDEBUG('buddies: ' . implode(', ', array_keys($buddy))); // Get Ignore Users $ignore = array(); if (trim($vbulletin->userinfo['ignorelist'])) { $ignorelist = preg_split('/( )+/', trim($vbulletin->userinfo['ignorelist']), -1, PREG_SPLIT_NO_EMPTY); foreach ($ignorelist AS $ignoreuserid) { if (!$buddy["$ignoreuserid"]) { $ignore["$ignoreuserid"] = 1; } } } DEVDEBUG('ignored users: ' . implode(', ', array_keys($ignore))); } $show['threads'] = true; $threadbits = ''; $threadbits_sticky = ''; $counter = 0; $toread = 0; while ($thread = $db->fetch_array($threads)) { // AND $counter++ < $perpage) // build thread data $thread = process_thread_array($thread, $lastread, $foruminfo['allowicons']); $realthreadid = $thread['realthreadid']; if ($thread['sticky']) { $threadbit =& $threadbits_sticky; } else { $threadbit =& $threadbits; } ($hook = vBulletinHook::fetch_hook('threadbit_display')) ? eval($hook) : false; // Soft Deleted Thread if ($thread['visible'] == 2) { $thread['deletedcount']++; $show['threadtitle'] = (can_moderate($forumid) OR ($vbulletin->userinfo['userid'] != 0 AND $vbulletin->userinfo['userid'] == $thread['postuserid'])) ? true : false; $show['deletereason'] = (!empty($thread['del_reason'])) ? true : false; $show['viewthread'] = (can_moderate($forumid)) ? true : false; $show['managethread'] = (can_moderate($forumid, 'candeleteposts') OR can_moderate($forumid, 'canremoveposts')) ? true : false; $show['moderated'] = ($thread['hiddencount'] > 0 AND can_moderate($forumid, 'canmoderateposts')) ? true : false; $show['deletedthread'] = $canseedelnotice; eval('$threadbit .= "' . fetch_template('threadbit_deleted') . '";'); } else { if (!$thread['visible']) { $thread['hiddencount']++; } $show['moderated'] = ($thread['hiddencount'] > 0 AND can_moderate($forumid, 'canmoderateposts')) ? true : false; $show['deletedthread'] = ($thread['deletedcount'] > 0 AND $canseedelnotice) ? true : false; eval('$threadbit .= "' . fetch_template('threadbit') . '";'); } } $db->free_result($threads); unset($thread, $counter); $pagenav = construct_page_nav($pagenumber, $perpage, $totalthreads, 'forumdisplay.php?' . $vbulletin->session->vars['sessionurl'] . "f=$forumid", "" . (!empty($vbulletin->GPC['perpage']) ? "&pp=$perpage" : '') . (!empty($vbulletin->GPC['prefixid']) ? "&prefixid=" . $vbulletin->GPC['prefixid'] : '') . (!empty($vbulletin->GPC['sortfield']) ? "&sort=$sortfield" : "") . (!empty($vbulletin->GPC['sortorder']) ? "&order=" . $vbulletin->GPC['sortorder'] : '') . (!empty($vbulletin->GPC['daysprune']) ? "&daysprune=$daysprune" : '') ); eval('$sortarrow[' . $sortfield . '] = "' . fetch_template('forumdisplay_sortarrow') . '";'); } unset($threads, $dotthreads); // get colspan for bottom bar $foruminfo['bottomcolspan'] = 6; if ($foruminfo['allowicons']) { $foruminfo['bottomcolspan']++; } if ($foruminfo['allowratings']) { $foruminfo['bottomcolspan']++; } $show['threadslist'] = true; ///////////////////////////////// } // end forum can contain threads else { $show['threadslist'] = false; } ///////////////////////////////// if ($newthreads < 1 AND $unreadchildforums < 1) { mark_forum_read($foruminfo, $vbulletin->userinfo['userid'], TIMENOW); } eval('$forumhome_markread_script = "' . fetch_template('forumhome_markread_script') . '";'); construct_forum_rules($foruminfo, $forumperms); $show['forumsearch'] = iif (!$show['search_engine'] AND $forumperms & $vbulletin->bf_ugp_forumpermissions['cansearch'] AND $vbulletin->options['enablesearches'], true, false); $show['forumslist'] = iif ($forumshown, true, false); $show['stickies'] = iif ($threadbits_sticky != '', true, false); eval('$ad_location[\'ad_forumdisplay_afterthreads\'] = "' . fetch_template('ad_forumdisplay_afterthreads') . '";'); ($hook = vBulletinHook::fetch_hook('forumdisplay_complete')) ? eval($hook) : false; eval('print_output("' . fetch_template('FORUMDISPLAY') . '");'); /*======================================================================*\ || #################################################################### || # || # CVS: $RCSfile$ - $Revision: 26420 $ || #################################################################### \*======================================================================*/ ?>