PDA

View Full Version : =V.2= vB3 Similar Threads


Velocd
20 Dec 2002, 23:40
vB3 Similar Threads =Version 2=
by Velocd

This hack, as well all my other vB2 hacks, I no longer provide support for (being I run vB3 and it's too much hassel to debug vB2). When vB3 Release Candidate comes out, by request I might convert some of my hacks.


Update - Version 2.1
View this post (http://www.vbulletin.org/forum/showthread.php?postid=333346#post333346) for complete information.


Description:

I recoded the old vB3 Similar Threads hack earlier today, realizing a much better and enhanced method of making it work.
Also, I made a new thread for this hack mainly so it would be better known, since the old one had many unsolved issues.

Improvements:

It no longer compares threads via a similarity or priority level, but rather using a MySQL string-comparison function.
I experienced no slow downs on any pages, and many of my pages seem to be generating .20 faster (from the old version).
The comparison between threads is even more accurate and efficient, and best of all requires no toggling of a priority setting like the previous version. The threads are now searched via the one and only query, making things faster. ;)
The hack has been tested on 2.2.6 and 2.2.9, and also does not require the use of PHP function trim(), so older versions of PHP should deal no trouble.
The overall appearance of the hack has been enhanced to look more vB3 as well :p


The MySQL function MATCH..AGAINST requires MySQL version 3.23.23 or later, else the hack will not operate.

Screenshots:

Refer to the .zip, they are located inside. ;)


Upgrading?

If you are upgrading from the old version, just replace the codechunk.txt file in the location of the old chunk, as well replacing the templates.

---------------

Remember, if you use this hack on your forum, please click the install button! ^__^

side note: once installed, the similar-thread box will not show until you start replying to threads or create new ones. I predict this has something to do with the altering of the field title to FULLTEXT

side note 2: if for some reason you are getting an error about FULLTEXT not being functionable on your thread table, you are running a non-MyISAM table type, and thus must be converted. Run this query to do so:

ALTER TABLE `thread` TYPE = MYISAM

ZiRu$
20 Dec 2002, 23:47
Nice....i dont hack my board any more though....

Boofo
21 Dec 2002, 01:14
In the install file for this hack, you said to do this:

c. Modify the values "$limit" and "$type" to your preference.

There is no $type variable to change. :)

Boofo
21 Dec 2002, 01:18
Also, I replied to a thread, but no Similar thread box showed up. Will it only show "New" threads that are similar, or will it pick up the old ones once the threads are created or replied to?

EDIT: I got it working. I had to put the code under "Show Threads" instead of "Show Posts", like you have in your install file. :) Is there a way to get the last poster to list also?

TheComputerGuy
21 Dec 2002, 07:44
Thanks for making a better hack!!

Chris M
21 Dec 2002, 08:20
Thanks:)

Satan

TECK
21 Dec 2002, 08:53
With your hack, you will display all private forum threads, if they match the text. You need to use perms for this in order to make it efficient.
I install it, but heavily modified based on forum perms. ;)

Here it is the code I used:
$similarthreads = '';
$similarthreadbits = '';
$threadscount = 0;
$forumperms = $DB_site->query("
SELECT forumid,canview
FROM forumpermission
WHERE usergroupid=$bbuserinfo[usergroupid]
");
while ( $forumperm = $DB_site->fetch_array( $forumperms ) )
{
$ipermcache["$forumperm[forumid]"] = $forumperm;
}
$DB_site->free_result( $forumperms );
unset( $forumperm );
$getforums = $DB_site->query("
SELECT forumid,parentid,displayorder
FROM forum
WHERE displayorder<>0 AND active=1
ORDER BY parentid,displayorder
");
while ( $getforum = $DB_site->fetch_array( $getforums ) )
{
$iforumcache["$getforum[parentid]"]["$getforum[displayorder]"]["$getforum[forumid]"] = $getforum;
if ( !isset( $ipermcache["$getforum[forumid]"]['canview'] ) )
{
$iforumperms[] = $getforum['forumid'];
}
}
$DB_site->free_result( $getforums );
unset( $getforum );
if ( !empty( $iforumperms ) )
{
$iforumperms = 'AND thread.forumid IN( ' . implode( ',' , $iforumperms ) . ' )';
}
$otherthreads = $DB_site->query("
SELECT thread.threadid,thread.forumid,thread.title,thread.replycount,thread.postusernam e,forum.title as forumtitle
FROM thread
LEFT JOIN forum ON( forum.forumid=thread.forumid )
WHERE MATCH( thread.title ) AGAINST( '" . addslashes( $thread['title'] ) . "' )
AND thread.visible=1
AND thread.open<>10
AND thread.threadid<>$thread[threadid] $iforumperms
ORDER BY dateline DESC LIMIT 5
");
while ( $otherthread = $DB_site->fetch_array( $otherthreads ) )
{
$threadscount++;
eval( '$similarthreadbits .= "' . gettemplate( 'showthread_similarthreadbit' ) . '";' );
}
if ( !empty( $threadscount ) )
{
eval( '$similarthreads = "' . gettemplate( 'showthread_similarthreads' ) . '";' );
}
Feel free to use it in your install file. :)
BTW, thanks for a great hack!

xware
21 Dec 2002, 15:20
phpmyadmin said:
The used table type doesn't support FULLTEXT indexes
Why?

xxxsaint
21 Dec 2002, 15:25
nice hack - I won't be installing it though.

Velocd
21 Dec 2002, 16:36
Heh, thanks for providing that Teck, I had figured another way to do it but a bit tacky and lazy on my part ;)


$discluded = "2,3";

then using..
AND thread.forumid NOT IN ($discluded)

I've also updated it with your request Boofo, but I'll add Tecks' add-on first then post the revised version. :p

Velocd
21 Dec 2002, 16:54
Alright, the .zip has been updated with version 2.1.

Updated:
+ Added permission check, with thanks going to Teck for supplying the code. ;)
+ Enhanced "last poster" information, requested by Boofo
+ Updated screenshot

