]> git.wh0rd.org - tt-rss.git/commitdiff
require version information in all additional themes
authorAndrew Dolgov <noreply@fakecake.org>
Tue, 9 Dec 2014 12:16:53 +0000 (15:16 +0300)
committerAndrew Dolgov <noreply@fakecake.org>
Tue, 9 Dec 2014 12:16:53 +0000 (15:16 +0300)
classes/pref/prefs.php
include/functions2.php
index.php
prefs.php
themes/night.css

index 57123723912d628ed9abf7cc2f73386dcc112eb0..da11f55e1bed81f454a5af0a334808caa89fed8c 100644 (file)
@@ -571,7 +571,8 @@ class Pref_Prefs extends Handler_Protected {
 
                        } else if ($pref_name == "USER_CSS_THEME") {
 
-                               $themes = array_map("basename", glob("themes/*.css"));
+                               $themes = array_filter(array_map("basename", glob("themes/*.css")),
+                                       "theme_valid");
 
                                print_select($pref_name, $value, $themes,
                                        'dojoType="dijit.form.Select"');
index 31ca98035e953b87fb940a733d4dd68a42c94200..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;
                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;
+       }
 ?>
index 74498b8f45a7f4a3b1ee47feeba2d74422d03674..4f2a9a860dd9292e97a77efd0813c71b20c6614c 100644 (file)
--- a/index.php
+++ b/index.php
@@ -65,7 +65,7 @@
 
        <?php if ($_SESSION["uid"]) {
                $theme = get_pref( "USER_CSS_THEME", $_SESSION["uid"], false);
-               if ($theme && file_exists("themes/$theme")) {
+               if ($theme && theme_valid("$theme")) {
                        echo stylesheet_tag("themes/$theme");
                } else {
                        echo stylesheet_tag("themes/default.css");
index cc62677981dfc30f2632bb19a69efda228c43928..191f452c4e11cad86e0639cbe238ef45447244e6 100644 (file)
--- a/prefs.php
+++ b/prefs.php
@@ -41,7 +41,7 @@
 
        <?php if ($_SESSION["uid"]) {
                $theme = get_pref( "USER_CSS_THEME", $_SESSION["uid"], false);
-               if ($theme && file_exists("themes/$theme")) {
+               if ($theme && theme_valid("$theme")) {
                        echo stylesheet_tag("themes/$theme");
                } else {
                        echo stylesheet_tag("themes/default.css");
index 78b73f09ae5a0900f96a60b4028bf5584459327f..5a236a911ed5fbb8a9b6c20ba64bc23b6cc15460 100644 (file)
@@ -1,3 +1,4 @@
+/* supports-version:1.15 */
 @import "default.css";
 
 body#ttrssMain #feeds-holder {