From 3de875b138883812696821a1e12aaf51afece44c Mon Sep 17 00:00:00 2001
From: Tobias Herre <tobias.herre@wikimedia.de>
Date: Fri, 17 Dec 2021 14:00:12 +0100
Subject: [PATCH] Download after sent per mail

---
 submit.php | 24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/submit.php b/submit.php
index b2c9f0d..8e2644c 100644
--- a/submit.php
+++ b/submit.php
@@ -1,3 +1,17 @@
+<?php
+session_start();
+
+if ($_GET['lst']=='1'){
+	$file = "Antrag.pdf";
+	header('Content-Disposition: attachment; filename="'. $file . '"');
+	header('Content-Length: ' . strlen($_SESSION['lst']));
+	
+	echo $_SESSION['lst'];
+
+	die;
+}
+?>
+
 <html>
 <head>
 	<title>Kostenerstattungsforumlar</title>
@@ -13,10 +27,7 @@
 
 </head>
 <body>
-
 <?php
-session_start();
-
 
 error_log("SUBMIT\n");
 
@@ -464,9 +475,14 @@ if ($_POST['sendmail']=='yes'){
 		class="button is-orange"><?=_("Kopie des Antrags herunterladen")?></button>
 	</div> -->
 <?php
-
+	echo '<a href="./submit.php?lst=1" target="_blank">Kopie des Antrags herunterladen</a>';
+	echo "<br>";
 	echo '<a href="./">
 	Weiteren Antrag auf Kostenerstattung stellen</a><BR>';
+
+	$_SESSION['lst']=file_get_contents("$resultnam.pdf");
+	session_write_close();
+
 	die;