To upgrade from V2:

Just update the template1.txt and the codechunk.txt over the previous code.

Velocd
21 Dec 2002, 16:59
Originally posted by xware
phpmyadmin said:
The used table type doesn't support FULLTEXT indexes
Why?

What version of MySQL & vBulletin are you running?

TECK
21 Dec 2002, 17:01
/me clicked Install :p :D
Btw, the perms will add 2 queries, for a total of 3. But is better then editing every time the showthread.php, once you change the perm settings.

xware
21 Dec 2002, 17:12
Originally posted by Velocd


What version of MySQL & vBulletin are you running?
PHP v4.2.2
mysql v3.23.54

Velocd
21 Dec 2002, 17:33
What about your vBulletin version? This hack has been tested on 2.2.6 and 2.2.9, thus suggesting it should work for 2.2.7 and 2.2.8 as well. If there are issues with older versions, I'll need to modify the vB database info of this hack.

TECK
21 Dec 2002, 17:40
Originally posted by xware

PHP v4.2.2
mysql v3.23.54
Make a file with the content:
<?php
error_reporting( E_ALL & ~E_NOTICE );
include_once( './global.php' );

cpheader( '<title>Run Query</title>' );

$runquery = "ALTER TABLE thread ADD FULLTEXT( title )";
$DB_site->reporterror = 1;
$DB_site->query( $runquery );

print_r( 'Query successful:<br>' );
print_r( '<font face="Courier New"> ' . $runquery . '</font><br><br>' );
print_r( 'Do not forget to delete this file.' );

cpfooter();
?>
Save it as doquery.php and upload it onto your /admin folder.
Once uploaded, load it through your browser and let me know if you get any errors. If you do, post them here...

TECK
21 Dec 2002, 17:42
Velocd, is working on 2.2.8 for sure. :)

xware
21 Dec 2002, 17:42
Originally posted by Velocd
What about your vBulletin version? This hack has been tested on 2.2.6 and 2.2.9, thus suggesting it should work for 2.2.7 and 2.2.8 as well. If there are issues with older versions, I'll need to modify the vB database info of this hack.

my vb is 2.2.9 and phpmyadmin is 2.2.5

TECK
21 Dec 2002, 17:43
Forget about phpmyadmin, do what I asked you... please.

xware
21 Dec 2002, 17:48
Originally posted by TECK

Make a file with the content:
<?php
error_reporting( E_ALL & ~E_NOTICE );
include_once( './global.php' );

cpheader( '<title>Run Query</title>' );

$runquery = "ALTER TABLE thread ADD FULLTEXT( title )";
$DB_site->reporterror = 1;
$DB_site->query( $runquery );

print_r( 'Query successful:<br>' );
print_r( '<font face="Courier New"> ' . $runquery . '</font><br><br>' );
print_r( 'Do not forget to delete this file.' );

cpfooter();
?>
Save it as doquery.php and upload it onto your /admin folder.
Once uploaded, load it through your browser and let me know if you get any errors. If you do, post them here...


The used table type doesn't support FULLTEXT indexes
Same error...
Maybe I must check my thread table.

TECK
21 Dec 2002, 17:51
Hmm, it looks like your table is not set as MyISAM? Only the MyISAM table type supports FULLTEXT indexes...
Are you sure about the MySQL ver?

XIanX
21 Dec 2002, 17:51
I installed the hack and it seems to work fine on my forum except one thing. My forum jump stopped working! See for yourself, http://forums.zforcenetwork.com/showthread.php?s=&postid=10111#post10111

TECK
21 Dec 2002, 17:57
Heh, is my perms that kill it... I will post a fix... I don't use forumJump because it saves me 2 queries. :p

Velocd
21 Dec 2002, 17:57
Originally posted by XIanX
I installed the hack and it seems to work fine on my forum except one thing. My forum jump stopped working! See for yourself, http://forums.zforcenetwork.com/showthread.php?s=&postid=10111#post10111

Indeed, you are correct about that. It may be something to do with variable conflict, I'll check it out ;)

TECK
21 Dec 2002, 18:03
Velocd, I'll let you have fun. :)
Look at the function makeforumjump().

Guys, just disable the forumJump it will save you 2 queries all over the board... who use it anyway to navigate? Nobody.

XIanX
21 Dec 2002, 18:04
Originally posted by TECK
Guys, just disable the forumJump it will save you 2 queries all over the board... who use it anyway to navigate? Nobody. I use it. :bandit:

xware
21 Dec 2002, 18:04
Originally posted by TECK
Hmm, it looks like your table is not set as MyISAM? Only the MyISAM table type supports FULLTEXT indexes...
Are you sure about the MySQL ver?


My thread table is ISAM.
Thanks.

XIanX
21 Dec 2002, 18:07
I've disabled my forumjump for the time eing. :bunny:

Velocd
21 Dec 2002, 18:13
I was at first pondering if there was a way to combine the forum permissions in forum jump function with that of this hack, but then after reading your post Teck it dawned on me that I never do use the forum jump..and it is quite useless.. :p (another 2 queries saved.. ^_^)

If you wanna solve your problem still Xianx, place the code in codechunk.txt under makeforumjump(), and that should do it.

TECK
21 Dec 2002, 18:20
Just unset $iforumcache and $ipermcache, that should do it... if you really want to have both sets of queries... But I find it useless, IMO. Just kill the forumJump. :)

Velocd
21 Dec 2002, 18:24
xware, back up your database just incase of any freak errors occur, and then run this query to convert to MyISAM:


ALTER TABLE `thread` TYPE = MYISAM

