|
17 | 17 | exit;
|
18 | 18 | }
|
19 | 19 |
|
| 20 | +// logout |
20 | 21 | if ((basename($_filename) == 'logout') || (isset($_GET['logout']))) {
|
21 |
| - foreach ($_SESSION as $k=>$v) { |
22 |
| - sess($k, null); |
23 |
| - } |
24 |
| - |
25 |
| - if (isset($i_next)) { |
26 |
| - sess('next', $i_next); |
27 |
| - } elseif (isMethod('GET') && isset($_SERVER['HTTP_REFERER'])) { |
28 |
| - sess('next', $_SERVER['HTTP_REFERER']); |
29 |
| - } |
30 |
| - |
31 |
| - if (isSess('next')) { |
32 |
| - $next = sess('next', null); |
33 |
| - $next = str_replace('https://', 'http://', $next); |
34 |
| - header('Location: '.$next); |
35 |
| - } else { |
36 |
| - header('Location: /'); |
37 |
| - } |
38 |
| - exit; |
| 22 | + isset($i_next)?clearSession($i_next):clearSession(); |
39 | 23 | }
|
40 | 24 |
|
41 | 25 | if (!in_array($_method, array('GET', 'HEAD')) && !isset($i_query))
|
|
85 | 69 | httpStatusExit(403, 'Forbidden');
|
86 | 70 | }
|
87 | 71 |
|
| 72 | +// add Vary header |
| 73 | +header("Vary: Accept, Origin, If-Modified-Since, If-None-Match"); |
| 74 | + |
88 | 75 | // directory indexing
|
89 | 76 | if (is_dir($_filename) || substr($_filename,-1) == '/') {
|
90 | 77 | // add meta relation
|
|
140 | 127 | exit;
|
141 | 128 | } else {
|
142 | 129 | // always revalidate cache for RDF documents
|
143 |
| - header("Vary: Accept, Origin, If-Modified-Since, ETag"); |
144 | 130 | header("Cache-Control: max-age=0", true);
|
145 | 131 | }
|
146 | 132 |
|
|
172 | 158 | }
|
173 | 159 |
|
174 | 160 | // add ETag and Last-Modified headers
|
175 |
| -if (strlen($etag)) |
| 161 | +if (strlen($etag)) { |
176 | 162 | $etag = trim(array_shift(explode(' ', $etag)));
|
177 |
| -header('ETag: "'.$etag.'"'); |
| 163 | + header('ETag: "'.$etag.'"'); |
| 164 | +} |
| 165 | + |
178 | 166 | header('Last-Modified: '.gmdate('D, d M Y H:i:s', $last_modified).' GMT', true, 200);
|
179 | 167 |
|
180 |
| -if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) || isset($_SERVER['HTTP_IF_NONE_MATCH'])) { |
181 |
| - if (@strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) == $last_modified || |
182 |
| - str_replace('"', '', trim($_SERVER['HTTP_IF_NONE_MATCH'])) == $etag) { |
183 |
| - header("HTTP/1.1 304 Not Modified"); |
184 |
| - exit; |
| 168 | +if (CACHING) { |
| 169 | + if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) || isset($_SERVER['HTTP_IF_NONE_MATCH'])) { |
| 170 | + if (@strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) == $last_modified || |
| 171 | + str_replace('"', '', trim($_SERVER['HTTP_IF_NONE_MATCH'])) == $etag) { |
| 172 | + header("HTTP/1.1 304 Not Modified"); |
| 173 | + exit; |
| 174 | + } |
185 | 175 | }
|
186 | 176 | }
|
187 | 177 |
|
|
231 | 221 | $g->reload();
|
232 | 222 | }
|
233 | 223 |
|
234 |
| -// ETag |
235 |
| -$etag = $g->etag(); |
236 |
| -if ($etag) |
237 |
| - header('ETag: "'.$etag.'"'); |
238 |
| - |
239 | 224 | // LDP type
|
240 | 225 | if (is_dir($_filename))
|
241 |
| - header("Link: <http://www.w3.org/ns/ldp#Container>; rel=\"type\"", false); |
| 226 | + header("Link: <http://www.w3.org/ns/ldp#BasicContainer>; rel=\"type\"", false); |
242 | 227 | else
|
243 | 228 | header("Link: <http://www.w3.org/ns/ldp#Resource>; rel=\"type\"", false);
|
244 | 229 |
|
|
0 commit comments