mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 21:49:15 +01:00
MDL-23984 make_upload_directory() cleanup - we now throw exceptions by default which should prevent a lot of strange problems
This commit is contained in:
parent
c426ef3aa5
commit
71904f4d2b
@ -123,7 +123,7 @@ $CFG->lang = $options['lang'];
|
||||
|
||||
//download lang pack with optional notification
|
||||
if ($CFG->lang != 'en') {
|
||||
make_upload_directory('lang', false);
|
||||
make_upload_directory('lang');
|
||||
if ($cd = new component_installer('http://download.moodle.org', 'langpack/2.0', $CFG->lang.'.zip', 'languages.md5', 'lang')) {
|
||||
if ($cd->install() == COMPONENT_ERROR) {
|
||||
if ($cd->get_error() == 'remotedownloaderror') {
|
||||
|
@ -50,7 +50,7 @@ function blog_rss_add_http_header($context, $title, $filtertype, $filterselect=0
|
||||
|
||||
//$componentname = 'blog';
|
||||
//rss_add_http_header($context, $componentname, $filterselect, $title);
|
||||
|
||||
|
||||
if (!isloggedin()) {
|
||||
$userid = $CFG->siteguest;
|
||||
} else {
|
||||
@ -230,24 +230,16 @@ function blog_rss_file_name($type, $id, $tagid=0) {
|
||||
//This function saves to file the rss feed specified in the parameters
|
||||
function blog_rss_save_file($type, $id, $tagid=0, $contents='') {
|
||||
global $CFG;
|
||||
|
||||
|
||||
$status = true;
|
||||
|
||||
//blog creates some additional dirs within the rss cache so make sure they all exist
|
||||
if (! $basedir = make_upload_directory ('cache/rss/blog')) {
|
||||
//Cannot be created, so error
|
||||
$status = false;
|
||||
}
|
||||
if (! $basedir = make_upload_directory ('cache/rss/blog/'.$type)) {
|
||||
//Cannot be created, so error
|
||||
$status = false;
|
||||
}
|
||||
make_upload_directory('cache/rss/blog');
|
||||
make_upload_directory('cache/rss/blog/'.$type);
|
||||
|
||||
if ($status) {
|
||||
$filename = blog_rss_file_name($type, $id, $tagid);
|
||||
$expandfilename = false; //we're supplying a full file path
|
||||
$status = rss_save_file('blog', $filename, $contents, $expandfilename);
|
||||
}
|
||||
$filename = blog_rss_file_name($type, $id, $tagid);
|
||||
$expandfilename = false; //we're supplying a full file path
|
||||
$status = rss_save_file('blog', $filename, $contents, $expandfilename);
|
||||
|
||||
return $status;
|
||||
}
|
||||
|
@ -40,11 +40,10 @@ class grade_export_xml extends grade_export {
|
||||
/// Calculate file name
|
||||
$downloadfilename = clean_filename("{$this->course->shortname} $strgrades.xml");
|
||||
|
||||
make_upload_directory('temp/gradeexport', false);
|
||||
make_upload_directory('temp/gradeexport');
|
||||
$tempfilename = $CFG->dataroot .'/temp/gradeexport/'. md5(sesskey().microtime().$downloadfilename);
|
||||
if (!$handle = fopen($tempfilename, 'w+b')) {
|
||||
print_error('cannotcreatetempdir');
|
||||
return false;
|
||||
}
|
||||
|
||||
/// time stamp to ensure uniqueness of batch export
|
||||
|
@ -107,9 +107,7 @@ if ($formdata = $mform->get_data()) {
|
||||
|
||||
// use current (non-conflicting) time stamp
|
||||
$importcode = get_new_importcode();
|
||||
if (!$filename = make_upload_directory('temp/gradeimport/cvs/'.$USER->id, true)) {
|
||||
die;
|
||||
}
|
||||
$filename = make_upload_directory('temp/gradeimport/cvs/'.$USER->id);
|
||||
$filename = $filename.'/'.$importcode;
|
||||
|
||||
$text = $mform->get_file_content('userfile');
|
||||
|
@ -563,9 +563,7 @@ function is_dataroot_insecure($fetchtest=false) {
|
||||
preg_match('|(https?://[^/]+)|i', $CFG->wwwroot, $matches);
|
||||
$httpdocroot = $matches[1];
|
||||
$datarooturl = $httpdocroot.'/'. substr($dataroot, strlen($siteroot));
|
||||
if (make_upload_directory('diag', false) === false) {
|
||||
return INSECURE_DATAROOT_WARNING;
|
||||
}
|
||||
make_upload_directory('diag');
|
||||
$testfile = $CFG->dataroot.'/diag/public.txt';
|
||||
if (!file_exists($testfile)) {
|
||||
file_put_contents($testfile, 'test file, do not delete');
|
||||
|
@ -308,9 +308,7 @@ class csv_import_reader {
|
||||
function get_new_iid($type) {
|
||||
global $USER;
|
||||
|
||||
if (!$filename = make_upload_directory('temp/csvimport/'.$type.'/'.$USER->id, false)) {
|
||||
print_error('cannotcreatetempdir');
|
||||
}
|
||||
$filename = make_upload_directory('temp/csvimport/'.$type.'/'.$USER->id);
|
||||
|
||||
// use current (non-conflicting) time stamp
|
||||
$iiid = time();
|
||||
|
@ -64,7 +64,7 @@ class MoodleExcelWorkbook {
|
||||
$this->latin_output = true;
|
||||
}
|
||||
/// Choose our temporary directory - see MDL-7176, found by paulo.matos
|
||||
make_upload_directory('temp/excel', false);
|
||||
make_upload_directory('temp/excel');
|
||||
$this->pear_excel_workbook->setTempDir($CFG->dataroot.'/temp/excel');
|
||||
}
|
||||
|
||||
|
@ -75,8 +75,8 @@ class MoodleODSWorkbook {
|
||||
require_once($CFG->libdir.'/filelib.php');
|
||||
|
||||
$dir = 'temp/ods/'.time();
|
||||
make_upload_directory($dir, false);
|
||||
make_upload_directory($dir.'/META-INF', false);
|
||||
make_upload_directory($dir);
|
||||
make_upload_directory($dir.'/META-INF');
|
||||
$dir = "$CFG->dataroot/$dir";
|
||||
$files = array();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user