xware
21 Dec 2002, 18:36
Originally posted by Velocd
xware, back up your database just incase of any freak errors occur, and then run this query to convert to MyISAM:


ALTER TABLE `thread` TYPE = MYISAM



Works well now.
Thank you!

NTLDR
21 Dec 2002, 20:16
Originally posted by Velocd
side note: once installed, the similar-thread box will not show until you start replying to threads or create new ones. I predict this has something to do with the altering of the field title to FULLTEXT

This isn't true for me, it works fine after updating from your old version without any new posts being made :)

I've changed:

ORDER BY dateline

to:

ORDER BY dateline DESC

This way I get the most recent matches as oposed to the oldest matches ;) (IMO seems more sensible that way).

/me clicks install :D

Boofo
21 Dec 2002, 20:26
The line you changed was already in the version I downloaded last night. Is there another version out?

When I put the code in the old spot (from the first version) it also worked without having to update anything. I could never get it to work under the "Show Posts" area, only under the "Show Threads" area. Could that have something to do with it?

Velocd
21 Dec 2002, 20:52
It's not suppose to go under the "Show Posts" area, this hack is meant to show when viewing a thread, therefore it goes in the "show threads" area. Check the new version and its more clear in the instructions now.

In the original version I did have your suggestion NTLDR, but for some reason took it out upgrading. It has been re-added. ;)

Boofo
21 Dec 2002, 21:17
I couldn't find the line in the "Show Threads" section (it was only in the "Show Posts" section for me) to add the codechunk to so I added it ABOVE this piece of code (like you had in your release of the first version):

if ($noshutdownfunc) {
$DB_site->query("UPDATE thread SET views=views+1 WHERE threadid='$threadid'");
} else {
$shutdownqueries[]="UPDATE LOW_PRIORITY thread SET views=views+1 WHERE threadid='$threadid'";
}

if ($bbuserinfo[cookieuser]) {
set_bbarraycookie('threadview', $threadid, time());
}

That might make it easier for everyone to find. :)

Also, I do not have a "$discluded" variable to set at all in the codechunk file.

Boofo
21 Dec 2002, 22:04
Ok, another problem. I lost the forums listing in the forumjump now. When you view a thread, they are no longer there. They are there when viewing a forum, though. Any idea on how to fix this?

Bison
21 Dec 2002, 22:12
For some reason, this version doesn't work as good as the last one ... I get all sorts of thread title matches that don't have any simularities!

What thread titles is this version trying to read? Cause it aint reading them right!

[revert to original in a hurry!]

Boofo
21 Dec 2002, 23:11
Rolodex, try putting the chunkcode above this line and see if that helps. It fixed my forumjump problem and the threads are only showing similar threads if they really ARE similar. Let me know if it works for you.

eval("dooutput(\"".gettemplate("showthread")."\");");

Velocd
21 Dec 2002, 23:18
It's much more accurate for me, not to mention the pages load way faster ^________^

Boofo, refer to the 2nd page about your problem with the forum jump, that issue was already brought up.

Boofo
21 Dec 2002, 23:38
Ok, I see. Sorry I missed that. :) But where I have it now, it seems to be a lot more accurate. It is supposed to pick words out of the title and use those, right? Well, now it does that even better. Any word in the title and it pulls up a Similar thread with the same word in it. Isn't that how it is supposed to work? And will it be alright where I have it now or will it mess with anything, do you know? :)

Auero
21 Dec 2002, 23:41
=/ Okay, it's not working at all for me. I've followed the install file exactly and I still cant get anything to display....????

Velocd
22 Dec 2002, 02:27
@boofo: you're fine ;)

@auero: Make sure you have placed the variable $similarthreads in your showthread template.

Give me a link to your forums, and I'll check it out if it is still not working.

ptm
22 Dec 2002, 04:29
Whew!!! :D :D Got it working perfectly. :)

Bison
22 Dec 2002, 06:40
Originally posted by Boofo
Rolodex, try putting the chunkcode above this line and see if that helps. It fixed my forumjump problem and the threads are only showing similar threads if they really ARE similar. Let me know if it works for you.

eval("dooutput(\"".gettemplate("showthread")."\");");

So far, so good ... but occassionally when I click on a thread link the page comes up blank. I have to refresh the page or click on the back button to get the pages back ... yikes!

Velocd
22 Dec 2002, 17:01
I just realized a good fix for this hack, to make it more accurate. I noticed with the first version I had it check for similar threads only in the forum which the thread originated in. If you do this with this hack, you get much more valid results, mostly if you have a large forum.

I've updated the instructions to include this, so just re-upgrade the codechunk.txt.

If you want to just do it manually, find (in the codechunk):

AND thread.visible=1


And replace it with:

AND thread.visible=1 AND thread.forumid=$thread[forumid]

Velocd
22 Dec 2002, 17:11
Actually.. I just realized that if this is done, the displaying of which forum the similar thread is in is pointless.

Although, I just got another good idea: Search the parent forum and all sub-forums within for similar threads, that the thread originates from.

Now if I can only figure out how to do this.... ;)

NTLDR
22 Dec 2002, 18:23
A note on the permissions for this hack. They only work if custom permissions are applied to all forums (which have different permissions) as it ignores inherited permissions. I've had to disable this hack now till they work correctly.

Bison
22 Dec 2002, 21:35
Another question ... why are you pointing the category background in your showthread_simularthreads template to:

<tr align="center" bgcolor="#336D95" background="http://www.vbulletin.org/forum/images/catagory_backing.gif" background="http://www.vbulletin.org/forum/images/catagory_backing.gif">

Is there a reason for this, or are you "unknowingly" duplicating the same mistake in every update of this hack?

Velocd
23 Dec 2002, 01:06
It's only one small mistake Rolodex, nobody is perfect, eh? I'm quite lazy as it is, so I'll update it next time I figure it need be. If it's gonna kill you, then well.. I bid you the best farewell ;) j/k

