]> git.wh0rd.org - tt-rss.git/commitdiff
automatically logout user when session expires
authorAndrew Dolgov <fox@bah.spb.su>
Sat, 19 Nov 2005 14:46:23 +0000 (15:46 +0100)
committerAndrew Dolgov <fox@bah.spb.su>
Sat, 19 Nov 2005 14:46:23 +0000 (15:46 +0100)
backend.php
error.php
tt-rss.js

index 5cb58fb607b7a11d52be99a7fb67cb8e72ace2d8..4b9d3a7f3e1bfbf32a38e000ccca6bcab062c829 100644 (file)
@@ -1,7 +1,21 @@
 <?
        session_start();
 
-       if (!$_SESSION["uid"]) { exit; }
+       $op = $_REQUEST["op"];
+
+       if (($op == "rpc" || $op == "updateAllFeeds" || 
+                       $op == "forceUpdateAllFeeds") && !$_REQUEST["noxml"]) {
+               header("Content-Type: application/xml");
+       }
+
+       if (!$_SESSION["uid"]) {
+
+               if (($op == "rpc" || $op == "updateAllFeeds" || 
+                       $op == "forceUpdateAllFeeds")) {
+                       print "<error error-code=\"6\"/>";
+               }
+               exit;
+       }
 
        define(SCHEMA_VERSION, 2);
 
        require_once "functions.php";
        require_once "magpierss/rss_fetch.inc";
 
-       $op = $_REQUEST["op"];
-
-       if (($op == "rpc" || $op == "updateAllFeeds") && !$_REQUEST["noxml"]) {
-               header("Content-Type: application/xml");
-       }
-
        $script_started = getmicrotime();
 
        $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME); 
                                $error_code = 5;
                        }
 
-                       print "<error code='$error_code'/>";
+                       print "<error error-code='$error_code'/>";
                }
 
                if ($subop == "globalPurge") {
index 1fd59ed700ee5873fe4e4b45b7c4eff1947da16a..1569d309efc34364d36fe98fe6b948315c7c922e 100644 (file)
--- a/error.php
+++ b/error.php
 
        $ERRORS[5] = "Incorrect database schema version.";
 
+       $ERRORS[6] = "Not authorized.";
+
+       if ($_GET["c"] == 6) {
+               header("Location: login.php");
+       }
+
 ?>
 
 <html>
index e6dbc1b9c81d76bc83679381b377a3ed6083a7b2..70412fcb42762d6cb751bed0977b244f43224cc7 100644 (file)
--- a/tt-rss.js
+++ b/tt-rss.js
@@ -70,7 +70,7 @@ function refetch_callback() {
                        notify("refetch_callback: backend did not return valid XML");
                        return;
                }
-
+       
                var reply = xmlhttp.responseXML.firstChild;
 
                if (!reply) {
@@ -78,6 +78,12 @@ function refetch_callback() {
                        return;
                } 
 
+               var error_code = reply.getAttribute("error-code");
+       
+               if (error_code && error_code != 0) {
+                       return fatalError(error_code);
+               }
+
                var f_document = window.frames["feeds-frame"].document;
 
                for (var l = 0; l < reply.childNodes.length; l++) {
@@ -133,7 +139,7 @@ function backend_sanity_check_callback() {
                        return;
                }
 
-               var error_code = reply.getAttribute("code");
+               var error_code = reply.getAttribute("error-code");
        
                if (error_code && error_code != 0) {
                        return fatalError(error_code);