This repository has been archived on 2025-02-26. You can view files and clone it, but cannot push or open issues or pull requests.
szurubooru/src/Views/layout-file.phtml

39 lines
1.2 KiB
PHTML
Raw Normal View History

2013-10-07 20:45:09 +02:00
<?php
$lastModified = $this->context->transport->lastModified;
$eTag = $this->context->transport->fileHash;
$ttl = $this->context->transport->cacheDaysToLive * 24 * 3600;
2013-10-19 13:00:03 +02:00
$ifModifiedSince = isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])
? $_SERVER['HTTP_IF_MODIFIED_SINCE']
: false;
2013-10-19 13:00:03 +02:00
$eTagHeader = isset($_SERVER['HTTP_IF_NONE_MATCH'])
? trim(trim($_SERVER['HTTP_IF_NONE_MATCH']), '"')
: false;
2013-10-19 13:00:03 +02:00
\Chibi\Util\Headers::set('ETag', '"' . $eTag . '"');
\Chibi\Util\Headers::set('Last-Modified', gmdate('D, d M Y H:i:s \G\M\T', $lastModified));
\Chibi\Util\Headers::set('Pragma', 'public');
\Chibi\Util\Headers::set('Cache-Control', 'public, max-age=' . $ttl);
\Chibi\Util\Headers::set('Expires', gmdate('D, d M Y H:i:s \G\M\T', time() + $ttl));
2013-10-13 13:37:18 +02:00
if (isset($this->context->transport->customFileName))
{
2014-04-29 21:35:29 +02:00
\Chibi\Util\Headers::set(
'Content-Disposition',
'inline; filename="' . $this->context->transport->customFileName . '"');
}
2014-04-27 15:59:29 +02:00
\Chibi\Util\Headers::set(
'Content-Type',
$this->context->transport->mimeType);
2013-10-19 13:00:03 +02:00
if (strtotime($ifModifiedSince) == $lastModified or $eTagHeader == $eTag)
{
\Chibi\Util\Headers::setCode('304');
exit;
2013-10-07 20:45:09 +02:00
}
echo $this->context->transport->fileContent;
flush();