]> git.mxchange.org Git - friendica.git/blob - view/theme/vier/style.php
934e51ee2542315066f858f10f91de337e2911e7
[friendica.git] / view / theme / vier / style.php
1 <?php
2
3 use Friendica\Core\Config;
4 use Friendica\Core\PConfig;
5
6 $uid = get_theme_uid();
7
8 $style = PConfig::get($uid, 'vier', 'style');
9
10 if ($style == "")
11         $style = Config::get('vier', 'style');
12
13 if ($style == "")
14         $style = "plus";
15
16 if ($style == "flat")
17         $stylecssfile = 'view/theme/vier/flat.css';
18 else if ($style == "netcolour")
19         $stylecssfile = 'view/theme/vier/netcolour.css';
20 else if ($style == "breathe")
21         $stylecssfile = 'view/theme/vier/breathe.css';
22 else if ($style == "plus")
23         $stylecssfile = 'view/theme/vier/plus.css';
24 else if ($style == "dark")
25         $stylecssfile = 'view/theme/vier/dark.css';
26
27 if (file_exists($THEMEPATH."//style.css")) {
28         $stylecss = file_get_contents($THEMEPATH."//style.css")."\n";
29         $modified = filemtime($THEMEPATH."//style.css");
30 }
31
32 $stylemodified = filemtime($stylecssfile);
33 $stylecss .= file_get_contents($stylecssfile);
34
35 if ($stylemodified > $modified)
36         $modified = $stylemodified;
37
38 $modified = gmdate('r', $modified);
39
40 $etag = md5($stylecss);
41
42 // Only send the CSS file if it was changed
43 header('Cache-Control: public');
44 header('ETag: "'.$etag.'"');
45 header('Last-Modified: '.$modified);
46
47 if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) || isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
48
49         $cached_modified = gmdate('r', strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']));
50         $cached_etag = str_replace(array('"', "-gzip"), array('', ''),
51                                 stripslashes($_SERVER['HTTP_IF_NONE_MATCH']));
52
53         if (($cached_modified == $modified) && ($cached_etag == $etag)) {
54                 header('HTTP/1.1 304 Not Modified');
55                 exit();
56         }
57 }
58 echo $stylecss;