3 * @file view/theme/vier/style.php
5 use Friendica\Core\Logger;
6 use Friendica\Core\Config;
7 use Friendica\Core\PConfig;
9 use Friendica\Model\Profile;
11 $uid = $_REQUEST['puid'] ?? 0;
13 $style = DI::pConfig()->get($uid, 'vier', 'style');
16 $style = Config::get('vier', 'style');
26 $style = \Friendica\Util\Strings::sanitizeFilePathItem($style);
28 foreach (['style', $style] as $file) {
29 $stylecssfile = $THEMEPATH . DIRECTORY_SEPARATOR . $file .'.css';
30 if (file_exists($stylecssfile)) {
31 $stylecss .= file_get_contents($stylecssfile);
32 $stylemodified = filemtime($stylecssfile);
33 if ($stylemodified > $modified) {
34 $modified = $stylemodified;
37 //TODO: use Logger::ERROR?
38 Logger::log('Error: missing file: "' . $stylecssfile .'" (userid: '. $uid .')');
41 $modified = gmdate('r', $modified);
43 $etag = md5($stylecss);
45 // Only send the CSS file if it was changed
46 header('Cache-Control: public');
47 header('ETag: "'.$etag.'"');
48 header('Last-Modified: '.$modified);
50 if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) || isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
51 $cached_modified = gmdate('r', strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']));
52 $cached_etag = str_replace(['"', "-gzip"], ['', ''],
53 stripslashes($_SERVER['HTTP_IF_NONE_MATCH']));
55 if (($cached_modified == $modified) && ($cached_etag == $etag)) {
56 header('HTTP/1.1 304 Not Modified');