Advertisement:

Author Topic: 3 domain using same data base how to?  (Read 2219 times)

nairam

  • Newbie
  • *
  • Posts: 5
3 domain using same data base how to?
« on: November 27, 2015, 01:15:00 pm »
Hello,
I have 3 domains www.aaa.com www.bbb.com www.ccc.com
aaa.com is the primary domain
bbb.com and ccc.com is addon domain on the same host.
I wan domain www.bbb.com and ccc.com to use same data base as the domain www.aaa.com but still have they own theme. (the rest of the structure will be identical on all 3 domains)
I install osclass 3.5.9 on all domain's then i change the config.php for domains bbb.com and ccc.com in every way which I found it here on the forum, on goolge and alswere... it is very frustrating because in the moment i change the config.php for the site bbb.com with the settings of aaa.com the domain bbb.com takes the look and the name of aaa.com ....
Please someone explain me step by step (and for dummies:)) how set this up....
Thank you

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: 3 domain using same data base how to?
« Reply #1 on: November 27, 2015, 04:25:54 pm »
Hi,

In the beginning, each config.php must be esentially  kept as it was created when the installation for that domain/subdomain was done, sharing only same database data.

If you want to share images between domains, see here:

http://forums.osclass.org/general-help/upload-path/msg133443/#msg133443

If you want User Login data also common, see here:

http://forums.osclass.org/general-help/upload-path/msg133621/#msg133621

Regards

nairam

  • Newbie
  • *
  • Posts: 5
Re: 3 domain using same data base how to?
« Reply #2 on: November 27, 2015, 07:52:14 pm »
I want more.... :)) than sharing users and images. I want to share and the add's ... In fact I want to share ALL except the theme (the look of the page).... Each page must have its own look (theme) in rest all must be shared...

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: 3 domain using same data base how to?
« Reply #3 on: November 28, 2015, 03:02:21 pm »
In that case, I think I've found a rather easy solution:

You have just a single installation and all domains/subdomains are directed to that.

Then you use a very simple plugin to switch themes depending on domain/subodmain. This would be the core of it:

Code: [Select]
<?php
$themes 
= array(
    
'www.aaa.com' => 'bender',
    
'www.bbb.com' => 'modern',
    
'www.ccc.com' => 'osclasswizards',
);

if (
$themes[osc_get_domain()]) Preference::newInstance()->set('theme'$themes[osc_get_domain()]);
?>


I'm attaching the base plugin (you'll need to change this code -array $themes).

Regards

nairam

  • Newbie
  • *
  • Posts: 5
Re: 3 domain using same data base how to?
« Reply #4 on: November 28, 2015, 04:39:05 pm »
Thank you teseo I will study this to... Until then I try this but still have problems... Where Im doing wrong?

domain aaa.ro is main domain on the host
domain bbb.ro is an addondomain
so I have:
for the domain aaa.ro
/home/aaa/public_html/

with this folders:
oc-admin
oc-content
oc-includes
bbb.ro

and this files:
CHANGELOG.txt
Config-sample.php
config.php
favicon..ico
index.php
licenses,txt
oc-load.php
robots.txt

Domain bbb.ro is in:
/home/aaa/public_html/bbb.ro/

1.
I copy all the files and folders (except bbb.ro) from  /home/aaa/public_html/ to: /home/aaa/public_html/bbb.ro/
and I have the same structure (except bbb.ro)

with this folders:
oc-admin
oc-content
oc-includes

and this files:
CHANGELOG.txt
Config-sample.php
config.php
favicon..ico
index.php
licenses,txt
oc-load.php
robots.txt

2.
I modify in the file /home/aaa/public_html/bbb.ro/config.php ONLY this line:
from:
define('WEB_PATH', 'http://www.aaa.ro/');
to:
define('WEB_PATH', 'http://www.bbb.ro/');
save close


3.
I go to /home/aaa/public_html/bbb.ro/oc-includes/osclass/helpers
Open the file hDefines.php and change this line:

from:
function osc_content_path() {
        return(CONTENT_PATH);
    }
