|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* ***************************************************************************** |
|
5
|
|
|
* Contributions to this work were made on behalf of the GÉANT project, a |
|
6
|
|
|
* project that has received funding from the European Union’s Framework |
|
7
|
|
|
* Programme 7 under Grant Agreements No. 238875 (GN3) and No. 605243 (GN3plus), |
|
8
|
|
|
* Horizon 2020 research and innovation programme under Grant Agreements No. |
|
9
|
|
|
* 691567 (GN4-1) and No. 731122 (GN4-2). |
|
10
|
|
|
* On behalf of the aforementioned projects, GEANT Association is the sole owner |
|
11
|
|
|
* of the copyright in all material which was developed by a member of the GÉANT |
|
12
|
|
|
* project. GÉANT Vereniging (Association) is registered with the Chamber of |
|
13
|
|
|
* Commerce in Amsterdam with registration number 40535155 and operates in the |
|
14
|
|
|
* UK as a branch of GÉANT Vereniging. |
|
15
|
|
|
* |
|
16
|
|
|
* Registered office: Hoekenrode 3, 1102BR Amsterdam, The Netherlands. |
|
17
|
|
|
* UK branch address: City House, 126-130 Hills Road, Cambridge CB2 1PQ, UK |
|
18
|
|
|
* |
|
19
|
|
|
* License: see the web/copyright.inc.php file in the file structure or |
|
20
|
|
|
* <base_url>/copyright.php after deploying the software |
|
21
|
|
|
*/ |
|
22
|
|
|
?> |
|
23
|
|
|
<?php |
|
24
|
|
|
|
|
25
|
|
|
require_once dirname(dirname(dirname(dirname(__FILE__)))) . "/config/_config.php"; |
|
26
|
|
|
|
|
27
|
|
|
$validator = new \web\lib\common\InputValidation(); |
|
28
|
|
|
if (isset($_GET["id"]) && $validator->databaseReference($_GET["id"])) { |
|
29
|
|
|
// check if data is public for this blob call |
|
30
|
|
|
$blob = \web\lib\admin\UIElements::getBlobFromDB($id, TRUE); |
|
31
|
|
|
if (is_bool($blob)) { |
|
32
|
|
|
echo "No valid ID"; |
|
33
|
|
|
} |
|
34
|
|
|
$finalBlob = base64_decode($blob); |
|
35
|
|
|
// Set data type and caching for 30 days |
|
36
|
|
|
$info = new finfo(); |
|
37
|
|
|
$filetype = $info->buffer($finalBlob, FILEINFO_MIME_TYPE); |
|
38
|
|
|
header("Content-type: " . $filetype); |
|
39
|
|
|
|
|
40
|
|
|
switch ($filetype) { |
|
41
|
|
|
case "text/rtf": // fall-through, same treatment |
|
42
|
|
|
case "application/rtf": |
|
43
|
|
|
header("Content-Disposition: attachment; filename='download.rtf'"); |
|
44
|
|
|
break; |
|
45
|
|
|
case "text/plain": |
|
46
|
|
|
header("Content-Disposition: attachment; filename='download.txt'"); |
|
47
|
|
|
break; |
|
48
|
|
|
default: |
|
49
|
|
|
// do nothing special with the Content-Disposition header |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
header("Cache-Control: must-revalidate"); |
|
53
|
|
|
$offset = 60 * 60 * 24 * 30; |
|
54
|
|
|
// gmdate can't possibly fail, because it operates on time() and an integer offset |
|
55
|
|
|
$ExpStr = "Expires: " . /** @scrutinizer ignore-type */ gmdate("D, d M Y H:i:s", time() + $offset) . " GMT"; |
|
56
|
|
|
header($ExpStr); |
|
57
|
|
|
// Print out the image |
|
58
|
|
|
echo $finalBlob; |
|
59
|
|
|
} else { |
|
60
|
|
|
echo "No valid ID"; |
|
61
|
|
|
} |
|
62
|
|
|
|