diff --git a/admin/langimport.php b/admin/langimport.php index 713f608ad0b..476dbaf0808 100644 --- a/admin/langimport.php +++ b/admin/langimport.php @@ -58,7 +58,7 @@ $notice_error = array(); if (($mode == INSTALLATION_OF_SELECTED_LANG) and confirm_sesskey() and !empty($pack)) { set_time_limit(0); - make_upload_directory('temp'); + make_temp_directory(''); make_upload_directory('lang'); $installer = new lang_installer($pack); @@ -149,7 +149,7 @@ if ($mode == UPDATE_ALL_LANG) { } } - make_upload_directory('temp'); + make_temp_directory(''); make_upload_directory('lang'); // clean-up currently installed versions of the packs diff --git a/admin/timezoneimport.php b/admin/timezoneimport.php index a09f17d5330..90419733076 100644 --- a/admin/timezoneimport.php +++ b/admin/timezoneimport.php @@ -22,8 +22,8 @@ if (!$ok or !confirm_sesskey()) { $message = '

'; - $message .= $CFG->dataroot.'/temp/olson.txt
'; - $message .= $CFG->dataroot.'/temp/timezone.txt
'; + $message .= $CFG->tempdir.'/olson.txt
'; + $message .= $CFG->tempdir.'/timezone.txt
'; $message .= 'http://download.moodle.org/timezone/
'; $message .= ''.$CFG->dirroot.'/lib/timezone.txt
'; $message .= '
'; @@ -43,7 +43,7 @@ /// First, look for an Olson file locally - $source = $CFG->dataroot.'/temp/olson.txt'; + $source = $CFG->tempdir.'/olson.txt'; if (!$importdone and is_readable($source)) { if ($timezones = olson_to_timezones($source)) { update_timezone_records($timezones); @@ -53,7 +53,7 @@ /// Next, look for a CSV file locally - $source = $CFG->dataroot.'/temp/timezone.txt'; + $source = $CFG->tempdir.'/timezone.txt'; if (!$importdone and is_readable($source)) { if ($timezones = get_records_csv($source, 'timezone')) { update_timezone_records($timezones); @@ -64,14 +64,14 @@ /// Otherwise, let's try moodle.org's copy $source = 'http://download.moodle.org/timezone/'; if (!$importdone && ($content=download_file_content($source))) { - if ($file = fopen($CFG->dataroot.'/temp/timezone.txt', 'w')) { // Make local copy + if ($file = fopen($CFG->tempdir.'/timezone.txt', 'w')) { // Make local copy fwrite($file, $content); fclose($file); - if ($timezones = get_records_csv($CFG->dataroot.'/temp/timezone.txt', 'timezone')) { // Parse it + if ($timezones = get_records_csv($CFG->tempdir.'/timezone.txt', 'timezone')) { // Parse it update_timezone_records($timezones); $importdone = $source; } - unlink($CFG->dataroot.'/temp/timezone.txt'); + unlink($CFG->tempdir.'/timezone.txt'); } } diff --git a/admin/uploadpicture.php b/admin/uploadpicture.php index c57e1362203..2a716962f7b 100644 --- a/admin/uploadpicture.php +++ b/admin/uploadpicture.php @@ -72,7 +72,7 @@ if ($formdata = $mform->get_data()) { // Create a unique temporary directory, to process the zip file // contents. - $zipdir = my_mktempdir($CFG->dataroot.'/temp/', 'usrpic'); + $zipdir = my_mktempdir($CFG->tempdir.'/', 'usrpic'); $dstfile = $zipdir.'/images.zip'; if (!$mform->save_file('userpicturesfile', $dstfile, true)) { diff --git a/auth/mnet/auth.php b/auth/mnet/auth.php index 9c463d66e9f..b4e733c9140 100644 --- a/auth/mnet/auth.php +++ b/auth/mnet/auth.php @@ -311,7 +311,7 @@ class auth_plugin_mnet extends auth_plugin_base { $fetchrequest->add_param($localuser->username); if ($fetchrequest->send($remotepeer) === true) { if (strlen($fetchrequest->response['f1']) > 0) { - $imagefilename = $CFG->dataroot . '/temp/mnet-usericon-' . $localuser->id; + $imagefilename = $CFG->tempdir . '/mnet-usericon-' . $localuser->id; $imagecontents = base64_decode($fetchrequest->response['f1']); file_put_contents($imagefilename, $imagecontents); if (process_new_icon($usercontext, 'user', 'icon', 0, $imagefilename)) { diff --git a/backup/controller/restore_controller.class.php b/backup/controller/restore_controller.class.php index f523df97950..50ec1027d02 100644 --- a/backup/controller/restore_controller.class.php +++ b/backup/controller/restore_controller.class.php @@ -32,7 +32,7 @@ */ class restore_controller extends backup implements loggable { - protected $tempdir; // Directory under dataroot/temp/backup awaiting restore + protected $tempdir; // Directory under tempdir/backup awaiting restore protected $restoreid; // Unique identificator for this restore protected $courseid; // courseid where restore is going to happen @@ -61,7 +61,7 @@ class restore_controller extends backup implements loggable { /** * - * @param string $tempdir Directory under dataroot/temp/backup awaiting restore + * @param string $tempdir Directory under tempdir/backup awaiting restore * @param int $courseid Course id where restore is going to happen * @param bool $interactive backup::INTERACTIVE_YES[true] or backup::INTERACTIVE_NO[false] * @param int $mode backup::MODE_[ GENERAL | HUB | IMPORT | SAMESITE ] diff --git a/backup/converter/convertlib.php b/backup/converter/convertlib.php index 773055cb238..61b148bd754 100644 --- a/backup/converter/convertlib.php +++ b/backup/converter/convertlib.php @@ -147,7 +147,7 @@ abstract class base_converter implements loggable { public function get_workdir_path() { global $CFG; - return "$CFG->dataroot/temp/backup/$this->workdir"; + return "$CFG->tempdir/backup/$this->workdir"; } /** @@ -156,7 +156,7 @@ abstract class base_converter implements loggable { public function get_tempdir_path() { global $CFG; - return "$CFG->dataroot/temp/backup/$this->tempdir"; + return "$CFG->tempdir/backup/$this->tempdir"; } /// public static methods ////////////////////////////////////////////////// diff --git a/backup/converter/moodle1/lib.php b/backup/converter/moodle1/lib.php index aef888e44c6..86e2026b579 100644 --- a/backup/converter/moodle1/lib.php +++ b/backup/converter/moodle1/lib.php @@ -89,7 +89,7 @@ class moodle1_converter extends base_converter { public static function detect_format($tempdir) { global $CFG; - $filepath = $CFG->dataroot . '/temp/backup/' . $tempdir . '/moodle.xml'; + $filepath = $CFG->tempdir . '/backup/' . $tempdir . '/moodle.xml'; if (file_exists($filepath)) { // looks promising, lets load some information $handle = fopen($filepath, 'r'); diff --git a/backup/converter/moodle1/simpletest/testlib.php b/backup/converter/moodle1/simpletest/testlib.php index addc174d124..cd1987025bf 100644 --- a/backup/converter/moodle1/simpletest/testlib.php +++ b/backup/converter/moodle1/simpletest/testlib.php @@ -39,38 +39,38 @@ class moodle1_converter_test extends UnitTestCase { global $CFG; $this->tempdir = convert_helper::generate_id('simpletest'); - check_dir_exists("$CFG->dataroot/temp/backup/$this->tempdir/course_files/sub1"); - check_dir_exists("$CFG->dataroot/temp/backup/$this->tempdir/moddata/unittest/4/7"); + check_dir_exists("$CFG->tempdir/backup/$this->tempdir/course_files/sub1"); + check_dir_exists("$CFG->tempdir/backup/$this->tempdir/moddata/unittest/4/7"); copy( "$CFG->dirroot/backup/converter/moodle1/simpletest/files/moodle.xml", - "$CFG->dataroot/temp/backup/$this->tempdir/moodle.xml" + "$CFG->tempdir/backup/$this->tempdir/moodle.xml" ); copy( "$CFG->dirroot/backup/converter/moodle1/simpletest/files/icon.gif", - "$CFG->dataroot/temp/backup/$this->tempdir/course_files/file1.gif" + "$CFG->tempdir/backup/$this->tempdir/course_files/file1.gif" ); copy( "$CFG->dirroot/backup/converter/moodle1/simpletest/files/icon.gif", - "$CFG->dataroot/temp/backup/$this->tempdir/course_files/sub1/file2.gif" + "$CFG->tempdir/backup/$this->tempdir/course_files/sub1/file2.gif" ); copy( "$CFG->dirroot/backup/converter/moodle1/simpletest/files/icon.gif", - "$CFG->dataroot/temp/backup/$this->tempdir/moddata/unittest/4/file1.gif" + "$CFG->tempdir/backup/$this->tempdir/moddata/unittest/4/file1.gif" ); copy( "$CFG->dirroot/backup/converter/moodle1/simpletest/files/icon.gif", - "$CFG->dataroot/temp/backup/$this->tempdir/moddata/unittest/4/icon.gif" + "$CFG->tempdir/backup/$this->tempdir/moddata/unittest/4/icon.gif" ); copy( "$CFG->dirroot/backup/converter/moodle1/simpletest/files/icon.gif", - "$CFG->dataroot/temp/backup/$this->tempdir/moddata/unittest/4/7/icon.gif" + "$CFG->tempdir/backup/$this->tempdir/moddata/unittest/4/7/icon.gif" ); } public function tearDown() { global $CFG; if (empty($CFG->keeptempdirectoriesonbackup)) { - fulldelete("$CFG->dataroot/temp/backup/$this->tempdir"); + fulldelete("$CFG->tempdir/backup/$this->tempdir"); } } @@ -440,7 +440,7 @@ as it is parsed from the backup file.

