3 * @file view/theme/vier/style.php
5 use Friendica\Core\Logger;
6 use Friendica\Core\Config;
7 use Friendica\Core\PConfig;
8 use Friendica\Model\Profile;
10 $uid = defaults($_REQUEST, 'puid', 0);
12 $style = PConfig::get($uid, 'vier', 'style');
15 $style = Config::get('vier', 'style');
25 foreach (['style', $style] as $file) {
26 $stylecssfile = $THEMEPATH . DIRECTORY_SEPARATOR . $file .'.css';
27 if (file_exists($stylecssfile)) {
28 $stylecss .= file_get_contents($stylecssfile);
29 $stylemodified = filemtime($stylecssfile);
30 if ($stylemodified > $modified) {
31 $modified = $stylemodified;
34 //TODO: use Logger::ERROR?
35 Logger::log('Error: missing file: "' . $stylecssfile .'" (userid: '. $uid .')');
38 $modified = gmdate('r', $modified);
40 $etag = md5($stylecss);
42 // Only send the CSS file if it was changed
43 header('Cache-Control: public');
44 header('ETag: "'.$etag.'"');
45 header('Last-Modified: '.$modified);
47 if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) || isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
48 $cached_modified = gmdate('r', strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']));
49 $cached_etag = str_replace(['"', "-gzip"], ['', ''],
50 stripslashes($_SERVER['HTTP_IF_NONE_MATCH']));
52 if (($cached_modified == $modified) && ($cached_etag == $etag)) {
53 header('HTTP/1.1 304 Not Modified');