10-27-2000, 04:13 AM
The index thread function in global.php is another guilty
party of using a while loop to execute queries. This
does away with that. I tested it on my test board with
regular users and guests and all was well.
Find these two lines in global.php and replace it with my code below:
// ###################### Start indexthread #######################
and
// ###################### Start makeforumjump #######################
Insert this code in place
function indexthread($threadid) {
//adds a thread into the search index
global $DB_site;
$thread=$DB_site->query_first("SELECT threadid,title FROM thread WHERE threadid=$threadid");
$subject=$thread[title];
$posts=$DB_site->query("SELECT post.userid, post.username AS guestname, pagetext, user.username AS username
FROM post
LEFT JOIN user ON (user.userid = post.userid)
WHERE threadid=$thread[threadid] AND visible=1");
while ($post=$DB_site->fetch_array($posts))
{
if ($post[userid]!=0)
{
if ($post[username] != "")
{
$usernames.=" $post[username] ";
}
}
else
{
if ($post[guestname] != "")
{
$usernames.=" $post[guestname] ";
}
}
$pagetext.=" $post[pagetext] ";
}
$subject=wordsonly($subject);
$pagetext=$subject." ".wordsonly($pagetext);
$usernames=wordsonly($usernames);
$DB_site->query("UPDATE thread SET subjectindex=' ".addslashes($subject)." ',threadindex=' ".addslashes($pagetext)." ',userindex=' ".addslashes($usernames)." ' WHERE threadid=$threadid");
return 1;
}
party of using a while loop to execute queries. This
does away with that. I tested it on my test board with
regular users and guests and all was well.
Find these two lines in global.php and replace it with my code below:
// ###################### Start indexthread #######################
and
// ###################### Start makeforumjump #######################
Insert this code in place
function indexthread($threadid) {
//adds a thread into the search index
global $DB_site;
$thread=$DB_site->query_first("SELECT threadid,title FROM thread WHERE threadid=$threadid");
$subject=$thread[title];
$posts=$DB_site->query("SELECT post.userid, post.username AS guestname, pagetext, user.username AS username
FROM post
LEFT JOIN user ON (user.userid = post.userid)
WHERE threadid=$thread[threadid] AND visible=1");
while ($post=$DB_site->fetch_array($posts))
{
if ($post[userid]!=0)
{
if ($post[username] != "")
{
$usernames.=" $post[username] ";
}
}
else
{
if ($post[guestname] != "")
{
$usernames.=" $post[guestname] ";
}
}
$pagetext.=" $post[pagetext] ";
}
$subject=wordsonly($subject);
$pagetext=$subject." ".wordsonly($pagetext);
$usernames=wordsonly($usernames);
$DB_site->query("UPDATE thread SET subjectindex=' ".addslashes($subject)." ',threadindex=' ".addslashes($pagetext)." ',userindex=' ".addslashes($usernames)." ' WHERE threadid=$threadid");
return 1;
}