dirroot/backup/converter/moodle1/simpletest/files/questions.xml", - "$CFG->dataroot/temp/backup/$this->tempdir/moodle.xml" + "$CFG->tempdir/backup/$this->tempdir/moodle.xml" ); $converter = convert_factory::get_converter('moodle1', $this->tempdir); $converter->convert(); diff --git a/backup/import.php b/backup/import.php index 6ba891171d1..7c0c0b25055 100644 --- a/backup/import.php +++ b/backup/import.php @@ -96,7 +96,7 @@ if ($backup->get_stage() == backup_ui::STAGE_FINAL) { // Check whether the backup directory still exists. If missing, something // went really wrong in backup, throw error. Note that backup::MODE_IMPORT // backups don't store resulting files ever - $tempdestination = $CFG->dataroot . '/temp/backup/' . $backupid; + $tempdestination = $CFG->tempdir . '/backup/' . $backupid; if (!file_exists($tempdestination) || !is_dir($tempdestination)) { print_error('unknownbackupexporterror'); // shouldn't happen ever } diff --git a/backup/lib.php b/backup/lib.php index 3a4e5da9778..e479e9009b1 100644 --- a/backup/lib.php +++ b/backup/lib.php @@ -54,9 +54,9 @@ $status = true; //Get files and directories in the temp backup dir witout descend - $list = get_directory_list($CFG->dataroot."/temp/backup", "", false, true, true); + $list = get_directory_list($CFG->tempdir."/backup", "", false, true, true); foreach ($list as $file) { - $file_path = $CFG->dataroot."/temp/backup/".$file; + $file_path = $CFG->tempdir."/backup/".$file; $moddate = filemtime($file_path); if ($status && $moddate < $delete_from) { //If directory, recurse @@ -81,12 +81,12 @@ function check_and_create_backup_dir($backup_unique_code) { global $CFG; - $status = check_dir_exists($CFG->dataroot."/temp",true); + $status = check_dir_exists($CFG->tempdir."",true); if ($status) { - $status = check_dir_exists($CFG->dataroot."/temp/backup",true); + $status = check_dir_exists($CFG->tempdir."/backup",true); } if ($status) { - $status = check_dir_exists($CFG->dataroot."/temp/backup/".$backup_unique_code,true); + $status = check_dir_exists($CFG->tempdir."/backup/".$backup_unique_code,true); } return $status; @@ -162,7 +162,7 @@ function clear_backup_dir($backup_unique_code) { global $CFG; - $rootdir = $CFG->dataroot."/temp/backup/".$backup_unique_code; + $rootdir = $CFG->tempdir."/backup/".$backup_unique_code; //Delete recursively $status = delete_dir_contents($rootdir); @@ -237,7 +237,7 @@ && $DB->delete_records('backup_files', array('backup_code'=>$preferences->backup_unique_code)); //Now, delete temp directory (if exists) - $file_path = $CFG->dataroot."/temp/backup/".$preferences->backup_unique_code; + $file_path = $CFG->tempdir."/backup/".$preferences->backup_unique_code; if (is_dir($file_path)) { $status = delete_dir_contents($file_path); //There is nothing, delete the directory itself @@ -348,7 +348,7 @@ if (strlen($info_ser) > $max_db_storage) { //Calculate filename (in current_backup_dir, $backup_unique_code_$table_$old_id.info) - $filename = $CFG->dataroot."/temp/backup/".$backup_unique_code."/".$backup_unique_code."_".$table."_".$old_id.".info"; + $filename = $CFG->tempdir."/backup/".$backup_unique_code."/".$backup_unique_code."_".$table."_".$old_id.".info"; //Save data to file $status = backup_data2file($filename,$info_ser); //Set info_to save @@ -394,7 +394,7 @@ //If info field = "infile", get file contents if (!empty($status->info) && $status->info == "infile") { - $filename = $CFG->dataroot."/temp/backup/".$backup_unique_code."/".$backup_unique_code."_".$table."_".$old_id.".info"; + $filename = $CFG->tempdir."/backup/".$backup_unique_code."/".$backup_unique_code."_".$table."_".$old_id.".info"; //Read data from file $status2 = backup_file2data($filename,$info); if ($status2) { diff --git a/backup/restorefile.php b/backup/restorefile.php index 79f5f85e895..d89143de631 100644 --- a/backup/restorefile.php +++ b/backup/restorefile.php @@ -64,7 +64,7 @@ require_capability('moodle/restore:restorecourse', $context); $browser = get_file_browser(); // check if tmp dir exists -$tmpdir = $CFG->dataroot . '/temp/backup'; +$tmpdir = $CFG->tempdir . '/backup'; if (!check_dir_exists($tmpdir, true, true)) { throw new restore_controller_exception('cannot_create_backup_temp_dir'); } diff --git a/backup/util/factories/backup_factory.class.php b/backup/util/factories/backup_factory.class.php index 9655e8716bc..a24905c51c8 100644 --- a/backup/util/factories/backup_factory.class.php +++ b/backup/util/factories/backup_factory.class.php @@ -60,9 +60,9 @@ abstract class backup_factory { // Create file_logger, observing $CFG->backup_file_logger_level // defaulting to $dfltloglevel - check_dir_exists($CFG->dataroot . '/temp/backup', true, true); // need to ensure that temp/backup already exists + check_dir_exists($CFG->tempdir . '/backup', true, true); // need to ensure that temp/backup already exists $fllevel = isset($CFG->backup_file_logger_level) ? $CFG->backup_file_logger_level : $dfltloglevel; - $enabledloggers[] = new file_logger($fllevel, true, true, $CFG->dataroot . '/temp/backup/' . $backupid . '.log'); + $enabledloggers[] = new file_logger($fllevel, true, true, $CFG->tempdir . '/backup/' . $backupid . '.log'); // Create database_logger, observing $CFG->backup_database_logger_level and defaulting to LOG_WARNING // and pointing to the backup_logs table diff --git a/backup/util/helper/backup_file_manager.class.php b/backup/util/helper/backup_file_manager.class.php index c5b0121f4df..fb6477a6996 100644 --- a/backup/util/helper/backup_file_manager.class.php +++ b/backup/util/helper/backup_file_manager.class.php @@ -43,7 +43,7 @@ class backup_file_manager { public static function get_backup_storage_base_dir($backupid) { global $CFG; - return $CFG->dataroot . '/temp/backup/' . $backupid . '/files'; + return $CFG->tempdir . '/backup/' . $backupid . '/files'; } /** diff --git a/backup/util/helper/backup_general_helper.class.php b/backup/util/helper/backup_general_helper.class.php index 20238fe50e9..73b5d3b4014 100644 --- a/backup/util/helper/backup_general_helper.class.php +++ b/backup/util/helper/backup_general_helper.class.php @@ -114,7 +114,7 @@ abstract class backup_general_helper extends backup_helper { $info = new stdclass(); // Final information goes here - $moodlefile = $CFG->dataroot . '/temp/backup/' . $tempdir . '/moodle_backup.xml'; + $moodlefile = $CFG->tempdir . '/backup/' . $tempdir . '/moodle_backup.xml'; if (!file_exists($moodlefile)) { // Shouldn't happen ever, but... throw new backup_helper_exception('missing_moodle_backup_xml_file', $moodlefile); } diff --git a/backup/util/helper/backup_helper.class.php b/backup/util/helper/backup_helper.class.php index d1fd91df5a9..67bd78e8638 100644 --- a/backup/util/helper/backup_helper.class.php +++ b/backup/util/helper/backup_helper.class.php @@ -34,7 +34,7 @@ abstract class backup_helper { */ static public function check_and_create_backup_dir($backupid) { global $CFG; - if (!check_dir_exists($CFG->dataroot . '/temp/backup/' . $backupid, true, true)) { + if (!check_dir_exists($CFG->tempdir . '/backup/' . $backupid, true, true)) { throw new backup_helper_exception('cannot_create_backup_temp_dir'); } } @@ -44,7 +44,7 @@ abstract class backup_helper { */ static public function clear_backup_dir($backupid) { global $CFG; - if (!self::delete_dir_contents($CFG->dataroot . '/temp/backup/' . $backupid)) { + if (!self::delete_dir_contents($CFG->tempdir . '/backup/' . $backupid)) { throw new backup_helper_exception('cannot_empty_backup_temp_dir'); } return true; @@ -56,7 +56,7 @@ abstract class backup_helper { static public function delete_backup_dir($backupid) { global $CFG; self::clear_backup_dir($backupid); - return rmdir($CFG->dataroot . '/temp/backup/' . $backupid); + return rmdir($CFG->tempdir . '/backup/' . $backupid); } /** @@ -132,9 +132,9 @@ abstract class backup_helper { $status = true; // Get files and directories in the temp backup dir witout descend - $list = get_directory_list($CFG->dataroot . '/temp/backup', '', false, true, true); + $list = get_directory_list($CFG->tempdir . '/backup', '', false, true, true); foreach ($list as $file) { - $file_path = $CFG->dataroot . '/temp/backup/' . $file; + $file_path = $CFG->tempdir . '/backup/' . $file; $moddate = filemtime($file_path); if ($status && $moddate < $deletefrom) { //If directory, recurse diff --git a/backup/util/helper/convert_helper.class.php b/backup/util/helper/convert_helper.class.php index 539f4f832dc..1be31ae11ca 100644 --- a/backup/util/helper/convert_helper.class.php +++ b/backup/util/helper/convert_helper.class.php @@ -85,7 +85,7 @@ abstract class convert_helper { public static function detect_moodle2_format($tempdir) { global $CFG; - $dirpath = $CFG->dataroot . '/temp/backup/' . $tempdir; + $dirpath = $CFG->tempdir . '/backup/' . $tempdir; $filepath = $dirpath . '/moodle_backup.xml'; if (!is_dir($dirpath)) { diff --git a/backup/util/loggers/simpletest/testlogger.php b/backup/util/loggers/simpletest/testlogger.php index cbd11fb8808..9374346ae93 100644 --- a/backup/util/loggers/simpletest/testlogger.php +++ b/backup/util/loggers/simpletest/testlogger.php @@ -230,7 +230,7 @@ class logger_test extends UnitTestCase { function test_file_logger() { global $CFG; - $file = $CFG->dataroot . '/temp/test/test_file_logger.txt'; + $file = $CFG->tempdir . '/test/test_file_logger.txt'; // Remove the test dir and any content @remove_dir(dirname($file)); // Recreate test dir @@ -272,7 +272,7 @@ class logger_test extends UnitTestCase { unlink($file); // delete file // Try one html file - $file = $CFG->dataroot . '/temp/test/test_file_logger.html'; + $file = $CFG->tempdir . '/test/test_file_logger.html'; $options = array('depth' => 1); $lo = new file_logger(backup::LOG_ERROR, true, true, $file); $this->assertTrue($lo instanceof file_logger); @@ -289,7 +289,7 @@ class logger_test extends UnitTestCase { unlink($file); // delete file // Instantiate, write something, force deletion, try to write again - $file = $CFG->dataroot . '/temp/test/test_file_logger.html'; + $file = $CFG->tempdir . '/test/test_file_logger.html'; $lo = new mock_file_logger(backup::LOG_ERROR, true, true, $file); $this->assertTrue(file_exists($file)); $message = 'testing file_logger'; @@ -313,7 +313,7 @@ class logger_test extends UnitTestCase { } // Instantiate in (near) impossible path - $file = $CFG->dataroot . '/temp/test_azby/test_file_logger.txt'; + $file = $CFG->tempdir . '/test_azby/test_file_logger.txt'; try { $lo = new file_logger(backup::LOG_WARNING, true, true, $file); $this->assertTrue(false, 'base_logger_exception expected'); @@ -324,7 +324,7 @@ class logger_test extends UnitTestCase { } // Instatiate one file logger with level = backup::LOG_NONE - $file = $CFG->dataroot . '/temp/test/test_file_logger.txt'; + $file = $CFG->tempdir . '/test/test_file_logger.txt'; $lo = new file_logger(backup::LOG_NONE, true, true, $file); $this->assertTrue($lo instanceof file_logger); $this->assertFalse(file_exists($file)); diff --git a/backup/util/plan/backup_plan.class.php b/backup/util/plan/backup_plan.class.php index 08166210da0..f21385cc5f4 100644 --- a/backup/util/plan/backup_plan.class.php +++ b/backup/util/plan/backup_plan.class.php @@ -43,7 +43,7 @@ class backup_plan extends base_plan implements loggable { throw new backup_plan_exception('wrong_backup_controller_specified'); } $this->controller = $controller; - $this->basepath = $CFG->dataroot . '/temp/backup/' . $controller->get_backupid(); + $this->basepath = $CFG->tempdir . '/backup/' . $controller->get_backupid(); parent::__construct('backup_plan'); } diff --git a/backup/util/plan/restore_plan.class.php b/backup/util/plan/restore_plan.class.php index 27b1cfce2e4..3d0c6ca34a9 100644 --- a/backup/util/plan/restore_plan.class.php +++ b/backup/util/plan/restore_plan.class.php @@ -50,7 +50,7 @@ class restore_plan extends base_plan implements loggable { throw new restore_plan_exception('wrong_restore_controller_specified'); } $this->controller = $controller; - $this->basepath = $CFG->dataroot . '/temp/backup/' . $controller->get_tempdir(); + $this->basepath = $CFG->tempdir . '/backup/' . $controller->get_tempdir(); $this->preloaded = false; $this->decoder = new restore_decode_processor($this->get_restoreid(), $this->get_info()->original_wwwroot, $CFG->wwwroot); $this->missingmodules = false; diff --git a/backup/util/plan/simpletest/teststep.php b/backup/util/plan/simpletest/teststep.php index 0e0b567a0a2..8643c4d734a 100644 --- a/backup/util/plan/simpletest/teststep.php +++ b/backup/util/plan/simpletest/teststep.php @@ -195,7 +195,7 @@ class backup_step_test extends UnitTestCase { function test_backup_structure_step() { global $CFG; - $file = $CFG->dataroot . '/temp/test/test_backup_structure_step.txt'; + $file = $CFG->tempdir . '/test/test_backup_structure_step.txt'; // Remove the test dir and any content @remove_dir(dirname($file)); // Recreate test dir @@ -295,7 +295,7 @@ class mock_backup_task_basepath extends backup_task { public function get_taskbasepath() { global $CFG; - return $CFG->dataroot . '/temp/test'; + return $CFG->tempdir . '/test'; } } diff --git a/backup/util/ui/restore_ui_stage.class.php b/backup/util/ui/restore_ui_stage.class.php index a50f2592517..cd19b7db5eb 100644 --- a/backup/util/ui/restore_ui_stage.class.php +++ b/backup/util/ui/restore_ui_stage.class.php @@ -153,7 +153,7 @@ class restore_ui_stage_confirm extends restore_ui_independent_stage { } public function process() { global $CFG; - if (!file_exists("$CFG->dataroot/temp/backup/".$this->filename)) { + if (!file_exists("$CFG->tempdir/backup/".$this->filename)) { throw new restore_ui_exception('invalidrestorefile'); } $outcome = $this->extract_file_to_dir(); @@ -168,7 +168,7 @@ class restore_ui_stage_confirm extends restore_ui_independent_stage { $this->filepath = restore_controller::get_tempdir_name($this->contextid, $USER->id); $fb = get_file_packer(); - return ($fb->extract_to_pathname("$CFG->dataroot/temp/backup/".$this->filename, "$CFG->dataroot/temp/backup/$this->filepath/")); + return ($fb->extract_to_pathname("$CFG->tempdir/backup/".$this->filename, "$CFG->tempdir/backup/$this->filepath/")); } /** @@ -236,7 +236,7 @@ class restore_ui_stage_destination extends restore_ui_independent_stage { } public function process() { global $CFG, $DB; - if (!file_exists("$CFG->dataroot/temp/backup/".$this->filepath) || !is_dir("$CFG->dataroot/temp/backup/".$this->filepath)) { + if (!file_exists("$CFG->tempdir/backup/".$this->filepath) || !is_dir("$CFG->tempdir/backup/".$this->filepath)) { throw new restore_ui_exception('invalidrestorepath'); } if (optional_param('searchcourses', false, PARAM_BOOL)) { diff --git a/backup/util/xml/output/simpletest/testoutput.php b/backup/util/xml/output/simpletest/testoutput.php index a1d6bad675c..502bd9a3a03 100644 --- a/backup/util/xml/output/simpletest/testoutput.php +++ b/backup/util/xml/output/simpletest/testoutput.php @@ -219,7 +219,7 @@ class xml_output_test extends UnitTestCase { function test_file_xml_output() { global $CFG; - $file = $CFG->dataroot . '/temp/test/test_file_xml_output.txt'; + $file = $CFG->tempdir . '/test/test_file_xml_output.txt'; // Remove the test dir and any content @remove_dir(dirname($file)); // Recreate test dir @@ -232,7 +232,7 @@ class xml_output_test extends UnitTestCase { $this->assertTrue($xo instanceof xml_output); // Try to init file in (near) impossible path - $file = $CFG->dataroot . '/temp/test_azby/test_file_xml_output.txt'; + $file = $CFG->tempdir . '/test_azby/test_file_xml_output.txt'; $xo = new file_xml_output($file); try { $xo->start(); @@ -243,7 +243,7 @@ class xml_output_test extends UnitTestCase { } // Try to init file already existing - $file = $CFG->dataroot . '/temp/test/test_file_xml_output.txt'; + $file = $CFG->tempdir . '/test/test_file_xml_output.txt'; file_put_contents($file, 'createdtobedeleted'); // create file manually $xo = new file_xml_output($file); try { @@ -256,7 +256,7 @@ class xml_output_test extends UnitTestCase { unlink($file); // delete file // Send some output and check - $file = $CFG->dataroot . '/temp/test/test_file_xml_output.txt'; + $file = $CFG->tempdir . '/test/test_file_xml_output.txt'; $xo = new file_xml_output($file); $xo->start(); $xo->write('first text'); @@ -266,7 +266,7 @@ class xml_output_test extends UnitTestCase { // With buffer of 4 bytes, send 3 contents of 3 bytes each // so we force both buffering and last write on stop - $file = $CFG->dataroot . '/temp/test/test_file_xml_output.txt'; + $file = $CFG->tempdir . '/test/test_file_xml_output.txt'; $xo = new file_xml_output($file); $xo->set_buffersize(5); $xo->start(); @@ -278,7 +278,7 @@ class xml_output_test extends UnitTestCase { unlink($file); // delete file // Write some line feeds, tabs and friends - $file = $CFG->dataroot . '/temp/test/test_file_xml_output.txt'; + $file = $CFG->tempdir . '/test/test_file_xml_output.txt'; $string = "\n\r\tcrazy test\n\r\t"; $xo = new file_xml_output($file); $xo->start(); @@ -288,7 +288,7 @@ class xml_output_test extends UnitTestCase { unlink($file); // delete file // Write some UTF-8 chars - $file = $CFG->dataroot . '/temp/test/test_file_xml_output.txt'; + $file = $CFG->tempdir . '/test/test_file_xml_output.txt'; $string = 'áéíóú'; $xo = new file_xml_output($file); $xo->start(); diff --git a/blocks/community/communitycourse.php b/blocks/community/communitycourse.php index e99643965e1..74e4bcd68ff 100644 --- a/blocks/community/communitycourse.php +++ b/blocks/community/communitycourse.php @@ -88,7 +88,7 @@ $cancelrestore = optional_param('cancelrestore', false, PARAM_INT); if ($usercandownload and $cancelrestore and confirm_sesskey()) { $filename = optional_param('filename', '', PARAM_ALPHANUMEXT); //delete temp file - unlink($CFG->dataroot . '/temp/backup/' . $filename . ".mbz"); + unlink($CFG->tempdir . '/backup/' . $filename . ".mbz"); } /// Download diff --git a/blocks/community/locallib.php b/blocks/community/locallib.php index a2a0ce15ca4..f76088fc34c 100644 --- a/blocks/community/locallib.php +++ b/blocks/community/locallib.php @@ -86,12 +86,12 @@ class block_community_manager { $params['courseid'] = $course->id; $params['filetype'] = HUB_BACKUP_FILE_TYPE; - make_upload_directory('temp/backup'); + make_temp_directory('backup'); $filename = md5(time() . '-' . $course->id . '-'. $USER->id . '-'. random_string(20)); $url = new moodle_url($course->huburl.'/local/hub/webservice/download.php', $params); - $path = $CFG->dataroot.'/temp/backup/'.$filename.".mbz"; + $path = $CFG->tempdir.'/backup/'.$filename.".mbz"; $fp = fopen($path, 'w'); $curlurl = $course->huburl.'/local/hub/webservice/download.php?filetype=' .HUB_BACKUP_FILE_TYPE.'&courseid='.$course->id; @@ -122,7 +122,7 @@ class block_community_manager { if (!$fs->file_exists($record->contextid, $record->component, $record->filearea, 0, $record->filepath, $record->filename)) { $fs->create_file_from_pathname($record, - $CFG->dataroot.'/temp/backup/'.$filename.".mbz"); + $CFG->tempdir.'/backup/'.$filename.".mbz"); } $filenames = array(); diff --git a/blog/rsslib.php b/blog/rsslib.php index 3fea97f3bfc..4cc9a8070c0 100644 --- a/blog/rsslib.php +++ b/blog/rsslib.php @@ -223,9 +223,9 @@ function blog_rss_file_name($type, $id, $tagid=0) { global $CFG; if ($tagid) { - return "$CFG->dataroot/cache/rss/blog/$type/$id/$tagid.xml"; + return "$CFG->cachedir/rss/blog/$type/$id/$tagid.xml"; } else { - return "$CFG->dataroot/cache/rss/blog/$type/$id.xml"; + return "$CFG->cachedir/rss/blog/$type/$id.xml"; } } @@ -236,8 +236,8 @@ function blog_rss_save_file($type, $id, $tagid=0, $contents='') { $status = true; //blog creates some additional dirs within the rss cache so make sure they all exist - make_upload_directory('cache/rss/blog'); - make_upload_directory('cache/rss/blog/'.$type); + make_cache_directory('rss/blog'); + make_cache_directory('rss/blog/'.$type); $filename = blog_rss_file_name($type, $id, $tagid); $expandfilename = false; //we're supplying a full file path diff --git a/config-dist.php b/config-dist.php index 4ca2b728e02..6a5f7fc1b0d 100644 --- a/config-dist.php +++ b/config-dist.php @@ -347,10 +347,16 @@ $CFG->admin = 'admin'; // // $CFG->themedir = '/location/of/extra/themes'; // +// It is possible to specify different cache and temp directories, use local fast filesystem. +// The directories must not be accessible via web. +// +// $CFG->tempdir = '/var/www/moodle/temp'; +// $CFG->cachedir = '/var/www/moodle/cache'; +// // If $CFG->langstringcache is enabled (which should always be in production // environment), Moodle keeps aggregated strings in its own internal format // optimised for performance. By default, this on-disk cache is created in -// $CFG->dataroot/cache/lang. In cluster environment, you may wish to specify +// $CFG->cachedir/lang. In cluster environment, you may wish to specify // an alternative location of this cache so that each web server in the cluster // uses its own local cache and does not need to access the shared dataroot. // Make sure that the web server process has write permission to this location diff --git a/enrol/authorize/uploadcsv.php b/enrol/authorize/uploadcsv.php index 8e0fbec5954..697d3549e4d 100644 --- a/enrol/authorize/uploadcsv.php +++ b/enrol/authorize/uploadcsv.php @@ -54,8 +54,8 @@ echo $OUTPUT->heading($struploadcsv); if (!$form->get_data()) { $form->display(); } else { - $filename = $CFG->dataroot . '/temp/enrolauthorize/importedfile_'.time().'.csv'; - make_upload_directory('temp/enrolauthorize'); + $filename = $CFG->tempdir . '/enrolauthorize/importedfile_'.time().'.csv'; + make_temp_directory('enrolauthorize'); // Fix mac/dos newlines $text = $form->get_file_content('csvfile'); $text = preg_replace('!\r\n?!', "\n", $text); diff --git a/files/externallib.php b/files/externallib.php index dc351b6e93a..85b90987777 100644 --- a/files/externallib.php +++ b/files/externallib.php @@ -207,7 +207,7 @@ class moodle_file_external extends external_api { throw new moodle_exception('nofile'); } // saving file - $dir = make_upload_directory('temp/wsupload'); + $dir = make_temp_directory('wsupload'); if (empty($fileinfo['filename'])) { $filename = uniqid('wsupload', true).'_'.time().'.tmp'; diff --git a/filter/tex/latex.php b/filter/tex/latex.php index 47c7c3bd364..2f84bc220cc 100644 --- a/filter/tex/latex.php +++ b/filter/tex/latex.php @@ -19,8 +19,8 @@ global $CFG; // construct directory structure - $this->temp_dir = $CFG->dataroot . "/temp/latex"; - make_upload_directory('temp/latex'); + $this->temp_dir = $CFG->tempdir . "/latex"; + make_temp_directory('latex'); } /** diff --git a/filter/tex/lib.php b/filter/tex/lib.php index 5f569228a8e..c6b5989fb93 100644 --- a/filter/tex/lib.php +++ b/filter/tex/lib.php @@ -104,8 +104,8 @@ function filter_tex_updatedcallback($name) { if (file_exists("$CFG->dataroot/filter/algebra")) { remove_dir("$CFG->dataroot/filter/algebra"); } - if (file_exists("$CFG->dataroot/temp/latex")) { - remove_dir("$CFG->dataroot/temp/latex"); + if (file_exists("$CFG->tempdir/latex")) { + remove_dir("$CFG->tempdir/latex"); } $DB->delete_records('cache_filters', array('filter'=>'tex')); diff --git a/grade/edit/outcome/import.php b/grade/edit/outcome/import.php index f0bc6461d76..6e6286746ca 100644 --- a/grade/edit/outcome/import.php +++ b/grade/edit/outcome/import.php @@ -60,8 +60,8 @@ if (!$upload_form->get_data()) { } print_grade_page_head($courseid, 'outcome', 'import', get_string('importoutcomes', 'grades')); -$imported_file = $CFG->dataroot . '/temp/outcomeimport/importedfile_'.time().'.csv'; -make_upload_directory('temp/outcomeimport'); +$imported_file = $CFG->tempdir . '/outcomeimport/importedfile_'.time().'.csv'; +make_temp_directory('outcomeimport'); // copying imported file if (!$upload_form->save_file('userfile', $imported_file, true)) { diff --git a/grade/export/xml/grade_export_xml.php b/grade/export/xml/grade_export_xml.php index a978b0dbe20..38cb353574a 100644 --- a/grade/export/xml/grade_export_xml.php +++ b/grade/export/xml/grade_export_xml.php @@ -40,8 +40,8 @@ class grade_export_xml extends grade_export { /// Calculate file name $downloadfilename = clean_filename("{$this->course->shortname} $strgrades.xml"); - make_upload_directory('temp/gradeexport'); - $tempfilename = $CFG->dataroot .'/temp/gradeexport/'. md5(sesskey().microtime().$downloadfilename); + make_temp_directory('gradeexport'); + $tempfilename = $CFG->tempdir .'/gradeexport/'. md5(sesskey().microtime().$downloadfilename); if (!$handle = fopen($tempfilename, 'w+b')) { print_error('cannotcreatetempdir'); } diff --git a/grade/import/csv/index.php b/grade/import/csv/index.php index 04844b05b12..886bf4303d0 100644 --- a/grade/import/csv/index.php +++ b/grade/import/csv/index.php @@ -91,7 +91,7 @@ if ($id) { } if ($importcode = optional_param('importcode', '', PARAM_FILE)) { - $filename = $CFG->dataroot.'/temp/gradeimport/cvs/'.$USER->id.'/'.$importcode; + $filename = $CFG->tempdir.'/gradeimport/cvs/'.$USER->id.'/'.$importcode; $fp = fopen($filename, "r"); $headers = fgets($fp, GRADE_CSV_LINE_LENGTH); $header = explode($csv_delimiter, $headers); @@ -111,7 +111,7 @@ if ($formdata = $mform->get_data()) { // use current (non-conflicting) time stamp $importcode = get_new_importcode(); - $filename = make_upload_directory('temp/gradeimport/cvs/'.$USER->id); + $filename = make_temp_directory('gradeimport/cvs/'.$USER->id); $filename = $filename.'/'.$importcode; $text = $mform->get_file_content('userfile'); @@ -164,7 +164,7 @@ if ($formdata = $mform->get_data()) { } else if ($formdata = $mform2->get_data()) { $importcode = clean_param($formdata->importcode, PARAM_FILE); - $filename = $CFG->dataroot.'/temp/gradeimport/cvs/'.$USER->id.'/'.$importcode; + $filename = $CFG->tempdir.'/gradeimport/cvs/'.$USER->id.'/'.$importcode; if (!file_exists($filename)) { print_error('cannotuploadfile'); diff --git a/lib/componentlib.class.php b/lib/componentlib.class.php index 0042cdb0188..0bb7c713c87 100644 --- a/lib/componentlib.class.php +++ b/lib/componentlib.class.php @@ -281,13 +281,13 @@ class component_installer { return COMPONENT_UPTODATE; } /// Create temp directory if necesary - if (!make_upload_directory('temp', false)) { + if (!make_temp_directory('', false)) { $this->errorstring='cannotcreatetempdir'; return COMPONENT_ERROR; } /// Download zip file and save it to temp $source = $this->sourcebase.'/'.$this->zippath.'/'.$this->zipfilename; - $zipfile= $CFG->dataroot.'/temp/'.$this->zipfilename; + $zipfile= $CFG->tempdir.'/'.$this->zipfilename; if($contents = download_file_content($source)) { if ($file = fopen($zipfile, 'w')) { diff --git a/lib/csvlib.class.php b/lib/csvlib.class.php index 9cf39db8338..2eb9df30bf6 100644 --- a/lib/csvlib.class.php +++ b/lib/csvlib.class.php @@ -121,7 +121,7 @@ class csv_import_reader { $this->_columns = $columns; // cached columns // open file for writing - $filename = $CFG->dataroot.'/temp/csvimport/'.$this->_type.'/'.$USER->id.'/'.$this->_iid; + $filename = $CFG->tempdir.'/csvimport/'.$this->_type.'/'.$USER->id.'/'.$this->_iid; $fp = fopen($filename, "w"); fwrite($fp, serialize($columns)."\n"); @@ -161,7 +161,7 @@ class csv_import_reader { global $USER, $CFG; - $filename = $CFG->dataroot.'/temp/csvimport/'.$this->_type.'/'.$USER->id.'/'.$this->_iid; + $filename = $CFG->tempdir.'/csvimport/'.$this->_type.'/'.$USER->id.'/'.$this->_iid; if (!file_exists($filename)) { return false; } @@ -188,7 +188,7 @@ class csv_import_reader { if (!empty($this->_fp)) { $this->close(); } - $filename = $CFG->dataroot.'/temp/csvimport/'.$this->_type.'/'.$USER->id.'/'.$this->_iid; + $filename = $CFG->tempdir.'/csvimport/'.$this->_type.'/'.$USER->id.'/'.$this->_iid; if (!file_exists($filename)) { return false; } @@ -247,9 +247,9 @@ class csv_import_reader { global $USER, $CFG; if ($full) { - @remove_dir($CFG->dataroot.'/temp/csvimport/'.$this->_type.'/'.$USER->id); + @remove_dir($CFG->tempdir.'/csvimport/'.$this->_type.'/'.$USER->id); } else { - @unlink($CFG->dataroot.'/temp/csvimport/'.$this->_type.'/'.$USER->id.'/'.$this->_iid); + @unlink($CFG->tempdir.'/csvimport/'.$this->_type.'/'.$USER->id.'/'.$this->_iid); } } @@ -310,7 +310,7 @@ class csv_import_reader { function get_new_iid($type) { global $USER; - $filename = make_upload_directory('temp/csvimport/'.$type.'/'.$USER->id); + $filename = make_temp_directory('csvimport/'.$type.'/'.$USER->id); // use current (non-conflicting) time stamp $iiid = time(); diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index 83c897f1367..c48ec98e23a 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -124,7 +124,7 @@ function xmldb_main_upgrade($oldversion) { } if ($oldversion < 2008030602) { - @unlink($CFG->dataroot.'/cache/languages'); + @unlink($CFG->cachedir.'/languages'); if (file_exists("$CFG->dataroot/lang")) { // rename old lang directory so that the new and old langs do not mix diff --git a/lib/excellib.class.php b/lib/excellib.class.php index def025c74ab..8b1262daa35 100644 --- a/lib/excellib.class.php +++ b/lib/excellib.class.php @@ -64,8 +64,8 @@ class MoodleExcelWorkbook { $this->latin_output = true; } /// Choose our temporary directory - see MDL-7176, found by paulo.matos - make_upload_directory('temp/excel'); - $this->pear_excel_workbook->setTempDir($CFG->dataroot.'/temp/excel'); + make_temp_directory('excel'); + $this->pear_excel_workbook->setTempDir($CFG->tempdir.'/excel'); } /** diff --git a/lib/filelib.php b/lib/filelib.php index 4f7ec4d93c6..02c350150c2 100644 --- a/lib/filelib.php +++ b/lib/filelib.php @@ -2176,7 +2176,7 @@ function put_records_csv($file, $records, $table = NULL) { echo "x"; - if(!($fp = @fopen($CFG->dataroot.'/temp/'.$file, 'w'))) { + if(!($fp = @fopen($CFG->tempdir.'/'.$file, 'w'))) { print_error('put_records_csv failed to open '.$file); } @@ -2935,9 +2935,9 @@ class curl_cache { function __construct($module = 'repository'){ global $CFG; if (!empty($module)) { - $this->dir = $CFG->dataroot.'/cache/'.$module.'/'; + $this->dir = $CFG->cachedir.'/'.$module.'/'; } else { - $this->dir = $CFG->dataroot.'/cache/misc/'; + $this->dir = $CFG->cachedir.'/misc/'; } if (!file_exists($this->dir)) { mkdir($this->dir, $CFG->directorypermissions, true); diff --git a/lib/filestorage/zip_packer.php b/lib/filestorage/zip_packer.php index 4eb67c0b14a..a593d06f420 100644 --- a/lib/filestorage/zip_packer.php +++ b/lib/filestorage/zip_packer.php @@ -57,8 +57,8 @@ class zip_packer extends file_packer { $fs = get_file_storage(); - check_dir_exists($CFG->dataroot.'/temp/zip'); - $tmpfile = tempnam($CFG->dataroot.'/temp/zip', 'zipstor'); + check_dir_exists($CFG->tempdir.'/zip'); + $tmpfile = tempnam($CFG->tempdir.'/zip', 'zipstor'); if ($result = $this->archive_to_pathname($files, $tmpfile)) { if ($file = $fs->get_file($contextid, $component, $filearea, $itemid, $filepath, $filename)) { @@ -282,7 +282,7 @@ class zip_packer extends file_packer { return $archivefile->extract_to_pathname($this, $contextid, $component, $filearea, $itemid, $pathbase, $userid); } - check_dir_exists($CFG->dataroot.'/temp/zip'); + check_dir_exists($CFG->tempdir.'/zip'); $pathbase = trim($pathbase, '/'); $pathbase = ($pathbase === '') ? '/' : '/'.$pathbase.'/'; @@ -360,7 +360,7 @@ class zip_packer extends file_packer { } else { // large file, would not fit into memory :-( - $tmpfile = tempnam($CFG->dataroot.'/temp/zip', 'unzip'); + $tmpfile = tempnam($CFG->tempdir.'/zip', 'unzip'); if (!$fp = fopen($tmpfile, 'wb')) { @unlink($tmpfile); $processed[$name] = 'Can not write temp file'; // TODO: localise diff --git a/lib/formslib.php b/lib/formslib.php index aadc8a04b1c..d579b8773d0 100644 --- a/lib/formslib.php +++ b/lib/formslib.php @@ -652,7 +652,7 @@ abstract class moodleform { if (!$this->get_new_filename($elname)) { return false; } - if (!$dir = make_upload_directory('temp/forms')) { + if (!$dir = make_temp_directory('forms')) { return false; } if (!$tempfile = tempnam($dir, 'tempup_')) { diff --git a/lib/javascript.php b/lib/javascript.php index 9e19def5719..02ab49a7f87 100644 --- a/lib/javascript.php +++ b/lib/javascript.php @@ -67,7 +67,7 @@ minify($jsfiles); function minify($files) { global $CFG; - $cachedir = $CFG->dataroot.'/cache/js'; + $cachedir = $CFG->cachedir.'/js'; // make sure the cache dir exist if (!file_exists($cachedir)) { @mkdir($cachedir, $CFG->directorypermissions, true); diff --git a/lib/minify/config.php b/lib/minify/config.php index 4ea33d1a331..7e29c0b26e7 100644 --- a/lib/minify/config.php +++ b/lib/minify/config.php @@ -40,7 +40,7 @@ $min_enableBuilder = false; * For best performance, specify your temp directory here. Otherwise Minify * will have to load extra code to guess. Some examples below: */ -$min_cachePath = $CFG->dataroot.'/temp'; +$min_cachePath = $CFG->tempdir.''; /** diff --git a/lib/moodlelib.php b/lib/moodlelib.php index bfb8855e163..2a512553c75 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -1370,14 +1370,14 @@ function purge_all_caches() { get_string_manager()->reset_caches(); // purge all other caches: rss, simplepie, etc. - remove_dir($CFG->dataroot.'/cache', true); + remove_dir($CFG->cachedir.'', true); // make sure cache dir is writable, throws exception if not - make_upload_directory('cache'); + make_cache_directory(''); // hack: this script may get called after the purifier was initialised, // but we do not want to verify repeatedly this exists in each call - make_upload_directory('cache/htmlpurifier'); + make_cache_directory('htmlpurifier'); clearstatcache(); } @@ -5263,7 +5263,7 @@ function get_file_storage() { $trashdirdir = $CFG->dataroot.'/trashdir'; } - $fs = new file_storage($filedir, $trashdirdir, "$CFG->dataroot/temp/filestorage", $CFG->directorypermissions, $CFG->filepermissions); + $fs = new file_storage($filedir, $trashdirdir, "$CFG->tempdir/filestorage", $CFG->directorypermissions, $CFG->filepermissions); return $fs; } @@ -5685,7 +5685,7 @@ function get_string_manager($forcereload=false) { if (empty($CFG->early_install_lang)) { if (empty($CFG->langcacheroot)) { - $langcacheroot = $CFG->dataroot . '/cache/lang'; + $langcacheroot = $CFG->cachedir . '/lang'; } else { $langcacheroot = $CFG->langcacheroot; } @@ -5697,7 +5697,7 @@ function get_string_manager($forcereload=false) { } if (empty($CFG->langmenucachefile)) { - $langmenucache = $CFG->dataroot . '/cache/languages'; + $langmenucache = $CFG->cachedir . '/languages'; } else { $langmenucache = $CFG->langmenucachefile; } diff --git a/lib/odslib.class.php b/lib/odslib.class.php index db2837f2f92..be1a5d9d6e2 100644 --- a/lib/odslib.class.php +++ b/lib/odslib.class.php @@ -74,10 +74,10 @@ class MoodleODSWorkbook { global $CFG; require_once($CFG->libdir.'/filelib.php'); - $dir = 'temp/ods/'.time(); - make_upload_directory($dir); - make_upload_directory($dir.'/META-INF'); - $dir = "$CFG->dataroot/$dir"; + $dir = 'ods/'.time(); + make_temp_directory($dir); + make_temp_directory($dir.'/META-INF'); + $dir = "$CFG->tempdir/$dir"; $files = array(); $handle = fopen("$dir/mimetype", 'w'); diff --git a/lib/outputlib.php b/lib/outputlib.php index 8712d5ac903..8feae4c83d5 100644 --- a/lib/outputlib.php +++ b/lib/outputlib.php @@ -44,7 +44,7 @@ function theme_reset_all_caches() { require_once("$CFG->libdir/filelib.php"); set_config('themerev', empty($CFG->themerev) ? 1 : $CFG->themerev+1); - fulldelete("$CFG->dataroot/cache/theme"); + fulldelete("$CFG->cachedir/theme"); } /** @@ -613,7 +613,7 @@ class theme_config { if (!defined('THEME_DESIGNER_CACHE_LIFETIME')) { define('THEME_DESIGNER_CACHE_LIFETIME', 4); // this can be also set in config.php } - $candidatesheet = "$CFG->dataroot/cache/theme/$this->name/designer.ser"; + $candidatesheet = "$CFG->cachedir/theme/$this->name/designer.ser"; if (!file_exists($candidatesheet)) { $css = $this->css_content(); check_dir_exists(dirname($candidatesheet)); diff --git a/lib/outputrequirementslib.php b/lib/outputrequirementslib.php index fb8decbed48..5d9038428e8 100644 --- a/lib/outputrequirementslib.php +++ b/lib/outputrequirementslib.php @@ -1213,6 +1213,6 @@ function js_reset_all_caches() { require_once("$CFG->libdir/filelib.php"); set_config('jsrev', empty($CFG->jsrev) ? 1 : $CFG->jsrev+1); - fulldelete("$CFG->dataroot/cache/js"); + fulldelete("$CFG->cachedir/js"); } diff --git a/lib/pdflib.php b/lib/pdflib.php index 9c036aa386c..7444bc61a81 100644 --- a/lib/pdflib.php +++ b/lib/pdflib.php @@ -67,7 +67,7 @@ define('K_PATH_URL', $CFG->wwwroot . '/lib/tcpdf/'); define('K_PATH_FONTS', K_PATH_MAIN . 'fonts/'); /** cache directory for temporary files (full path) */ -define('K_PATH_CACHE', $CFG->dataroot . '/cache/'); +define('K_PATH_CACHE', $CFG->cachedir . '/'); /** images directory */ define('K_PATH_IMAGES', $CFG->dirroot . '/'); diff --git a/lib/profilerlib.php b/lib/profilerlib.php index dcded905caf..a33cd1226ab 100644 --- a/lib/profilerlib.php +++ b/lib/profilerlib.php @@ -64,7 +64,7 @@ class Profiler { global $CFG, $USER; // List all files under our temporary directory - $tempdir = $CFG->dataroot . '/temp/profile/' . $USER->id; + $tempdir = $CFG->tempdir . '/profile/' . $USER->id; if ($files = scandir($tempdir)) { // Concatenate the files print_r($files); diff --git a/lib/rsslib.php b/lib/rsslib.php index 15dd6eb2832..36973a5a4da 100644 --- a/lib/rsslib.php +++ b/lib/rsslib.php @@ -92,7 +92,7 @@ function rss_print_link($contextid, $userid, $componentname, $id, $tooltiptext=' function rss_delete_file($componentname, $instance) { global $CFG; - $dirpath = "$CFG->dataroot/cache/rss/$componentname"; + $dirpath = "$CFG->cachedir/rss/$componentname"; if (is_dir($dirpath)) { $dh = opendir($dirpath); while (false !== ($filename = readdir($dh))) { @@ -145,7 +145,7 @@ function rss_save_file($componentname, $filename, $contents, $expandfilename=tru $status = true; - if (! $basedir = make_upload_directory ('cache/rss/'. $componentname)) { + if (! $basedir = make_cache_directory ('rss/'. $componentname)) { //Cannot be created, so error $status = false; } @@ -170,7 +170,7 @@ function rss_save_file($componentname, $filename, $contents, $expandfilename=tru function rss_get_file_full_name($componentname, $filename) { global $CFG; - return "$CFG->dataroot/cache/rss/$componentname/$filename.xml"; + return "$CFG->cachedir/rss/$componentname/$filename.xml"; } function rss_get_file_name($instance, $sql) { diff --git a/lib/setup.php b/lib/setup.php index de4ebddbd55..d2d3bfcffb9 100644 --- a/lib/setup.php +++ b/lib/setup.php @@ -36,6 +36,8 @@ * - $CFG->dataroot - Path to moodle data files directory on server's filesystem. * - $CFG->dirroot - Path to moodle's library folder on server's filesystem. * - $CFG->libdir - Path to moodle's library folder on server's filesystem. + * - $CFG->tempdir - Path to moodle's temp file directory on server's filesystem. + * - $CFG->cachedir - Path to moodle's cache directory on server's filesystem. * * @global object $CFG * @name $CFG @@ -96,6 +98,16 @@ if (!isset($CFG->admin)) { // Just in case it isn't defined in config.php // Set up some paths. $CFG->libdir = $CFG->dirroot .'/lib'; +// Allow overriding of tempdir but be backwards compatible +if (!isset($CFG->tempdir)) { + $CFG->tempdir = "$CFG->dataroot/temp"; +} + +// Allow overriding of cachedir but be backwards compatible +if (!isset($CFG->cachedir)) { + $CFG->cachedir = "$CFG->dataroot/cache"; +} + // The current directory in PHP version 4.3.0 and above isn't necessarily the // directory of the script when run from the command line. The require_once() // would fail, so we'll have to chdir() diff --git a/lib/setuplib.php b/lib/setuplib.php index d0bce1fb5c9..f45221b8b54 100644 --- a/lib/setuplib.php +++ b/lib/setuplib.php @@ -860,7 +860,7 @@ function init_performance_info() { if (function_exists('apd_set_pprof_trace')) { // APD profiling if ($USER->id > 0 && $CFG->perfdebug >= 15) { - $tempdir = $CFG->dataroot . '/temp/profile/' . $USER->id; + $tempdir = $CFG->tempdir . '/profile/' . $USER->id; mkdir($tempdir); apd_set_pprof_trace($tempdir); $PERF->profiling = true; @@ -1105,25 +1105,16 @@ function check_dir_exists($dir, $create = true, $recursive = true) { } /** - * Create a directory in dataroot and make sure it is writable. + * Create a directory and make sure it is writable. * - * @param string $directory a string of directory names under $CFG->dataroot eg temp/something + * @private + * @param string $dir the full path of the directory to be created * @param bool $exceptiononerror throw exception if error encountered * @return string|false Returns full path to directory if successful, false if not; may throw exception */ -function make_upload_directory($directory, $exceptiononerror = true) { +function make_writable_directory($dir, $exceptiononerror = true) { global $CFG; - // Make sure a .htaccess file is here, JUST IN CASE the files area is in the open and .htaccess is supported - if (!file_exists("$CFG->dataroot/.htaccess")) { - if ($handle = fopen("$CFG->dataroot/.htaccess", 'w')) { // For safety - @fwrite($handle, "deny from all\r\nAllowOverride None\r\nNote: this file is broken intentionally, we do not want anybody to undo it in subdirectory!\r\n"); - @fclose($handle); - } - } - - $dir = "$CFG->dataroot/$directory"; - if (file_exists($dir) and !is_dir($dir)) { if ($exceptiononerror) { throw new coding_exception($dir.' directory can not be created, file with the same name already exists.'); @@ -1155,6 +1146,73 @@ function make_upload_directory($directory, $exceptiononerror = true) { return $dir; } +/** + * Protect a directory from web access. + * Could be extended in the future to support other mechanisms (e.g. other webservers). + * + * @private + * @param string $dir the full path of the directory to be protected + */ +function protect_directory($dir) { + // Make sure a .htaccess file is here, JUST IN CASE the files area is in the open and .htaccess is supported + if (!file_exists("$dir/.htaccess")) { + if ($handle = fopen("$dir/.htaccess", 'w')) { // For safety + @fwrite($handle, "deny from all\r\nAllowOverride None\r\nNote: this file is broken intentionally, we do not want anybody to undo it in subdirectory!\r\n"); + @fclose($handle); + } + } +} + +/** + * Create a directory under dataroot and make sure it is writable. + * Do not use for temporary and cache files - see make_temp_directory() and make_cache_directory(). + * + * @param string $directory the full path of the directory to be created under $CFG->dataroot + * @param bool $exceptiononerror throw exception if error encountered + * @return string|false Returns full path to directory if successful, false if not; may throw exception + */ +function make_upload_directory($directory, $exceptiononerror = true) { + global $CFG; + + if (strpos($directory, 'temp/') === 0 or $directory === 'temp') { + debugging('Use make_temp_directory() for creation of temporary directory and $CFG->tempdir to get the location.'); + + } else if (strpos($directory, 'cache/') === 0 or $directory === 'cache') { + debugging('Use make_cache_directory() for creation of chache directory and $CFG->cachedir to get the location.'); + } + + protect_directory($CFG->dataroot); + return make_writable_directory("$CFG->dataroot/$directory", $exceptiononerror); +} + +/** + * Create a directory under tempdir and make sure it is writable. + * Temporary files should be used during the current request only! + * + * @param string $directory the full path of the directory to be created under $CFG->tempdir + * @param bool $exceptiononerror throw exception if error encountered + * @return string|false Returns full path to directory if successful, false if not; may throw exception + */ +function make_temp_directory($directory, $exceptiononerror = true) { + global $CFG; + protect_directory($CFG->tempdir); + return make_writable_directory("$CFG->tempdir/$directory", $exceptiononerror); +} + +/** + * Create a directory under cachedir and make sure it is writable. + * + * @param string $directory the full path of the directory to be created under $CFG->cachedir + * @param bool $exceptiononerror throw exception if error encountered + * @return string|false Returns full path to directory if successful, false if not; may throw exception + */ +function make_cache_directory($directory, $exceptiononerror = true) { + global $CFG; + protect_directory($CFG->cachedir); + return make_writable_directory("$CFG->cachedir/$directory", $exceptiononerror); +} + + function init_memcached() { global $CFG, $MCACHE; diff --git a/lib/simplepie/moodle_simplepie.php b/lib/simplepie/moodle_simplepie.php index c6e1f6dafca..54e2d07ee3f 100644 --- a/lib/simplepie/moodle_simplepie.php +++ b/lib/simplepie/moodle_simplepie.php @@ -88,7 +88,7 @@ class moodle_simplepie extends SimplePie private static function get_cache_directory() { global $CFG; - return $CFG->dataroot.'/cache/simplepie/'; + return $CFG->cachedir.'/simplepie/'; } /** diff --git a/lib/simpletest/broken_testfiltermanager.php b/lib/simpletest/broken_testfiltermanager.php index c68129bddc3..596512fcbda 100644 --- a/lib/simpletest/broken_testfiltermanager.php +++ b/lib/simpletest/broken_testfiltermanager.php @@ -65,7 +65,7 @@ class filter_manager_test extends UnitTestCase { global $CFG; $this->filtermanager = new testable_filter_manager(); $this->olddirroot = $CFG->dirroot; - $CFG->dirroot = $CFG->dataroot . '/temp'; + $CFG->dirroot = $CFG->tempdir . ''; } public function tearDown() { diff --git a/lib/textlib.class.php b/lib/textlib.class.php index a488b8c339f..558be5c5282 100644 --- a/lib/textlib.class.php +++ b/lib/textlib.class.php @@ -83,7 +83,7 @@ class textlib { // And this directory must exist to allow Typo to cache conversion // tables when using internal functions - make_upload_directory('temp/typo3temp/cs'); + make_temp_directory('typo3temp/cs'); // Make sure typo is using our dir permissions $GLOBALS['TYPO3_CONF_VARS']['BE']['folderCreateMask'] = decoct($CFG->directorypermissions); @@ -95,7 +95,7 @@ class textlib { // to forward slashed because Typo3 requires it. define ('PATH_t3lib', str_replace('\\','/',$CFG->libdir.'/typo3/')); define ('PATH_typo3', str_replace('\\','/',$CFG->libdir.'/typo3/')); - define ('PATH_site', str_replace('\\','/',$CFG->dataroot.'/temp/')); + define ('PATH_site', str_replace('\\','/',$CFG->tempdir.'/')); define ('TYPO3_OS', stristr(PHP_OS,'win')&&!stristr(PHP_OS,'darwin')?'WIN':''); $typo3cs = new t3lib_cs(); diff --git a/lib/upgradelib.php b/lib/upgradelib.php index 6a93f6e57ec..1d99efa60b1 100644 --- a/lib/upgradelib.php +++ b/lib/upgradelib.php @@ -1319,7 +1319,7 @@ function upgrade_language_pack($lang='') { upgrade_started(false); echo $OUTPUT->heading(get_string('langimport', 'admin').': '.$lang); - @mkdir ($CFG->dataroot.'/temp/'); //make it in case it's a fresh install, it might not be there + @mkdir ($CFG->tempdir.'/'); //make it in case it's a fresh install, it might not be there @mkdir ($CFG->dataroot.'/lang/'); require_once($CFG->libdir.'/componentlib.class.php'); diff --git a/lib/weblib.php b/lib/weblib.php index d314ef249a1..fb51289efee 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -1187,7 +1187,7 @@ function reset_text_filters_cache() { global $CFG, $DB; $DB->delete_records('cache_text'); - $purifdir = $CFG->dataroot.'/cache/htmlpurifier'; + $purifdir = $CFG->cachedir.'/htmlpurifier'; remove_dir($purifdir, true); } @@ -1514,7 +1514,7 @@ function purify_html($text, $options = array()) { if (empty($purifiers[$type])) { // make sure the serializer dir exists, it should be fine if it disappears later during cache reset - $cachedir = $CFG->dataroot.'/cache/htmlpurifier'; + $cachedir = $CFG->cachedir.'/htmlpurifier'; check_dir_exists($cachedir); require_once $CFG->libdir.'/htmlpurifier/HTMLPurifier.safe-includes.php'; diff --git a/mod/assignment/lib.php b/mod/assignment/lib.php index 2f18113c32d..2ee9aa1bd52 100644 --- a/mod/assignment/lib.php +++ b/mod/assignment/lib.php @@ -3723,7 +3723,7 @@ function assignment_extend_settings_navigation(settings_navigation $settings, na function assignment_pack_files($filesforzipping) { global $CFG; //create path for new zip file. - $tempzip = tempnam($CFG->dataroot.'/temp/', 'assignment_'); + $tempzip = tempnam($CFG->tempdir.'/', 'assignment_'); //zip files $zipper = new zip_packer(); if ($zipper->archive_to_pathname($filesforzipping, $tempzip)) { diff --git a/mod/data/lib.php b/mod/data/lib.php index 3794952bb71..2bee85bf059 100644 --- a/mod/data/lib.php +++ b/mod/data/lib.php @@ -2463,7 +2463,7 @@ function data_preset_path($course, $userid, $shortname) { } else if ($userid == 0) { $path = $CFG->dirroot.'/mod/data/preset/'.$shortname; } else if ($userid < 0) { - $path = $CFG->dataroot.'/temp/data/'.-$userid.'/'.$shortname; + $path = $CFG->tempdir.'/data/'.-$userid.'/'.$shortname; } return $path; @@ -3142,8 +3142,8 @@ function data_presets_export($course, $cm, $data, $tostorage=false) { global $CFG, $DB; $presetname = clean_filename($data->name) . '-preset-' . gmdate("Ymd_Hi"); - $exportsubdir = "temp/mod_data/presetexport/$presetname"; - make_upload_directory($exportsubdir); + $exportsubdir = "mod_data/presetexport/$presetname"; + make_temp_directory($exportsubdir); $exportdir = "$CFG->dataroot/$exportsubdir"; // Assemble "preset.xml": diff --git a/mod/data/preset.php b/mod/data/preset.php index 34273cf0b95..7f1a21317eb 100644 --- a/mod/data/preset.php +++ b/mod/data/preset.php @@ -190,7 +190,7 @@ if (optional_param('sesskey', false, PARAM_BOOL) && confirm_sesskey()) { } else if ($action == 'finishimport') { $overwritesettings = optional_param('overwritesettings', false, PARAM_BOOL); if (!$fullname) { - $presetdir = $CFG->dataroot.'/temp/forms/'.required_param('directory', PARAM_ALPHANUMEXT); + $presetdir = $CFG->tempdir.'/forms/'.required_param('directory', PARAM_ALPHANUMEXT); if (!file_exists($presetdir) || !is_dir($presetdir)) { print_error('cannotimport'); } diff --git a/mod/feedback/analysis_to_excel.php b/mod/feedback/analysis_to_excel.php index 33920e588ec..389c5fa1262 100644 --- a/mod/feedback/analysis_to_excel.php +++ b/mod/feedback/analysis_to_excel.php @@ -79,7 +79,7 @@ $mygroupid = groups_get_activity_group($cm); // Creating a workbook // $workbook = new EasyWorkbook("-"); $workbook = new MoodleExcelWorkbook('-'); -// $workbook->setTempDir($CFG->dataroot.'/temp'); +// $workbook->setTempDir($CFG->tempdir.''); $workbook->send($filename); // $workbook->setVersion(8); diff --git a/mod/lesson/import.php b/mod/lesson/import.php index 0b00e20a2d1..f9cb68ef170 100644 --- a/mod/lesson/import.php +++ b/mod/lesson/import.php @@ -68,8 +68,8 @@ if ($data = $mform->get_data()) { $realfilename = $mform->get_new_filename('questionfile'); //TODO: Leave all imported questions in Questionimport for now. - $importfile = "{$CFG->dataroot}/temp/questionimport/{$realfilename}"; - make_upload_directory('temp/questionimport'); + $importfile = "{$CFG->tempdir}/questionimport/{$realfilename}"; + make_temp_directory('questionimport'); if (!$result = $mform->save_file('questionfile', $importfile, true)) { throw new moodle_exception('uploadproblem'); } diff --git a/mod/scorm/lib.php b/mod/scorm/lib.php index f61820ed9e3..16fcb32f95f 100644 --- a/mod/scorm/lib.php +++ b/mod/scorm/lib.php @@ -976,7 +976,7 @@ function scorm_extend_navigation($navigation, $course, $module, $cm) { function scorm_debug_log_filename($type, $scoid) { global $CFG, $USER; - $logpath = $CFG->dataroot.'/temp/scormlogs'; + $logpath = $CFG->tempdir.'/scormlogs'; $logfile = $logpath.'/'.$type.'debug_'.$USER->id.'_'.$scoid.'.log'; return $logfile; } @@ -994,7 +994,7 @@ function scorm_debug_log_write($type, $text, $scoid) { if (!$debugenablelog || empty($text)) { return; } - if (make_upload_directory('temp/scormlogs/')) { + if (make_temp_directory('scormlogs/')) { $logfile = scorm_debug_log_filename($type, $scoid); @file_put_contents($logfile, date('Y/m/d H:i:s O')." DEBUG $text\r\n", FILE_APPEND); } diff --git a/mod/scorm/mod_form.php b/mod/scorm/mod_form.php index dc2dcabd48c..98dda8b3880 100644 --- a/mod/scorm/mod_form.php +++ b/mod/scorm/mod_form.php @@ -328,8 +328,8 @@ class mod_scorm_mod_form extends moodleform_mod { return $errors; } $file = reset($files); - $filename = $CFG->dataroot.'/temp/scormimport/scrom_'.time(); - make_upload_directory('temp/scormimport'); + $filename = $CFG->tempdir.'/scormimport/scrom_'.time(); + make_temp_directory('scormimport'); $file->copy_content_to($filename); $packer = get_file_packer('application/zip'); diff --git a/mod/upgrade.txt b/mod/upgrade.txt index ffd77b25818..116e20d9444 100644 --- a/mod/upgrade.txt +++ b/mod/upgrade.txt @@ -59,3 +59,4 @@ required changes in code: * fix missing parameter types in optional_param() and required_param() * use new optional_param_array(), required_param_array() or clean_param_array() when dealing with array parameters * textlib->asort() replaced by specialized collatorlib::asort() +* use new make_temp_directory() and make_cache_directory() diff --git a/question/format/blackboard_six/format.php b/question/format/blackboard_six/format.php index cf43bba11f2..44216b7fadf 100644 --- a/question/format/blackboard_six/format.php +++ b/question/format/blackboard_six/format.php @@ -46,12 +46,12 @@ class qformat_blackboard_six extends qformat_default { global $CFG; - $status = $this->check_dir_exists($CFG->dataroot."/temp",true); + $status = $this->check_dir_exists($CFG->tempdir."",true); if ($status) { - $status = $this->check_dir_exists($CFG->dataroot."/temp/bbquiz_import",true); + $status = $this->check_dir_exists($CFG->tempdir."/bbquiz_import",true); } if ($status) { - $status = $this->check_dir_exists($CFG->dataroot."/temp/bbquiz_import/".$unique_code,true); + $status = $this->check_dir_exists($CFG->tempdir."/bbquiz_import/".$unique_code,true); } return $status; @@ -61,7 +61,7 @@ class qformat_blackboard_six extends qformat_default { global $CFG; // for now we will just say everything happened okay note - // that a mess may be piling up in $CFG->dataroot/temp/bbquiz_import + // that a mess may be piling up in $CFG->tempdir/bbquiz_import // TODO return true at top of the function renders all the following code useless return true; @@ -189,7 +189,7 @@ class qformat_blackboard_six extends qformat_default { } $unique_code = time(); - $temp_dir = $CFG->dataroot."/temp/bbquiz_import/".$unique_code; + $temp_dir = $CFG->tempdir."/bbquiz_import/".$unique_code; $this->temp_dir = $temp_dir; if ($this->check_and_create_import_dir($unique_code)) { if(is_readable($filename)) { diff --git a/question/format/qti_two/format.php b/question/format/qti_two/format.php index 88cdcbb5565..d0688bd4950 100644 --- a/question/format/qti_two/format.php +++ b/question/format/qti_two/format.php @@ -263,9 +263,9 @@ function handle_questions_media(&$questions, $path, $courseid) { global $CFG, $OUTPUT, $USER; $courseid = $this->course->id; - $path = 'temp/qformat_qti_two/' . $USER->id . '/' . $this->filename; + $path = 'qformat_qti_two/' . $USER->id . '/' . $this->filename; // create a directory for the exports (if not already existing) - if (!make_upload_directory($path)) { + if (!make_temp_directory($path)) { throw new moodle_exception('cannotcreatepath', 'question', '', $path); } $path = $CFG->dataroot . '/' . $path; diff --git a/question/import.php b/question/import.php index 0001e1ae208..20b6c9a4c73 100644 --- a/question/import.php +++ b/question/import.php @@ -83,8 +83,8 @@ if ($form = $import_form->get_data()) { // or one from the filesarea. $realfilename = $import_form->get_new_filename('newfile'); - $importfile = "{$CFG->dataroot}/temp/questionimport/{$realfilename}"; - make_upload_directory('temp/questionimport'); + $importfile = "{$CFG->tempdir}/questionimport/{$realfilename}"; + make_temp_directory('questionimport'); if (!$result = $import_form->save_file('newfile', $importfile, true)) { throw new moodle_exception('uploadproblem'); } diff --git a/repository/lib.php b/repository/lib.php index b6f09a78ce7..2c558b6cc8a 100644 --- a/repository/lib.php +++ b/repository/lib.php @@ -1310,11 +1310,11 @@ abstract class repository { */ public function prepare_file($filename) { global $CFG; - if (!file_exists($CFG->dataroot.'/temp/download')) { - mkdir($CFG->dataroot.'/temp/download/', $CFG->directorypermissions, true); + if (!file_exists($CFG->tempdir.'/download')) { + mkdir($CFG->tempdir.'/download/', $CFG->directorypermissions, true); } - if (is_dir($CFG->dataroot.'/temp/download')) { - $dir = $CFG->dataroot.'/temp/download/'; + if (is_dir($CFG->tempdir.'/download')) { + $dir = $CFG->tempdir.'/download/'; } if (empty($filename)) { $filename = uniqid('repo', true).'_'.time().'.tmp'; diff --git a/theme/image.php b/theme/image.php index cac1765bd22..e00f5592f7f 100644 --- a/theme/image.php +++ b/theme/image.php @@ -45,7 +45,7 @@ if (file_exists("$CFG->dirroot/theme/$themename/config.php")) { image_not_found(); } -$candidatelocation = "$CFG->dataroot/cache/theme/$themename/pix/$component"; +$candidatelocation = "$CFG->cachedir/theme/$themename/pix/$component"; if ($rev > -1) { if (file_exists("$candidatelocation/$image.error")) { diff --git a/theme/javascript.php b/theme/javascript.php index 9b359a1f97a..6e8a79d785b 100644 --- a/theme/javascript.php +++ b/theme/javascript.php @@ -46,7 +46,7 @@ if (file_exists("$CFG->dirroot/theme/$themename/config.php")) { die('Theme was not found, sorry.'); } -$candidate = "$CFG->dataroot/cache/theme/$themename/javascript_$type.js"; +$candidate = "$CFG->cachedir/theme/$themename/javascript_$type.js"; if ($rev > -1 and file_exists($candidate)) { if (!empty($_SERVER['HTTP_IF_NONE_MATCH']) || !empty($_SERVER['HTTP_IF_MODIFIED_SINCE'])) { diff --git a/theme/styles.php b/theme/styles.php index ce6ada05da9..6fcde59e1b6 100644 --- a/theme/styles.php +++ b/theme/styles.php @@ -50,7 +50,7 @@ if ($type === 'ie') { send_ie_css($themename, $rev); } -$candidatesheet = "$CFG->dataroot/cache/theme/$themename/css/$type.css"; +$candidatesheet = "$CFG->cachedir/theme/$themename/css/$type.css"; if (file_exists($candidatesheet)) { if (!empty($_SERVER['HTTP_IF_NONE_MATCH']) || !empty($_SERVER['HTTP_IF_MODIFIED_SINCE'])) { @@ -97,11 +97,11 @@ if ($type === 'editor') { $cssfiles[] = $val; } } - $cssfile = "$CFG->dataroot/cache/theme/$themename/css/$key.css"; + $cssfile = "$CFG->cachedir/theme/$themename/css/$key.css"; store_css($theme, $cssfile, $cssfiles); $allfiles = array_merge($allfiles, $cssfiles); } - $cssfile = "$CFG->dataroot/cache/theme/$themename/css/all.css"; + $cssfile = "$CFG->cachedir/theme/$themename/css/all.css"; store_css($theme, $cssfile, $allfiles); } send_cached_css($candidatesheet, $rev); diff --git a/theme/styles_debug.php b/theme/styles_debug.php index 25a50e6a9b2..67277bc7262 100644 --- a/theme/styles_debug.php +++ b/theme/styles_debug.php @@ -46,7 +46,7 @@ if (file_exists("$CFG->dirroot/theme/$themename/config.php")) { // no gzip compression when debugging -$candidatesheet = "$CFG->dataroot/cache/theme/$themename/designer.ser"; +$candidatesheet = "$CFG->cachedir/theme/$themename/designer.ser"; if (!file_exists($candidatesheet)) { css_not_found();