]> git.mxchange.org Git - friendica.git/blob - view/theme/vier/style.php
407e080550e13d31a23b0e91f031c8aa6c6a0d32
[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 ($style == "") {
14         $style = Config::get('vier', 'style');
15 }
16
17 if ($style == "") {
18         $style = "plus";
19 }
20
21 if ($style == "flat") {
22         $stylecssfile = 'view/theme/vier/flat.css';
23 } else if ($style == "netcolour") {
24         $stylecssfile = 'view/theme/vier/netcolour.css';
25 } else if ($style == "breathe") {
26         $stylecssfile = 'view/theme/vier/breathe.css';
27 } else if ($style == "plus") {
28         $stylecssfile = 'view/theme/vier/plus.css';
29 } else if ($style == "dark") {
30         $stylecssfile = 'view/theme/vier/dark.css';
31 } else if ($style == "plusminus") {
32         $stylecssfile = 'view/theme/vier/plusminus.css';
33 }
34
35 if (file_exists($THEMEPATH."//style.css")) {
36         $stylecss = file_get_contents($THEMEPATH."//style.css")."\n";
37         $modified = filemtime($THEMEPATH."//style.css");
38 }
39
40 $stylemodified = filemtime($stylecssfile);
41 $stylecss .= file_get_contents($stylecssfile);
42
43 if ($stylemodified > $modified) {
44         $modified = $stylemodified;
45 }
46
47 $modified = gmdate('r', $modified);
48
49 $etag = md5($stylecss);
50
51 // Only send the CSS file if it was changed
52 header('Cache-Control: public');
53 header('ETag: "'.$etag.'"');
54 header('Last-Modified: '.$modified);
55
56 if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) || isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
57
58         $cached_modified = gmdate('r', strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']));
59         $cached_etag = str_replace(array('"', "-gzip"), array('', ''),
60                                 stripslashes($_SERVER['HTTP_IF_NONE_MATCH']));
61
62         if (($cached_modified == $modified) && ($cached_etag == $etag)) {
63                 header('HTTP/1.1 304 Not Modified');
64                 exit();
65         }
66 }
67 echo $stylecss;