@NTLDR: When you say inherited permissions, do you mean specific permissions geared to user groups? Also, can you give an example of how it is not working? I have user group and forum permissions set, and this hack is working correctly--unless I am overlooking something.

Schorsch
23 Dec 2002, 02:06
thanks!! very nice modification :)

TECK
23 Dec 2002, 02:28
Originally posted by Rolodex
Another question ... why are you pointing the category background in your showthread_simularthreads template to:

<tr align="center" bgcolor="#336D95" background="http://www.vbulletin.org/forum/images/catagory_backing.gif" background="http://www.vbulletin.org/forum/images/catagory_backing.gif">

Is there a reason for this, or are you "unknowingly" duplicating the same mistake in every update of this hack?
Because he wanted to see if you are checking everything and not install it no matter how.

Velocd, I will recommend your hack as HOTM. :)
Is one of the very few hacks I installed from many out there...

A small recomandation, try to use into the templates the direct variables pulled from the fetched array. No need to redefine them again inside. Look at my code example (permissions)...

Also, for NTLDR, the perms code listed few posts above are set based on my forum settings. I don't use access masks to save a query on all pages (everyone should do the same!!!) So yes, the perms will not be inherited.
Disable the masks, set your perms individually, or even better, write your own set of perms if you want an extra query on showthread.php file (for a total of 4, instead of 3, as it has now the hack). ;)

Velocd
23 Dec 2002, 03:52
Thanks for the comments and suggestion, Teck ;)

I've updated the .zip once again, fixing some minor stuff :p

DrkFusion
23 Dec 2002, 03:55
Great Hack, I installed the first one, I will install this one.

/me clicks install

Bison
23 Dec 2002, 05:08
Originally posted by Velocd
It's only one small mistake Rolodex, nobody is perfect, eh? I'm quite lazy as it is, so I'll update it next time I figure it need be. If it's gonna kill you, then well.. I bid you the best farewell ;) j/k

It's not a point of it killing me dude, it just looked like you should have noticed this after the second update ... that's all.

And TECK, you have a way of budding in on sh*t that makes you look even more like the jerk you really are ... sometimes it best to shut the f*ck up when the attention is NOT pointed @ you!

TECK
23 Dec 2002, 08:23
Rolodex, is the way you posted acting like the smart ass. Instead of being normal and posting the error, like:
"Velocd, I noticed this error, I think it should be this way, not this way..."
you decided to show your "superiority".
My example, listed 2 lines above, is a constructive way to correct an issue, not your way, but you cannot realize this.
This guy Velocd made a great addition to vBulletin and instead of being nice and modest you act like the HTML wizo, when is such a small mistake.

Hey, I make those kind of HTML mistakes every day, I'm not as perfect as you are and "I don't notice everything" because, as Velocd said, I'm human. Making a good piece of code (like Velocd's) is alot more important in my eyes then a small template editing typo. I was looking for a solution like this and he made it easy for me because I didn't know I could run a query like the one he wrote... so I also helped him with the perms to make this hack a really good one.
You are right about one thing, I shouldn't waste my time posting to those kind of people like you.

TheComputerGuy
23 Dec 2002, 12:35
I use the Forum Jump, and tried to do what you said to do on page 2...yet..my forumjump still does not show properly...any ideas...

TECK
23 Dec 2002, 14:15
Place the code just about the eval(); and unset the perm and forum cache:
unset( $iforumcache );
unset( $ipermcache );

// Velocd's code here...

eval("dooutput(\"".gettemplate("showthread")."\");");
It should take care of the problem.

DrkFusion
23 Dec 2002, 14:31
Thanks teck, I was having the same error.

Regards

NTLDR
23 Dec 2002, 15:01
Originally posted by Velocd
@NTLDR: When you say inherited permissions, do you mean specific permissions geared to user groups? Also, can you give an example of how it is not working? I have user group and forum permissions set, and this hack is working correctly--unless I am overlooking something.

Example Structure:

-Catagory
--Forum 1

If I set the canview permission for Catagory to no for a usergroup, when using the forum that usergroup cannot see Forum 1, however threads in Forum 1 will still show up as similar threads even if though they can't access the thread.

TECK
23 Dec 2002, 16:31
Lee, is normal. I explained to you where is the prob few posts above.
Get on my board for the fix, if you really really want to use access masks (it will add another query). :)

NTLDR
23 Dec 2002, 16:44
I did try what I thought would account for access masks but it didn't work, probablt the code I used was wrong. I'll take a look at TW.com now, thanks for the info TECK :)

XIanX
23 Dec 2002, 16:59
Originally posted by TECK
Lee, is normal. I explained to you where is the prob few posts above.
Get on my board for the fix, if you really really want to use access masks (it will add another query). :) How is having access masks off on a forum even feasible for most people? I have a admin/mod forum, if I turn access masks off, non admins/mods can view the board.

TECK
23 Dec 2002, 20:30
Set perms individually for each forum. A little longer in the procedure but it will save you a precious query.

TECK
23 Dec 2002, 20:33
Originally posted by NTLDR
I did try what I thought would account for access masks but it didn't work, probablt the code I used was wrong. I'll take a look at TW.com now, thanks for the info TECK :)
Heh, I didn't know also. Chen was kind to show me a trick, is pretty complex (at least for me) :D

NTLDR
23 Dec 2002, 21:17
I have to agree the permissions is one of the harder things to accomplish ;)

Have you got a link for the code as I couldn't find it at TW.com.

TECK
23 Dec 2002, 21:31
I will post it in there later on after I test it properly... :)

sparky2
24 Dec 2002, 04:41
Slick hack, but I'd prefer a LINK ~~ rather than assuming each user wants to "view similar threads" every showthread.php page view.

