summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIneiev <ineiev@gnu.org>2024-10-22 08:56:54 +0000
committerIneiev <ineiev@gnu.org>2024-10-22 17:56:01 +0000
commitfe88ab40cb3eb3bf250224c46c17b33c85ea0249 (patch)
tree5d7a4ddda88ee097bdf7e8aba9728faf02d5d938
parent9f292fa9240ea631285dc6059dc0783cbb5094cd (diff)
downloadsavane-fe88ab40cb3eb3bf250224c46c17b33c85ea0249.tar.gz
add Source-Code-Offer header
-rw-r--r--NEWS2
-rw-r--r--frontend/php/file.php11
2 files changed, 8 insertions, 5 deletions
diff --git a/NEWS b/NEWS
index 029c174d..0ef6c5c3 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,8 @@
[FRONTEND]
+* A 'Source-Code-Offer' header is added when serving tracker attachments.
+
* The headers are omitted when serving tracker attachments when the respective
fields are empty.
diff --git a/frontend/php/file.php b/frontend/php/file.php
index 5d6635f0..97325ffd 100644
--- a/frontend/php/file.php
+++ b/frontend/php/file.php
@@ -163,15 +163,17 @@ if ($row['filename'] != basename (rawurldecode ($_SERVER['PHP_SELF'])))
. "registered in the database")
);
-$path = $sys_trackers_attachments_dir . '/' . $file_id;
+$path = "$sys_trackers_attachments_dir/$file_id";
if (!is_readable ($path))
file_exit_error (_("No access to the file."));
-# Download the patch with the correct filetype.
+$row['agpl'] = trim (git_agpl_notice ('This file is served with Savane.'));
+
+# Serve the file with respective attributes.
$headers = [
'filetype' => 'Content-Type: ', 'filesize' => 'Content-Length: ',
'filename' => 'Content-Disposition: attachment; filename=',
- 'description' => 'Content-Description: '
+ 'description' => 'Content-Description: ', 'agpl' => 'Source-Code-Offer: '
];
foreach ($headers as $field => $h)
{
@@ -180,7 +182,6 @@ foreach ($headers as $field => $h)
$val = str_replace (["\n", "\r"], ' ', $row[$field]);
header ("$h$val");
}
-# Dump file to the browser.
-readfile ("$sys_trackers_attachments_dir/$file_id");
+readfile ($path);
exit (0);
?>