]> git.wh0rd.org - tt-rss.git/blobdiff - backend.php
update translations
[tt-rss.git] / backend.php
index 33c3a45d4af923e1a1c732ab75a7a57b70f969a0..925f81087bdeab4799658a191110a08f6b5bebe2 100644 (file)
        require_once "modules/pref-filters.php";
        require_once "modules/pref-labels.php";
        require_once "modules/pref-users.php";
-       require_once "modules/pref-feed-browser.php"; 
 
        if (!sanity_check($link)) { return; }
 
 
                        }
 
+                       $_SESSION["viewfeed:counters_stamp"] = time();
+
                        outputFeedList($link, $tags);
                break; // feeds
 
                                }
                        }
 
-
 //                     if (get_pref($link, "SYNC_COUNTERS") || ($mode == "prefetch" && $csync)) {
+
+                       if (time() - $_SESSION["view:counters_stamp"] > 3 && $mode == "prefetch") {
                                print "<counters>";
                                getAllCounters($link, $omode);
                                print "</counters>";
-//                     }
+                               $_SESSION["view:counters_stamp"] = time();
+                       }
 
                        print "</reply>";
                break; // view
                        $csync = $_GET["csync"];
                        $order_by = db_escape_string($_GET["order_by"]);
 
-                       ccache_update($link, $feed, $_SESSION["uid"], $cat_view);
+                       /* Updating a label ccache means recalculating all of the caches
+                        * so for performance reasons we don't do that here */
+
+//                     if (time() - $_SESSION["viewfeed:ccache_update_stamp"] > 120) {
+                               if ($feed >= 0) {
+                                       ccache_update($link, $feed, $_SESSION["uid"], $cat_view);
+                               }
+                               $_SESSION["viewfeed:ccache_update_stamp"] = time();
+//                     }
 
                        set_pref($link, "_DEFAULT_VIEW_MODE", $view_mode);
                        set_pref($link, "_DEFAULT_VIEW_LIMIT", $limit);
                                        WHERE id = '$feed' AND owner_uid = ".$_SESSION["uid"]);
                        }
 
-                       print "<headlines id=\"$feed\"><![CDATA[";
+                       if (!$next_unread_feed) {
+                               print "<headlines id=\"$feed\" is_cat=\"$cat_view\"><![CDATA[";
+                       } else {
+                               print "<headlines id=\"$next_unread_feed\" is_cat=\"$cat_view\"><![CDATA[";
+                       }
                
                        $override_order = false;
 
                        print "<headlines-count value=\"$headlines_count\"/>";
                        print "<vgroup-last-feed value=\"$vgroup_last_feed\"/>";
 
-                       $headlines_unread = ccache_find($link, $returned_feed, $_SESSION["uid"]);
+                       $headlines_unread = ccache_find($link, $returned_feed, $_SESSION["uid"],
+                                       $cat_view, true);
+
+                       if ($headlines_unread == -1) {
+                               $headlines_unread = getFeedUnread($link, $returned_feed, $cat_view);
+
+                       }
 
                        print "<headlines-unread value=\"$headlines_unread\"/>";
                        printf("<disable-cache value=\"%d\"/>", $disable_cache);
 
                        if ($_GET["debug"]) $timing_info = print_checkpoint("20", $timing_info);
 
-                       $viewfeed_ctr_interval = 300;
-
-                       if ($csync || $_SESSION["bw_limit"]) {
-                               $viewfeed_ctr_interval = 60;
-                       }
 
 //                     if (get_pref($link, "SYNC_COUNTERS") ||                         
 //                                     time() - $_SESSION["get_all_counters_stamp"] > $viewfeed_ctr_interval) {
 //                             print "</counters>";
 //                     }
 
-                       if (get_pref($link, 'COMBINED_DISPLAY_MODE')) {
-                               print "<counters>";
-                               getAllCounters($link, $omode, $feed);
-                               print "</counters>";
+                       if (get_pref($link, 'COMBINED_DISPLAY_MODE') || $subop || 
+                               time() - $_SESSION["viewfeed:counters_stamp"] > 60) {
+                               if (!$offset) {
+                                       print "<counters>";
+                                       getAllCounters($link, $omode, $feed);
+                                       print "</counters>";
+                                       $_SESSION["viewfeed:counters_stamp"] = time();
+                               }
                        }
 
                        if ($_GET["debug"]) $timing_info = print_checkpoint("30", $timing_info);
                        $match_on = db_escape_string($_GET["m"]);
                        $search_mode = db_escape_string($_GET["smode"]);
 
+                       if (SINGLE_USER_MODE) {
+                               authenticate_user($link, "admin", null);
+                       }
+
                        if (!$_SESSION["uid"] && $user && $pass) {
                                authenticate_user($link, $user, $pass);
                        }
                        }
                break; // rss
 
-               case "labelFromSearch":
-                       $search = db_escape_string($_GET["search"]);
-                       $search_mode = db_escape_string($_GET["smode"]);
-                       $match_on = db_escape_string($_GET["match"]);
-                       $is_cat = db_escape_string($_GET["is_cat"]);
-                       $title = db_escape_string($_GET["title"]);
-                       $feed = sprintf("%d", $_GET["feed"]);
-
-                       $label_qparts = array();
-
-                       $search_expr = getSearchSql($search, $match_on);
-
-                       if ($is_cat) {
-                               if ($feed != 0) {
-                                       $search_expr .= " AND ttrss_feeds.cat_id = $feed ";
-                               } else {
-                                       $search_expr .= " AND ttrss_feeds.cat_id IS NULL ";
-                               }
-                       } else {
-                               if ($search_mode == "all_feeds") {
-                                       // NOOP
-                               } else if ($search_mode == "this_cat") {
-
-                                       $tmp_result = db_query($link, "SELECT cat_id
-                                               FROM ttrss_feeds WHERE id = '$feed'");
-
-                                       $cat_id = db_fetch_result($tmp_result, 0, "cat_id");
-
-                                       if ($cat_id > 0) {
-                                               $search_expr .= " AND ttrss_feeds.cat_id = $cat_id ";
-                                       } else {
-                                               $search_expr .= " AND ttrss_feeds.cat_id IS NULL ";
-                                       }
-                               } else {
-                                       $search_expr .= " AND ttrss_feeds.id = $feed ";
-                               }
-
-                       }
-
-                       $search_expr = db_escape_string($search_expr);
-
-                       print $search_expr;
-
-                       if ($title) {
-                               $result = db_query($link,
-                                       "INSERT INTO ttrss_labels (sql_exp,description,owner_uid) 
-                                       VALUES ('$search_expr', '$title', '".$_SESSION["uid"]."')");
-                       }
-               break; // labelFromSearch
-
                case "getUnread":
                        $login = db_escape_string($_GET["login"]);