Also, it seems like this hack is a LOT of work just to duplicate functionality that's already built into search.php
(select a subforum // search in titles only )

In showthread.php, you might want (need) to check $searchenabled and $cansearch values
and conditionally null the template if search isn't currently enabled...

but piping it to search.php would take care of:
-- PARENT/sibling title searches
-- permissions
-- runs the title text through BADWORDS

In other words, I'm suggesting that you try this approach:

Create a link to search.php (essentially, a submit button)
& pass post['title'] and forumid as hidden fields
(user sees nothing other than a button, or link, labeled "find similar threads")

Boofo
24 Dec 2002, 04:44
Originally posted by sparky2
Slick hack, but I'd prefer a LINK ~~ rather than assuming each user wants to "view similar threads" every showthread.php page view.

Also, it seems like this hack is a LOT of work just to duplicate functionality that's already built into search.php
(select a subforum // search in titles only )

In showthread.php, you might want (need) to check $searchenabled and $cansearch values
and conditionally null the template if search isn't currently enabled...

but piping it to search.php would take care of:
-- PARENT/sibling title searches
-- permissions
-- runs the title text through BADWORDS

In other words, I'm suggesting that you try this approach:

Create a link to search.php (essentially, a submit button)
& pass post['title'] and forumid as hidden fields
(user sees nothing other than a button, or link, labeled "find similar threads")

That sounds interesting. Could you come up with something like that?

boatdesign
24 Dec 2002, 06:12
What are the minimum PHP version and MySQL version requirements for this hack to run? Does it still require PHP 4.1 or will it run on 4.0.6?

TheComputerGuy
24 Dec 2002, 12:28
TECK, thanks for offering what you did, but it doesn't work properly, I tried to uninstall the hack and my forum jump does not work :(

TECK
24 Dec 2002, 12:53
Ok, I enabled the forumJump just for you. I will take it off tomorrow...
Use tester/test to login onto my board and see that it's working. :D

View this forum, for example:
http://www.teckwizards.com/forum/forumdisplay.php?forumid=5

Velocd
24 Dec 2002, 15:09
@sparky2: yeah, that is certainly possible, but that would cancel out the purpose of this hack being named as "vB3 Similar Threads," as it is suppose to visually look and function like the vB3 feature over at vBulletin.com. Despite the fact that I use a mySQL function MATCH..AGAINST which is probably not as efficient compared to the method Freddie used, which he explained here (http://www.vbulletin.org/forum/showthread.php?postid=286453#post286453), but oh well.... this version works well enough for me. :p

Feel free to make that request yourself, as it surely isn't difficult to do. ;)

TECK
24 Dec 2002, 16:18
Well, in VB2 the word table is not indexed... and I think that Freddie used there several LEFT JOIN's which also affect the performance...

TheComputerGuy
24 Dec 2002, 20:56
TECK, you da man as usual, I will retry on a clean showthread file. Your recommendation for where to place it...Do i place chunk.txt right above the last line? I believe that is the part I got confused on

Thank you so much for helping me.

TECK
25 Dec 2002, 02:01
Originally posted by TheComputerGuy
Your recommendation for where to place it...Do i place chunk.txt right above the last line? I believe that is the part I got confused on

Thank you so much for helping me.
Notice the // Velocd's code here... part? Replace that line with the chunkcode (that makes me think of biscuits, heh)...

sparky2
27 Dec 2002, 12:18
Originally posted by TECK
Well, in VB2 the word table is not indexed...

Huh???

run this query:
show create table word

and you'll see that both (of the 2) columns are indexed

Velocd
27 Dec 2002, 18:46
Actually it might vary from version sparky2, as both of my columns in the word table are not indexed ;) (running on 2.2.6)

It's not that significant anyway :p

VirtueTech
29 Dec 2002, 07:28
It appears "freddie" was right that this was not the most optimized way to go about "similar threads".


Query: SELECT

thread.threadid,thread.lastposter,thread.title,thread.postusername,thread.replyc ount,thread.

lastpost,thread.postuserid,
thread.dateline,forum.title AS

ftitle,forum.forumid,forum.parentlist
FROM thread
LEFT JOIN forum ON (thread.forumid=forum.forumid)
WHERE thread.threadid<>256184 AND thread.forumid IN( 192,62,186,65,64,60,187,271,59,61,138,228,127,214,265,67,68,69,70,71,72,73,74,12 3,142,232,137,227,66,212,145,234,166,125,216,124,215,141,231,139,229,144,233,126 ,213,131,219,247,129,130,218,146,235,128,217,269,270,140,230,147,236,143,221,135 ,225,136,226,165,168,167,164,132,220,133,222,134,223,177,178,183,267,13,190,18,1 62,2,1,12,15,9,4,169,25,188,29,10,19,24,23,33,31,30,53,39,55,56,172,41,42,17,7,2 7,37,26,16,28,20,32,38,47,179,44,173,303,22,46,45,11,5,51,170,49,50,52,75,76,77, 78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,10 3,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,14 9,150,151,152,148,153,154,155,156,157,158,159,160,161,224,174,175,171,180,3,185, 264,34,204,21,195,57,304,194,197,198,199,196,200,208,205,201,202,203,268,207,210 ,211,266,305,273,277,289,278,274,276,275,288,293,292,291,279,286,287,285,298,282 ,284,290,299,302,301,300,295,297,296 )
AND MATCH(thread.title) AGAINST ('old stock from closed store-cocker stuff, lots of redz and more')
AND thread.open<>10
AND thread.visible=1
ORDER BY dateline DESC
LIMIT 4
Time before: 0.39137995243073
Time after: 3.3633810281754


Check out the delay! :(

Nice try though. I was excited that you had made this hack...too bad I can't use it. Thanks anyway.

Velocd
29 Dec 2002, 07:40
Ah yes, but I could defiantly understand why with your forums VirtueTechy--they're massive :p

Then again, this version of the hack is more improved from the last, in the major effect that it will compare threads to the current thread viewing until it has gathered whatever you set as "LIMIT", in your case 4. (in contrast to the old version where it would retrieve ALL threads, then compare). Not to mention, your forum must have dozens of threads with similar titles, so this hack shouldn't have a problem finding 4 similar threads and quickly. Then again, each similar thread could be seperated by 300 non-similar threads, thus having to read more.

This hack still proves very useful for the smaller forums, such as mine with 1,938 threads and not the slightest decrease in performance. ;)

Velocd
29 Dec 2002, 07:51
I just thought of some suggestions that could be done, if you are up to hacking yourself, otherwise I might think of implementing this later. You could either do what Spark2 suggested here (http://www.vbulletin.org/forum/showthread.php?postid=334382#post334382), or make it appear in a small pop-up window. To do this create a seperate PHP file known as similarthread.php, then inside contain all the data of codechunk.txt, but at the top of the file insuring that global.php is being required, error-reporting enabled, and surrounding the file by the php open and close tags. Then in the template that contains template2.txt, put the html, $header, $headerinlcude, body, and other basic tags in it. Then in the showthread.php, make a link appearing like this:
<a href="#" onClick="window.open('similarthread.php?s=&threadtitle=$thread[title]','javascript_1','width=x,height=y,scrollbars=1,resizable=no,menubar=no,toolbar= no'); return false;"><u>Click to view similar threads</u></a>


Just configure the "width" and "height" attributes, and also whatever you want to use as a link caption (whether it be text or image).

Also in similarthread.php, change the variable "$thread['title']" in the query WHERE clause to $threadtitle (not sure if arrays can be passed through URL's)

This method at least it gives the users their option of viewing the similar threads, but doesn't decrease the output speed of the thread. ;)

VirtueTech
29 Dec 2002, 07:56
Not a bad thought. Just to let you know I wasn't trying to down this hack. You did a wonderful job. I was just making you all aware of the problem large forums like myself would have.

Thanks for the alternative Spark2 and Velocd! :)

TECK
29 Dec 2002, 12:44
VirtueTech, here are my stats:
Page generated in 0.19562302 seconds (80.92% PHP - 19.08% MySQL) with 20 queries

Is not the script. Feel free to check my board for time and performance. :)
Cheers.

VirtueTech
29 Dec 2002, 14:03
Originally posted by TECK
VirtueTech, here are my stats:
Page generated in 0.19562302 seconds (80.92% PHP - 19.08% MySQL) with 20 queries

Is not the script. Feel free to check my board for time and performance. :)
Cheers.

Thats because you have like 20 forums. I have over 190. On top of that there is over 1.4 million posts. Thus the delay in going through the titles even though it is indexed. Also the reason why "freddie" used the method he did in vb3

ChurchMedia
08 Jan 2003, 00:18
I'm getting this error:

Fatal error: [] operator not supported for strings in /home/virtual/site6/fst/var/www/html/community/forum/showthread.php on line 500

X-Fan
10 Jan 2003, 00:22
Great hack, thanks!

I was experiencing some slowness as well, so I tried to come up with a way to limit this feature to only selected forums.

Basically, at the start of the codechunk.txt, put this...


if ($curforumid==2 or $curforumid==3 or $curforumid==4) {
$similarforum = "2,3,4"; //Limit search to these forums


...replacing the curforumid numbers with whatever forums you want to have include this feature, and the similarforum numbers to whatever forums you want the feature to search for matches.

At the end of codechunk.txt put this:


}


Now delete everything from...


$forumperms = $DB_site->query("


...down to:


$iforumperms = 'AND thread.forumid IN( ' . implode( ',' , $iforumperms ) . ' )';
}


As its unnecessary to check forum permissions when you're specifying what forums to find matches in.

Now, find this line:


WHERE thread.threadid<>$thread[threadid] $iforumperms


And replace it with this:


WHERE thread.threadid<>$thread[threadid]


Then find:


AND thread.visible=1


And after that add:


AND thread.forumid IN ($similarforum)


To only allow the hack to search for similar threads in those specified forums. However, it's still pretty slow for me, so I'm thinking something's not working right.

Any help would be greatly appreciated! :)

