]> git.wh0rd.org Git - tt-rss.git/commitdiff
perform backend sanity check on startup, update schema version in backend.php
authorAndrew Dolgov <fox@madoka.spb.ru>
Wed, 16 Nov 2005 07:59:46 +0000 (08:59 +0100)
committerAndrew Dolgov <fox@madoka.spb.ru>
Wed, 16 Nov 2005 07:59:46 +0000 (08:59 +0100)
backend.php
functions.js
tt-rss.css
tt-rss.js

index 77812b981a5306ec2f5278e226d00682909fe738..2ed2f926640ac9a4b7e0e90d7ec7b986ee91b18f 100644 (file)
@@ -1,5 +1,5 @@
 <?
-       define(SCHEMA_VERSION, 1);
+       define(SCHEMA_VERSION, 2);
 
        $op = $_GET["op"];
 
@@ -28,6 +28,7 @@
                pg_query("set client_encoding = 'utf-8'");
        }
 
+/*
        $result = db_query($link, "SELECT schema_version FROM ttrss_version");
 
        $schema_version = db_fetch_result($result, 0, "schema_version");
@@ -37,7 +38,8 @@
                        (got version $schema_version; expected ".SCHEMA_VERSION.")";
                return;
        }
-       
+*/
+
        $fetch = $_GET["fetch"];
 
        /* FIXME this needs reworking */
 
                        print "Marked active page as read.";
                }
+
+               if ($subop == "sanityCheck") {
+
+                       $error_code = 0;
+
+                       $result = db_query($link, "SELECT schema_version FROM ttrss_version");
+
+                       $schema_version = db_fetch_result($result, 0, "schema_version");
+
+                       if ($schema_version != SCHEMA_VERSION) {
+                               $error_code = 5;
+                       }
+
+                       print "<error code='$error_code'/>";
+               }
        }
        
        if ($op == "feeds") {
index 78e3bbaaed8b2f97a4b1572cbb0b06cfce660a76..aa3169ac99c88122815c720afec3ceca2122bace 100644 (file)
@@ -416,4 +416,7 @@ function hideOrShowFeeds(doc, hide) {
 
 }
 
+function fatalError(code) {
+       window.location = "error.php?c=" + param_escape(code);
 
+}
index 0d6d223a485cc0654c54a1ce45792c8da7be5e72..271037a90c6c252f0864b2ed431adf80bb7a7e5c 100644 (file)
@@ -497,3 +497,9 @@ ul.nomarks {
        padding : 10px; 
 }
 
+div.bigErrorMsg {
+       border : 1px solid #c0c0c0;
+       background : #fff0f0;
+       padding : 30px;
+       margin : 20px;
+}
index 77f90303fcdfb05e9e214276a4a8d4d9cb6a6481..13b7e50a64d368f89ade399513db9cc84ab94406 100644 (file)
--- a/tt-rss.js
+++ b/tt-rss.js
@@ -121,6 +121,32 @@ function refetch_callback() {
        }
 }
 
+function backend_sanity_check_callback() {
+
+       if (xmlhttp.readyState == 4) {
+               
+               if (!xmlhttp.responseXML) {
+                       fatalError(3);
+                       return;
+               }
+
+               var reply = xmlhttp.responseXML.firstChild;
+
+               if (!reply) {
+                       fatalError(3);
+                       return;
+               }
+
+               var error_code = reply.getAttribute("code");
+       
+               if (error_code && error_code != 0) {
+                       return fatalError(error_code);
+               }
+
+               init_second_stage();
+       } 
+}
+
 function updateFeed(feed_id) {
 
        var query_str = "backend.php?op=rpc&subop=updateFeed&feed=" + feed_id;
@@ -297,7 +323,15 @@ function updateTitle(s) {
 
 function genericSanityCheck() {
 
-       if (!xmlhttp) {
+       if (!xmlhttp) fatalError(1);
+
+       setCookie("ttrss_vf_test", "TEST");
+       
+       if (getCookie("ttrss_vf_test") != "TEST") {
+               fatalError(2);
+       }
+
+/*     if (!xmlhttp) {
                document.getElementById("headlines").innerHTML = 
                        "<b>Fatal error:</b> This program requires XmlHttpRequest " + 
                        "to function properly. Your browser doesn't seem to support it.";
@@ -312,7 +346,7 @@ function genericSanityCheck() {
                        "to function properly. Your browser doesn't seem to support them.";
 
                return false;
-       }
+       } */
 
        return true;
 }
@@ -324,14 +358,19 @@ function init() {
        if (!genericSanityCheck()) 
                return;
 
+       xmlhttp.open("GET", "backend.php?op=rpc&subop=sanityCheck", true);
+       xmlhttp.onreadystatechange=backend_sanity_check_callback;
+       xmlhttp.send(null);
+
+}
+
+function init_second_stage() {
+
        setCookie("ttrss_vf_actfeed", "");
 
        updateFeedList(false, false);
        document.onkeydown = hotkey_handler;
 
-       setTimeout("timeout()", 1800*1000);
-       scheduleFeedUpdate(true);
-
        var content = document.getElementById("content");
 
        if (getCookie("ttrss_vf_vmode")) {
@@ -348,6 +387,10 @@ function init() {
 //             viewfeed(getCookie("ttrss_vf_actfeed"), 0, '');
 //     }
 
+       setTimeout("timeout()", 2*1000);
+//     scheduleFeedUpdate(true);
+
+
 }
 
 function quickMenuGo() {
@@ -493,3 +536,5 @@ function toggleDispRead() {
        }
 
 }
+
+