header('Content-Disposition: attachment; filename="'.$filename.'"');
if (strpos($CFG->wwwroot, 'https://') === 0) { //https sites - watch out for IE! KB812935 and KB316431
- header('Cache-Control: private, max-age=10');
+ header('Cache-Control: private, max-age=10, no-transform');
header('Expires: '. gmdate('D, d M Y H:i:s', 0) .' GMT');
header('Pragma: ');
} else { //normal http - prevent caching at all cost
- header('Cache-Control: private, must-revalidate, pre-check=0, post-check=0, max-age=0');
+ header('Cache-Control: private, must-revalidate, pre-check=0, post-check=0, max-age=0, no-transform');
header('Expires: '. gmdate('D, d M Y H:i:s', 0) .' GMT');
header('Pragma: no-cache');
}
$private = ' private,';
}
$nobyteserving = false;
- header('Cache-Control:'.$private.' max-age='.$lifetime);
+ header('Cache-Control:'.$private.' max-age='.$lifetime.', no-transform');
header('Expires: '. gmdate('D, d M Y H:i:s', time() + $lifetime) .' GMT');
header('Pragma: ');
} else { // Do not cache files in proxies and browsers
$nobyteserving = true;
if (strpos($CFG->wwwroot, 'https://') === 0) { //https sites - watch out for IE! KB812935 and KB316431
- header('Cache-Control: private, max-age=10');
+ header('Cache-Control: private, max-age=10, no-transform');
header('Expires: '. gmdate('D, d M Y H:i:s', 0) .' GMT');
header('Pragma: ');
} else { //normal http - prevent caching at all cost
- header('Cache-Control: private, must-revalidate, pre-check=0, post-check=0, max-age=0');
+ header('Cache-Control: private, must-revalidate, pre-check=0, post-check=0, max-age=0, no-transform');
header('Expires: '. gmdate('D, d M Y H:i:s', 0) .' GMT');
header('Pragma: no-cache');
}
if (isloggedin() and !isguestuser()) {
$private = ' private,';
}
- header('Cache-Control:'.$private.' max-age='.$lifetime);
+ header('Cache-Control:'.$private.' max-age='.$lifetime.', no-transform');
header('Expires: '. gmdate('D, d M Y H:i:s', time() + $lifetime) .' GMT');
header('Pragma: ');
} else { // Do not cache files in proxies and browsers
if (strpos($CFG->wwwroot, 'https://') === 0) { //https sites - watch out for IE! KB812935 and KB316431
- header('Cache-Control: private, max-age=10');
+ header('Cache-Control: private, max-age=10, no-transform');
header('Expires: '. gmdate('D, d M Y H:i:s', 0) .' GMT');
header('Pragma: ');
} else { //normal http - prevent caching at all cost
- header('Cache-Control: private, must-revalidate, pre-check=0, post-check=0, max-age=0');
+ header('Cache-Control: private, must-revalidate, pre-check=0, post-check=0, max-age=0, no-transform');
header('Expires: '. gmdate('D, d M Y H:i:s', 0) .' GMT');
header('Pragma: no-cache');
}
*/
function byteserving_send_file($handle, $mimetype, $ranges, $filesize) {
// better turn off any kind of compression and buffering
- @ini_set('zlib.output_compression', 'Off');
+ ini_set('zlib.output_compression', 'Off');
$chunksize = 1*(1024*1024); // 1MB chunks - must be less than 2MB!
if ($handle === false) {
}
if (!isset($this->emulateredirects)) {
- $this->emulateredirects = (ini_get('open_basedir') or ini_get('safe_mode'));
+ $this->emulateredirects = ini_get('open_basedir');
}
}
return trim(format_text($intro, $activity->introformat, $options, null));
}
+/**
+ * Removes the usage of Moodle files from a text.
+ *
+ * In some rare cases we need to re-use a text that already has embedded links
+ * to some files hosted within Moodle. But the new area in which we will push
+ * this content does not support files... therefore we need to remove those files.
+ *
+ * @param string $source The text
+ * @return string The stripped text
+ */
+function strip_pluginfile_content($source) {
+ $baseurl = '@@PLUGINFILE@@';
+ // Looking for something like < .* "@@pluginfile@@.*" .* >
+ $pattern = '$<[^<>]+["\']' . $baseurl . '[^"\']*["\'][^<>]*>$';
+ $stripped = preg_replace($pattern, '', $source);
+ // Use purify html to rebalence potentially mismatched tags and generally cleanup.
+ return purify_html($stripped);
+}
+
/**
* Legacy function, used for cleaning of old forum and glossary text only.
*
if ($cacheable) {
// Allow caching on "back" (but not on normal clicks).
- @header('Cache-Control: private, pre-check=0, post-check=0, max-age=0');
+ @header('Cache-Control: private, pre-check=0, post-check=0, max-age=0, no-transform');
@header('Pragma: no-cache');
@header('Expires: ');
} else {
// Do everything we can to always prevent clients and proxies caching.
@header('Cache-Control: no-store, no-cache, must-revalidate');
- @header('Cache-Control: post-check=0, pre-check=0', false);
+ @header('Cache-Control: post-check=0, pre-check=0, no-transform', false);
@header('Pragma: no-cache');
@header('Expires: Mon, 20 Aug 1969 09:23:00 GMT');
@header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
if ($PAGE) {
$PAGE->set_context(null);
$PAGE->set_pagelayout('redirect'); // No header and footer needed.
+ $PAGE->set_title(get_string('pageshouldredirect', 'moodle'));
}
if ($url instanceof moodle_url) {
if (!file_exists($imagepath) or !is_file($imagepath)) {
$imagepath = $dir . '/yui/' . $module . '/assets/skins/sam/' . $image;
}
-} else if ($version == 'gallery' && count($parts)==3) {
- list($module, $version, $image) = $parts;
- $imagepath = "$CFG->dirroot/lib/yui/gallery/$module/$version/assets/skins/sam/$image";
+} else if ($version == 'gallery' && count($parts) >= 3) {
+ list($revision, $module, , , , $image) = $parts;
+ $imagepath = "$CFG->dirroot/lib/yuilib/gallery/$module/assets/skins/sam/$image";
} else if (count($parts) == 1 && ($version == $CFG->yui3version || $version == $CFG->yui2version)) {
list($image) = $parts;
if ($version == $CFG->yui3version) {
header('HTTP/1.1 304 Not Modified');
header('Last-Modified: '. gmdate('D, d M Y H:i:s', filemtime($imagepath)) .' GMT');
header('Expires: '. gmdate('D, d M Y H:i:s', time() + $lifetime) .' GMT');
- header('Cache-Control: public, max-age='.$lifetime);
+ header('Cache-Control: public, max-age='.$lifetime.', no-transform');
header('Content-Type: '.$mimetype);
header('Etag: "'.$etag.'"');
die;
header('Last-Modified: '. gmdate('D, d M Y H:i:s', filemtime($imagepath)) .' GMT');
header('Expires: '. gmdate('D, d M Y H:i:s', time() + $lifetime) .' GMT');
header('Pragma: ');
- header('Cache-Control: public, max-age=315360000');
+ header('Cache-Control: public, max-age=315360000, no-transform');
header('Accept-Ranges: none');
header('Content-Type: '.$mimetype);
header('Content-Length: '.filesize($imagepath));