X-Fan
10 Jan 2003, 00:25
Also, another question - is there a way to omit specific words from the matching process? Or perhaps a way to add keywords to threads and allow matching to those?

I'm just trying to find a way for the matching process to be more accurate on my forums, as currently it's not overly accurate.

TECK
10 Jan 2003, 04:32
Originally posted by VirtueTech


Thats because you have like 20 forums. I have over 190. On top of that there is over 1.4 million posts. Thus the delay in going through the titles even though it is indexed. Also the reason why "freddie" used the method he did in vb3
You are right. I tested this on a huge board also... and is slow, unfortunatelly.

maestrosdelweb
13 Jan 2003, 19:14
Great hack.

I'm installing it right now.

Erwin
15 Jan 2003, 11:41
Mmm... I am using version 1 of this hack, and it is working well on a reasonably sized forum (half a million posts). Should I upgrade? I am loathed to since everything is working fine.

Gutspiller
16 Jan 2003, 05:20
I installed this hack and it works great with my forum! :banana:

I have one question though. The way that it works, I take it it does a type of search for these "similar threads" I want to change the way it works and make it more precise by only searching the titles and not the contents of the threads. This way it wont matter the contents of the post is, the similarity will have to occur in the title of the threads.

Can somebody help me how to do this? It should be fairly easy, I just have any clue. :(

Please help.

Elvis
16 Jan 2003, 05:52
I'd strongly suggest replacing:


ORDER BY dateline DESC


with


ORDER BY threadid DESC


on a board that dates back a couple years worth of posts... this seems to help show only the most recent 'similar threads'

Boofo
16 Jan 2003, 09:37
All that will do is display it in order by tread title instead of order by date. I think it only looks at the thread title for matches already, doesn't it? ;)

Elvis
16 Jan 2003, 13:04
Originally posted by Boofo
All that will do is display it in order by tread title instead of order by date. I think it only looks at the thread title for matches already, doesn't it? ;)


a) by 'threadid DESC' it orders the found threads in descensing thread ID order... which gives you the most recent threads, in order that they have been started, not replied to. It's much more relevant to pull up things from this year.. than say 2001.


