]> git.mxchange.org Git - friendica.git/blob - view/theme/vier/style.php
[frio] Fix wrongly removed content wrapper and fix CSS instead. (#5496) (#5505)
[friendica.git] / view / theme / vier / style.php
1 <?php
2 /**
3  * @file view/theme/vier/style.php
4  */
5 use Friendica\Core\Config;
6 use Friendica\Core\PConfig;
7 use Friendica\Model\Profile;
8
9 $uid = Profile::getThemeUid();
10
11 $style = PConfig::get($uid, 'vier', 'style');
12
13 if (empty($style)) {
14         $style = Config::get('vier', 'style');
15 }
16
17 if (empty($style)) {
18         $style = "plus";
19 }
20
21 $stylecss = '';
22 $modified = '';
23
24 foreach (['style', $style] as $file) {
25         $stylecssfile = $THEMEPATH . DIRECTORY_SEPARATOR . $file .'.css';
26         if (file_exists($stylecssfile)) {
27                 $stylecss .= file_get_contents($stylecssfile);
28                 $stylemodified = filemtime($stylecssfile);
29                 if ($stylemodified > $modified) {
30                         $modified = $stylemodified;
31                 }
32         } else {
33                 //TODO: use LOGGER_ERROR?
34                 logger('Error: missing file: "' . $stylecssfile .'" (userid: '. $uid .')');
35         }
36 }
37 $modified = gmdate('r', $modified);
38
39 $etag = md5($stylecss);
40
41 // Only send the CSS file if it was changed
42 header('Cache-Control: public');
43 header('ETag: "'.$etag.'"');
44 header('Last-Modified: '.$modified);
45
46 if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) || isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
47         $cached_modified = gmdate('r', strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']));
48         $cached_etag = str_replace(['"', "-gzip"], ['', ''],
49                                 stripslashes($_SERVER['HTTP_IF_NONE_MATCH']));
50
51         if (($cached_modified == $modified) && ($cached_etag == $etag)) {
52                 header('HTTP/1.1 304 Not Modified');
53                 exit();
54         }
55 }
56 echo $stylecss;