- break;
-
- }
-
- outputFeedList($link, $tags);
- break; // feeds
-
- case "view":
-
- $id = db_escape_string($_GET["id"]);
- $feed_id = db_escape_string($_GET["feed"]);
- $cids = split(",", db_escape_string($_GET["cids"]));
- $mode = db_escape_string($_GET["mode"]);
- $omode = db_escape_string($_GET["omode"]);
-
- $csync = $_GET["csync"];
-
- print "<reply>";
-
- // in prefetch mode we only output requested cids, main article
- // just gets marked as read (it already exists in client cache)
-
- if ($mode == "") {
- outputArticleXML($link, $id, $feed_id);
- } else if ($mode == "zoom") {
- outputArticleXML($link, $id, $feed_id, true, true);
- } else {
- catchupArticleById($link, $id, 0);
- ccache_update($link, $feed_id, $_SESSION["uid"]);
- }
-
- if (!$_SESSION["bw_limit"]) {
- foreach ($cids as $cid) {
- if ($cid) {
- outputArticleXML($link, $cid, $feed_id, false);
- }
- }
- }
-
-// if (get_pref($link, "SYNC_COUNTERS") || ($mode == "prefetch" && $csync)) {
-
- if (time() - $_SESSION["view:counters_stamp"] > 10) {
- print "<counters>";
- getAllCounters($link, $omode);
- print "</counters>";
- $_SESSION["view:counters_stamp"] = time();
- }
-
- print "</reply>";
- break; // view
-
- case "viewfeed":
-
- $print_exec_time = true;
- $timing_info = getmicrotime();
-
- print "<reply>";
-
- if ($_GET["debug"]) $timing_info = print_checkpoint("0", $timing_info);
-
- $omode = db_escape_string($_GET["omode"]);
-
- $feed = db_escape_string($_GET["feed"]);
- $subop = db_escape_string($_GET["subop"]);
- $view_mode = db_escape_string($_GET["view_mode"]);
- $limit = db_escape_string($_GET["limit"]);
- $cat_view = db_escape_string($_GET["cat"]);
- $next_unread_feed = db_escape_string($_GET["nuf"]);
- $offset = db_escape_string($_GET["skip"]);
- $vgroup_last_feed = db_escape_string($_GET["vgrlf"]);
- $csync = $_GET["csync"];
- $order_by = db_escape_string($_GET["order_by"]);
-
- /* 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);
- set_pref($link, "_DEFAULT_VIEW_ORDER_BY", $order_by);
-
- if (!$cat_view && preg_match("/^[0-9][0-9]*$/", $feed)) {
- db_query($link, "UPDATE ttrss_feeds SET last_viewed = NOW()
- WHERE id = '$feed' AND owner_uid = ".$_SESSION["uid"]);
- }
-
- 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;
-
- switch ($order_by) {
- case "date":
- if (get_pref($link, 'REVERSE_HEADLINES', $owner_uid)) {
- $override_order = "updated";
- } else {
- $override_order = "updated DESC";
- }
- break;
-
- case "title":
- $override_order = "updated DESC";
- break;
-
- case "score":
- $override_order = "score DESC";
- break;
- }
-
- $ret = outputHeadlinesList($link, $feed, $subop,
- $view_mode, $limit, $cat_view, $next_unread_feed, $offset,
- $vgroup_last_feed, $override_order);
-
- $topmost_article_ids = $ret[0];
- $headlines_count = $ret[1];
- $returned_feed = $ret[2];
- $disable_cache = $ret[3];
- $vgroup_last_feed = $ret[4];
-
- print "]]></headlines>";
-
- print "<headlines-count value=\"$headlines_count\"/>";
- print "<vgroup-last-feed value=\"$vgroup_last_feed\"/>";
-
- $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("10", $timing_info);
-
- if (is_array($topmost_article_ids) && !get_pref($link, 'COMBINED_DISPLAY_MODE') && !$_SESSION["bw_limit"]) {
- print "<articles>";
- foreach ($topmost_article_ids as $id) {
- outputArticleXML($link, $id, $feed, false);
- }
- print "</articles>";
- }
-
- if ($_GET["debug"]) $timing_info = print_checkpoint("20", $timing_info);
-
-
-// if (get_pref($link, "SYNC_COUNTERS") ||
-// time() - $_SESSION["get_all_counters_stamp"] > $viewfeed_ctr_interval) {
-// 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();