vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 2.x Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=4)
-   -   =V.2= vB3 Similar Threads (https://vborg.vbsupport.ru/showthread.php?t=46860)

Velocd 12-20-2002 10:00 PM

=V.2= vB3 Similar Threads
 
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 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:
PHP Code:

ALTER TABLE `threadTYPE MYISAM 


ZiRu$ 12-20-2002 10:47 PM

Nice....i dont hack my board any more though....

Boofo 12-21-2002 12:14 AM

In the install file for this hack, you said to do this:

Code:

c.  Modify the values "$limit" and "$type" to your preference.
There is no $type variable to change. :)

Boofo 12-21-2002 12:18 AM

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 12-21-2002 06:44 AM

Thanks for making a better hack!!

Chris M 12-21-2002 07:20 AM

Thanks:)

Satan

TECK 12-21-2002 07:53 AM

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:
Code:

$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.postusername,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 12-21-2002 02:20 PM

phpmyadmin said:
The used table type doesn't support FULLTEXT indexes
Why?

xxxsaint 12-21-2002 02:25 PM

nice hack - I won't be installing it though.

Velocd 12-21-2002 03:36 PM

Heh, thanks for providing that Teck, I had figured another way to do it but a bit tacky and lazy on my part ;)

PHP Code:

$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 12-21-2002 03:54 PM

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 12-21-2002 03:59 PM

Quote:

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 12-21-2002 04:01 PM

[high]* TECK clicked Install :p :D
[/high]
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 12-21-2002 04:12 PM

Quote:

Originally posted by Velocd


What version of MySQL & vBulletin are you running?

PHP v4.2.2
mysql v3.23.54

Velocd 12-21-2002 04:33 PM

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 12-21-2002 04:40 PM

Quote:

Originally posted by xware

PHP v4.2.2
mysql v3.23.54

Make a file with the content:
Code:

<?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 [high]doquery.php[/high] 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 12-21-2002 04:42 PM

Velocd, is working on 2.2.8 for sure. :)

xware 12-21-2002 04:42 PM

Quote:

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 12-21-2002 04:43 PM

Forget about phpmyadmin, do what I asked you... please.

xware 12-21-2002 04:48 PM

Quote:

Originally posted by TECK

Make a file with the content:
Code:

<?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 [high]doquery.php[/high] 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 12-21-2002 04:51 PM

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 12-21-2002 04:51 PM

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/show...0111#post10111

TECK 12-21-2002 04:57 PM

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 12-21-2002 04:57 PM

Quote:

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/show...0111#post10111
Indeed, you are correct about that. It may be something to do with variable conflict, I'll check it out ;)

TECK 12-21-2002 05:03 PM

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 12-21-2002 05:04 PM

Quote:

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 12-21-2002 05:04 PM

Quote:

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 12-21-2002 05:07 PM

I've disabled my forumjump for the time eing. :bunny:

Velocd 12-21-2002 05:13 PM

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 12-21-2002 05:20 PM

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 12-21-2002 05:24 PM

xware, back up your database just incase of any freak errors occur, and then run this query to convert to MyISAM:

PHP Code:

ALTER TABLE `threadTYPE MYISAM 


xware 12-21-2002 05:36 PM

Quote:

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:

PHP Code:

ALTER TABLE `threadTYPE MYISAM 



Works well now.
Thank you!

NTLDR 12-21-2002 07:16 PM

Quote:

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:

PHP Code:

ORDER BY dateline 

to:

PHP Code:

ORDER BY dateline DESC 

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

[high]* NTLDR clicks install :D[/high]

Boofo 12-21-2002 07:26 PM

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 12-21-2002 07:52 PM

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 12-21-2002 08:17 PM

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):

Code:

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 12-21-2002 09:04 PM

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 12-21-2002 09:12 PM

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 12-21-2002 10:11 PM

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.

Code:

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

Velocd 12-21-2002 10:18 PM

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.


All times are GMT. The time now is 06:04 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01438 seconds
  • Memory Usage 1,841KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (6)bbcode_code_printable
  • (6)bbcode_php_printable
  • (10)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (40)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete