-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresults.php
More file actions
executable file
·105 lines (70 loc) · 2.6 KB
/
results.php
File metadata and controls
executable file
·105 lines (70 loc) · 2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?php
include("/share1/proj/eem/templates/functions.php");
// from htaccess rewrite
// maps /x1234/image.png to /x1234/expression_geneset.eemHtml/image.png
$id = $_GET['id'];
$document = $_GET['document'];
$path = DATAPATH . "$id/expression_geneset.eemHtml/$document";
$downloadPath = DATAPATH . "$id/$document";
if (file_exists($path)) {
$info = pathinfo($path);
$ext = $info['extension'];
$png = (strtolower($ext)=="png");
$jpg = ((strtolower($ext)=="jpg") || (strtolower($ext)=="jpeg"));
$gif = (strtolower($ext)=="gif");
$pdf = (strtolower($ext)=="pdf");
$txt = (strtolower($ext)=="txt");
if ($png || $jpg || $gif || $pdf) {
if ($png) {
$extension = "png";
} elseif ($jpg) {
$extension = "jpg";
} elseif ($gif) {
$extension = "gif";
} elseif ($pdf) {
$extension = "pdf";
}
// Getting headers sent by the client.
$headers = apache_request_headers();
// Checking if the client is validating his cache and if it is current.
if (isset($headers['If-Modified-Since']) && (strtotime($headers['If-Modified-Since']) == filemtime($path))) {
// Client's cache IS current, so we just respond '304 Not Modified'.
header('Last-Modified: '.gmdate('D, d M Y H:i:s', filemtime($path)).' GMT', true, 304);
} else {
// Image not cached or cache outdated, we respond '200 OK' and output the image.
header('Last-Modified: '.gmdate('D, d M Y H:i:s', filemtime($path)).' GMT', true, 200);
header('Content-Length: '.filesize($path));
header("Content-Type: image/$extension");
print file_get_contents($path);
}
} else if($txt) {
header('Last-Modified: '.gmdate('D, d M Y H:i:s', filemtime($path)).' GMT', true, 200);
header('Content-Length: '.filesize($path));
header("Content-Type: text/plain");
print file_get_contents($path);
} else {
include($path);
}
} else if(file_exists($downloadPath)) {
/* error with Safari..
"Frame load interrupted"
But manually (double-clicking) starts the decompression process...
*/
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$contentType = finfo_file($finfo, $downloadPath);
header("Pragma: public");
header("Cache-Control: private",false);
//header('Content-type: application/octet-stream');
header("Content-Type: $contentType");
header('Content-Disposition: attachment; filename="' . $meta["zip"] . '"');
header("Content-Transfer-Encoding: binary");
header('Content-Length: ' . filesize($downloadPath));
ob_clean();
flush();
readfile($downloadPath);
//print file_get_contents($downloadPath);
} else {
header("HTTP/1.0 404 Not Found");
include("/share1/proj/eem/htdocs/404.html");
}
?>