Page 1 of 1
Permissions with 2.5.2: possible feature?
Posted: 26 Jul 2009, 13:18
by bole
Jan,
Excellent choice to set folder permissions to 755 by default, as it is much safer than 777 for obvious reasons. However...
My FTP-user (used by Joomla to create the folders) and the user creating the thumbnails (apache) are not the same, so I get an awful lot of errors while creating these thumbs. 775 fixes this problem, but is still not the preferred way to go... I was thinking about how to get Phoca work with both 755 permissions, but still being able to create thumbnails.
Is it possible, to rewrite the thumbnail-creation process to make use of the Joomla FTP-layer? This would immediately stop all the errors (as both the folder and the files are owned by the FTP-user), but you will still be able to use the safer 755 permission settings.
Some time ago I also played with the GD_libary, and from my LIMITED knowledge from then, it seems possible to me...
Re: Permissions with 2.5.2: possible feature?
Posted: 27 Jul 2009, 14:51
by Jan
Is it possible, to rewrite the thumbnail-creation process to make use of the Joomla FTP-layer?
Hi, Phoca Gallery uses Joomla! method JFolder::create to create folders, so if the FTP layer is enabled it is used during creation of folders in Phoca Gallery.
Jan
Re: Permissions with 2.5.2: possible feature?
Posted: 27 Jul 2009, 21:49
by bole
Yes, I know. So all the folders created by Phoca gallery get owner "FTP-User".
But the problem isn't the folder, it is the Thumbnail. Or actually, the GD-Libary creating the thumbnail.
While the GD is writing the thumbnail to the disk, it does that as user "Apache" -> thus creating permission problems with settin 755.
If you are able to modify the process of creating thumbnails in such way, that GD uses the Joomla FTP-layer, those thumbnails will also have owner "FTP-User", instead of "Apache". Then you will never have any problem with permissions, file owners etc etc.
You know what I'm trying to say?
Re: Permissions with 2.5.2: possible feature?
Posted: 27 Jul 2009, 22:18
by Jan
Hi,
before GD will write the files on the server, the thumbs folders will be created with this method:
@JFolder::create($folderThumbnail, (int)$folder_permissions );
so all folders can have ftp ownership
Yes, the files are created by GD, so they can get apache ownership.
As Phoca Gallery mostly only writes the thumbnails, there should be only problem with folder ownership not with file ownership. But of course, control permissions of files will be better but I don't know if there is some way to do it because maybe there is no way how GD can create images with ftp layer

Re: Permissions with 2.5.2: possible feature?
Posted: 28 Jul 2009, 10:49
by bole
I still was wondering how we could get this to work, and found a way. I do not know if this is an practical way, but at least give it a chance.
I found this in
http://nl.php.net/function.imagejpeg:
imageXXX() only has two options, save as a file, or send to the browser. It does not provide you the oppurtunity to manipulate the final GIF/JPG/PNG file stream. So I start the output buffering, use imageXXX() to output the data stream to the browser, get the contents of the stream, and use clean to silently discard the buffered contents.
Code: Select all
....your code for creating the thumbnail etc etc...
ob_start(); // Start output buffering
imagejpeg($tmp, NULL, 100); //create image and store in output buffer
$final_image = ob_get_contents(); //store output buffer contents in variable
ob_end_clean(); // clean the buffer
Now the image is stored in $final_image, which can be used with Joomla's
JFile::write API to store it on the server, and thus using the (safer) FTP-option when it is available. If this works, both the file and the folder are owned by the same user, as they are both created by the Joomla framework via FTP.
Only problem we might see, might be the use of the output buffer by some other process, but I'm not
that into the Joomla Core.
Let me know what your opinion is!
Re: Permissions with 2.5.2: possible feature?
Posted: 28 Jul 2009, 12:49
by Jan
Hi, I think this can be solution for individual severs, I think we cannot do it as standard (possible problem with ob_start(), possible problems with performance during creating thumbnails). Maybe we should write some guide so users which will have problems with ownership and permissions can hardcode it
Jan
Re: Permissions with 2.5.2: possible feature?
Posted: 28 Jul 2009, 19:02
by bole
Hmm, it might not be a problem at all:
Output buffers are stackable, that is, you may call ob_start() while another ob_start() is active. Just make sure that you call ob_end_flush() the appropriate number of times. If multiple output callback functions are active, output is being filtered sequentially through each of them in nesting order.
PHP OB_Start manual
Didn't know this...
So, it seems to be an improvement that should work...
Re: Permissions with 2.5.2: possible feature?
Posted: 05 Aug 2009, 01:29
by Jan
Hi, I have tested it and seems it should working, so I have included it into Phoca Gallery 2.5.5
Jan