scratch – Diff between revs 81 and 83
?pathlinks?
Rev 81 | Rev 83 | |||
---|---|---|---|---|
Line 88... | Line 88... | |||
88 | "timestamp" => $timestamp |
88 | "timestamp" => $timestamp |
|
89 | ) |
89 | ) |
|
90 | ); |
90 | ); |
|
91 | break; |
91 | break; |
|
92 | case 'GET': |
92 | case 'GET': |
|
- | 93 | ### Tell browser not to cache files. |
||
- | 94 | header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0"); |
||
- | 95 | header("Cache-Control: post-check=0, pre-check=0", false); |
||
- | 96 | header("Pragma: no-cache"); |
||
- | 97 | |
||
93 | ### If no file has been specified for download then return. |
98 | ### If no file has been specified for download then return. |
|
94 | if (!isset($_GET['hash']) or empty($_GET['hash'])) { |
99 | if (!isset($_GET['hash']) or empty($_GET['hash'])) { |
|
95 | http_response_code(404); |
100 | http_response_code(404); |
|
96 | die('File not found.'); |
101 | die('File not found.'); |
|
97 | } |
102 | } |
|
Line 135... | Line 140... | |||
135 | realpath($pathPart['dirname']), realpath($config['STORE_FOLDER'])) != 0) { |
140 | realpath($pathPart['dirname']), realpath($config['STORE_FOLDER'])) != 0) { |
|
136 | http_response_code(500); |
141 | http_response_code(500); |
|
137 | die('Internal server error.'); |
142 | die('Internal server error.'); |
|
138 | } |
143 | } |
|
Line 139... | Line 144... | |||
139 | |
144 | |
|
140 | ### Hook for HTML files to display properly. |
145 | ### Hook for various file extensions. |
|
141 | switch(strtoupper($fileExtension)) { |
146 | switch(strtoupper($fileExtension)) { |
|
142 | case "HTML": |
147 | case "HTML": |
|
143 | case "HTM": |
148 | case "HTM": |
|
144 | header('Content-type: text/html'); |
149 | header('Content-type: text/html'); |
|
145 | break; |
150 | break; |
|
- | 151 | break; |
||
- | 152 | case "URL": |
||
- | 153 | if(preg_match("/URL=([^\n]*)\n/", file_get_contents($userPath), $matches)) { |
||
- | 154 | header('Location: '.$matches[1]); |
||
- | 155 | return; |
||
- | 156 | } |
||
146 | break; |
157 | break; |
|
147 | default: |
158 | default: |
|
148 | ### Open MIME info database and send the content type. |
159 | ### Open MIME info database and send the content type. |
|
149 | $finfo = finfo_open(FILEINFO_MIME_TYPE); |
160 | $finfo = finfo_open(FILEINFO_MIME_TYPE); |
|
150 | if (!$finfo) { |
161 | if (!$finfo) { |
|
Line 154... | Line 165... | |||
154 | header('Content-type: '.finfo_file($finfo, $userPath)); |
165 | header('Content-type: '.finfo_file($finfo, $userPath)); |
|
155 | finfo_close($finfo); |
166 | finfo_close($finfo); |
|
156 | break; |
167 | break; |
|
157 | } |
168 | } |
|
Line 158... | Line -... | |||
158 | |
- | ||
159 | ### Tell browser not to cache files. |
- | ||
160 | header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0"); |
- | ||
161 | header("Cache-Control: post-check=0, pre-check=0", false); |
- | ||
162 | header("Pragma: no-cache"); |
169 | |
|
163 | ### Send the file along with the inline content disposition. |
170 | ### Send the file along with the inline content disposition. |
|
164 | header('Content-length: '.(int)get_file_size($userPath)); |
171 | header('Content-length: '.(int)get_file_size($userPath)); |
|
165 | header('Content-Disposition: inline; filename="' . basename($userPath) . '"'); |
172 | header('Content-Disposition: inline; filename="' . basename($userPath) . '"'); |
|
166 | header('Content-Transfer-Encoding: binary'); |
173 | header('Content-Transfer-Encoding: binary'); |