From 212c503bfbad7f7ab787192d01ec99f9351360cc Mon Sep 17 00:00:00 2001 From: Christophe HENRY Date: Fri, 12 Mar 2021 23:30:49 +0000 Subject: [PATCH] Forces download when using "source" as a style --- index.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/index.php b/index.php index 1a05672..d666e75 100644 --- a/index.php +++ b/index.php @@ -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 <<