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 = $_REQUEST['puid'] ?? 0;
12 $style = PConfig::get($uid, 'vier', 'style');
15 $style = Config::get('vier', 'style');
25 $style = \Friendica\Util\Strings::sanitizeFilePathItem($style);
27 foreach (['style', $style] as $file) {
28 $stylecssfile = $THEMEPATH . DIRECTORY_SEPARATOR . $file .'.css';
29 if (file_exists($stylecssfile)) {
30 $stylecss .= file_get_contents($stylecssfile);
31 $stylemodified = filemtime($stylecssfile);
32 if ($stylemodified > $modified) {
33 $modified = $stylemodified;
36 //TODO: use Logger::ERROR?
37 Logger::log('Error: missing file: "' . $stylecssfile .'" (userid: '. $uid .')');
40 $modified = gmdate('r', $modified);
42 $etag = md5($stylecss);
44 // Only send the CSS file if it was changed
45 header('Cache-Control: public');
46 header('ETag: "'.$etag.'"');
47 header('Last-Modified: '.$modified);
49 if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) || isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
50 $cached_modified = gmdate('r', strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']));
51 $cached_etag = str_replace(['"', "-gzip"], ['', ''],
52 stripslashes($_SERVER['HTTP_IF_NONE_MATCH']));
54 if (($cached_modified == $modified) && ($cached_etag == $etag)) {
55 header('HTTP/1.1 304 Not Modified');