]> git.wh0rd.org - tt-rss.git/blobdiff - include/functions2.php
require version information in all additional themes
[tt-rss.git] / include / functions2.php
index 29594076c1c6baaac8fc87560a41652863b269c8..45c73b3736487df1d46af8a11035b6e6cf941664 100644 (file)
                $params["default_view_order_by"] = get_pref("_DEFAULT_VIEW_ORDER_BY");
                $params["bw_limit"] = (int) $_SESSION["bw_limit"];
                $params["label_base_index"] = (int) LABEL_BASE_INDEX;
-               $params["theme"] = get_pref("USER_CSS_THEME", false, false);
+
+               $theme = get_pref( "USER_CSS_THEME", false, false);
+               $params["theme"] = theme_valid("$theme") ? $theme : "";
+
                $params["plugins"] = implode(", ", PluginHost::getInstance()->get_plugin_names());
 
                $params["php_platform"] = PHP_OS;
                foreach ($entries as $entry) {
                        if (!iframe_whitelisted($entry)) {
                                $entry->setAttribute('sandbox', 'allow-scripts');
+                       } else {
+                               if ($_SERVER['HTTPS'] == "on") {
+                                       $entry->setAttribute("src",
+                                               str_replace("http://", "https://",
+                                                       $entry->getAttribute("src")));
+                               }
                        }
-
                }
 
                $allowed_elements = array('a', 'address', 'audio', 'article', 'aside',
                return LABEL_BASE_INDEX - 1 + abs($feed);
        }
 
+       function theme_valid($file) {
+               if ($file == "default.css") return true; // needed for array_filter
+               $file = "themes/" . basename($file);
+
+               if (file_exists($file) && is_readable($file)) {
+                       $fh = fopen($file, "r");
+
+                       if ($fh) {
+                               $header = fgets($fh);
+                               fclose($fh);
+
+                               return strpos($header, "supports-version:" . VERSION_STATIC) !== FALSE;
+                       }
+               }
+
+               return false;
+       }
 ?>