Hi, I'm trying to add in forumhome, latest threads included text.
There is a hack in vb.org that does this, but couple of members suggested that it makes the server to be overloaded if many users are logged in the same time because its performs full table scans. the suggestion was to put a time/date limit in the query - but no one updated the instruction.
I got no answer over there so please help me if you can.
I just want that someone will look at the code and to tell if there really is that kind of problem.
here is the full code:
Also, I would also like to add the forum names that the threads are in.
Any help would be really appreciated.
Thanks
There is a hack in vb.org that does this, but couple of members suggested that it makes the server to be overloaded if many users are logged in the same time because its performs full table scans. the suggestion was to put a time/date limit in the query - but no one updated the instruction.
I got no answer over there so please help me if you can.
I just want that someone will look at the code and to tell if there really is that kind of problem.
here is the full code:
PHP Code:
$forumperms = array();
foreach($forumcache AS $forum) {
$forumperms["$forum[forumid]"] = fetch_permissions($forum['forumid']);
// ## HIDE FORUMS WITHOUT THE CANVIEW OR CANVIEWOTHERS PERMISSION ##
if (!($forumperms["$forum[forumid]"] & CANVIEW) || !($forumperms["$forum[forumid]"] & CANVIEWOTHERS)) {
$limitfids .= ','.$forum['forumid'];
}
}
unset($forum);
if ($vboptions['threadpreview'] > 0) {
$previewfield = ', post.pagetext AS preview';
$previewjoin = 'LEFT JOIN '.TABLE_PREFIX.'post AS post ON(post.postid = thread.firstpostid)';
}
$getthreads = $DB_site->query("
## GET LATEST THREADS ##
SELECT pagetext, thread.*,thread.iconid AS threadiconid $previewfield
FROM ".TABLE_PREFIX."thread AS thread
LEFT JOIN ".TABLE_PREFIX."deletionlog AS deletionlog ON(thread.threadid = deletionlog.primaryid AND type = 'thread')
$previewjoin
WHERE open = '1'
AND forumid NOT IN (0$limitfids)
AND thread.visible = '1'
AND deletionlog.primaryid IS NULL
ORDER BY lastpost
DESC LIMIT 5");
while($thread = $DB_site->fetch_array($getthreads)) {
$threads = true;
$thread['message'] = parse_bbcode2($thread['pagetext'], 0, 0, 1, 1);
if (strlen($thread['message']) > 500)
{
$tobecontinued = '... <a href="' . $vboptions[bburl] . '/showthread.php?t=' . $thread[threadid] . '">äîùê ì÷øåà</a>';
$thread['message'] = substr($thread['message'], 0, 500).$tobecontinued;}
$thread['title'] = fetch_censored_text(fetch_trimmed_title(unhtmlspecialchars($thread['title']), 68));
$thread['date'] = vbdate($vboptions['dateformat'], $thread['lastpost'], 1);
$thread['time'] = vbdate($vboptions['timeformat'], $thread['lastpost']);
$thread['replycount'] = vb_number_format($thread['replycount']);
// show goto new post
$show['firstnew'] = false;
$bbforumview = fetch_bbarray_cookie('forum_view', $thread['forumid']);
if ($bbforumview > $bbuserinfo['lastvisit']) {
$lastread = $bbforumview;
} else {
$lastread = $bbuserinfo['lastvisit'];
}
if ($thread['lastpost'] > $lastread) {
$threadview = fetch_bbarray_cookie('thread_lastview', $thread['threadid']);
if ($thread['lastpost'] > $threadview) {
$show['firstnew'] = true;
$show['icon'] = false;
}
}
exec_switch_bg();
eval("\$threadbits .= \"".fetch_template('forumhome_latestthreadbit')."\";");
}
if ($threads) {
$show['latestthreads'] = true;
}
// memory saving
unset($thread, $threads);
$DB_site->free_result($getthreads);
Any help would be really appreciated.
Thanks
Comment