Register Members List Search Today's Posts Mark Forums Read

Reply
 
Mod Options
Shared user database for multiple forums, same server Details »
Shared user database for multiple forums, same server
Mod Version: 1.00, by CyberRanger (Member) CyberRanger is offline
Developer Last Online: Jan 2015 I like it Show Printable Version Email this Page

This modification is in the archives.
vB Version: 3.0.9 Rating: (0 vote - 0 average) Installs: 15
Released: 12 Oct 2005 Last Update: Never Downloads: 1
Not Supported Code Changes  

For version 3.5x+, please see http://www.vbulletin.org/forum/showthread.php?t=118473

This thread will detail how to have a single login for multiple forums. It makes the following assumptions:
  • A valid vbulletin license exists for each install
  • All forums will be on the same server
  • You already have one forum operational AND that forum uses a BLANK $tableprefix!
  • One database will contain all the tables
This thread is a follow-up from this discussion over at vbulletin.com. Thanks to Brains for some pointers!

Here are the steps:
  1. Copy your forum directories to a parallel directory (for example copy /www/forums to /www/new_forums)
  2. In /includes/config.php, change $tableprefix (line 91) to a new prefix [for example $tableprefix = 'new_';]
  3. Run the vb install from the new directory (/www/new_forums/install/install.php)
  4. During the install, be sure NOT to empty the tables. If you have any doubt about what this means, stop NOW! If you empty the tables, you will lose all of your existing data from a prior install!
  5. Download the files from these directories to your PC: /new_forums, /new_forums/admincp, /new_forums/archive, /new_forums/includes, /new_forums/modcp, /new_forums/subscriptions
  6. We are now going to make global changes to the files in the folders (and subfolders) above. I used Dreamweaver's "edit-find and replace" function with "find in" set to "Entire Current Local Site". We are basically going to remove the "TABLE_PREFIX" from any code dealing with the user. (Note - if you are comfortable with unix command, you could do these changes from the command line on the server.)
  7. Run the following find and replace operations:
    • Find [" . TABLE_PREFIX . "user] (find what's inside the brackets). Replace with [“.”user] This should find 562 instances of user, usergroup, userfield, and usertextfield
    • Find [" . TABLE_PREFIX . "strikes] (find what's inside the brackets). Replace with [“.”strikes] This should find 5 instances of strikes
    • Find [" . TABLE_PREFIX . "pm] (find what's inside the brackets). Replace with [“.”pm] This should find 61 instances of pm, pmtext, pmtextid, and pmreceipt.
    • Upload these directories back to the server.
  8. We now need to do a little fine tuning
    • In /includes/functions.php: on line 1171 remove the table_prefix before $idname.
    • In /includes/adminfunctions: modify print_choser_row (line 1161)to check for $tableid of user, usergroups


      Block Disabled:      (Update License Status)  
      Suspended or Unlicensed Members Cannot View Code.

    • In /includes/adminfunctions_user.php around line 116 (construct_style_chooser)


      Block Disabled:      (Update License Status)  
      Suspended or Unlicensed Members Cannot View Code.


Done! Both forums are now accessed by the same user table! PM's are unified across forums as is the user count.

Download Now

Only licensed members can download files, Click Here for more information.

Show Your Support

  • To receive notifications regarding updates -> Click to Mark as Installed.
  • This modification may not be copied, reproduced or published elsewhere without author's permission.
  #16  
Old 13 Oct 2005, 20:21
CyberRanger's Avatar
CyberRanger CyberRanger is offline
 
Join Date: Mar 2004
Originally Posted by Bad Bunny
The only real use I would have for this is if it totally ran like 2 distinct forums that only shared the core user information (username, password, & email).
That would be very hard to do given the current database layout.
Reply With Quote
  #17  
Old 13 Oct 2005, 20:48
Paul M's Avatar
Paul M Paul M is offline
 
Join Date: Sep 2004
Real name: Paul M
I might be more useful if you actually created a second prefix (TABLE_PREFIX_USERS) and used this, rather than removing the prefix - most people use a prefix for a reason.
__________________
Former vBulletin.org Staff Member


Cable Forum
Please do not PM me about custom work - I no longer undertake any.
Note: I will not answer support questions via e-mail or PM - please use the relevant thread or forum.
Reply With Quote
  #18  
Old 13 Oct 2005, 21:47
CyberRanger's Avatar
CyberRanger CyberRanger is offline
 
Join Date: Mar 2004
Originally Posted by Paul M
I might be more useful if you actually created a second prefix (TABLE_PREFIX_USERS) and used this, rather than removing the prefix - most people use a prefix for a reason.
Yes, absolutely. You may have noticed that in my "find and replace" commands I didn't totally remove TABLE_PREFIX. Instead, where the code reads " . TABLE_PREFIX . ", I replaced that with "." One could easily substitute anything else where the dot is between the quotes. Also, if you need to go back and replace TABLE_PREFIX, you could do a "find-replace" on say ["."user] replace with [". SHARED_TABLE_PREFIX . "user].
Reply With Quote
  #19  
Old 17 Oct 2005, 09:57
lanas lanas is offline
 
Join Date: Aug 2005
bash script

On a Linux/Unix machine, you can use this script


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Run this script from the forum root 4 times: one for "user" (as above), one for "cp", one for "pm", and one for "custom".

Of course, you still need to manually modify the scripts that use a variable like $table instead of 'user[...]' (and stuff), as stated in first post, adding USER_PREFIX where needed, and insert somewhere your definition (I inserted it in class_core.php, just below the TABLE_PREFIX one).
I also noticed a lack in the first post: if you want to also keep avatar images, you should modify image.php in line 129, adding as usual "USER_PREFIX . " before TABLE_PREFIX.

Last edited by lanas; 17 Oct 2005 at 10:49.
Reply With Quote
  #20  
Old 19 Oct 2005, 14:53
CyberRanger's Avatar
CyberRanger CyberRanger is offline
 
Join Date: Mar 2004
Handy little script. Note that when you run it you should be logged as the web server user. The file's owner and group will get changed to whoever you run the script as. Also, the files will have the permissions changed to whatever that users umask is set to, which will probably be 644 and okay.

I also had to change:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

to:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

for it to run on my Suse system.
Reply With Quote
  #21  
Old 19 Oct 2005, 21:26
auz1111's Avatar
auz1111 auz1111 is offline
 
Join Date: Nov 2002
any idea if this will be ported over to 3.5?

And do you think there is a way to have a parent forum where all threads are shown, but in the seperate/child forums just threads/posts from that forum are shown.

maybe an extra field in the thread row that specifies if it belongs to one of the child forums or just the main...
__________________
www.schiphop.net
Reply With Quote
  #22  
Old 22 Oct 2005, 02:16
tscbh tscbh is offline
 
Join Date: Jun 2005
Hi westpointer,

I am wondering if you can put each forum on its own database. I have 3 sites and I am planning to add more in the future. This would be easier to backup and maintain the all the sites.
Reply With Quote
  #23  
Old 22 Oct 2005, 03:02
CyberRanger's Avatar
CyberRanger CyberRanger is offline
 
Join Date: Mar 2004
Originally Posted by tscbh
Hi westpointer,

I am wondering if you can put each forum on its own database. I have 3 sites and I am planning to add more in the future. This would be easier to backup and maintain the all the sites.
I'm not sure how one would do that. It's a much more complicated situation.
Reply With Quote
  #24  
Old 22 Oct 2005, 03:05
CyberRanger's Avatar
CyberRanger CyberRanger is offline
 
Join Date: Mar 2004
Originally Posted by auz1111
any idea if this will be ported over to 3.5?
I've just moved one of my sites to 3.5 so I'll check it out. I don't imagine it would be much different.
Originally Posted by auz1111
And do you think there is a way to have a parent forum where all threads are shown, but in the seperate/child forums just threads/posts from that forum are shown....
That's a whole different creature. This hack doesn't impact threads or posts at all. Depending on exactly what you need, you may be able to achieve this through different styles. But, I'm not sure.
Reply With Quote
  #25  
Old 24 Oct 2005, 14:44
Matthijs Matthijs is offline
 
Join Date: Apr 2002
Originally Posted by tscbh
Hi westpointer,

I am wondering if you can put each forum on its own database. I have 3 sites and I am planning to add more in the future. This would be easier to backup and maintain the all the sites.
As long as they are on the same server, it shouldn't be a problem. You have to change the search-and-replace stuff, though.
The syntax for MySQL is "SELECT foo FROM database.table" so if you change the TABLE_PREFIX to include the database-name and give the db-user access to all databases, it should work without problems...

Edit: you might even put the shared tables in a separate database from the rest of the tables. There are no problems with JOINs and such across databases, I have done that many times...

Last edited by Matthijs; 24 Oct 2005 at 14:51.
Reply With Quote
  #26  
Old 24 Oct 2005, 15:20
CyberRanger's Avatar
CyberRanger CyberRanger is offline
 
Join Date: Mar 2004
Originally Posted by Matthijs
As long as they are on the same server, it shouldn't be a problem. You have to change the search-and-replace stuff, though.
The syntax for MySQL is "SELECT foo FROM database.table" so if you change the TABLE_PREFIX to include the database-name and give the db-user access to all databases, it should work without problems...

Edit: you might even put the shared tables in a separate database from the rest of the tables. There are no problems with JOINs and such across databases, I have done that many times...
Duh ... you are exactly right. That would be a much cleaner solution.
Reply With Quote
  #27  
Old 24 Oct 2005, 15:37
auz1111's Avatar
auz1111 auz1111 is offline
 
Join Date: Nov 2002
Originally Posted by westpointer
I've just moved one of my sites to 3.5 so I'll check it out. I don't imagine it would be much different.
That's a whole different creature. This hack doesn't impact threads or posts at all. Depending on exactly what you need, you may be able to achieve this through different styles. But, I'm not sure.

I would love to be able to do it with different style, but i want it to feel like a completely different forum. When working with styles the main forum in the breadcrumb is always the parent forum so it doesn't look like the sub forum is the main one. know what i mean?
__________________
www.schiphop.net
Reply With Quote
  #28  
Old 26 Oct 2005, 03:51
boostedsti boostedsti is offline
 
Join Date: Nov 2003
Originally Posted by westpointer
I've just moved one of my sites to 3.5 so I'll check it out. I don't imagine it would be much different.
That's a whole different creature. This hack doesn't impact threads or posts at all. Depending on exactly what you need, you may be able to achieve this through different styles. But, I'm not sure.
I did the same it works but cant get registration to work correctly.. It still loads the data in the wrong table..

Last edited by boostedsti; 26 Oct 2005 at 03:53.
Reply With Quote
  #29  
Old 31 Oct 2005, 06:55
hugojr hugojr is offline
 
Join Date: Oct 2005
Mysql Error After I Did This Hack

here is the error I am getting

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

what does this mean?

Last edited by hugojr; 31 Oct 2005 at 07:06.
Reply With Quote
  #30  
Old 31 Oct 2005, 07:07
hugojr hugojr is offline
 
Join Date: Oct 2005
please help me bump
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Mod Options

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


New To Site? Need Help?

All times are GMT. The time now is 18:53.

Layout Options | Width: Wide Color: