Advertisement:

Author Topic: Linking several osclass websites together  (Read 5018 times)

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: Linking several osclass websites together
« Reply #15 on: February 18, 2014, 03:41:16 pm »
Well, this is too important to go giving advice happily and with no personal testing. :D

So just done: Two installations with two databases that I'll call "users_manager' and 'users_slave', both with the same MySQL user and password.

I've skipped the mysql_proxy auxiliar script to avoid complicate things in the fundamental test, so that one-line modification only on DBCommandClass.php of users_slave installation:

Code: [Select]
$sql = str_replace('oc_t_user', 'users_manager.oc_t_user', $sql);
Now I login on users_slave installation with credentials of an user that only exits on users_manager, and voila:

SELECT * FROM (users_manager.oc_t_user) WHERE pk_i_id = '5'

SELECT * FROM (users_manager.oc_t_user_description) WHERE fk_i_user_id = '5'

SELECT dt_access_date, s_access_ip FROM (users_manager.oc_t_user) WHERE pk_i_id = 5 AND dt_access_date <= '2014-02-18 13:21:55'

UPDATE users_manager.oc_t_user SET dt_access_date = '2014-02-18 14:21:55', s_access_ip = 'XXX.XXX.XXX.XXX' WHERE pk_i_id = 5


...logged in. As you can see not only read queries (SELECT) are succesful, but also writing (UPDATE).

The more I think about this idea, the farther I get from it, for various reasons. Yes, it would be nice, 'cool', with clear advantages and so on, but it would have some drawbacks, too. So, complete separation might not be so bad after all.

Well, we are experimenting here, my friend, if you see drawbacks I would like to know what they are. If serious and unsurmountable, I'll give up, of course I don't want to cause problems but solve them. ???

Regards

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: Linking several osclass websites together
« Reply #16 on: February 18, 2014, 04:23:49 pm »
My apologies, the problem with the method using the external script mysql_proxy.php was a missing semicolon to close the line:

Corrected

Code: [Select]
<?php
function mysql_proxy_out($sql) {
            return 
str_replace('[PREFIX]t_user''users_manager.[PREFIX]t_user'$sql);
}
// Replace [PREFIX] with your real prefix, i.e. oc_
?>

Regards

tomshaft

  • Hero Member
  • *****
  • Posts: 862
  • Osshaft for Osclass - Add 650 posts to my total
Re: Linking several osclass websites together
« Reply #17 on: February 18, 2014, 04:33:54 pm »
Just tried the one liner. No errors but no login on master.

Here is what I have:
Two v.3.3.2's
One database
Master has oc_
Slave has db_

Can log in just one but not the other. I'll go back to the "Corrected" method because that has a lot of potential. Funny I tried a semi-colon about everyplace and way I could think of including where you placed it.

I learn near nothing doing it this way but could you send your files for this so I could compare?

Tom