b) Yes, but Im not changing WHAT it searches, just how it orders them.

Gutspiller
18 Jan 2003, 17:09
Can somebody still help me with my first question? I want it so that the way it ranks similar threads is done by thread title alone and not by the contents of the thread. The way my forum is setup the current searching isn't as good as if it was based on the title of the thread alone.

Anybody? :(

Boofo
18 Jan 2003, 17:27
That's how it already searches.

Gutspiller
18 Jan 2003, 20:41
Originally posted by Boofo
That's how it already searches. hmmm. :surprised:

Well how about making the words that are before each other more important that the following words.

So a title that is "Unreal II movie"

wont bring up similar threads, just because their title has the word "movie" in it. Movie isn't going to be important. But other titles that have "Unreal" are going to be more important .

Can you do that?

Boofo
18 Jan 2003, 20:46
It should bring up anything that has "movie" or "Unreal" in it. And even "II". I have mine set to show 10 threads instead of the default 5. Maybe that will help? It would be kind of hard to selectively pick the order of words in the title, I think.

Gutspiller
18 Jan 2003, 22:27
Originally posted by Boofo
It should bring up anything that has "movie" or "Unreal" in it. And even "II". I have mine set to show 10 threads instead of the default 5. Maybe that will help? It would be kind of hard to selectively pick the order of words in the title, I think. OK, I changed it to 10 and out of those ten threads, only 2 reffer to Unreal or Unreal 2. Is it possible to have it use the first words of the title? I mean movie could be anynumber of threads. Most threads are going to have the important words first. So I was hoping something could be done about having it more relative to the other words. This way the closer they are to the beginning of the thread title, the higher ranking they have in the search. Is something like this possible?

I was also noticing that the previous version of this hack supported descriptions, but I didn't happen to notice anywhere in the code to turn that feature on. Is it in there and I missed it or does V2 not support descriptions?

Xyphen
24 Jan 2003, 20:54
Ok, I have a test forum, where there are only 2 threads -_- so far, but the smiliar threads thing doesn't show up on showthread? why, help please, I am using vb2.2.9, there are no errors, just that smiliar threads don't show up, nothing shows up, everything is exactly the same as it was before i installed the hack, I even replied in both threads and made a new thread, doesn't work at all. help plz..

andyrose
24 Feb 2003, 06:43
I installed this hack at www.neomega.net/forum, and it works like a charm. Excellent job.

FleaBag
27 Feb 2003, 21:45
OK I'm having a problem with the hack...

As you can see here (http://dragonninja.co.uk/showthread.php?s=&threadid=2677), the table for the similar threads is created, but theres no links or information in it. As far as I know everything is installed and working correctly - I had this installed on 2.2.8, but now I've upgraded to 2.3.0 it doesn't work. Any help would be appreciated, thanks.

L-Mane
28 Feb 2003, 23:34
I get this error at the bottom of threads but the hack works...hmmmm

rfield ON userfield.userid=user.userid ".iif ($avatarenabled,"LEFT JOIN avatar ON avatar.avatarid=user.avatarid LEFT JOIN customavatar ON customavatar.userid=user.userid","")." LEFT JOIN attachment ON attachment.attachmentid=post.attachmentid WHERE $postids ORDER BY dateline $postorder "); if (!$getperms['cangetattachment']) { $viewattachedimages=0; } $postbits = ''; $counter=0; $postdone = array(); $sigcache = array(); while ($post=$DB_site->fetch_array($posts) and $counter++<$perpage) { if ($postdone[$post[postid]]) { $counter--; continue; } else { $postdone[$post[postid]]=1; } $postbits .= getpostbit($post); } $pagenav = getpagenav($totalposts,"showthread.php?s=$session[sessionhash]&threadid=$threadid&perpage=$perpage".iif(isset($highlight), "&highlight=$highlight", "")); $DB_site->free_result($posts); unset($post); unset($sigcache); //don't need the signature cache anymore if ($thread[open]) { $replyclose="{replyimage}"; } else { $replyclose="{closedthreadimage}"; } if ($thread[lastpost]>$bbuserinfo[lastvisit]) { // do blue arrow link if ($firstnew) { $newpostlink="#newpost"; } else { $newpostlink="showthread.php?s=$session[sessionhash]&threadid=$threadid&goto=newpost"; } eval("\$firstunread = \"".gettemplate("showthread_firstunread")."\";"); } else { $firstunread=""; } if ($forum[allowratings]) { eval("\$threadrateselect = \"".gettemplate("showthread_threadrate")."\";"); } else { $threadrateselect = " "; } if (ismoderator($thread['forumid']) or $getperms['canopenclose'] or $getperms['candeletethread'] or $getperms['canmove']) { eval("\$adminoptions = \"".gettemplate("showthread_adminoptions")."\";"); } else { $adminoptions = " "; } getforumrules($forum,$getperms); updateuserforum($thread['forumid']); eval("dooutput(\"".gettemplate("showthread")."\");"); ?>

L-Mane
02 Mar 2003, 06:09
Uppin

FleaBag
04 Mar 2003, 22:42
Velocd, any ideas?

iggy123
07 Mar 2003, 20:15
Hmmm. I am having real problems with this hack. I have done as the instructions say but at the bottom of the page i can't see anything.
I edited the showthread.php - as i couldn't find the

II. In showthread.php, under the "showthread" NOT showpost section
a. Find:


makeforumjump()

I don;t get any error messages and everything appears to be working fine
But when i post a new thread nothing shows up under neath - Tell me I am doing something simple?

i am running 2.3.0 http://texasmiltia.net/forums/

iggy123
07 Mar 2003, 20:27
D'oh fixed it!!! I am an assh01e LOL I forgot to add the

$similarthreads

to the showthread template.... looks cool now thnx

Mike11212
08 Mar 2003, 04:33
i think i posted my last question in the wrong thread.
Is there a way to hide certain forums from being displayed?

walah.net
08 Mar 2003, 09:47
Nice Hack .. Thank You :)

Zachery
08 Mar 2003, 19:16
.

Gutspiller
08 Mar 2003, 21:42
Originally posted by Faranth
. Quit spamming Faranth. Sh|t. You fill my email box up and waste my time for me to come to the thread to see what people have said and it's just a F'ing period. :tired:

Mike11212
09 Mar 2003, 00:37
anyone know how to hide specific forums?

FleaBag
10 Mar 2003, 06:34
Finally got this working in 2.3.0... I think the Attachments As Files hack was messing it up.

Shepski
11 Mar 2003, 12:31
marvelous hack, installed on my v2.2.6 with no problems at all :)

