diff --git a/admin/filters.html b/admin/filters.html index f98fe2498c6f4..5f7f10fe5a13d 100644 --- a/admin/filters.html +++ b/admin/filters.html @@ -113,6 +113,21 @@ + + : + + filteruploadedfiles, "", "", ""); + ?> + + + + +   "> diff --git a/admin/filters.php b/admin/filters.php index 45373087b947a..abb3b5df2aa3f 100644 --- a/admin/filters.php +++ b/admin/filters.php @@ -32,6 +32,8 @@ $strinactive = get_string("inactive"); $strcachetext = get_string("cachetext", "admin"); $strconfigcachetext = get_string("configcachetext"); + $strfilteruploadedfiles = get_string("filteruploadedfiles", "admin"); + $strconfigfilteruploadedfiles = get_string("configfilteruploadedfiles"); print_header("$site->shortname: $strmanagefilters", "$site->fullname", "$stradministration -> ". diff --git a/file.php b/file.php index 42973de01d453..3c4e0da045a4d 100644 --- a/file.php +++ b/file.php @@ -49,20 +49,26 @@ header("Content-length: ".filesize($pathname)); - if ($mimetype == "text/html") { - header("Content-type: text/html"); - echo format_text(implode('', file($pathname)), FORMAT_HTML, NULL, $courseid); // Filter HTML files - - } else if ($mimetype == "text/plain") { - header("Content-type: text/html"); - $options->newlines = false; - echo "
";
-            echo format_text(implode('', file($pathname)), FORMAT_MOODLE, $options, $courseid);  // Filter TEXT files
-            echo "
"; - - } else { + if (empty($CFG->filteruploadedfiles)) { header("Content-type: $mimetype"); readfile($pathname); + + } else { /// Try and put the file through filters + if ($mimetype == "text/html") { + header("Content-type: text/html"); + echo format_text(implode('', file($pathname)), FORMAT_HTML, NULL, $courseid); + + } else if ($mimetype == "text/plain") { + header("Content-type: text/html"); + $options->newlines = false; + echo "
";
+                echo format_text(implode('', file($pathname)), FORMAT_MOODLE, $options, $courseid);
+                echo "
"; + + } else { /// Just send it out raw + header("Content-type: $mimetype"); + readfile($pathname); + } } } else { error("Sorry, but the file you are looking for was not found ($pathname)", "course/view.php?id=$courseid"); diff --git a/lang/en/admin.php b/lang/en/admin.php index fc8489e9d9c5f..a7fff473ee722 100755 --- a/lang/en/admin.php +++ b/lang/en/admin.php @@ -3,6 +3,7 @@ $string['cachetext'] = 'Text cache lifetime'; +$string['filteruploadedfiles'] = 'Filter uploaded files'; $string['upgradelogs'] = 'For full functionality, your old logs need to be upgraded. More information'; $string['upgradelogsinfo'] = 'Some changes have way some logs are stored. To be able to view all of your old logs on a per-activity basis, your old logs need to be upgraded. Depending on your site this can take a long time (eg several hours) and can be quite taxing on the database for large sites. Once you start this process you should let it finish (by keeping the browser window open). Don\'t worry - your site will work fine for other people while the logs are being upgraded.

Do you want to upgrade your logs now?'; diff --git a/lang/en/moodle.php b/lang/en/moodle.php index 8da1d0f7cf66a..d6b4cebaef738 100644 --- a/lang/en/moodle.php +++ b/lang/en/moodle.php @@ -131,6 +131,7 @@ $string['configcountry'] = 'If you set a country here, then this country will be selected by default on new user accounts. To force users to choose a country, just leave this unset.'; $string['configdebug'] = 'If you turn this on, then PHP\'s error_reporting will be increased so that more warnings are printed. This is only useful for developers.'; $string['configerrorlevel'] = 'Choose the amount of PHP warnings that you want to be displayed. Normal is usually the best choice.'; +$string['configfilteruploadedfiles'] = 'Enabling this setting will cause Moodle to process all uploaded HTML and text files with the filters before displaying them.'; $string['configforcelogin'] = 'Normally, the front page of the site and the course listings (but not courses) can be read by people without logging in to the site. If you want to force people to log in before they do ANYTHING on the site, then you should enable this setting.'; $string['configframename'] = 'If you are embedding Moodle within a web frame, then put the name of this frame here. Otherwise this value should remain as \'_top\''; $string['configfullnamedisplay'] = 'This defines how names are shown when they are displayed in full. For most mono-lingual sites the most efficient setting is the default \"Given names + Surname\", but you may choose to hide surnames altogether, or to leave it up to the current language pack to decide (some languages have different conventions).'; diff --git a/lib/defaults.php b/lib/defaults.php index c6a579cd89947..cb581f24f1440 100644 --- a/lib/defaults.php +++ b/lib/defaults.php @@ -10,6 +10,7 @@ "changepassword" => true, "country" => "", "debug" => 7, + "filteruploadedfiles" => true, "forcelogin" => false, "fullnamedisplay" => "firstname lastname", "framename" => "_top",