3 * @file view/theme/vier/style.php
5 use Friendica\Core\Logger;
6 use Friendica\Core\Config;
9 $uid = $_REQUEST['puid'] ?? 0;
11 $style = DI::pConfig()->get($uid, 'vier', 'style');
14 $style = DI::config()->get('vier', 'style');
24 $style = \Friendica\Util\Strings::sanitizeFilePathItem($style);
26 foreach (['style', $style] as $file) {
27 $stylecssfile = $THEMEPATH . DIRECTORY_SEPARATOR . $file .'.css';
28 if (file_exists($stylecssfile)) {
29 $stylecss .= file_get_contents($stylecssfile);
30 $stylemodified = filemtime($stylecssfile);
31 if ($stylemodified > $modified) {
32 $modified = $stylemodified;
35 //TODO: use Logger::ERROR?
36 Logger::log('Error: missing file: "' . $stylecssfile .'" (userid: '. $uid .')');
39 $modified = gmdate('r', $modified);
41 $etag = md5($stylecss);
43 // Only send the CSS file if it was changed
44 header('Cache-Control: public');
45 header('ETag: "'.$etag.'"');
46 header('Last-Modified: '.$modified);
48 if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) || isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
49 $cached_modified = gmdate('r', strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']));
50 $cached_etag = str_replace(['"', "-gzip"], ['', ''],
51 stripslashes($_SERVER['HTTP_IF_NONE_MATCH']));
53 if (($cached_modified == $modified) && ($cached_etag == $etag)) {
54 header('HTTP/1.1 304 Not Modified');