Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 3.7 > vBulletin 3.7 Add-ons

Reply
 
Thread Tools
Share users database among many forums Details »»
Share users database among many forums
Version: 0.10, by mangel.ajo mangel.ajo is offline
Developer Last Online: May 2012 Show Printable Version Email this Page

Category: Major Additions - Version: 3.7.2 Rating:
Released: 07-10-2008 Last Update: 07-12-2008 Installs: 61
Re-useable Code Code Changes Translations Is in Beta Stage  
No support by the author.

This is a feature requested many times, and we are still waiting, so I released a patch to be able to run many forums with the same user database.

This is an EXPERIMENTAL PATCH I'm running on my forums.

Code:
--- ../../../private/upload/includes/class_core.php     2008-07-10 11:17:32.000000000 +0200
+++ class_core.php      2008-07-11 17:44:20.000000000 +0200
@@ -405,6 +405,33 @@
                $this->connection_recent =& $link;
                $this->querycount++;

+               $shared_tables = Array("user","useractivation","userban","usertitle","userchangelog","usertextfield","userfield","usergroup","userlist","usernote","profilevisitor","reputation","reputationlevel","spamlog","strikes","pm","pmreceipt","pmtext","avatar","profilefield");
+
+               $main_prefix = "FP_";
+               foreach ($shared_tables as $shared_table)
+               {
+                       $orig = TABLE_PREFIX.$shared_table;
+                       $dst  = $main_prefix.$shared_table;
+
+                       $this->sql = str_replace($orig." ",$dst." "  ,$this->sql);
+                       $this->sql = str_replace($orig.".",$dst."."  ,$this->sql);
+                       $this->sql = str_replace($orig."\r",$dst."\r",$this->sql);
+                       $this->sql = str_replace($orig."\n",$dst."\n",$this->sql);
+                       $this->sql = str_replace($orig."\t",$dst."\t",$this->sql);
+
+               }
+

                if ($queryresult = $this->functions[$buffered ? 'query' : 'query_unbuffered']($this->sql, $link))
                {
You can add "session" to $shared_tables if you want to share your sessions among forums under the same domain (Thanks Lionel)

This is only useful for new forums joining anothers one user database.

Requirements:
  • An old forum where all users are.
  • Sharing the same database, using diferent prefixes for tables (TABLE_PREFIX)
For example: Imagine we have FORUM_A , FORUM_B, and FORUM_C each one with their respective licenses.

FORUM A has table prefix FA_ in database, FORUM_B has FB_ and FORUM_C has FC_

FORUM A is the main, and older forum, where we have all our users.

then we would install FORUM_B and FORUM_C normally, using the same database that FORUM_A uses, but setting up their own table prefixes.


once FB_ and FC_ are installed then we go patching class_core.php from FORUM_B and FORUM_C setting up $main_prefix = "FA_"; so they use FORUM_A for shared tables.

Possible problems:
  • memcached issues?, not sure
  • avatar/signature pics/etc issues when storage is set to disk.
  • more to come...


Author: Optimizacion Web

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #82  
Old 12-18-2008, 08:18 PM
Chunky Monkey Chunky Monkey is offline
 
Join Date: Oct 2008
Posts: 76
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Can I somehow allow guests to view forums on installation B that guests are prevented from viewing on installation A? If so, how? Also, can I prevent other forums that exist at installation A from showing up at installation B?

Installation B's purpose will be to allow guests at domain B access to forums that are restricted on installation A at domain A. They should have the same users, same posts, etc. How can I accomplish this?

Thank you!
Reply With Quote
  #83  
Old 12-19-2008, 03:12 AM
goncalo goncalo is offline
 
Join Date: Mar 2007
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by SirAdrian View Post
Another (similar) solution is to use MySQL 5's views.

(Example: db2.user is a view of db1.user)
Thank you very much SirAdrian, and congratulations, your solution is great, it took me a couple of hours to make it work.

Congratulations also of course to Mangel.ajo and all you guys that try to improve VBulletin and help each others.

Your solution was good also but I prefered the VIEW one suggested by SirAdrian. Why?

The View option is great, in spite of being also a php programmer, I didn't know that MySQL already had it, it's really great, it's like a way to make a symbolic link to another table.

I don't like changing my code, specially because one day I'ld need to reinstall it again and would forget to make all the updates, with the View option it's very easy, and I noticed it's an option that you are ignoring although it's a great one.

I didn't change any code and have now 2 forums working as one.

What have I done?

- First search all users on my forum b to check if they existed on forum A or not, and if so, correct the situation.
- When I had all users different somehow (small forums I had only to change 5 users that didn't post for over 1 year), I ran a small php script to add all those users one by one on the new forum updating user, usertextfield, userfield fields, the ones that are created with each new user.
- Then I ran a script to find to which userid on the new forum each user on the old forum had.
- Now, changed the user and userfield and usertextfield tables to something like "old_user", and creating a new VIEW for each of those 3 tables pointing them to the same tables on the new forum.

From that moment one, it was done. All users signing up would be added to the new forum user table, and each user signing up on the new forum would be able to login to the old forum as well (signing on forum A and logging to B), because they all shared the same database.

This without changing any code.

But now there are stuff que needs to be done, you have lots of tables there that needed to be changed here also. For each table that we want to be used on the new forum (forum A) you need to rename the table do "old_" and creating a view to the new forum database, so that all those tables are ran on the new forum. I've did this for over 20 tables, like smilies, user reputations, usergroup, many tables that I wanted to be using the new forum.

Even the pm table are duplicated now, the 2 forums with separated private messages, but I'll do the same to those, so that all pm's go to the same database.

Having this done, only one thing was left, obviously, the usernames were all mixed up on the old forum, where their usernames changed so the posts appear with the wrong author.

So as we already had the table showing each user's old and new id, something like:
$olduseridbpt['572']=1027;//Old user 572 is now 1027;
We just need the script to have an update userid query on each table saying that the old user will be the new one, with a simple script (carefull that if the user 100 changes to 80, and then the 80 changes to 200, two users instead of one will have the same number which is bad).

Then we run this process in all tables that have a record and that user's userid or fromuserid (pmtext), receiptto, from, etc. I've done this in seconds with php scripts, on these tables:
threadpost,threadrate,pollvote,post,posthash,pm,pm receipt,pm,pmtext,moderator,moderatorlog,customava tar,customprofilepic,useractivation,subscribeforum ,subscribethread,administrator,attachmenteditlog,s igparsed,userlist,userlistrelationid.

All the tables that had the old user id's were now updated. Now everything is at 100%.

Took me only a couple of hours to program the scripts to make the users update on the tables, create views, test databases, etc, without changing any of the VBulletin code.

The old forum treats the views as they were on its own database so everything is perfect without changing any code.

If you have 2 new forums, it would take minutes! Just change about 20 tables that you want on forum A instead of B after installing forum B, make their views, without changing any code, and it's working perfectly in minutes, and you can reinstall vbulletin many times without having to update anything. All this with views.

I don't mix the session table with a view because there are forum-specific fields there like "inthread" which tell the users in which thread they are, and also I didn't put as a view the datastore table which shows things like how many users ate in a forum, those need to be separated.

Anyway many thanks for this thread, and to SirArthur also, which saved me a lot of time with a simple tip and I wanted to share this with others, because I hate changing code.
Reply With Quote
  #84  
Old 12-20-2008, 07:07 PM
Chunky Monkey Chunky Monkey is offline
 
Join Date: Oct 2008
Posts: 76
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Can this mod be made so that the two installations of vb can share forums with different forums having different permissions at each installtion?

Thanks!
Reply With Quote
  #85  
Old 12-21-2008, 01:18 AM
gibgib gibgib is offline
 
Join Date: Nov 2003
Location: Maroochydore, Australia
Posts: 54
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Brass monkey,
chunky,
the funky monkey,

I am having problems getting Admins on install A to be admins on install B. I'm OK as member 1 & un-editable in the config.php file. Already tried adding a new admin usergroup on install B.
Still experimenting though!

Be careful with housekeeping on the install B, eg if you have not set any ranks, usertitles, etc on install B to match A & execute rebuild member titles & ranks on install B control panel, you will lose member data. There's probably a few hidden problems like this.
Anything to do with shared tables I am using the install A control panel for now.
Reply With Quote
  #86  
Old 01-02-2009, 02:42 PM
merk_aus merk_aus is offline
 
Join Date: Feb 2008
Location: Australia
Posts: 582
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

ok i had this working on my forum but it got hacked and i had to begin again and now it doesnt seem to work with the forum prefix?
Reply With Quote
  #87  
Old 01-06-2009, 03:39 AM
gibgib gibgib is offline
 
Join Date: Nov 2003
Location: Maroochydore, Australia
Posts: 54
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by merk_aus View Post
ok i had this working on my forum but it got hacked and i had to begin again and now it doesnt seem to work with the forum prefix?
Don't underestimate the power of the "i"
If you have mysqli as db type in the config file on the second forum this mod doesn't work. Make it "mysql"

Has anyone upgraded a forum or all forums with this mod working?
I'm tempted to remove the added lines while I upgrade each forum to 3.7 then add the lines back in afterwards.
Thoughts?
Reply With Quote
  #88  
Old 01-25-2009, 08:05 AM
gibgib gibgib is offline
 
Join Date: Nov 2003
Location: Maroochydore, Australia
Posts: 54
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Has anyone upgraded to 3.8 on one, or all of the shared forums as yet?
Any hiccups?
Reply With Quote
  #89  
Old 01-25-2009, 11:31 AM
tiekie tiekie is offline
 
Join Date: Sep 2007
Posts: 76
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

how safe and secure is this?
Reply With Quote
  #90  
Old 02-12-2009, 05:00 PM
ps2wiz ps2wiz is offline
 
Join Date: Apr 2005
Posts: 217
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by gibgib View Post
Got it to work!!

This mod WILL NOT work if you have the database type on the subsequent forums set to 'mysqli' in the config.php. Change it to 'mysql'.
Hope that saves some pulling of hair out of your noggin

Starting pulling my hair out, until I found this post.

Thanks!
Reply With Quote
  #91  
Old 02-27-2009, 10:45 AM
ROTPAR ROTPAR is offline
 
Join Date: May 2004
Posts: 140
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

can anyone please give me a detailed step by step introduction, how to make this work ? I understand some basics but I am not a coder Thank you in advance
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 10:58 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04802 seconds
  • Memory Usage 2,311KB
  • Queries Executed 25 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)bbcode_code
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (11)post_thanks_box
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete