vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.5 Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=113)
-   -   Multiple Forums using a single user table (https://vborg.vbsupport.ru/showthread.php?t=118473)

e2s 06-12-2006 10:00 PM

Multiple Forums using a single user table
 
This was originaly done in 3.0.9 by westpointer you can view that thread here

This Modification is for VB3.5.4 This is not supported but I will give as much help as I possible can.

I have this working now on 2 sites

The main site is http://forums.everything2stroke.com

Slave sites are
http://forums.everythingmx.com
and
http://forums.everythingduners.com

After a successfull install of this modification your sites will share User, PM, and sesson data.

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
  • One database will contain all the tables
A valid vbulletin license exists for each install


Follow these steps

1.) Download your new copy of VB that contains a seperate license key
2.) Go to /includes/config.php.new rename the file to config.php and make necessary changes to the file. See VB Directions. Make sure this code has a different setting than the master site for table prefix.

PHP Code:

 //          ****** TABLE PREFIX ******
 //          Prefix that your vBulletin tables have in the database.
$config['Database']['tableprefix'] = ''

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 all files and directories to your PC from the new install location.

6.) You will need a tool to do a mass Search and replace on all files. I use WildEdit. Here is what you will do using a tool like Wild Edit.
  • Search for [" . TABLE_PREFIX . "user] Replace with [" . "vb3_user] where "vb3_" is the prefix to your master site. 110 Files modified 599 Total changes made
  • Search for [" . TABLE_PREFIX . "strikes] Replace with [" . "vb3_strikes] where "vb3_" is the prefix to your master site 4 Files modified 8 Total changes made
  • Search for [" . TABLE_PREFIX . "pm] Replace with [" . "vb3_pm] where "vb3_" is the prefix to your master site 16 Files modified 77 Total changes made
  • Search for [" . TABLE_PREFIX . "session] Replace with [" . "vb3_session] where "vb3_" is the prefix to your master site 20 Files modified 31 Total changes made

Now to modify some of the code.

In /include/class_dm.php

Search for:
PHP Code:

 function fetch_insert_sql($tableprefix$table)

            { 

Add below change vb3_ to your master site prefix:
PHP Code:

if ($table == "vb3_pmtext")

            {

                        
$sql "INSERT INTO {$table}\r\n\t(" implode(', 'array_keys($this->$table)) . 


")\r\nVALUES\r\n\t(";

            

            }

            else 


Go to /include/class_dm_pm.php

Search for:
PHP Code:

var $table 'pmtext'

Replace with making vb3_ the prefix to your master site:
PHP Code:

var $table 'vb3_pmtext'


Search for:
PHP Code:

$pmtextid = ($this->existing['pmtextid'] ? $this->existing['pmtextid'] : $this->pmtext['pmtextid']); 

Replace with where vb3_ is the prefix to your master site:
PHP Code:

$pmtextid = ($this->existing['pmtextid'] ? $this->existing['pmtextid'] : $this->vb3_pmtext['pmtextid']); 

Search for:
PHP Code:

$this->dbobject->query_write("INSERT INTO " TABLE_PREFIX "pm (pmtextid, userid) VALUES ($pmtextid$user[userid])"); 

Replace with where vb3_ is the prefix to your master site:
PHP Code:

$this->dbobject->query_write("INSERT INTO " "vb3_pm (pmtextid, userid) VALUES ($pmtextid$user[userid])"); 

Search for:
PHP Code:

" . $this->dbobject->escape_string($user['username']) . "', '" . $this->dbobject->escape_string($this->pmtext['title']) . 

Replace with where vb3_ is the prefix to your master site:
PHP Code:

" . $this->dbobject->escape_string($user['username']) . "', '" . $this->dbobject->escape_string($this->vb3_pmtext['title']) . 


Go to /include/class_dm_user.php

Search for:
PHP Code:

$return $this->db_update(TABLE_PREFIX'user'$this->condition$doquery$delayed); 

Replace with where vb3_ is the prefix to your master site:
PHP Code:

$return $this->db_update('vb3_''user'$this->condition$doquery$delayed); 

Search for:
PHP Code:

$this->db_update(TABLE_PREFIX'userfield',     $this->condition$doquery$delayed); 

Replace with where vb3_ is the prefix to your master site:
PHP Code:

$this->db_update('vb3_''userfield',     $this->condition$doquery$delayed); 

Search for:
PHP Code:

$this->db_update(TABLE_PREFIX'usertextfield'$this->condition$doquery$delayed); 

Replace with where vb3_ is the prefix to your master site:
PHP Code:

$this->db_update('vb3_''usertextfield'$this->condition$doquery$delayed); 

Search for:
PHP Code:

if ($return $this->db_insert(TABLE_PREFIX'user'$doquery)) 

Replace with where vb3_ is the prefix to your master site:
PHP Code:

if ($return $this->db_insert('vb3_''user'$doquery)) 

Search for:
PHP Code:

$this->db_insert(TABLE_PREFIX'userfield',     $doquery); 

Replace with where vb3_ is the prefix to your master site:
PHP Code:

$this->db_insert('vb3_''userfield',     $doquery); 

Search for:
PHP Code:

$this->db_insert(TABLE_PREFIX'usertextfield'$doquery); 

Replace with where vb3_ is the prefix to your master site:
PHP Code:

$this->db_insert('vb3_''usertextfield'$doquery); 

Search for:
PHP Code:

DELETE FROM " . TABLE_PREFIX . "session 

Replace with where vb3_ is the prefix to your master site:
PHP Code:

DELETE FROM ?.?vb3_session 

Search for:
PHP Code:

INSERT INTO " . TABLE_PREFIX . "passwordhistory (useridpasswordpassworddate

Replace with where vb3_ is the prefix to your master site:
PHP Code:

INSERT INTO " . "vb3_passwordhistory (useridpasswordpassworddate

Search for:
PHP Code:

 UPDATE " . TABLE_PREFIX . "session SET 

Replace with where vb3_ is the prefix to your master site:
PHP Code:

   UPDATE ?.?vb3_session SET 


That is all the code modification.


The only other item I did is remove a couple cron jobs.

Go into Scheduled tasks then to Scheduled Task Manager

Delete the following CRON jobs from the Slave Site

User Promotions*
Birthdays
Activation Reminder Email

This will eliminate members getting emails from the primary and secondary sites
*not sure if this will duplicate efforts between primary and secondary sites I have it running on both sites still waiting to see if it causes any issues.


Please post here if you have any problems and questions I will try my best to keep up with everyone to help you through this. Once you get the code done the first time you can just do a mass search and replace on your license code and you can be up and running in minutes with a new site.

This is my first major modification so I hope I posted this all correct, again Thanks to Westpointer for his original work without his post this would not have been possible.

Thanks

UPDATE:

Please make this changes it will allow you to make changes to usergroups in the subscription section and when editing a user.

admincp/adminfunctions.php
Search for
PHP Code:

                $result $vbulletin->db->query_read("SELECT title, $tableid FROM " TABLE_PREFIX "$tablename $wherecondition ORDER BY title"); 

Replace with
PHP Code:

if ($tablename == "usergroup")
                {
                
$result $vbulletin->db->query_read("SELECT title, $tableid FROM " "vb3_$tablename $wherecondition ORDER BY title");
                }
                else
                {
                
$result $vbulletin->db->query_read("SELECT title, $tableid FROM " TABLE_PREFIX "$tablename $wherecondition ORDER BY title");
                } 


Ntfu2 06-13-2006 02:48 PM

awesome, i will definetly be trying this out.

What if i have my sites on two different hard drives, but the same server. And MySQL for each is on the same disk as well.

e2s 06-13-2006 03:08 PM

If I understand correct you just have 2 hard drives in your server and the sites happen to be on opposite hard drives. As long as you are only running 1 MySql for both sites you shouldn't have any issues. The path to your install is in the Config.php this Modification is just changing were a second site looks for User, PM, and session data.

Now I have not done this with 2 existing forums. I have only created a new forum to attach to my existing forum. You could still do it with 2 existing forums but it would take a little more effort since you would have to merge your userdatabase and some PM's would be lost unless you could merge those as well. I have no experiance in doing this so I am not sure I could be of much help

e2s 06-13-2006 03:11 PM

Oh just for the record I have successfully made vBadvanced CMPS work on the slave site. There is just a few modification you need to make to the modules. If you are looking to do this PM me.

www.everythingmx.com

I hope to intergrate other products soon like Photopost but not sure when I will get to it.

Ntfu2 06-13-2006 03:45 PM

awesome :)

im going to give it a shot with two existing forms and see how it goes

e2s 06-13-2006 03:46 PM

Just be sure you do a backup of your databse

RMS-Chef 06-13-2006 08:07 PM

How are paid subscriptions effected by this if at all?
If they buy a subscription on the slave site, does it effect anything on the existing main site?

lovevn 06-13-2006 09:14 PM

Hi
You are using your forums on different domains but I want to use it as the fllowing ways:

Master forum : mydomain.com/forum
Slave forum:forum/mydomain.com

Is it possible?

Thanks

Steve F 06-14-2006 06:21 AM

This must be one of the most sought after hacks, great work e2s, thank you for sharing with us and thanks Westpointer for the original idea :)!

lovevn: I am sure it would work

e2s 06-14-2006 09:02 AM

Quote:

Originally Posted by lovevn
Hi
You are using your forums on different domains but I want to use it as the fllowing ways:

Master forum : mydomain.com/forum
Slave forum:forum/mydomain.com

Is it possible?

Thanks

If I understand correctly your just looking to point a subdomain forum to your forum directory. That can be done in your server config without even touching the code

e2s 06-14-2006 09:04 AM

Quote:

Originally Posted by RMS-Chef
How are paid subscriptions effected by this if at all?
If they buy a subscription on the slave site, does it effect anything on the existing main site?

That is a great question but I don't have the answer. I know in the current setup all the usergroups are used by the slave sites so if a member is a paid member in the master site they will also be a paid member in the slave.

I will look into what it will take to get the subscription to work on the slave sites.

e2s 06-14-2006 09:05 AM

Quote:

Originally Posted by Steve F
This must be one of the most sought after hacks, great work e2s, thank you for sharing with us and thanks Westpointer for the original idea :)!

lovevn: I am sure it would work

Thanks Steve, hopefully it will help some people out.

TheComputerGuy 06-14-2006 11:13 AM

awesome hack e2s!

e2s 06-14-2006 11:37 AM

Quote:

Originally Posted by RMS-Chef
How are paid subscriptions effected by this if at all?
If they buy a subscription on the slave site, does it effect anything on the existing main site?

Looks like this can be taken care of real easy I am going to try this today and if all works well i will post up the instructions. It should just be a mass Search and replace on table subscriptions and subscriptionlog


Thanks ComputerGuy

utw-Mephisto 06-14-2006 12:57 PM

Quote:

Originally Posted by e2s
I have no experiance in doing this so I am not sure I could be of much help

Can't you use Impex ? just wondering .

lovevn 06-14-2006 02:26 PM

Thanks for your reply @e2s

BTW I have one question:

Quote:

Search for [" . TABLE_PREFIX . "user] Replace with [" . "vb3_user] where "vb3_" is the prefix to your master site. 110 Files modified
If in my master site I do not user prefix so which one is correct?

1. [" . "_user]

2. [" . "user]

Thanks

e2s 06-14-2006 03:25 PM

Number 2 if you have nothing for a prefix.

Snake 06-14-2006 04:57 PM

Great idea!

e2s 06-15-2006 03:46 PM

Ok I have the paid subscriptions working but it is not perfect and kind of wierd how you have to go about getting it to work on the slave sites.

Here are the directions

1.) Search for [" . TABLE_PREFIX . "payment] Replace with [" . "vb3_payment] where "vb3_" is the prefix to your master site. 16 Files modified 36 Total Changes

2.) Search for [" . TABLE_PREFIX . "subscription] Replace with [" . "vb3_subscription] where "vb3_" is the prefix to your master site. 20 Files modified 68 Total Changes

IMPORTANT: This next change is needed regardless if you want to manage users from the slave site Admin console. This will make the Primary Usergroup list correct when editing a user or setting up a new subscription.

admincp/adminfunctions.php
Search for
PHP Code:

                $result $vbulletin->db->query_read("SELECT title, $tableid FROM " TABLE_PREFIX "$tablename $wherecondition ORDER BY title"); 

Replace with
PHP Code:

if ($tablename == "usergroup")
                {
                
$result $vbulletin->db->query_read("SELECT title, $tableid FROM " "vb3_$tablename $wherecondition ORDER BY title");
                }
                else
                {
                
$result $vbulletin->db->query_read("SELECT title, $tableid FROM " TABLE_PREFIX "$tablename $wherecondition ORDER BY title");
                } 

Now to get Subscriptions to appear on your slave site you have to log into the slave site Admin console and create a dummy subscription which seems to activate paid subscriptions. The subscriptions from your Master site will be the only options your members will have however. You must create and edit your subscriptions from the Master site only.

I looked at the code for a long time and just don't understand enough of it to find out what it works the way it does. However I have tested the paid subscription and everything works perfect.

futuredood 06-20-2006 07:15 PM

if i were to click "find more posts by user a", would it be able to come up with threads and posts by that user in both forums? that way, i can follow "user a" between both forums?

i was searching for a hack that this one kind of fulfills.. https://vborg.vbsupport.ru/showthread.php?t=119107

e2s 06-21-2006 11:30 AM

Posts and Threads are seperate between sites only User, PM, and Session data is shared between sites.

This is not to say it would not be possible. It would probably just take some modification to the search.php so that it looks that the 2 forums you want it to display.

Interesting I might look into this if I find time

futuredood 06-21-2006 10:00 PM

Quote:

Originally Posted by e2s
Posts and Threads are seperate between sites only User, PM, and Session data is shared between sites.

This is not to say it would not be possible. It would probably just take some modification to the search.php so that it looks that the 2 forums you want it to display.

Interesting I might look into this if I find time

That'd be cool, especially since their's so many user profile mods making interaction between people greater.

HuangA 06-23-2006 10:11 PM

I was drafting a similar mod before 3.5, then realized that 3.5 was suppose to have a similar feature (if I'm not mistaken), and decided to stop working on it... its too bad that the feature never made it to live...

e2s 06-26-2006 10:42 AM

I don't recall any supposed feature for 3.5. I know they have teh Master and Slave Database but I really don't know that much about it.

Milad 06-28-2006 02:58 AM

$verynice

e2s 06-29-2006 02:15 PM

Thank you.

bonjurkes 06-30-2006 11:31 AM

ok, it sounds a great idea but i have questions about it

2-) will i use same database with my master board?

6-) i will use vb3_ for my slave board, and the prefix for my master board is . (default one) must i do that mass change that told at step 6 ?

SaN-DeeP 06-30-2006 03:13 PM

wonderful addon, I will have to test this before going for some live implementation :)

thumbsucker 06-30-2006 04:32 PM

Ok, so having a slave forum means that you share the same user DB.

But I assume the slave and master forums can have different discussion sections?

How would changing user groups on the slave affect the master? All changes are made essentially simultanously on both?

utw-Mephisto 07-01-2006 10:49 PM

What about the file edits when I don't use a prefix on the master , like

Quote:

Replace with where vb3_ is the prefix to your master site:
$this->db_insert('vb3_', 'usertextfield', $doquery);

Since I don't use prefixes for the master, would I change it to :

Code:

$this->db_insert('.', 'usertextfield', $doquery);
???

Also :
Quote:

Go to /include/class_dm_pm.php

Search for : var $table = 'pmtext';

change to : var $table = 'vb3_pmtext';
But once again, my master does not have a prefix ... would I have to change it to

Code:

change to : var $table = '._pmtext';

HuangA 07-01-2006 11:27 PM

Quote:

Originally Posted by e2s
I don't recall any supposed feature for 3.5. I know they have teh Master and Slave Database but I really don't know that much about it.

Was a hidden thing, look at public beta1's phrase tables ;)

bonjurkes 07-04-2006 09:44 PM

i have a second question

i have 2 boards at different subdomains at same domain

I moved some of the threads from board 1 to board 2

and now i have a problem like that

My user has 6k messages, after the move at first board it shows his message count as 4k and it shows same number at second board as 4k

mustnt it show it like 2k or is it happening because they are sharing the same user table?

e2s 07-05-2006 03:34 PM

The total posts of a user is stored in the user table so the amount of posts he has will be for both sites. This modification does not have a way to change it so it shows different post counts for each site.

utw-Mephisto 07-05-2006 06:10 PM

http://www.ut2007world.com/images/pu.../icon_bump.gif

Quote:

Originally Posted by utw-Mephisto
What about the file edits when I don't use a prefix on the master , like




Since I don't use prefixes for the master, would I change it to :

Code:

$this->db_insert('.', 'usertextfield', $doquery);
???

Also :


But once again, my master does not have a prefix ... would I have to change it to

Code:

change to : var $table = '._pmtext';


MikeTrin 07-16-2006 02:30 PM

Any advice for someone merging users on 2 existing vb message boards?

e2s 07-19-2006 03:26 PM

Yes on number one

question 2 would be pmtext no _

e2s 07-19-2006 03:27 PM

Quote:

Originally Posted by MikeTrin
Any advice for someone merging users on 2 existing vb message boards?

Sorry I didn't have that situation with my sites I started all new sites. Might be able to work with the usertables in access and get once site to append to the other site. Not really sure

jstep 07-21-2006 07:43 PM

What other options are there to wildedit?

also is prefix like your username in cpanel, you know database name is

username_sportsconvo

or is it sportsconvo

Thanks

Jstep

bonjurkes 07-21-2006 08:12 PM

Quote:

Originally Posted by jstep
What other options are there to wildedit?

also is prefix like your username in cpanel, you know database name is

username_sportsconvo

or is it sportsconvo

Thanks

Jstep

no, it is the vb prefix that you set at your config.php

Hornstar 07-22-2006 08:35 AM

I have just bought a second vbulletin, I will buy a third if this will work.

I have three different domains all on the same server. www.a.com - Main site
www.b.com and www.c.com

I want to have the main sites data with User, PM, and sesson data. to be shared with the other 2 sites.

Now if a new user signs up on www.b.com will that users info be inserted into the database for www.a.com ?

I'm just not sure on one other thing as well. Is it possible to lock out the config.php from being read except for the sever and myself when i log into ftp, because I run www.a.com and my friend runs www.b.com and I dont want him to know the user and pass to the mysql database and to have access to the database at all, as if I was to lose it, that would be seriously bad lol.

Just wondering on the security wise of this issue, thanks.


All times are GMT. The time now is 06:21 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.02585 seconds
  • Memory Usage 1,929KB
  • 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
  • (4)bbcode_code_printable
  • (33)bbcode_php_printable
  • (13)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