Safe mode yet again

Safe mode yet again

by Martin Skjöldebrand -
Number of replies: 7
OK, people - before you let flames scorche the earth (or net or whatever), yes I've read the long thread on safe_mode. And yes I know what safe mode is and why it's there. And yes I suppose you are very tired of seeing questions on safe mode.

Hi,

I'm new around here (stating the bleedin' obvious). Just want to know: is there a chance of a workaround for safe mode in either 1.2 or 2.0? And regarding the latter, when is "early" 2004 any ideas?

I'm playing with Moodle 1.1.1 for our chess club  and it's a wonderful piece of software. Really, neat. My ISP however is *not* going to do anything on their part to allow Moodle upload files. ("99 % of the software work around safe_mode, so my only suggestion is to look for something else."). I tried pointing it upload to the directory that my copy of Photoshare (a module for PostNuke that displays photo, which you first must upload). Photoshare works nicely with safe_mode on and also rights files and displays them from Postnuke. Perhaps there is something in Photoshare that can be implemented in Moodle? (It's been a very long time since I did anything with PHP, sorry).

Regards,

/Martin S.
Average of ratings: -
In reply to Martin Skjöldebrand

Re: Safe mode yet again

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Photoshare gets around Safe Mode by storing the photos directly in the database.

This is the only real solution (as mentioned here) and part of requirements for the new document management system to replace the current file system. It's not a quick hack, however ... in the meantime it's much easier to just change hosts.


In reply to Martin Dougiamas

Re: Safe mode yet again

by Martin Skjöldebrand -
Yes, photoshare can store photos in the database.
However, the way I have it set up I set two directories

(These are from my Photoshare admin page)
Folder for storing image files on disc (if required) (The webserver is able to write to this folder)

and

Folder for temporary files (The webserver is able to write to this folder)

Both are within my public_html structure. So photoshare is able to write to directories under safe_mode or am I missing something obvious again?

/Martin S.
In reply to Martin Skjöldebrand

Re: Safe mode yet again

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
"So photoshare is able to write to directories under safe_mode"

Are there photos in there?  Are they ever read by scripts or are they called directly from web pages?  Can you delete or modify photos?  

Safe mode prevents scripts owned by one user id reading files owned by another.  Your scripts are owned by you, but the uploaded files are owned by the web server user.   There's not any easy way around this (hence the name safe mode wink ).  I had a quick look at the Photoshare code but I can't see that he's doing anything different than Moodle is doing. 

If you can send me access (privately) to your working site that might help.
In reply to Martin Dougiamas

Re: Safe mode yet again

by Martin Skjöldebrand -
Yes there are photos in there, Thumbnails among others. I *suppose* that the thumbnails are accessed through Photoshare (the main directory is filled with img files that the files you see in the Photoshare albums. You can at least delete photos from the Photoshare Album through the users interface.
I've sent you particulars as to how to access the site and Photoshare.
In reply to Martin Skjöldebrand

Re: Safe mode yet again

by Martin Skjöldebrand -
OK, I've been playing a bit more with Moodle and it looks like it actually should be able to write to some of the safe_mode servers. I created a quiz and then got a "Can't create a directory" error. I manually created the directory through my FTP client and then I actually got through creating a quiz using that directory(?). I can access the quiz later on as well. I got brave tried Files got the same type of error, created a directory ("1") manually through FTP and it shows up in Files in Moodle.

I can't upload to the Files directory though sad. But this is exactly what Photoshare does. I don't think it can be that hard cracking this problem, I can upload files to a photodirectory using Photoshare.

Don't know if you ever got time to check on Photoshare. Too bad I am very rusty on PHP or else I'd give it a shot.

Anyway, Merry Christmas to all!

/M.
In reply to Martin Skjöldebrand

Re: Safe mode yet again

by Geoff Roberts -

I too am cursed with safe mode.

However I do have a file upload script that works just fine elsewhere on my server.:
http://uni.monjo.com/add.php?page=artist (if you want the code just ask!)

I am not sure if the problem with Moodle is it tries to set the folders permissions, or rename files or if it uses tmp directories.

However the problem is the file is CHMOD at 0600.

Possible things Moodle can do:
keep the files at 600, so they cant be edited by anyone, but rename them:
aaa000.jpg etc and store this in the database.
Then have a script that can be ran to see any uploaded picture (eg user pics) that isnt being used and delete it from the webserver.

In reply to Geoff Roberts

Re: Safe mode yet again

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
I never found time to look at Martin Skjöldebrand's site or play with safe mode myself, but if someone wants to take this issue up and look closely at the code involved there might just be a solution.