To:
function osc_content_path() {
        return("/home/aaa/public_html/oc-content/");
    }

click save and close

4.
I go to /home/aaa/public_html/bbb.ro/oc-includes/osclass/helpers
Open the file hItems.php and change this line:
from:
function osc_resource_url() {
        return (string) osc_resource_path().osc_resource_id().".".osc_resource_field("s_extension");
    }
TO:
function osc_resource_url() {
        return (string)"http://www.bbb.ro/oc-content/uploads/".osc_resource_id().".".osc_resource_field("s_extension");
    }

click save

5.
same file as nr. 4 change this line to:
from:
function osc_resource_thumbnail_url() {
        return (string) osc_resource_path().osc_resource_id()."_thumbnail.".osc_resource_field("s_extension");
    }
To:
function osc_resource_thumbnail_url() {
        return (string)"http://www.bbb.ro/oc-content/uploads/".osc_resource_id()."_thumbnail.".osc_resource_field("s_extension");
    }

Click save and close



6.
I go to:
/home/aaa/public_html/bbb.ro/oc-includes/osclass/frm/
Open this file Item.form.class.php
Now is some complication because i found 2 lines starting with <?php echo osc_apply_filter

6.a.
is like that:
<div id="<?php echo $_r['pk_i_id'];?>" fkid="<?php echo $_r['fk_i_item_id'];?>" name="<?php echo $_r['s_name'];?>">
                        <img src="<?php echo osc_apply_filter('resource_path', osc_base_url() . $_r['s_path']) . $_r['pk_i_id'] . '_thumbnail.' . $_r['s_extension']; ?>" /><a href="javascript:delete_image(<?php echo $_r['pk_i_id'].", ".$_r['fk_i_item_id'].", '".$_r['s_name']."', '".Params::getParam('secret')."'";?>);"  class="delete"><?php _e('Delete'); ?></a>
                    </div>

I change it to:

<div id="<?php echo $_r['pk_i_id'];?>" fkid="<?php echo $_r['fk_i_item_id'];?>" name="<?php echo $_r['s_name'];?>">
                        <img src="<?php echo osc_apply_filter('resource_path', 'http://www.bbb.ro/' . $_r['s_path']) . $_r['pk_i_id'] . '_thumbnail.' . $_r['s_extension']; ?>" /><a href="javascript:delete_image(<?php echo $_r['pk_i_id'].", ".$_r['fk_i_item_id'].", '".$_r['s_name']."', '".Params::getParam('secret')."'";?>);"  class="delete"><?php _e('Delete'); ?></a>
                    </div>


6.b.
is like that
<div class="ajax_preview_img"><img src="<?php echo osc_apply_filter('resource_path', osc_base_url().$_r['s_path']).$_r['pk_i_id'].'_thumbnail.'.$_r['s_extension']; ?>" alt="<?php echo osc_esc_html($img); ?>"></div>

I change to:
<div class="ajax_preview_img"><img src="<?php echo osc_apply_filter('resource_path', 'http://www.bbb.ro' .$_r['s_path']).$_r['pk_i_id'].'_thumbnail.'.$_r['s_extension']; ?>" alt="<?php echo osc_esc_html($img); ?>"></div>


Click save close.



WHAT Im doing wrong?




teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: 3 domain using same data base how to?
« Reply #5 on: November 28, 2015, 04:51:44 pm »
No, forget about the other procedures, restore any file you might have changed.

For your desired environment:

Quote
I want to share ALL except the theme (the look of the page).... Each page must have its own look (theme) in rest all must be shared...

...you should only have a single installation in (for instance) /home/aaa/public_html/, with all the themes you'll be using.

Then you alter the DNS of your subdomains to point to same data as your main domain (IP + /home/aaa/public_html/).

Then you alter the virtual hosts info of your subdomains to point to same folder as your main domain (/home/aaa/public_html/).

Then all of them go to the same place, and the plugin just switchs the theme depending on what domain or subdomain is being used at the time.

Regards

« Last Edit: November 28, 2015, 05:41:29 pm by teseo »