well done m8

PurpleCow
12 Apr 2003, 07:48
Does this work with the current stable release of vB 2.3.0 ??

I have downloaded this and would like to install !

Thank much

AlexanderT
13 Apr 2003, 10:05
it works in 2.3.0.

Mireade
22 Apr 2003, 13:11
Very great hack !

What about putting this kind of possibility on a non vb page ?
Would it be difficult ?

And another suggestion to make it more "server friendly" :

Would it be possible to have just a link on which the user could click to get the related threads (so the query would not be systematic but just on demand) ?

Thank you

ChurchMedia
12 May 2003, 20:39
I'm really looking forward to getting this to work. I'm getting this error, however:

Fatal error: [] operator not supported for strings in /path/to/showthread.php on line 499

I'm running MySQL 3.23.41. I can send my showthread.php if it would help.

Thanks!!

hypedave
16 May 2003, 17:17
I have this hack running fine on one of my boards, I did the same install on another board, and my similar threads are not showing up, here is a link to check it out

http://boards.bluegoop.net/showthread.php?s=&threadid=10607

at the bottom you will see that it shows the Similar threads part

Vindicator
18 May 2003, 23:56
I have followed the instructions over and over, but I simply don't get an output. Seems to make no difference what so ever :(




Edit:
I have the obligitory $similarthreads in the showthread template, but this generates nothing.

Edit:
Sorted, started with a clean showthread.php file.

Thanks.

Vindi

Vindicator
19 May 2003, 21:19
This is wierd. I had it working. Made no further changes. Come to check the site 2 hours later and it's not showing again!!!

I'm the only person editing the site. All files are unchanged.

I've checked everything again, but no joy. This is being a right pain in the rear!

Edit:

Oh look, it fixed itself! Some wierd stuff going on with this hack

Ninth Dimension
27 Jun 2003, 12:42
nice hack, i've just installed it, but like many other people i've seen in this thread i can't get it to show any info. I believe that might be partly due to the forum having very few posts on it (i.e. it's a production site) but i'm making threads with similar titles and content in a bid to get it to show up and t's not doing anything.

can someone point me in the right direction? thanx.

Ninth Dimension
28 Jun 2003, 04:41
It's OK fella, i've got it working now, I was only using half the code needed, thank you very much, this add's an extra dimension to the forum :)

drumsy
22 Jul 2003, 23:48
How do I undo this query?

ALTER TABLE `thread` ADD FULLTEXT(`title`);

Chris-FH
21 Oct 2003, 06:34
Hello Folks...

I love this hack, itīs great...

But there is an interesting problem with the permissions. For my registered members, itīs all okay, but UNregistered people can see all threads including the internal ones...

The unregisterd have more rights than registered, I think to much... ;-)

Can someone help me?

vB: 2.30

C.

PsyBlast
24 Nov 2003, 21:01
i've followed the directions perfectly, but when I view a thread nothing . . . no similar threads . . .
http://www.gameinsider.net/forums/showthread.php?s=&threadid=32 to see help please . .

chrisvonc
06 Dec 2003, 23:15
Can anyone use the search/results features of this hack to replace the search/results feature in the Similar Topic hack?
http://www.vbulletin.org/forum/showthread.php?s=&threadid=54308

I find boths hack amazingly helpful on my forum but the Topic hack has stopped working 90% of the time. Since this one seems real solid and works everytime can this somehow be appiled to the Similar Topic hack?

tpearl5
06 Jan 2004, 23:03
Is there an easy way to exclude certain forums?

tpearl5
06 Jan 2004, 23:23
Nevermind, I figured it out.

Chris-FH
06 Jan 2004, 23:28
Please tell us tpeal5... :)

C.

tpearl5
06 Jan 2004, 23:48
Velocd kinda explained this earlier in the thread for what he used to exclude private forums... I used it to exclude newsgroup forums.

In the top of codeblock put:
$discluded = "50,60,70";
where the numbers are the forumid's that you want to exclude

after
WHERE thread.threadid<>$thread[threadid] $iforumperms
put:
AND thread.forumid NOT IN ($discluded)

Chris-FH
06 Jan 2004, 23:55
THX a Lot... :)

C.

chrisvonc
07 Jan 2004, 00:00
Any feel spry enough to take a stab at my request? :)
http://www.vbulletin.org/forum/showpost.php?p=450794&postcount=127