Gallery Permissions Issue

Gallery Permissions Issue, a forum discussion on Jojo CMS. Join us for more discussions on Gallery Permissions Issue on our Administration (backend and configuration) forum.

Back to Forum Index : Back to Administration (backend and configuration)   RSS
creativechaos

16 Aug 2008
Posts: 7

Hi,

I am having difficulties with adding a new gallery to the site. The issue is to do with the folder permissions but I am not sure why they are being set to what they are.

Here’s what I’m doing.

1. I got to “Content” > “Edit Gallery”
2. I add a new name to the gallery – call it “Test”
3. Click Save
4. Click on the Images tab
5. Try uploading an image and get error – “The file upload failed. Please contact the webmaster”

I notice that the system has created a new folder under /mysite/downloads/gallery3 in this case called “6” which references the galleryid.

This folder it appears is being created with permissions set to 755 by default.

If I change this to 777 manually on the server I can upload images.

The main “mysite” folder has permissions set to 777 so I would have thought that all sub folders would inherit these permissions. Can someone please tell me why the gallery is creating a folder that I cannot write to until I manually CHMOD it?

Thanks
Jaijaz Jaijaz

16 Aug 2008
Posts: 215

Hey,

Looking at the code Jojo always tries to set all directories that it makes as 777.

Is it possible that your server is over riding this and setting 755? I know my host sets all new directories as 755 by default and then needs to be changed manually.

Hope that helps.

Jai
If you not living on the edge you taking up too much space.
creativechaos

16 Aug 2008
Posts: 7

Thanks Jai,

I had a look over the code too and noticed that the RecursiveMkDir function does try forcing the permissions to 777...

I went to the hosts first as I assumed this was a server issue but they gave me the runaround and pointed back to the software.

I've got back to them with the code being used so hopefully they will give me a better response this time.

Just out of interest, you say that you host sets all new directories to 755 by default, so are you having the same issue when trying to create a gallery from the admin?

Just trying to find a way I don't have to manually update the permissions every time my client decides to add a new image gallery to the site!

Thanks.

Michael.

Jaijaz Jaijaz

17 Aug 2008
Posts: 215

Hey Michael,

So the plot gets deeper.

I have only have one client that is using the gallery plugin so I just got in and had a little play. It didn't work, same prob as you had. Interestingly the client has never said anything so obviously using that part of the site lots ;-). Found that the dir for the gallery didn't get created. Found that the gallery3 dir in downloads was set to 755. Changed it to 777 and everything working fine. Interesting the dir that was created for the gallery is set at 755 (as per host settings I think) but I was still able to upload an image successfully.

So where does that leave you. My suggestion would be to make sure that the gallery3 dir is set to 777 in downloads. My expirence was that as long at gallery3 is set to 777 it doesn't mater what the actual galleries dir is set.

Good luck.
Jai
If you not living on the edge you taking up too much space.
tom

Developer

tom

18 Aug 2008
Posts: 379

i think Jai's analysis is correct - afaik servers generally set new folders to the same permissions as the parent. so if the original mysite folder was at 755, then downloads will be set to that too when it was created and then so will the gallery3 folder and so on.
creativechaos

18 Aug 2008
Posts: 7

Hey Jai and Tom,

I realize now that this is a server issue and not a Jojo coding issue so thanks a lot for your assistance with this.

I have been in touch with the hosting support but they seem to be a bit lax in providing assistance.

The recursive directory permissions was the first thing I actually tried to resolve the problem. I've given 0777 permission to the downloads and gallery3 folder and all sub folders that are on the server at the time recursively pick this up.

The issue still existed however when creating a new directory through the Gallery3 upload script - the new folder (1, 2 etc) is always created with permissions of 0755

Where I am at now is modifying the plugins/jojo_core/classes/jojo.php file so we have the recursivemkdir function as:

static function recursiveMkdir($path = false) {
if (!$path) {
return false;
}
$res = -1;
if (!file_exists($path)) {
$res = Jojo::RecursiveMkdir(dirname($path));
if (!file_exists($path)) {
$res = mkdir($path, 0777);
chmod($path, 0777);
chown($path, "you");
}
}
return $res;
}


The chmod correctly assigns the permissions to the directory now so it is 0777 however the chown is not updating.

In the online control panel I have two choices for chown - "Webserver" or "You"

When I set the owner to "You" I can upload fine.

By default the server is setting it to "Webserver" which prevents me from uploading.

Again I went to my hosting support to find out what the owner should be as it is setting to "Webserver" when I try setting the php chown function to "You" or "root".

They came back telling me that it should be "You" and this is set through the control panel. (don't think they are the sharpest tools in the shed...)

Basically I think once I get this chown owner thing right I'll be all set. I guess it's just a case of the hosts telling me what owner I need to set, but I thought I'd post here where I'm at with this in case any one else runs into similar issues.

Cheers.

Michael.
tom

Developer

tom

18 Aug 2008
Posts: 379

from memory, last time we looked at that code, it seemed like the chmod was never going to get run, except in the one case where the webserver didn't have write permission, so it couldn't have generated the folder, and if it could somehow, a chmod wasn't going to be permitted either.. so it seemed broadly pointless

I can't remember whether we just deleted it at that point or ignored it, but those changes are probably only in the trunk copy at this point, because i think that was since the rc1 tag. Probably time we issued rc2.
creativechaos

18 Aug 2008
Posts: 7

Hi Tom,

I'm not real sure on the whole flow through the code but just noticed when I added the additional chmod($path, 0777); code into that routine, that the folder was successfully created with those permissions instead of 0755 which is the case without the line.

As I said, the chown update should fingers crossed also allow me to programatically define the folder as belonging to the "You" user and hence have the correct permissions to enable direct uploading from the admin.

A bit off the main topic but based on your post I thought I'd take a look at the latest nightly build and noticed that the gallery3 module has quite a number of changes from the rc1 build.

Would there be much needed to apply the latest gallery3 code to my current site which is rc1?

Worth trying or am I likely to break things?!!
tom

Developer

tom

18 Aug 2008
Posts: 379

i hope it doesn't break anything.. :p
I did try and code it so that existing functionality would be maintained.

I needed a gallery with caption handling, and the ability to have more than one gallery section on a site.. so the trunk copy can now optionally use "categories" (in the same way as articles - basically multiple instances of pages that reference the plugin).

Captions are passed through to the lightbox preview and the display in the thumbnail gallery is optional.

It adds a "edit gallery image data" page to admin for adding captions, credits, changing/adding/deleting images, and assigning categories (if used) - which is good for small edits, or for people without ftp skills. But like I said, it should still work in the usual way too, with bulk uploads via ftp.

I think i added more support for search, autotagging and in-place sitemap options as well. and a bit of stuff in global to pull out a random image from a random gallery to use as a teaser in other parts of the site.

I'll have a look at folding your code in and commiting it if it all seems ok with the installs we have running
Back to Forum Index : Back to Administration (backend and configuration)   RSS
You must be logged in to post a reply



You need to Register or Log In before posting on these forums.