« Last Edit: February 18, 2014, 04:56:46 pm by tomshaft »

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: Linking several osclass websites together
« Reply #18 on: February 18, 2014, 04:54:30 pm »
Hmm... Yes, seems there might problems with the master installation (anyway, master doesn't require modification of DBCommandClass.php, only slaves).

Folks, please put on hold all of this until I have the time to check all this thoroughly.  :-X

Regards

tomshaft

  • Hero Member
  • *****
  • Posts: 862
  • Osshaft for Osclass - Add 650 posts to my total
Re: Linking several osclass websites together
« Reply #19 on: February 18, 2014, 04:55:22 pm »
Update to my last post.

Only login is for the "site" I created user in...... :'(  :-[
Other install says I don't exist...... >:(


Tom

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: Linking several osclass websites together
« Reply #20 on: February 18, 2014, 05:28:13 pm »
Tom, the problem I've just detected is the contrary, everything went well on the slave installation with the user only referenced on the master DB, but problems with login on the master. ??? As I just told you, this will need more study (an possibly clean installations to start with).

Anyway, I'm going to stress what I told you all in the first place;

Quote
An idea that should be more effective than using MySQL triggers:

An idea to put to testing by the ones really interested in this feature (not my case, or what I would have presented here would be much more solid or not presented at all), now I'm yet more interested in the somewhat cryptic remarks of @dev101. Please buddy, elaborate to see if we should discard this idea of mine. ;)

Said that, I would like to separate the multisite matter (barely an idea) from the mysql_proxy pseudo-hook thing, this I have it working live for many months now with remarkable results. (See this thread for instance: http://forums.osclass.org/general-help/mysql-views/msg82975/#msg82975 ).

Regards

tomshaft

  • Hero Member
  • *****
  • Posts: 862
  • Osshaft for Osclass - Add 650 posts to my total
Re: Linking several osclass websites together
« Reply #21 on: February 18, 2014, 07:17:27 pm »
I understand. I posted exactly as you were posting the one about holding off. The forum system said someone was also posting but I chose to post anyway. Yours appeared just before mine.

I am and have been trying for many, many months as time permits so always interested in a thread on this topic. It just so happened that at this same time I and another forum member are working on this very thing but your idea is so superb we decided to try it.

Thanks so much for posting because this opens a nice dialog.

Tom

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: Linking several osclass websites together
« Reply #22 on: February 19, 2014, 01:26:26 am »
Hi again,

Progresses at least. It's not enough to share user tables on master database, you have to share sessions too to login on master or slave and be logged in both. Take this with a pinch of salt, but if you set he same session path for two installations, this seems to work at least for login/logout.

Master installation config.php:

Code: [Select]
session_save_path ( ABS_PATH . 'oc-content/uploads/' );
Slave installation config.php:

Code: [Select]
session_save_path ( '[path-to-master-installation]/oc-content/uploads/' );
And your cookies must be valid for the whole domain (mine are like that, but I couldn't recall if this is by default or I did something at some time) :D

CSRF token problems might arise, but then I've seen this only once, and my two testing installations are running Osclass 3.1.1, where CSRF errors are thrown seemingly randomly anyway, issue that I haven't seen at least on 3.1.2 installations. ???

Well, more food for testing, waiting for other bold explorers to share their experiences. ;)

Regards
« Last Edit: February 19, 2014, 03:50:21 pm by teseo »

tomshaft

  • Hero Member
  • *****
  • Posts: 862
  • Osshaft for Osclass - Add 650 posts to my total
Re: Linking several osclass websites together
« Reply #23 on: February 19, 2014, 11:01:22 am »
Originaly I was testing with 3.0.2 just to get away from all those CSRF errors. Thinking if it works with a simple version no reason to not work with newer versions but then got it in my head maybe newer versions have some magic code that could help so bypassed 3.1 and when for 3.3. No CSRF's but 3.3 sure is picky about theme display and plugins.

Anyway, I have wasted so much time trying this with sql and now feel dumb(er) because your idea is so much more straight forward. Never occurred to me to capture/Re-direct PRIOR too... :o
Been going over the database files hoping something jumps out of the code at me and wondering what exactly was the plan for define('MULTISITE', 0); in config and just how can this be used for this...

Curious that there seems to be enough existing code to allow this but I have not been able to do it.
Has anyone ever set the config-  define('MULTISITE', true);


When I do I get this and can't get past it (Brain dead):
Code: [Select]
Fatal error: Class 'SiteInfo' not found in K:\wamp\www\osclass33\oc-includes\osclass\helpers\hDatabaseInfo.php on line 85


Call Stack

Thanks for the updated post. I'm off to play some more.

Tom
« Last Edit: February 19, 2014, 03:47:30 pm by tomshaft »

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: Linking several osclass websites together
« Reply #24 on: February 19, 2014, 04:07:41 pm »
Curious that there seems to be enough existing code to allow this but I have not been able to do it.
Has anyone ever set the config-  define('MULTISITE', true);

As every big mansion, Osclass has its hidden doors and closed rooms... :D This is what I know of this:

http://forums.osclass.org/development/where-is-this-constant-is-used-define('multisite'-0)-in-config-php/msg2602/#msg2602

Take that into account, likely this might be more complicated than just share sessions and user tables, only full testing will say.


Quote
Fatal error: Class 'SiteInfo' not found in K:\wamp\www\osclass33\oc-includes\osclass\helpers\hDatabaseInfo.php on line 85

Did you set define('MULTISITE', true)? All that is incomplete, better to keep the default and try and find another path. ;)

One more thing, I said 3.2.2 when I wanted to say 3.1.2 (never have the time to go further, a busy period for me). :D

Regards

dev101

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 2155
  • osclass.work
Re: Linking several osclass websites together
« Reply #25 on: February 19, 2014, 04:44:25 pm »
now I'm yet more interested in the somewhat cryptic remarks of @dev101
Hi teseo,
sorry for not responding sooner, I do really appreciate your efforts, you are the only one here contributing some real work :)

There was nothing cryptic, I just think when you put some plugins like PM messages and few other ones (exotic), this might get into trouble. This was not a factual statement, just a precaussion.

As you said, this would require detailed testing -- and I was wondering, should I spent that [limited] time [lately] on this, or something more creative like separated themes, functionalities, plugin integration, corrections and all?

That is all what I meant, really.

I will try to find time and test your 2nd solution (as I haven't proper time to test 1st at all).

Regards and thank you!

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: Linking several osclass websites together
« Reply #26 on: February 19, 2014, 05:17:09 pm »
Thanks, buddy :)

I want to clarify that I think those maybe aren't alternative solutions, but complementary. As you say (and may be seen by that Garcia de Marina's post), this surely is more complicated than all this. Unfortunately, right now I just can barely point directions for those really interested and comment about their findings).

Regards

dev101

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 2155
  • osclass.work
Re: Linking several osclass websites together
« Reply #27 on: February 19, 2014, 05:26:11 pm »
and may be seen by that Garcia de Marina's post
hmmm, what post - can you point me to it? (I feel really tired lately and exausted on my job; trying to spend my half/one hour per day for the forum to see interesting topics and help others if I can  :-[ )

Testing is on my 'red' to-do list (top priority), and I would really like it (I cried for it how many times already?), but also started thinking [that] maybe separate domains or subdomains could be better/enough.

Regards teseo!

dev101

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 2155
  • osclass.work
Re: Linking several osclass websites together
« Reply #28 on: February 19, 2014, 05:30:55 pm »
Yes, in all this, I forgot to explain why I suddenly started changing my mind about integration. I discovered dynamic pages in Osclass, which I didn't know about untill recently (always some new trick under the hood in this script!) and so started thinking about that direction. Instead of integration, I could create different 'main' pages with items and search limited only to few categories. So, you do not install X scripts and domains/subdomains, but just use single instance and divide them this way. What do you think of this idea?

Regards

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: Linking several osclass websites together
« Reply #29 on: February 19, 2014, 05:56:18 pm »
I can completely relate to your situation regarding time and fatigue, believe me.  :-\ But in my case I think I find some relief in setting my real job aside for a little while to study a bit things like this (and you never know when anything could be useful for you personally, so...) :D

This is the Garcia's post:

http://forums.osclass.org/development/where-is-this-constant-is-used-define('multisite'-0)-in-config-php/msg2602/#msg2602

And the other thing, alwaysmore than one way to skin a cat, it depends on your current objective. For instance, the site I'm currently working for has a completely compartmentalized structure based on countries, but in the beginning I prefered to keep them all on the same installation/database. Maybe if this multisite feature was been completed at the time, I would have chosen another path, but seems we have no time for what-if's in this business of ours... :D

Kind regards