xoops forums

reynaldo

Not too shy to talk
Posted on: 2004/2/15 6:47
reynaldo
reynaldo (Show more)
Not too shy to talk
Posts: 106
Since: 2004/2/13
#1

TRUE Multisites hack.... at last!

I'm working on a TRUE multisites hack for Xoops.
Currently I'm testing it on my sites to make sure it is error free before releasing it.

What I mean for "TRUE" is that you are able to share only those tables you want to share, you no longer have the share all/none situation.

This hack is so simple yet so powerful you only have to edit two files to make it work.

Keep checking and post any ideas you may have, I'll post the download link as soon as I'm sure everything is working as expected.

Now some keywords to make sure everybody looking for multisites help get to this post, LOL:
multisites, multi sites, multisite, multi site, multi-sites, multi-site, multiple site, multiple sites.

Mikhail

Just can't stay away
Posted on: 2004/2/15 7:00
Mikhail
Mikhail (Show more)
Just can't stay away
Posts: 412
Since: 2003/1/19
#2

Re: TRUE Multisites hack.... at last!

Quote:

reynaldo wrote:
I'm working on a TRUE multisites hack for Xoops.
Currently I'm testing it on my sites to make sure it is error free before releasing it.

What I mean for "TRUE" is that you are able to share only those tables you want to share, you no longer have the share all/none situation.

This hack is so simple yet so powerful you only have to edit two files to make it work.

Keep checking and post any ideas you may have, I'll post the download link as soon as I'm sure everything is working as expected.


im running 5 diferent sites with the same users, same files, sabe db, diferent subdomains,... is easy: just edit some lines in "mainfile.php" and "database.php"...

Quote:

Now some keywords to make sure everybody looking for multisites help get to this post, LOL:
multisites, multi sites, multisite, multi site, multi-sites, multi-site, multiple site, multiple sites.

[/quote]

reynaldo

Not too shy to talk
Posted on: 2004/2/15 7:11
reynaldo
reynaldo (Show more)
Not too shy to talk
Posts: 106
Since: 2004/2/13
#3

Re: TRUE Multisites hack.... at last!

Quote:
im running 5 diferent sites with the same users, same files, sabe db, diferent subdomains,... is easy: just edit some lines in "mainfile.php" and "database.php"...


Mikhail:

Those are specifically the two files I had to edit :)

Would you mind posting which lines you have to add/modify in order to get it to work, or the url where you found the info?

I decided to do this hack myself as I couldn't find any resource explaining this.

davidl2

XOOPS is my life!
Posted on: 2004/2/15 11:56
davidl2
davidl2 (Show more)
XOOPS is my life!
Posts: 4843
Since: 2003/5/26
#4

Re: TRUE Multisites hack.... at last!

This is very exciting indeed!

I have actually recently done this by accident - using 1 database across two sites... except only with the same information on each (I accidently left a database pointing to the same location on both sites!)

Herko

XOOPS is my life!
Posted on: 2004/2/15 12:00
Herko
Herko (Show more)
XOOPS is my life!
Posts: 4238
Since: 2002/2/4 1
#5

Re: TRUE Multisites hack.... at last!

Can you send me the code changes please? I'll have our developers take a look at them

Herko

Mikhail

Just can't stay away
Posted on: 2004/2/15 13:19
Mikhail
Mikhail (Show more)
Just can't stay away
Posts: 412
Since: 2003/1/19
#6

Re: TRUE Multisites hack.... at last!

OBS:
IS JUST AN EXPERIMENTAL HACK,
IT IS NOT THE IDEAL WAY TO DO A "XOOPS MULTISITE".


database.php
function prefix($tablename='') {
if ( 
$tablename == '' ) {
return 
$this->prefix;
}
elseif ( 
$tablename == 'users' ) {
return 
'same_users';
}
elseif ( 
$tablename == 'groups_users_link' ) {
return 
'same_groups_users_link';
}
elseif ( 
$tablename == 'priv_msgs' ) {
return 
'same_priv_msgs';
}
elseif ( 
$tablename == 'session' ) {
return 
'same_session';
}
else {
return 
$this->prefix .'_'$tablename;
}
}




to use the same files with diferent sites/subdomains, just replace the mainfile.php for:
<?php
if (!(isset($subdominio))) {
$subdominio $HTTP_HOST;
$subdominio str_replace("www.","",$subdominio); 
$subdominio str_replace(".com","",$subdominio); 
$subdominio str_replace(".net","",$subdominio); 
$subdominio str_replace(".org","",$subdominio);


if (!(empty(
$subdominio))) {
include(
$subdominio."mainfile.php");
}
?>


reynaldo

Not too shy to talk
Posted on: 2004/2/20 5:35
reynaldo
reynaldo (Show more)
Not too shy to talk
Posts: 106
Since: 2004/2/13
#7

Re: TRUE Multisites hack.... at last!

It's interesting we arrived at the same solution with different code

My code is just a little different from yours:

Database.php:
function prefix($tablename='')
{
    
$myCommonTables = array('avatar''avatar_user_link''online''priv_msgs''stories''topics''users');
    
$myPrefix '';
    
    if (
in_array($tablename,$myCommonTables))
    {
        
$myPrefix 'xoops';
    }
    else 
$myPrefix $this->prefix;


    if ( 
$tablename != '' 
    {
        return 
$myPrefix .'_'$tablename;
    } 
    else 
    {
        return 
$myPrefix;
    }
}


As I don't use the same files with different domains/subdomains I didn't have to include the mainfile.php modification.

apleks

Just popping in
Posted on: 2004/2/23 14:01
apleks
apleks (Show more)
Just popping in
Posts: 2
Since: 2004/2/4 2
#8

Re: TRUE Multisites hack.... at last!

Ok, I tried this and at first sight it works, I can share whatever table I want, that was a simple hack, though, very effective for me now!

Anyone has found the caveats yet ? Is there any except the fact that this is not configurable via the XOOPS Admin interface ?

basby

Not too shy to talk
Posted on: 2004/2/23 17:57
basby
basby (Show more)
Not too shy to talk
Posts: 109
Since: 2003/1/28
#9

Re: TRUE Multisites hack.... at last!

What happens if there is a new XOOPS version. How to update your Xoops? In fact you need to chane more than one xoops-es,

Any ieas on that?

reynaldo

Not too shy to talk
Posted on: 2004/2/23 19:31
reynaldo
reynaldo (Show more)
Not too shy to talk
Posts: 106
Since: 2004/2/13
#10

Re: TRUE Multisites hack.... at last!

Quote:

basby wrote:
What happens if there is a new XOOPS version. How to update your Xoops? In fact you need to chane more than one xoops-es,

Any ieas on that?


Basby:
I'm using it with several domains, each one of them having their installation of Xoops. That's my setup, but as you can see from previous posts, you can modify the mainfile.php to run more than one XOOPS site from the same directory.

Anyway, if you have all your sites running from the same XOOPS installation, you would only have to upgrade one site and all of them would be automatically upgraded, *unless* a new version of XOOPS brings updates to the DB, in that case you would have to reinstall XOOPS to each one of the domains even if they all use the same dir.

That is the main reason why I wouldnt like to run lots of XOOPS sites from the same dir. I don't know, it would make me nervous knowing that if something goes wrong, all my sites would be down at once. And of course I would have to upgrade every site anyway after any major XOOPS release. Just my opinion and my 2 cents