Members: 10,140
Threads: 38,830
Posts: 159,367
Online: 25

Newest Member: Xoote


Old 08.04.2004, 00:16   #1
tomwoods
Baby Mamber
 
Join Date: Apr 2004
Posts: 16
tomwoods is on a distinguished road
Flame Multiple Mambo sites

Hi, people. Well, this comes from a discussion I had at the old mamboportal forum about a week ago. I had been wondering if there was any possibility of having multiple Mambo sites running on one server and sharing ONE user database.

That means that if you register in one of the sites, you could use the same username/password in the other installed Mambo sites.

So.. I got a bunch o' you-can't-do-that's and try-something-less-cool's , but at the last moment I thought up a way to get Mambo to this for me, so for all it's worth I though I'd share my hack with the mambo community.


------------------------------------------------------------------------
Mambo 4.5 hack to support multi-site / one usertable (backup your site AND database):

1) C'mon, back'em up.

2) In database.php, add:
///////////////////////////////////////////////////////////////////////////////////////

function database( $host='localhost', $user, $pass, $db, $table_prefix ) {
// perform a number of fatality checks, then die gracefully
if (!function_exists( 'mysql_connect' )) {
//or die( 'FATAL ERROR: MySQL support not available. Please check your configuration.' );
$mosSystemError = 1;
include "configuration.php";
include "offline.php";
exit();
}
if (!($this->_resource = @mysql_connect( $host, $user, $pass ))) {
//or die( 'FATAL ERROR: Connection to database server failed.' );
$mosSystemError = 1;
include "configuration.php";
include "offline.php";
exit();
}
if (!mysql_select_db($db)) {
//or die( "FATAL ERROR: Database not found. Operation failed with error: ".mysql_error());
$mosSystemError = 1;
include "configuration.php";
include "offline.php";
exit();
}
$this->_table_prefix = $table_prefix;
/* Tom: make a second prefix so we can later change depending on if we reference the users table or not */
global $mosConfig_users_dbprefix;
$this->_user_table_prefix = $mosConfig_users_dbprefix;
/* Tom: end edit */

}

///////////////////////////////////////////////////////////////////////////////////////



///////////////////////////////////////////////////////////////////////////////////////

function setQuery( $sql, $prefix='#__' ) {
/* Tom: substitute the prefixes that point to the users table with the central user table prefix */
$sql = str_replace('#__users', $this->_user_table_prefix.'users', $sql);
$sql = str_replace('mos_users', $this->_user_table_prefix.'users', $sql);
/* Tom: end edit */
$this->_sql = str_replace( $prefix, $this->_table_prefix, $sql );

}

///////////////////////////////////////////////////////////////////////////////////////




3) In configuration.php, add:
///////////////////////////////////////////////////////////////////////////////////////

$mosConfig_users_dbprefix = 'all_'; //tom: this is the prefix for the cross site user table

///////////////////////////////////////////////////////////////////////////////////////


4) Finally rename your mos_users table (or whatever prefix you use for your first mos site) to all_users.

5) Thats it! I think

Cheers,
Thomas Woodard
tomwoods is offline   Reply With Quote
Sponsored Links
Old 08.04.2004, 00:21   #2
wongnow
Mamber
 
wongnow's Avatar
 
Join Date: Apr 2004
Posts: 58
wongnow is on a distinguished road
Default Re: Multiple Mambo sites

Hey Thomas. Has this been through thorough testing and troubleshooting by you? Just wondering before I commit myself to this trial

Thanks for the post!
wongnow is offline   Reply With Quote
Old 08.04.2004, 00:49   #3
tomwoods
Baby Mamber
 
Join Date: Apr 2004
Posts: 16
tomwoods is on a distinguished road
Thumbs up Re: Multiple Mambo sites

I'm running Mambo 4.5 Stable-1.0.2. It works fine on the local testing version I have of my site, but of course thats just me. Probably if a few others install the hack and are happy with it I would say it was thoroghly tested, but it untill now I can only say it works like a champ for me . Still I strongly suggest you back up your stuff, even though I think its a pritty harmless hack.

I would only recommend that when you install your second and third (etc.) site, you take good care to always use a new table prefix.
tomwoods is offline   Reply With Quote
Old 08.04.2004, 04:05   #4
mmx
Expert Mamber
 
Join Date: Apr 2004
Location: Virginia Beach, Virginia USA
Posts: 309
mmx is on a distinguished road
Send a message via MSN to mmx
Default Re: Multiple Mambo sites

Nice hack Tom... having a lot of fun with this.
mmx is offline   Reply With Quote
Old 08.04.2004, 07:12   #5
garak
Guest
 
Posts: n/a
Default Re: Multiple Mambo sites

