Advertisement:

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

Pathfinder

  • Newbie
  • *
  • Posts: 18
Linking several osclass websites together
« on: February 01, 2014, 02:45:36 pm »
As I have said in my other posts, I am very new to osclass and have limited knowledge and ability, but I am trying to 'think ahead'.

At the moment I am working on developing a site - www.caravancleaningservices.co.uk - using V3.3.2 and Twitter theme.

What I would like to know is;

Is it possible to 'link' this site with others I will be developing in the future?

Let me explain what I am looking for.

I would like users to register just once on any of my sites and that registration be valid on all the others. The problem with that is that whilst the other sites will be using the same osclass versions they will be using different themes and layouts.

My site 'Caravan Cleaning' uses parent categories 'Butlins', 'Haven',etc. with sub categories. I want to develop a General Classifieds site where I would probably use the default Bender theme and the parent categories in 'Caravan Cleaning' site would be sub categories under a parent category 'Caravan Cleaning' in the new classified ads site.

I would like it so that if a user places and ad on one site it automatically appears on the other. eg. on site 'Caravan Cleaning Services' place an ad in 'Allhallows' (a sub category of 'Haven') and have it also appear in the 'Classified' site in 'Allhallows' (which would be a sub category of 'Haven' which would be a sub category of 'Caravan Cleaning').

I do hope that makes sense and somebody can tell me if it's possible.

I'm asking this now in case I have to make changes to my current site 'Caravan Cleaning Services' now in preparation for 'linking' with my new sites in the future.

dev101

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 2155
  • osclass.work
Re: Linking several osclass websites together
« Reply #1 on: February 01, 2014, 03:31:43 pm »
Hi Pathfinder,

I am also interested in this, but no step-by-step solution exists that I know of. I am still learning MySQL and so far, you can achieve this with sql triggers within a single db. All your installations should share same db (could be risky if you get into trouble with db for any reason), and use different prefixes. Then create sql triggers to sync some tables.

But, that is as far as I got, thing is - what tables are safe/should be synced? Because, there are foreign and primary keys, and so you have to know how to do it.

Regards

aide2001

  • Guest
Re: Linking several osclass websites together
« Reply #2 on: February 01, 2014, 04:14:02 pm »
You need one database for multiple styled sheets, hosted on one domain, with sub domains, and then in your config files on each sub domain you would need to link it to the main database.
Therefore if someone registered on one site they would be registered on all sites.
Think the best thing for you today for arguments sake is have one osclass install. with multiple sub domains, so the user can choose at the front point of call where to go. Hope this helps a little

dev101

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 2155
  • osclass.work
Re: Linking several osclass websites together
« Reply #3 on: February 01, 2014, 05:58:08 pm »
Hi aide2001,

using same db (with same prefix) for several installations effectively means you are cloning each instance, because you are limmited to theme and plugins settings, which are stored in the very same db. Simple solution with very limmited possibilities and not really the solution to the problem.

Regards

tomshaft

  • Hero Member
  • *****
  • Posts: 862
  • Osshaft for Osclass - Add 650 posts to my total
Re: Linking several osclass websites together
« Reply #4 on: February 01, 2014, 07:15:32 pm »
Only real way I know is data Integration.
This has a huge learning curve, at least for me..... :o

http://en.wikipedia.org/wiki/Data_integration

Tom

dev101

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 2155
  • osclass.work
Re: Linking several osclass websites together
« Reply #5 on: February 01, 2014, 09:53:19 pm »
Gotta love those wiki articles - say a bunch and yet nothing :D

Regards

tomshaft

  • Hero Member
  • *****
  • Posts: 862
  • Osshaft for Osclass - Add 650 posts to my total
Re: Linking several osclass websites together
« Reply #6 on: February 01, 2014, 11:59:45 pm »
Maybe that was a poor choice of samples but the idea of database combining looks sound.
Long ago I tried, failed and abandoned the idea.
Here is a link discussing similar. If I had a clue I would sure like to try something.

http://msdn.microsoft.com/en-us/library/bb510625.aspx

Tom

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: Linking several osclass websites together
« Reply #7 on: February 02, 2014, 01:45:26 am »
Corrected

Hi,

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

