Forces download when using "source" as a style

This commit is contained in:
Christophe HENRY 2021-03-12 23:30:49 +00:00
parent cdbc9614de
commit 212c503bfb
1 changed files with 8 additions and 1 deletions

View File

@ -301,7 +301,14 @@ $page_title = @$matches[1];
**/
if ("source" == $style) {
echo $fileContents;
$basename = basename($filePath);
header("Cache-Control: public");
header("Content-Disposition: attachment; filename=$basename");
header("Content-Type: text/plain");
header("Content-Transfer-Encoding: binary");
header('Content-Length: ' . filesize($filePath));
readfile($filePath);
exit();
} elseif ("pre" == $style) {
$fileContents = htmlspecialchars($fileContents, ENT_HTML5|ENT_NOQUOTES, "UTF-8", false);
echo <<<EOL