]> git.wh0rd.org Git - tt-rss.git/commitdiff
implement new version checking
authorAndrew Dolgov <fox@bah.spb.su>
Sun, 20 Aug 2006 04:27:48 +0000 (05:27 +0100)
committerAndrew Dolgov <fox@bah.spb.su>
Sun, 20 Aug 2006 04:27:48 +0000 (05:27 +0100)
backend.php
config.php-dist
functions.php
sanity_check.php

index 36fe325379fd66ef5191a1b6059b933efcb00a85..a218ff54f3f4441588c0c3c04ad78008632d28b3 100644 (file)
 
                } else {
 
+                       print check_for_update($link);
+
                        if (!SINGLE_USER_MODE) {
 
                                $result = db_query($link, "SELECT id,email FROM ttrss_users
index 5ce0e8c22e6ab2f40f68384bba371d1534549db0..97e0e93ff514b3e27e257fb7da14dae8f6201744 100644 (file)
        // Stop updating feeds of user who was never logged in
        // in specified amount of days. 0 disables.
 
-       define('CONFIG_VERSION', 3);
+       define('CHECK_FOR_NEW_VERSION', true);
+       // Check for new versions of tt-rss when entering preferences.
+
+       define('CONFIG_VERSION', 4);
        // Expected config version. Please update this option in config.php
        // if necessary (after migrating all new options from this file).
 
index 5feba77f08b1953058a7966bf199163797a6e99d..b62f27eaf81c5a3f8a5ba008c98e43a3ed6cfe8c 100644 (file)
 
                return $res;
        }
+
+       function check_for_update($link) {
+               $releases_feed = "http://tt-rss.spb.ru/releases.rss";
+
+               if (!CHECK_FOR_NEW_VERSION || $_SESSION["access_level"] < 10) {
+                       return;
+               }
+
+               error_reporting(0);
+               $rss = fetch_rss($releases_feed);
+               error_reporting (DEFAULT_ERROR_LEVEL);
+
+               if ($rss) {
+
+                       $items = $rss->items;
+
+                       if (!$items || !is_array($items)) $items = $rss->entries;
+                       if (!$items || !is_array($items)) $items = $rss;
+
+                       if (!is_array($items)) {
+                               return;
+                       }
+
+                       $last_item = $items[0];
+
+                       $last_version = trim(preg_replace("/(Milestone)|(completed)/", "", $last_item["title"]));
+                       $cur_version = preg_replace("/\.99/", "", VERSION);
+
+                       $release_url = $last_item["link"];
+
+                       if ($cur_version != $last_version) {
+                               return "<div class=\"notice\"><a target=\"_new\" href=\"$release_url\">
+                                               New version of Tiny-Tiny RSS is available.</a></div>";
+                       }
+               }
+       }
 ?>
index 1addd7b7e94e65affbe58fd256ad018193cabf13..ba738b9da8d0eb59026d6680c60ab6390c23b44c 100644 (file)
@@ -1,5 +1,5 @@
 <?php
-       define('EXPECTED_CONFIG_VERSION', 3);
+       define('EXPECTED_CONFIG_VERSION', 4);
 
        if (!file_exists("config.php")) {
                print "<b>Fatal Error</b>: You forgot to copy