News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

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

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

Previous topic - Next topic

Arantor

See, that's the thing. You've thrown so much in the posts, out of context, that it's very hard to actually follow.

I actually thought you needed updateStats(array('totalMembers' => '+')); first of all.

j4r3k

Sorry for the mess.
I updated my first post, is it clear now what I'm trying to achieve?
Deleted my other posts.

Mr. Doug

Quote from: j4r3k on March 31, 2010, 12:30:38 PM
Sorry for the mess.
I updated my first post, is it clear now what I'm trying to achieve?
Deleted my other posts.

That actually confuses things more sometimes...
--
Doug Hardman
doug (at) puttertalk (dot) com

j4r3k

OK, here is a solution that updates all your forums total members count right away after new user registration (there is no need to use 'update statistics' from admin panel). For SMF 1.1.11.

First of all we'll make it work using the 'update statistics' option too. In Subs.php

Find

updateSettings($changes);


Replace with

//updateSettings($changes);
foreach ($changes as $variable => $value)
{
db_query("
UPDATE prefix1_settings
SET value = " . ($value === true ? 'value + 1' : ($value === false ? 'value - 1' : "'$value'")) . "
WHERE variable = '$variable'
LIMIT 1", __FILE__, __LINE__);

db_query("
UPDATE prefix2_settings
SET value = " . ($value === true ? 'value + 1' : ($value === false ? 'value - 1' : "'$value'")) . "
WHERE variable = '$variable'
LIMIT 1", __FILE__, __LINE__);

$modSettings[$variable] = $value === true ? $modSettings[$variable] + 1 : ($value === false ? $modSettings[$variable] - 1 : stripslashes($value));
}


add more prefixes according to your needs.

Second step: make it work after user registration. In Subs.php

Find

if ($update)
{
foreach ($changeArray as $variable => $value)
{
db_query("
UPDATE {$db_prefix}settings
SET value = " . ($value === true ? 'value + 1' : ($value === false ? 'value - 1' : "'$value'")) . "
WHERE variable = '$variable'
LIMIT 1", __FILE__, __LINE__);


Replace with

if ($update)
{
foreach ($changeArray as $variable => $value)
{
db_query("
UPDATE {$db_prefix}settings
SET value = " . ($value === true ? 'value + 1' : ($value === false ? 'value - 1' : "'$value'")) . "
WHERE variable = '$variable'
LIMIT 1", __FILE__, __LINE__);

if ($variable == 'totalMembers')
{
db_query("
UPDATE prefix1_settings
SET value = " . ($value === true ? 'value + 1' : ($value === false ? 'value - 1' : "'$value'")) . "
WHERE variable = '$variable'
LIMIT 1", __FILE__, __LINE__);

db_query("
UPDATE prefix2_settings
SET value = " . ($value === true ? 'value + 1' : ($value === false ? 'value - 1' : "'$value'")) . "
WHERE variable = '$variable'
LIMIT 1", __FILE__, __LINE__);
}
$modSettings[$variable] = $value === true ? $modSettings[$variable] + 1 : ($value === false ? $modSettings[$variable] - 1 : stripslashes($value));



Note that in this step you must enter only the prefixes that are in other forums than you are currently editing. For example if your are editing Subs.php in forum with prefix1 then you enter prefix2, prefix3 into the if statement. prefix1 is handled by {$db_prefix}.

Remember to edit all Subs.php in each forum so the 'update statistics' and user registration works on each forum same way.

Liam.

Great bit there j4r3k, I'm soon to try that on my 1.1.11 test forums - have you tried if this works on 2.0 RC3 aswell though?

Hj Ahmad Rasyid Hj Ismail

Quote from: iKorp on April 10, 2010, 04:40:34 PM
Great bit there j4r3k, I'm soon to try that on my 1.1.11 test forums - have you tried if this works on 2.0 RC3 aswell though?
It's a littble bit complicated with 2.0 RC3 files. It is no longer just Subs.php file. You may have to go through other files as well. I normally use UltraEdit to check all files for the relevant code. By the VIEW tips & tricks in MySQL / phpAdmin works. That is all I can say.

j4r3k


Liam.

I have a mass search/replace program I could use... But would that be the only thing, changing it in all of the files instead of just Subs?

Hj Ahmad Rasyid Hj Ismail

Quote from: Liam. on April 11, 2010, 07:14:10 AM
I have a mass search/replace program I could use... But would that be the only thing, changing it in all of the files instead of just Subs?
Yes all the files in sources folder.

FireDitto

I'm using RC3, and I'm not entirely sure I'm searching for the correct thing, as I can't seem to find that which I need to replace...

Quote2. Modifying the source code
Open each of the .php files located in the Sources directory in your hard drive using a text editor program. Find all occurances of "{$db_prefix}members" and replace with "smf1_members" (without quotes). Do this for every single .php file in the Sources directory. Also find and replace the following:
"{$db_prefix}im_recipients" => "smf1_im_recipients"
"{$db_prefix}instant_messages" => "smf1_instant_messages"
"{$db_prefix}membergroups" => "smf1_membergroups"

am I looking for:
{$db_prefix}instant_messages
{$rpg2_}instant_messages
$rpg2_instant_messages
rpg2_instant_messages

... or what? Sorry, but I'm completely lost! >.< and nothing seems to be throwing up a result.
Second Pass Weyr<br />An AU Pernse RPG<br /><br />SMF 2.0.6 with SP 2.3.5

Hj Ahmad Rasyid Hj Ismail

You are looking for this:
Quote from: FireDitto on June 05, 2010, 10:34:12 PM
$db_prefix
with a note that it may not be in (or only in) the form of {$db_prefix}. Backup before you make any changes. Do read all the questions and guides in here, if any, especially regarding the caveat in doing this. Good luck in getting any help as this mod is way back to 2004 and there are many changes in SMF especially now it is 2.0 RC3 when then it was in very early 1.1.x.

IMHO,you might prefer this with some caveat as well.

Hj Ahmad Rasyid Hj Ismail

You are welcome. Hope we all will always try to learn and share earned knowledge to each other.

FireDitto

Ugh. I got an error.

I followed the instructions here with the added:

prefix_membergroups to shared_membergroups

And am now getting the following error on both sites:

"Connection Problems

Sorry, SMF was unable to connect to the database. This may be caused by the server being busy. Please try again later."


Did I screw up something in changing the membergroups, or elsewhere? I can't seem to find where I messed up.

Thanks.
Second Pass Weyr<br />An AU Pernse RPG<br /><br />SMF 2.0.6 with SP 2.3.5

Hj Ahmad Rasyid Hj Ismail

#333
Have you completed all the steps correctly? Because my forums also stop working until I have finished all the steps correctly. Remember, always to backup your database in full before doing this and restore it back if anything goes on.

Check this list:
1. Ensure using USE smf correctly i.e. change smf to your database name.
2. Ensure using ALTER TABLE correctly.
3. Ensure CREATE VIEW correctly as well.
4. Lastly, DO NOT keep original table in the same original name.

IMHO your forums seems not connecting to database may be due to any of the above. Solutions? Restore your database and do it again.

FireDitto

I'm not *positive* where I messed up, but I re-did it very carefully and it's working beautifully now.

Thanks =)
Second Pass Weyr<br />An AU Pernse RPG<br /><br />SMF 2.0.6 with SP 2.3.5

FireDitto

#335
Um, I'm having another issue now:

Although all the mods are installing correctly and without error, none of them are actually working... I thought it was a one off, and posted on the support thread, but after installing more with the same kind of results, I believe it's probably my editing of this that's cause the issue... somewhere.

Why would this be, and how do I correct it?
Second Pass Weyr<br />An AU Pernse RPG<br /><br />SMF 2.0.6 with SP 2.3.5

Hj Ahmad Rasyid Hj Ismail

Mods error might be due to the caveat as mentioned and discussed in this thread. If you can list the mods, maybe we will know where the fault came from.

Else, you have edited the sources file using the original mod which you shouldn't if you are using the database approach. If you did this, that may be the cause of your problem(s) and not the mod(s) (except if the mod is related to profile avatar like what Arantor had advised, although it is very unlikely in your case).

FireDitto

#337
My mods are as follows; this is more or less a complete list of the mods I'll be employing:

Not working

EzPortal - perfect install, but member changes are not being saved [eg, who can view what].
Sub Accounts - Installed perfectly, but comes up with "Unknown column 'mem.is_shareable' in 'field list'" when I activated it in the Administration panel, and it's now all I get on that forum... I expect that would just be a few edits to make it working?

Working:
Add IP2Location to track IP.
Effectivly Remove SMF Logo.
Display Name on Registration.
Member Color Link.
Team Page.
Justify BBC.
Custom Forms.

Waiting for Update
Multiple Forums Mod



Thanks for any help =)
Second Pass Weyr<br />An AU Pernse RPG<br /><br />SMF 2.0.6 with SP 2.3.5

Masterd


Hj Ahmad Rasyid Hj Ismail

Quote from: FireDitto on June 15, 2010, 12:47:04 AM
Not working

EzPortal - perfect install, but member changes are not being saved [eg, who can view what].
Sub Accounts - Installed perfectly, but comes up with "Unknown column 'mem.is_shareable' in 'field list'" when I activated it in the Administration panel, and it's now all I get on that forum... I expect that would just be a few edits to make it working?
I think Sub Account Mod as well as ezPortal do modify / add database. Maybe you want to share their tables too?

I listed the note on the Caveat & Gotchas of this database mod:
Quote from: Arantor on March 23, 2010, 06:09:41 PM
This thread does discuss multiple ways of doing it, but all require significant change or come with significant caveats and gotchas. There's no simple way that actually works cleanly without any side effects :(
Avatar Caveat:
Quote from: Arantor on March 05, 2010, 07:15:54 AM
Note that member avatars are shared if they use an external URL or pick from the gallery (since that's stored in the members table, along with their post count) but not if they upload their own (since that's stored in the attachments table)
Membergroup Caveat:
Quote from: Arantor on March 09, 2010, 10:12:29 AM
Yup, that's the idea but do see the caveats from me above, like about membergroups and so on.
Attachment Caveat:
Quote from: Arantor on March 27, 2010, 05:47:31 PM
Assuming you have two topic and two message tables, you'll be duplicating attachments unless you modify all the attachment handling code too (have fun with that)

Basically, an attachment is attached to a post by id. If you attach a file to message id 1000, the same attachment is visible in BOTH sides' message 1000.
Cookie Caveat:
Quote from: Mr. Doug on March 28, 2010, 08:26:56 AM
I've had no issues with cookies. Just make sure your cookies aren't named the same way. (keep them all different.)
Theme & Board Caveat:
Quote from: Mr. Doug on March 29, 2010, 08:38:17 AM
I found a caveat to a shared member DB. Make sure all the Themes on your boards are numbered the same way. If I make a change the default to one (and reset the members options), all 3 get the change pushed.
Custom Profile Caveat:
Quote from: Arantor on March 29, 2010, 08:41:20 AM
Note also that custom profile fields are also in that table...
Statistic Caveat:
Quote from: Mr. Doug on March 31, 2010, 08:36:06 AM
I ran into the same thing. If you run the "update statistics" maintenance, it fixes it. So now I just run that every few days until I can get around to writing a cron script that does it for me. Everything functions correctly, it just doesn't update the number of users in the bottom of the page..
Hope this will help. Happy testing! ;)

Advertisement: