]> git.wh0rd.org - tt-rss.git/blobdiff - backend.php
backend/loading: add missed break
[tt-rss.git] / backend.php
index d62b2db2d3e95a26573766ee6daf10839b9f735c..308ade0a727a44e1230f28e5d1f2e6c362dba61b 100644 (file)
@@ -44,8 +44,6 @@
        $subop = $_REQUEST["subop"];
        $mode = $_REQUEST["mode"];
 
-       $print_exec_time = false;
-
        if ((!$op || $op == "rss" || $op == "dlg") && !$_REQUEST["noxml"]) {
                        header("Content-Type: application/xml; charset=utf-8");
        } else {
@@ -62,7 +60,7 @@
 
        if (!($_SESSION["uid"] && validate_session($link)) && $op != "globalUpdateFeeds" &&
                        $op != "rss" && $op != "getUnread" && $op != "getProfiles" &&
-                       $op != "pubsub") {
+                       $op != "logout" && $op != "pubsub") {
 
                header("Content-Type: text/plain");
                print json_encode(array("error" => array("code" => 6)));
 
        $error = sanity_check($link);
 
-       if ($error['code'] != 0) {
+       if ($error['code'] != 0 && $op != "logout") {
                print json_encode(array("error" => $error));
                return;
        }
                                array_push($articles, format_article($link, $id, false));
                        } else if ($mode == "zoom") {
                                array_push($articles, format_article($link, $id, false, true, true));
+                       } else if ($mode == "raw") {
+                               if ($_REQUEST['html']) {
+                                       header("Content-Type: text/html");
+                                       print '<link rel="stylesheet" type="text/css" href="tt-rss.css"/>';
+                               }
+
+                               $article = format_article($link, $id, false);
+                               print $article['content'];
+                               return;
                        } else {
                                catchupArticleById($link, $id, 0);
                        }
                                print "-1;User not found";
                        }
 
-                       $print_exec_time = false;
                break; // getUnread
 
                case "digestTest":
                        print_r(prepare_headlines_digest($link, $_SESSION["uid"]));
-                       $print_exec_time = false;
                break; // digestTest
 
                case "digestSend":
                        send_headlines_digests($link);
-                       $print_exec_time = false;
                break; // digestSend
 
                case "loading":
+                       header("Content-type: text/html");
                        print __("Loading, please wait...") . " " .
                                "<img src='images/indicator_tiny.gif'>";
+               break;
 
                case "getProfiles":
                        $login = db_escape_string($_REQUEST["login"]);
                                        db_query($link, "UPDATE ttrss_feeds SET pubsub_state = 2
                                                WHERE id = '$feed_id'");
 
-                                       echo $_REQUEST['hub_challenge'];
+                                       print $_REQUEST['hub_challenge'];
+                                       return;
+
                                } else if ($mode == "unsubscribe") {
 
                                        db_query($link, "UPDATE ttrss_feeds SET pubsub_state = 0
                                                WHERE id = '$feed_id'");
 
-                                       echo $_REQUEST['hub_challenge'];
+                                       print $_REQUEST['hub_challenge'];
+                                       return;
+
                                } else if (!$mode) {
 
                                        // Received update ping, schedule feed update.
                        }
 
                break;
+
+               case "logout":
+                       logout_user();
+                       header("Location: tt-rss.php");
+               break;
+
+               default:
+                       header("Content-Type: text/plain");
+                       print json_encode(array("error" => array("code" => 7)));
+               break;
        } // Select action according to $op value.
 
        // We close the connection to database.
        db_close($link);
 ?>
-
-<?php if ($print_exec_time) { ?>
-<!-- <?php echo sprintf("Backend execution time: %.4f seconds", getmicrotime() - $script_started) ?> -->
-<?php } ?>