Advertisement:

Author Topic: Several installations sharing same database and images folder [Solved]  (Read 10123 times)

p206ab

  • Sr. Member
  • ****
  • Posts: 343
There are many topic about this here, but none of them resolved and as some of regulars here made Osclass or helped making it, there is no better place to ask and solve this once and for all.

It's about having multiple subdomains using same database. I've managed to edit everything by following this topic, so images are taken from main domain's folder. But the problem remains when an user wants to post a new ad on subdomain, where I can't redirect images to be uploaded to main domain's upload folder.

After going through every osclass file I've come up to this:
Everywhere where uploads are mentioned, they are called with function osc_uploads_path(),
 which is defined in hDefines.php to call:
Code: [Select]
function osc_uploads_path() {
        return(UPLOADS_PATH);
    }
while UPLOADS_PATH is defined in default-constants.php:
Code: [Select]
if( !defined('UPLOADS_PATH') ) {
        define('UPLOADS_PATH', CONTENT_PATH . 'uploads/');
    }
UPLOADS_PATH uses CONTENT_PATH, which is:
Code: [Select]
if( !defined('CONTENT_PATH') ) {
        define('CONTENT_PATH', ABS_PATH . 'oc-content/');
    }

What I've tried:
- Editing uploads-path by removing CONTENT_PATH part and extending 'uploads/' to 'maindomain.com/oc-content/uploads/'
- Editing uploads-path by removing CONTENT_PATH part and extending 'uploads/' to 'httpdocs/domainfolder/oc-content/uploads/'
- Editing CONTENT_PATH by removing ABS_PATH and externding oc-content the same as for uploads above, while keeping UPLOADS_PATH intact.

But none of this worked. I still can't attach images while placing an ad on subdomain. Main domain upload folder has permission 777.
I would really appreciate all the help, as this problem is making me nervous for about a month now.
« Last Edit: November 24, 2015, 09:35:47 pm by p206ab »

Aficionado

  • Guest
Re: Upload path
« Reply #1 on: November 15, 2015, 09:05:16 pm »
777 folder permission is a big NO.


p206ab

  • Sr. Member
  • ****
  • Posts: 343
Re: Upload path
« Reply #2 on: November 15, 2015, 09:17:22 pm »
777 folder permission is a big NO.

Will change that, thanks. Some tutorials said I should make it 777, so I've tried.
Any ideas on the main problem?
Can the fault be in fine uploader as its script in item.form.class.php calls multiple times for osc_base_url as in example below:
Code: [Select]
$(li).append('<div class="ajax_preview_img"><img src="<?php echo osc_base_url(); ?>oc-content/uploads/temp/'+responseJSON.uploadName+'" alt="' + responseJSON.uploadName + '"></div>');Should I change all of these base url functions to main domain url?

Aficionado

  • Guest
Re: Upload path
« Reply #3 on: November 15, 2015, 09:47:29 pm »
777 folder permission is a big NO.

Will change that, thanks. Some tutorials said I should make it 777, so I've tried.
Any ideas on the main problem?


You have a signature about "Osclass Tutorials" but you are using some dangerous security settings. A bit odd, isn't it ?

Permissions should be 644 for Files and 755 for Folders, for any php script. That works great IF the rest of the setup is correct. Otherwise it doesn't work, so people suggest 777 to HIDE other problems.



p206ab

  • Sr. Member
  • ****
  • Posts: 343
Re: Upload path
« Reply #4 on: November 15, 2015, 09:58:14 pm »
777 folder permission is a big NO.

Will change that, thanks. Some tutorials said I should make it 777, so I've tried.
Any ideas on the main problem?


You have a signature about "Osclass Tutorials" but you are using some dangerous security settings. A bit odd, isn't it ?

Permissions should be 644 for Files and 755 for Folders, for any php script. That works great IF the rest of the setup is correct. Otherwise it doesn't work, so people suggest 777 to HIDE other problems.

I guess I trusted the wrong people.. Thank you.
The problem with images still remains unsolved.

SmaRTeY

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 2519
Re: Upload path
« Reply #5 on: November 15, 2015, 10:38:56 pm »
Well besides the need for correct folder rights you also need the different domain 'users' as a group membership (I think) of the domain that is holding all uploaded files. Meaning imo your server settings need tweaking, Osclass is just php executing using the path it is supposed to use. So in case it is not working it means php is unable to execute most likely because of some security measure.

Are you on a VPS, DEDI or Shared hosting?

p206ab

  • Sr. Member
  • ****
  • Posts: 343
Re: Upload path
« Reply #6 on: November 16, 2015, 09:20:08 am »
Well besides the need for correct folder rights you also need the different domain 'users' as a group membership (I think) of the domain that is holding all uploaded files. Meaning imo your server settings need tweaking, Osclass is just php executing using the path it is supposed to use. So in case it is not working it means php is unable to execute most likely because of some security measure.

Are you on a VPS, DEDI or Shared hosting?

I'm on shared.
I'm not sure about access, as subdomains can take photos from main's upload folder to display them.
Only when posting a new ad on sub, they are not saved in main upload as I would like, but this probably isn't access problem, it's just something to edit on subdomains so it wouldn't use its own upload folder as it would normally and by default do and use main domain's upload folder instead.

