diff options
author | zotlabs <mike@macgirvin.com> | 2019-07-28 20:00:14 -0700 |
---|---|---|
committer | zotlabs <mike@macgirvin.com> | 2019-07-28 20:00:14 -0700 |
commit | 70e4a2c4fa69135dea97d1b6323fe6f8e17961c7 (patch) | |
tree | 38e8f097ec0d9aecb12dcce0bfcf239af37cebbf /boot.php | |
parent | 696359daba11c51d8f733dfa173e48b5e1de69ef (diff) | |
parent | 5695350e98a8a2c802ff419c5b29b0f01f0180df (diff) | |
download | volse-hubzilla-70e4a2c4fa69135dea97d1b6323fe6f8e17961c7.tar.gz volse-hubzilla-70e4a2c4fa69135dea97d1b6323fe6f8e17961c7.tar.bz2 volse-hubzilla-70e4a2c4fa69135dea97d1b6323fe6f8e17961c7.zip |
Merge branch 'dev' of https://framagit.org/hubzilla/core into dev
Diffstat (limited to 'boot.php')
-rwxr-xr-x | boot.php | 47 |
1 files changed, 46 insertions, 1 deletions
@@ -468,7 +468,7 @@ define ( 'NAMESPACE_YMEDIA', 'http://search.yahoo.com/mrss/' ); define ( 'ACTIVITYSTREAMS_JSONLD_REV', 'https://www.w3.org/ns/activitystreams' ); -define ( 'ZOT_APSCHEMA_REV', '/apschema/v1.7' ); +define ( 'ZOT_APSCHEMA_REV', '/apschema/v1.8' ); /** * activity stream defines */ @@ -896,6 +896,51 @@ class App { if(x($_GET,'q')) self::$cmd = escape_tags(trim($_GET['q'],'/\\')); + // Serve raw files from the file system in certain cases. + $filext = pathinfo(self::$cmd, PATHINFO_EXTENSION); + + $serve_rawfiles=[ + 'jpg'=>'image/jpeg', + 'jpeg'=>'image/jpeg', + 'gif'=>'image/gif', + 'png'=>'image/png', + 'ico'=>'image/vnd.microsoft.icon', + 'css'=>'text/css', + 'js'=>'text/javascript', + 'htm'=>'text/html', + 'html'=>'text/html', + 'map'=>'application/octet-stream', + 'ttf'=>'font/ttf', + 'woff'=>'font/woff', + 'woff2'=>'font/woff2', + 'svg'=>'image/svg+xml']; + + if (array_key_exists($filext, $serve_rawfiles) && file_exists(self::$cmd)) { + $staticfilecwd = getcwd(); + $staticfilerealpath = realpath(self::$cmd); + if(strpos($staticfilerealpath,$staticfilecwd) !== 0) { + header("HTTP/1.1 404 Not Found", true, 404); + killme(); + } + + $staticfileetag = '"'.md5($staticfilerealpath.filemtime(self::$cmd)).'"'; + header("ETag: ".$staticfileetag); + header("Cache-control: max-age=2592000"); + if(isset($_SERVER['HTTP_IF_NONE_MATCH'])) { + // If HTTP_IF_NONE_MATCH is same as the generated ETag => content is the same as browser cache + // So send a 304 Not Modified response header and exit + if($_SERVER['HTTP_IF_NONE_MATCH'] == $staticfileetag) { + header('HTTP/1.1 304 Not Modified', true, 304); + killme(); + } + } + header("Content-type: ".$serve_rawfiles[$filext]); + $handle = fopen(self::$cmd, "rb"); + fpassthru($handle); + fclose($handle); + killme(); + } + // unix style "homedir" if((substr(self::$cmd, 0, 1) === '~') || (substr(self::$cmd, 0, 1) === '@')) |