Trying to run Moodle in safe mode

Re: Safe mode and files

by Dick Davies -
Number of replies: 7

Well at last I am making progress!

I have found a way in safe mode php to make a folder which is usable - but it is a little flakey!What I've done is first of all make my uploads folder inside the moodle folder tree - then I have rewritten moodle/files/index.php so that the "mkdir" action calls /moodle/lib/moodlelib.php to make folders (to save doing work twice)

I've put some extra variables in config.php including a safe mode flag I've replaced the make_upload_directory() with code that uses ftp_mkdir()

The great thing about ftp is that when you log in to your own machine you can chose the username - provided you have the password - so folders are made with the correct ownership. Everything else (upload/delete) seems to work fine. The only problem is re-parenting all of the folder paths to adjust for the ftp home folder.

I'm wondering if it is worth putting such a switch in the released version config.php to enable the safe mode workaround.  Then the make_upload_directory() function could contain "normal" and "safe via ftp" code, the other change would be to moodle/files/index.php so that it calls make_upload_directory()

I'm happy to submit my code, but I'm not a developer so it probably needs a good seeing to.

 

In reply to Dick Davies

Re: Safe mode and files

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
Using FTP to make the directories! Now that's thinking outside the box! Well done!

As you've noticed the files/index.php script does everything itself - that's a hangover from an ancient time when I thought I'd release it as a standalone script. Much better that it uses the standard functions, yes.

I'll try and get this all into 1.0.9 - looks like it would help quite a few people.
In reply to Martin Dougiamas

Re: Safe mode and files

by Dick Davies -

Oops

Just realised that moodle/user/lib.php also has a mkdir() so I've changed that too - attached.

In reply to Dick Davies

Re: Safe mode and files

by Frank Riddick -

When I upload your files, now I get an error when attempt to access the Admin hyperlink.

Fatal error: Call to undefined function: ini_get_bool() in /home/virtual/site57/fst/var/www/html/educ/admin/index.php on line 26

I have at least traced it down to the file (/lib/moodlelib.php).  All three of the other files:

/config.php

/files/index.php

/user/lib.php

can be uploaded without producing the error.

Any ideas ?

 

In reply to Frank Riddick

Re: Safe mode and files

by Dick Davies -

I've already apologised to Frank directly that I haven't got time to look into his problem - maybe he is using a different version.

Looking forward to 1.1

(No pressure!!!!)smiley.gif