SmaRTeY

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 2519
Re: Upload path
« Reply #7 on: November 16, 2015, 10:58:31 am »
Okay, what is left is correct upload path for this to work and this has been discussed in same thread by cartagena68:
http://forums.osclass.org/general-help/how-to-have-2-domains-using-same-database/15/

Well besides the need for correct folder rights you also need the different domain 'users' as a group membership (I think) of the domain that is holding all uploaded files. Meaning imo your server settings need tweaking, Osclass is just php executing using the path it is supposed to use. So in case it is not working it means php is unable to execute most likely because of some security measure.

Are you on a VPS, DEDI or Shared hosting?

I'm on shared.
I'm not sure about access, as subdomains can take photos from main's upload folder to display them.
Only when posting a new ad on sub, they are not saved in main upload as I would like, but this probably isn't access problem, it's just something to edit on subdomains so it wouldn't use its own upload folder as it would normally and by default do and use main domain's upload folder instead.

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: Upload path
« Reply #8 on: November 16, 2015, 01:12:40 pm »
Hi,

Quote
images are taken from main domain's folder

If this is already solved, I think that first you need to make sure that everything will work fine once all images are stored on main domain uploads folder.

oc-includes/osclass/ItemActions.php

Find this line:

Code: [Select]
$folder = osc_uploads_path().(floor($itemId/100))."/";
Replace with:

Quote
// $folder = osc_uploads_path().(floor($itemId/100))."/";
$folder = '/[path-to-your-main-domain-root-folder]/oc-content/uploads/'.(floor($itemId/100))."/";

Change the part in orange and make some tests.

Regards

p206ab

  • Sr. Member
  • ****
  • Posts: 343
Re: Upload path
« Reply #9 on: November 16, 2015, 07:07:42 pm »
Quote
images are taken from main domain's folder

If this is already solved, I think that first you need to make sure that everything will work fine once all images are stored on main domain uploads folder.

oc-includes/osclass/ItemActions.php

Find this line:

Code: [Select]
$folder = osc_uploads_path().(floor($itemId/100))."/";
Replace with:


// $folder = osc_uploads_path().(floor($itemId/100))."/";
$folder = '/[path-to-your-main-domain-root-folder]/oc-content/uploads/'.(floor($itemId/100))."/";


Change the part in orange and make some tests.
Thanks,
I've tried changing this and placing a new ad and result is the following:
<img src="http://domain.com/1166_thumbnail." >
So extension is missing and folder (uploads/1/ or /2/) are missing.
Also I can't find uploaded image anywhere inside uploads folder, while adding .jpg at the end doesn't work either.
Maybe I messed up with other scripts..  :-\

SmaRTeY

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 2519
Re: Upload path
« Reply #10 on: November 16, 2015, 07:13:50 pm »
Maybe matter of turning off "Rewrites" first? (if you have it in use)

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: Upload path
« Reply #11 on: November 16, 2015, 08:48:22 pm »
Also I can't find uploaded image anywhere inside uploads folder

Not the rest, but this surprises me. ??? If you have everything in the same server and did this right:

Quote
$folder = '/[path-to-your-main-domain-root-folder]/oc-content/uploads/'.(floor($itemId/100))."/";

Uploaded images shoud be inside /[path-to-your-main-domain-root-folder]/oc-content/uploads/[number]

By "[path-to-your-main-domain-root-folder]" I mean your main domain Osclass installation root folder.

Regards

p206ab

  • Sr. Member
  • ****
  • Posts: 343
Re: Upload path
« Reply #12 on: November 16, 2015, 09:06:04 pm »
Turning off rewrites sadly didn't help. Tried on both sites.

As for $folder path it looks like this:
$folder =  '/var/www/domain.com/httpdocs/oc-content/uploads/'.(floor($itemId/100))."/";

I don't know where it ends, it posts an ad successfully, but image is not in main upload nor in subdomain upload folders. It just vanishes.  :o ??? ???

EDIT: Found them in temp folder of the subdomain I used to post ad. But with very strange name qqfile_5649fd721c704.jpg in 4 versions (.jpg + normal, thumbnail, preview). Usually they are named same as original image even in temp.
So something breaks when they should be transferred from temp to upload folder.
Debug log shows no error.
« Last Edit: November 16, 2015, 09:21:41 pm by p206ab »

SmaRTeY

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 2519
Re: Upload path
« Reply #13 on: November 16, 2015, 09:19:30 pm »
Image upload is usually two-step using ajax upload, do images when posting a new add appear in step 1? Ie. you add images and they appear as small images or is there no upload from the start so not even smaller images?

p206ab

  • Sr. Member
  • ****
  • Posts: 343
Re: Upload path
« Reply #14 on: November 16, 2015, 09:26:17 pm »
Image upload is usually two-step using ajax upload, do images when posting a new add appear in step 1? Ie. you add images and they appear as small images or is there no upload from the start so not even smaller images?

Yes, after I select them they upload normally and display under image uploader. If I inspect them, they are placed inside subdomain (the page I'm using) temp folder.