Friendica Communications Platform (please note that this is a clone of the repository at github, issues are handled there) https://friendi.ca
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 
 
 

59 rindas
1.4 KiB

  1. <?php
  2. /**
  3. * @file view/theme/vier/style.php
  4. */
  5. use Friendica\Core\Logger;
  6. use Friendica\Core\Config;
  7. use Friendica\DI;
  8. $uid = $_REQUEST['puid'] ?? 0;
  9. $style = DI::pConfig()->get($uid, 'vier', 'style');
  10. if (empty($style)) {
  11. $style = Config::get('vier', 'style');
  12. }
  13. if (empty($style)) {
  14. $style = "plus";
  15. }
  16. $stylecss = '';
  17. $modified = '';
  18. $style = \Friendica\Util\Strings::sanitizeFilePathItem($style);
  19. foreach (['style', $style] as $file) {
  20. $stylecssfile = $THEMEPATH . DIRECTORY_SEPARATOR . $file .'.css';
  21. if (file_exists($stylecssfile)) {
  22. $stylecss .= file_get_contents($stylecssfile);
  23. $stylemodified = filemtime($stylecssfile);
  24. if ($stylemodified > $modified) {
  25. $modified = $stylemodified;
  26. }
  27. } else {
  28. //TODO: use Logger::ERROR?
  29. Logger::log('Error: missing file: "' . $stylecssfile .'" (userid: '. $uid .')');
  30. }
  31. }
  32. $modified = gmdate('r', $modified);
  33. $etag = md5($stylecss);
  34. // Only send the CSS file if it was changed
  35. header('Cache-Control: public');
  36. header('ETag: "'.$etag.'"');
  37. header('Last-Modified: '.$modified);
  38. if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) || isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
  39. $cached_modified = gmdate('r', strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']));
  40. $cached_etag = str_replace(['"', "-gzip"], ['', ''],
  41. stripslashes($_SERVER['HTTP_IF_NONE_MATCH']));
  42. if (($cached_modified == $modified) && ($cached_etag == $etag)) {
  43. header('HTTP/1.1 304 Not Modified');
  44. exit();
  45. }
  46. }
  47. echo $stylecss;