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


All times are GMT. The time now is 02:02 PM.

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.01276 seconds
  • Memory Usage 1,750KB
  • 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
  • (2)bbcode_code_printable
  • (2)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)pagenav_pagelinkrel
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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