Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 3.0 > vBulletin 3.0 Full Releases
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Shared user database for multiple forums, same server Details »»
Shared user database for multiple forums, same server
Version: 1.00, by CyberRanger CyberRanger is offline
Developer Last Online: Jan 2015 Show Printable Version Email this Page

Version: 3.0.9 Rating:
Released: 10-11-2005 Last Update: Never Installs: 15
Code Changes  
No support by the author.

For version 3.5x+, please see https://vborg.vbsupport.ru/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

      PHP Code:
      if ($tableid == "user" OR $tableid == "usergroup") {
                      
      $result $DB_site->query("SELECT title, $tableid FROM "."$tablename $wherecondition ORDER BY title");
              } else {
                      
      $result $DB_site->query("SELECT title, $tableid FROM " TABLE_PREFIX "$tablename $wherecondition ORDER BY title"); // existing code
              

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

      PHP Code:
          $tableid $tablename "id";

          if (
      $tablename == "user" OR $tablename == "usergroupid") {
              
      $result $DB_site->query("
                  SELECT title, 
      $tableid
                  FROM "
      ."$tablename
                  WHERE userselect = 1
                  ORDER BY title
              "
      );

          } else {
                      
      // existing code
                              
      $result $DB_site->query("
                  SELECT title, 
      $tableid
                  FROM " 
      TABLE_PREFIX "$tablename
                  WHERE userselect = 1
                  ORDER BY title
              "
      );
          } 

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

Show Your Support

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

Comments
  #12  
Old 10-13-2005, 02:36 PM
CyberRanger's Avatar
CyberRanger CyberRanger is offline
 
Join Date: Mar 2004
Posts: 1,319
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by boostedsti
What about Subscriptions are those per user or per board?
Subscriptions to forums and threads would be by board. However, settings like always getting an email to a thread you start would be by user. The trick is looking at what is in the user table. That determines if the setting is by board or by user. For example, since the custom title is in the user table, it will be the same on both forums. (It cannot be different). Same for the user's signature. Since signature is in the usertextfield table (a shared table) it will be the same for both forums.
Quote:
Originally Posted by boostedsti
Also is that a backup copy you are using or is it really live?
Reason I ask is

Stats: Armchairgeneral
Threads: 1, Posts: 1, Members: 7,631
Welcome to our newest member, vernon.miles

Stats:strategyzoneonline
Threads: 32,469, Posts: 421,417, Members: 7,637
Welcome to our newest member, josephhnewkirk
Great question! It's live! Each forum has it's own stats table so one can see the threads and posts separately for each table. The user number will be off until the nightly cron runs that updates the user count. Some weird effects here but if you dig through the tables and the code it makes sense.
Quote:
Originally Posted by boostedsti
Either way I'm digging script.
Your sites are pretty sweet too.
Thanks!
Reply With Quote
  #13  
Old 10-13-2005, 02:37 PM
CyberRanger's Avatar
CyberRanger CyberRanger is offline
 
Join Date: Mar 2004
Posts: 1,319
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by goyo
Great hack...

Now only if we could use separate servers for this... :nervous:
Yes, that would be great but ... that's an entirely different beast! :nervous:
Reply With Quote
  #14  
Old 10-13-2005, 02:41 PM
CyberRanger's Avatar
CyberRanger CyberRanger is offline
 
Join Date: Mar 2004
Posts: 1,319
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Bad Bunny
What transfers with the character to both forums? All of their setting and profile (including profile pic and avatar)? Some of it? None of it?

Ideally it would seem to me you would have password and email the same while everything was per site.
Anything that is in the user* tables is shared between the sites. So, email, sig, custom title, etc. Avatars are trickier. Since the avatar field is in user, the user will have the same avatar number for each site. However, the avatar table is not shared so ... he could have a different avatar on each site. However, he could really only control what one of them looks like! If the user has a custom avatar, he could actually control what is displayed on each site. I guess ideally the avatar table should also be shared.
Reply With Quote
  #15  
Old 10-13-2005, 02:43 PM
CyberRanger's Avatar
CyberRanger CyberRanger is offline
 
Join Date: Mar 2004
Posts: 1,319
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by GoTTi
can u clear up number 8 for me. i dont understand what u mean...

before i start on a hack or modification i like to know exactly whats goin on...

this has nothing to do with posts right? just user login?
The posts and threads are not impacted at all. Only the user* tables, strike, and pm* tables are shared. (I'll clear up #8 in a bit!)
Reply With Quote
  #16  
Old 10-13-2005, 04:37 PM
Bad Bunny's Avatar
Bad Bunny Bad Bunny is offline
 
Join Date: Apr 2002
Posts: 555
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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).
Reply With Quote
  #17  
Old 10-13-2005, 06:21 PM
CyberRanger's Avatar
CyberRanger CyberRanger is offline
 
Join Date: Mar 2004
Posts: 1,319
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
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
  #18  
Old 10-13-2005, 06:48 PM
Paul M's Avatar
Paul M Paul M is offline
 
Join Date: Sep 2004
Location: Nottingham, UK
Posts: 23,748
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #19  
Old 10-13-2005, 07:47 PM
CyberRanger's Avatar
CyberRanger CyberRanger is offline
 
Join Date: Mar 2004
Posts: 1,319
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
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
  #20  
Old 10-17-2005, 07:57 AM
lanas lanas is offline
 
Join Date: Aug 2005
Posts: 5
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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

Code:
# !/bin/bash
# Replace a text inside all files of current dir
# Customize $a and $b variables

# text to search
a='TABLE_PREFIX . "user';

# text to replace
b='USER_PREFIX . TABLE_PREFIX . "user';

for i in `grep -lr $a`
 do
  echo $i;
  mv $i $i~
  sed -e "s/$a/$b/g" $i~ > $i
  rm $i~
done
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.
Reply With Quote
  #21  
Old 10-19-2005, 12:53 PM
CyberRanger's Avatar
CyberRanger CyberRanger is offline
 
Join Date: Mar 2004
Posts: 1,319
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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:
Code:
for i in `grep -lr $a`
to:
Code:
for i in `grep -lr $a *`
for it to run on my Suse system.
Reply With Quote
Reply


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:43 AM.


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.09554 seconds
  • Memory Usage 2,333KB
  • 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
  • (3)bbcode_code
  • (2)bbcode_php
  • (8)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
  • (3)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