• Welcome to Simple Machines Community Forum. Please login or sign up.
October 21, 2021, 08:58:23 PM

News:

Wondering if this will always be free?  See why free is better.


Share user database for 2 (or more) different forums.

Started by Spaceman-Spiff, September 03, 2004, 09:14:44 PM

Previous topic - Next topic

mcgiwer

November 11, 2009, 10:07:15 AM #240 Last Edit: January 04, 2010, 11:26:05 AM by mcgiwer
Here is my solution with allows to easier to manage the prefixes with one time source modification.

== Part 1 ==

Settings.php

FIND:


$db_prefix = "en_";


ADD AFTER:


$db_prefix1 = "shared_";
Michal D.
IT i Technika
Komitet Obrony Demokracji (KOD)
KOD woj. Dolnośląskie

Arantor

Question before you go any further: are you also updating the updateDBsettings and similar functions?
No good deed goes unpunished
All helpful urges should be circumvented

mcgiwer

Quote from: Arantor on November 11, 2009, 10:08:41 AM
Question before you go any further: are you also updating the updateDBsettings and similar functions?

All code will get updated... As I had wrotten, It's the part 1 of the changes
Michal D.
IT i Technika
Komitet Obrony Demokracji (KOD)
KOD woj. Dolnośląskie

Arantor

You're missing what I asked. Updating the Settings.php file is fine but you SHOULD NOT do it manually because when the user changes anything in there - including maintenance mode - the entire file is rebuilt from scratch. Thus I wanted to know if you'd updated the routine that adds values there.
No good deed goes unpunished
All helpful urges should be circumvented

mcgiwer

Quote from: Arantor on November 12, 2009, 09:14:14 AM
You're missing what I asked. Updating the Settings.php file is fine but you SHOULD NOT do it manually because when the user changes anything in there - including maintenance mode - the entire file is rebuilt from scratch. Thus I wanted to know if you'd updated the routine that adds values there.

Did you missed my answer? I had wrotten that all source files will get updated
Michal D.
IT i Technika
Komitet Obrony Demokracji (KOD)
KOD woj. Dolnośląskie

Arantor

I saw that. I'm merely pointing out that updateSettings is often overlooked in such things.
No good deed goes unpunished
All helpful urges should be circumvented

mcgiwer

Michal D.
IT i Technika
Komitet Obrony Demokracji (KOD)
KOD woj. Dolnośląskie

Hj Ahmad Rasyid Hj Ismail


mcgiwer

Quote from: Abu Fahim Ismail on December 09, 2009, 04:57:55 PM
Anyone use doing this for smf 2.0 rc2?

I am, but I got temporary busy with preparation to company registration
Michal D.
IT i Technika
Komitet Obrony Demokracji (KOD)
KOD woj. Dolnośląskie

Hj Ahmad Rasyid Hj Ismail

Quote from: mcgiwer on December 09, 2009, 05:52:30 PM
Quote from: Abu Fahim Ismail on December 09, 2009, 04:57:55 PM
Anyone use doing this for smf 2.0 rc2?

I am, but I got temporary busy with preparation to company registration
Can you provide some guide especially in Subs.php file? Thanks.

Ammoratti

I've followed instructions (and updates) given throughout this thread using v1.1.11, and things seem to be working beautifully.  Two SMF installations are sharing the same user table. Both forums share the same user listing, and login sessions persist between forums (when a user logs into one, he's logged onto both/logs off one, he's logged off both).

Here's an idea of how things are set up:

Original Forum: private.site.com
Second Forum: www.site.com/forum   <--intended to be the "public" forum.

However, there seems to be a conflict with membergroup assignments between the two forums.  As soon as an Admin configures membergroup assignments on one forum, those changes end up interfering with the membergroup settings on the other. 

If I restore the original variable to all membergroups prefixes in my source files ("smf1_membergroups" => "{$db_prefix}membergroups"), will this grant me the ability to manage independent membergroup listings for each SMF installation while sharing user lists?  Or, will this break something?

Thanks in advance, and I'm open to suggestions.

Arantor

Quote from: Ammoratti on January 04, 2010, 02:27:56 AM
If I restore the original variable to all membergroups prefixes in my source files ("smf1_membergroups" => "{$db_prefix}membergroups"), will this grant me the ability to manage independent membergroup listings for each SMF installation while sharing user lists?  Or, will this break something?

No it won't because the list of membergroups is a set of columns in the members table. You need to create a separate ID_GROUP, ID_POST_GROUP and additionalGroups columns (called something else) and have one of the installations reflect those columns instead. (Just take a look at how many changes that impacts though...)
No good deed goes unpunished
All helpful urges should be circumvented

gitchuone

Did this thread die?

Sorry to reopen it if so.

Maybe what I am trying to do is impossible, as it's just coming to me.

I followed the instructions from the beginning, and when I updated ALL THE .PHP files from /Sources and reloaded them to the second forum installation, I started getting database errors that my user didn't exist. That makes sense now because my Forum1 (where I have all my users established) is SMF 1.1.11, and my Forum2 (where I want to use all the members from Forum1) is SMF 2.0 RC2.

Am I right in believing that is the issue?

Or, am I just completely off base?

Wasn't someone going to compile all this info with updated versions?

David111567

Quote from: gitchuone on February 17, 2010, 01:00:46 AM
Did this thread die?

Sorry to reopen it if so.

Maybe what I am trying to do is impossible, as it's just coming to me.

I followed the instructions from the beginning, and when I updated ALL THE .PHP files from /Sources and reloaded them to the second forum installation, I started getting database errors that my user didn't exist. That makes sense now because my Forum1 (where I have all my users established) is SMF 1.1.11, and my Forum2 (where I want to use all the members from Forum1) is SMF 2.0 RC2.