1.- Choose one of your databases to work as "users_manager" (let's call it so).

2.- Intercept all queries before they reach the DB and redirect all mentions to [PREFIX]t_user and [PREFIX]t_user_description to users_manager.[PREFIX]t_user and users_manager.[PREFIX]t_user_description. You can do that with MySQL Proxy if you have root access to install it or simply slightly altering a core file:

oc-includes\osclass\classes\database\DBCommandClass.php

Code: [Select]
function query($sql)         {
            if($sql == '') {
                return false;
            }

            // MySQL Proxy simulation mod
                        require_once('mysql_proxy.php');
            $sql = mysql_proxy_out($sql); // end mod

            if( OSC_DEBUG_DB_EXPLAIN && $this->isSelectType($sql) ) {
                $this->query_debug($sql);
            }

Create a new script mysql_proxy.php in oc-includes\osclass\classes\database (or wherever you want, just remember to adjust the require_once 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_
?>

Now, this may be a very powerful feature, because in this new script you may alter each and everyone of the Osclass queries, and that is why I've created this  script (mine has a lot of tweaks to accelerate things), but if you only want this users manager feature, you can just insert

Code: [Select]
$sql = str_replace('[PREFIX]t_user', 'users_manager.[PREFIX]t_user', $sql);
in DBCommandClass.php, instead of the three lines starting with // MySQL Proxy simulation mod.

Regards

« Last Edit: February 18, 2014, 04:21:19 pm by teseo »

dev101

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 2155
  • osclass.work
Re: Linking several osclass websites together
« Reply #8 on: February 02, 2014, 03:41:52 am »
Hi teseo,
another hit from you again :)

This idea could be indeed a better solution for simplicity and possibly regarding concurency (always 'in sync', table/raw locks..).

1.- Choose one of your databases to work as "users_manager" (let's call it so).

So, do we create a new blank db users_manager with tables oc_t_user, oc_t_user_description, oc_t_user_email_tmp (?) and some plugins' specific tables like oc_t_user_log (?) or I didn't understand this right?

Regards,
dev101

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: Linking several osclass websites together
« Reply #9 on: February 02, 2014, 01:25:02 pm »
No need, just choose one of your normal databases to be what will manage user related affairs. The rest of the databases will keep their user tables but they will be empty and unused.

If things were to complicate (don't know, plugins specifities or some unfathomable circumstances ???), remember that you always may introduce conditions inside the mysql_proxy script, so some things might be database specific if that suits you.

Regards

tomshaft

  • Hero Member
  • *****
  • Posts: 862
  • Osshaft for Osclass - Add 650 posts to my total
Re: Linking several osclass websites together
« Reply #10 on: February 18, 2014, 12:01:50 am »
This has always been an interest of mine and currently working with another forum member trying to have 2 sites. Just tried Teseo solution but for some reason (My abilities) it is not working.

Anyone have a simpleton suggestion cause that's me.


Strange thing is for quite some time I have been able to do this on localhost but not live. Now lost it on localhost.

Tom

SmaRTeY

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 2519
Re: Linking several osclass websites together
« Reply #11 on: February 18, 2014, 12:15:21 am »
Hi Tom, what exactly have you implemented based on teseo's solution?

I think the ONE line in "DBCommandClass.php" should do the trick as long as you do this for all other site "DBCommandClass.php" as well. The trick is to have them all POINT to the one 'user database' and that line of code is just doing that.

teseo, correct me if I am wrong.

Regards,
Eric

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: Linking several osclass websites together
« Reply #12 on: February 18, 2014, 12:49:05 am »
Hi,

Well, I have to confess that I haven't tested this myself. :D It occurs to me now that the procedure assumes that the script has authorization to access all the databases involved (same MySQL user, same MySQL password). Maybe your problem, Tom? ???

Regards
« Last Edit: February 18, 2014, 12:52:16 am by teseo »

dev101

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 2155
  • osclass.work
Re: Linking several osclass websites together
« Reply #13 on: February 18, 2014, 04:17:21 am »
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.

Regards

tomshaft

  • Hero Member
  • *****
  • Posts: 862
  • Osshaft for Osclass - Add 650 posts to my total
Re: Linking several osclass websites together
« Reply #14 on: February 18, 2014, 01:31:18 pm »
I am going to show my ignorance but have to ask -  Why am I getting this error in the test file, mysql_proxy.php. Screenshot attached.

Seems no matter what I do I cannot correct it. I can introduce more errors, I'm pretty good at that.... :o
Tom