Quote:
Originally Posted by tomwoods
I'm running Mambo 4.5 Stable-1.0.2. It works fine on the local testing version I have of my site, but of course thats just me. Probably if a few others install the hack and are happy with it I would say it was thoroghly tested, but it untill now I can only say it works like a champ for me . Still I strongly suggest you back up your stuff, even though I think its a pritty harmless hack.

I would only recommend that when you install your second and third (etc.) site, you take good care to always use a new table prefix.
Hi all
Gayle did a hack for the install that allows you to set the prefix. I cant remember the sitename so I have attached the file.
  Reply With Quote
Old 09.04.2004, 00:30   #6
tomwoods
Baby Mamber
 
Join Date: Apr 2004
Posts: 16
tomwoods is on a distinguished road
Exclamation MultiSite PhpShop

Ah, and of course, there is always an exeption. This is the case with Phpshop for Mambo. Be warned that it uses its own database management file called db_mysql.php and because it doesn't always use its setQuery function, we have to change a few lines in that file to get the component up to speed:

In the setQuery function:
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function setQuery( $sql, $prefix='#__' ) {
global $mosConfig_dbprefix;
// Tom: changed to fix the prefix problem in multisite mambo
global $mosConfig_users_dbprefix;

$this->_sql = str_replace('#__users', $mosConfig_users_dbprefix.'users', $sql);
$this->_sql = str_replace('mos_users', $mosConfig_users_dbprefix.'users', $this->_sql);
// Tom: end change

$this->_sql = str_replace( $prefix, $mosConfig_dbprefix, $this->_sql );
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


In the query() function:
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if (stristr($q, $prefix))
// Tom: changed to fix the prefix problem in multisite mambo
global $mosConfig_users_dbprefix;
$q = str_replace('#__users', $mosConfig_users_dbprefix.'users', $q);
$q = str_replace('mos_users', $mosConfig_users_dbprefix.'users', $q);
// Tom: end change

$q = str_replace( $prefix, $mosConfig_dbprefix, $q );
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


Tested with the new 1.0a PhpShop version. Cheers!
tomwoods is offline   Reply With Quote
Old 09.04.2004, 00:43   #7
stingrey
Professional Mamber
 
stingrey's Avatar
 
Join Date: Apr 2004
Location: Marikina, Manila, Philippines
Posts: 776
stingrey is on a distinguished road
Default Re: Multiple Mambo sites

Good stuff, Tom


This will make a lot of people happy as this is a question that always gets asked.


One thing though, any particular reason you are still using 4.5 1.0.2

And if you do upgrade to latest can you report to us on whether your hack still works correctly
__________________
Joomla! Core Team Member
Software Coding & Design - Stability Team Leader
www.joomla.org
Former Mambo Core Team Member
stingrey is offline   Reply With Quote
Old 14.04.2004, 19:25   #8
Ready
Baby Mamber
 
Join Date: Apr 2004
Posts: 22
Ready is on a distinguished road
Default Re: Multiple Mambo sites

I was working on the same idea about a week back Tom. I shared the users table and found there was a small problem.

The registration of users is easy and works fine... BUT if you should decide to grant a new group permission to a user it isn't. Let me explain what happens...

When a new user is input into the DB he/she is also input on the core_acl_aro table. Everything works fine for that user on any site. BUT he/she was only entered on the core_acl_aro table on the site they registered at. Because of this they will only show up on admin panel of that site. All the other sites will not see him on the backend.

I was looking over the tables for the ACL, and it does look like the core_acl_aro file is the only effected one. A solution may be to share that one as well.

I am going to test it out now...
Ready is offline   Reply With Quote
Old 14.04.2004, 19:45   #9
tomwoods
Baby Mamber
 
Join Date: Apr 2004
Posts: 16
tomwoods is on a distinguished road
Smile Re: Multiple Mambo sites

Good going!
Make shure you share your findings.
tom
tomwoods is offline   Reply With Quote
Old 14.04.2004, 22:38   #10
Ready
Baby Mamber
 
Join Date: Apr 2004
Posts: 22
Ready is on a distinguished road
Default Re: Multiple Mambo sites

I just got back from the store... Was thinking about this... If we do share that additional table I don't think we will be able to restrict additional permissions to just one site (they would be applied to all the sites).

Do you have any ideas on this?
Ready is offline   Reply With Quote
Reply

Thread Tools
Display Modes

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Accessing Mambo components from non-mambo sites locokaress Component 'How Do I' Questions 7 06.05.2005 07:44
Why Mambo is better than PostNuke? Jazzy Community Smalltalk 42 19.11.2004 13:27


All times are GMT +2. The time now is 00:41.

Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
A vBSkinworks Design
© Copyright 2004-2008 by Arthur Konze Webdesign.