Moving some functions to setuplib.php so they are first
This commit is contained in:
@@ -3988,52 +3988,6 @@ function email_is_not_allowed($email) {
|
||||
|
||||
/// FILE HANDLING /////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Create a directory.
|
||||
*
|
||||
* @uses $CFG
|
||||
* @param string $directory a string of directory names under $CFG->dataroot eg stuff/assignment/1
|
||||
* param bool $shownotices If true then notification messages will be printed out on error.
|
||||
* @return string|false Returns full path to directory if successful, false if not
|
||||
*/
|
||||
function make_upload_directory($directory, $shownotices=true) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$currdir = $CFG->dataroot;
|
||||
|
||||
umask(0000);
|
||||
|
||||
if (!file_exists($currdir)) {
|
||||
if (! mkdir($currdir, $CFG->directorypermissions)) {
|
||||
if ($shownotices) {
|
||||
notify('ERROR: You need to create the directory '. $currdir .' with web server write access');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if ($handle = fopen($currdir.'/.htaccess', 'w')) { // For safety
|
||||
@fwrite($handle, "deny from all\r\n");
|
||||
@fclose($handle);
|
||||
}
|
||||
}
|
||||
|
||||
$dirarray = explode('/', $directory);
|
||||
|
||||
foreach ($dirarray as $dir) {
|
||||
$currdir = $currdir .'/'. $dir;
|
||||
if (! file_exists($currdir)) {
|
||||
if (! mkdir($currdir, $CFG->directorypermissions)) {
|
||||
if ($shownotices) {
|
||||
notify('ERROR: Could not find or create a directory ('. $currdir .')');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
//@chmod($currdir, $CFG->directorypermissions); // Just in case mkdir didn't do it
|
||||
}
|
||||
}
|
||||
|
||||
return $currdir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an upload directory for a particular module.
|
||||
|
||||
Reference in New Issue
Block a user