Am I right in believing that is the issue?

Or, am I just completely off base?

Wasn't someone going to compile all this info with updated versions?


it stands to reason...and common sense would DICTATE that you should be using the same versions of SMF for BOTH.....for this to work.

mkmeister

I did this very same thing, but in a much easier way and without changing code by just using mysql.

Say you have two forums with the prefixes forum1_ and forum2_.

All you do is make a copy of one of the tables that you want to share. Then for those prefixes, you just create a view in mysql by the same name of the shared table.

So for example, in the end, you'd end up with the real members table at something like 'shared_members'.
Then for the two different forums, you'd do something like this in mysql:
CREATE VIEW forum1_members AS SELECT * FROM shared_members;
CREATE VIEW forum2_members AS SELECT * FROM shared_members;

Clean, simple, and no big code changes.

gitchuone

Quote from: mkmeister on February 18, 2010, 01:14:15 PM
I did this very same thing, but in a much easier way and without changing code by just using mysql.

Say you have two forums with the prefixes forum1_ and forum2_.

All you do is make a copy of one of the tables that you want to share. Then for those prefixes, you just create a view in mysql by the same name of the shared table.

So for example, in the end, you'd end up with the real members table at something like 'shared_members'.
Then for the two different forums, you'd do something like this in mysql:
CREATE VIEW forum1_members AS SELECT * FROM shared_members;
CREATE VIEW forum2_members AS SELECT * FROM shared_members;

Clean, simple, and no big code changes.

The _members table from 1.1.11 has the same structure as the table from 2.0 RC2, so it "shouldn't" make a difference as far as I can tell.

The rest of the internets aren't giving me any solution as I guess it's obscure to try and import a single from a database into another table of the same database. Dunno.

I used part of the example that I've quoted and have received the error as such:

mysql> create view smf2_members as select * from smf_members;
ERROR 1050 (42S01): Table 'smf2_members' already exists

There IS content in the "existing" table 'smf2_members' but what I would be hoping for is some sort of "force" to allow the content from smf_members to just overwrite what is in smf2_members.

Ain't happenin' yet.

mkmeister

Quote from: gitchuone on February 19, 2010, 02:01:22 AM
Quote from: mkmeister on February 18, 2010, 01:14:15 PM
I did this very same thing, but in a much easier way and without changing code by just using mysql.

Say you have two forums with the prefixes forum1_ and forum2_.

All you do is make a copy of one of the tables that you want to share. Then for those prefixes, you just create a view in mysql by the same name of the shared table.

So for example, in the end, you'd end up with the real members table at something like 'shared_members'.
Then for the two different forums, you'd do something like this in mysql:
CREATE VIEW forum1_members AS SELECT * FROM shared_members;
CREATE VIEW forum2_members AS SELECT * FROM shared_members;

Clean, simple, and no big code changes.

The _members table from 1.1.11 has the same structure as the table from 2.0 RC2, so it "shouldn't" make a difference as far as I can tell.

The rest of the internets aren't giving me any solution as I guess it's obscure to try and import a single from a database into another table of the same database. Dunno.

I used part of the example that I've quoted and have received the error as such:

mysql> create view smf2_members as select * from smf_members;
ERROR 1050 (42S01): Table 'smf2_members' already exists

There IS content in the "existing" table 'smf2_members' but what I would be hoping for is some sort of "force" to allow the content from smf_members to just overwrite what is in smf2_members.

Ain't happenin' yet.

You'd have to move the current table first.

ALTER TABLE prefix_members RENAME TO prefix_members_backup;

All your data will still be in prefix_members_backup in case you need to use it.

Is that the main data you'd like to share with the other forums? If so you can just use that as your main shared table, rename it to something like shared_members and create the view based on that instead. Otherwise, you'll have to merge all the data from the various forums tables into the one shared table to insure unique IDs don't cross, and that can be tricky depending on how many tables you want shared that use that members tables data.

The next step I'm doing is sharing the same login session. I'll let you know if I get around to that and what I do. It's more difficult because the different forums are at completely different domains, so I can't just write an additional/global cookie or anything... I was able to hijack the login though by using the same cookie at another domain, which concerned me a little. Anyway, that's another topic for another day.

GrassrootsPA

I'm a SMF newbie running 2.0 RC2 and must admit the directions above are a bit over my head.

Just wanted to voice support for those that are skilled to figure out an easier way to share 2 forums installed on the same database, or at the VERY VERY least a shared login.

I am confused why a shared login cannot be implemented (so someone doesn't need to register for 2 different forums) if the tables are on the same database...wouldn't this be easy to pull off?
I'm Feeling This!

Hj Ahmad Rasyid Hj Ismail

Quote from: GrassrootsPA on February 28, 2010, 03:17:18 AM
I'm a SMF newbie running 2.0 RC2 and must admit the directions above are a bit over my head.

Just wanted to voice support for those that are skilled to figure out an easier way to share 2 forums installed on the same database, or at the VERY VERY least a shared login.

I am confused why a shared login cannot be implemented (so someone doesn't need to register for 2 different forums) if the tables are on the same database...wouldn't this be easy to pull off?
Why dont you use multiple forum mod instead? It is easier.

GrassrootsPA

Hey Abu,

I tried that but have been unable to get it to work. (There seems to be some bug in it. Plus isn't not exactly what I'm looking for)

In general, I'm blown away by how wonderful SMF is, but the one thing that I do not like is how difficult it seems to be to share login info for 2 forums installed on the same database (with different table prefixes, etc).

From a newbie's perspective, I assumed it would be pretty easy to have a universal login if 2 installs shared the same db, but I am finding out I thought wrong!

(In a perfect world I want to have 2 forums on separate domains with the same login)
I'm Feeling This!

Advertisement: