/* remove ill effects of magic quotes */
if (get_magic_quotes_gpc()) {
- $_GET = array_map('stripslashes', $_GET);
+ $_REQUEST = array_map('stripslashes', $_REQUEST);
$_POST = array_map('stripslashes', $_POST);
$_REQUEST = array_map('stripslashes', $_REQUEST);
$_COOKIE = array_map('stripslashes', $_COOKIE);
require_once "sessions.php";
require_once "modules/backend-rpc.php";
-/* if ($_GET["debug"]) {
+/* if ($_REQUEST["debug"]) {
define('DEFAULT_ERROR_LEVEL', E_ALL);
} else {
define('DEFAULT_ERROR_LEVEL', E_ERROR | E_WARNING | E_PARSE);
header("Content-Type: application/xml");
print_error_xml(7); exit;
}
-
+
+ if (SINGLE_USER_MODE) {
+ authenticate_user($link, "admin", null);
+ }
+
if (!($_SESSION["uid"] && validate_session($link)) && $op != "globalUpdateFeeds"
&& $op != "rss" && $op != "getUnread" && $op != "publish") {
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; }
ob_start("ob_gzhandler");
}
- $tags = $_GET["tags"];
+ $tags = $_REQUEST["tags"];
- $subop = $_GET["subop"];
+ $subop = $_REQUEST["subop"];
switch($subop) {
case "catchupAll":
db_query($link, "UPDATE ttrss_user_entries SET
last_read = NOW(),unread = false WHERE owner_uid = " . $_SESSION["uid"]);
+ ccache_zero_all($link, $_SESSION["uid"]);
+
break;
case "collapse":
- $cat_id = db_escape_string($_GET["cid"]);
-
- db_query($link, "UPDATE ttrss_feed_categories SET
- collapsed = NOT collapsed WHERE id = '$cat_id' AND owner_uid = " .
- $_SESSION["uid"]);
+ $cat_id = db_escape_string($_REQUEST["cid"]);
+ toggle_collapse_cat($link, $cat_id);
return;
break;
break;
case "catsort":
- $corder = db_escape_string($_GET["corder"]);
+ $corder = db_escape_string($_REQUEST["corder"]);
$cats = split(",", $corder);
}
+ $_SESSION["viewfeed:counters_stamp"] = time();
+
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"]);
+ $id = db_escape_string($_REQUEST["id"]);
+ $cids = split(",", db_escape_string($_REQUEST["cids"]));
+ $mode = db_escape_string($_REQUEST["mode"]);
+ $omode = db_escape_string($_REQUEST["omode"]);
- $csync = $_GET["csync"];
+ $csync = $_REQUEST["csync"];
print "<reply>";
// just gets marked as read (it already exists in client cache)
if ($mode == "") {
- outputArticleXML($link, $id, $feed_id);
+ outputArticleXML($link, $id, false);
} else if ($mode == "zoom") {
- outputArticleXML($link, $id, $feed_id, true, true);
+ outputArticleXML($link, $id, false, true, true);
} else {
catchupArticleById($link, $id, 0);
}
if (!$_SESSION["bw_limit"]) {
foreach ($cids as $cid) {
if ($cid) {
- outputArticleXML($link, $cid, $feed_id, false);
+ outputArticleXML($link, $cid, false, false);
}
}
}
+// if (get_pref($link, "SYNC_COUNTERS") || ($mode == "prefetch" && $csync)) {
- if (get_pref($link, "SYNC_COUNTERS") || ($mode == "prefetch" && $csync)) {
+ if (time() - $_SESSION["view:counters_stamp"] > 5 && $mode == "prefetch") {
print "<counters>";
getAllCounters($link, $omode);
print "</counters>";
+ $_SESSION["view:counters_stamp"] = time();
}
print "</reply>";
print "<reply>";
- if ($_GET["debug"]) $timing_info = print_checkpoint("0", $timing_info);
+ if ($_REQUEST["debug"]) $timing_info = print_checkpoint("0", $timing_info);
- $omode = db_escape_string($_GET["omode"]);
+ $omode = db_escape_string($_REQUEST["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"]);
+ $feed = db_escape_string($_REQUEST["feed"]);
+ $subop = db_escape_string($_REQUEST["subop"]);
+ $view_mode = db_escape_string($_REQUEST["view_mode"]);
+ $limit = (int) get_pref($link, "DEFAULT_ARTICLE_LIMIT");
+ $cat_view = db_escape_string($_REQUEST["cat"]);
+ $next_unread_feed = db_escape_string($_REQUEST["nuf"]);
+ $offset = db_escape_string($_REQUEST["skip"]);
+ $vgroup_last_feed = db_escape_string($_REQUEST["vgrlf"]);
+ $csync = $_REQUEST["csync"];
+ $order_by = db_escape_string($_REQUEST["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);
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;
+
+ 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;
- if ($feed == -4) {
+ case "score":
+ $override_order = "score DESC";
+ break;
+ }
- generate_dashboard_feed($link);
+ $ret = outputHeadlinesList($link, $feed, $subop,
+ $view_mode, $limit, $cat_view, $next_unread_feed, $offset,
+ $vgroup_last_feed, $override_order);
- } else {
-
- $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;
+ $topmost_article_ids = $ret[0];
+ $headlines_count = $ret[1];
+ $returned_feed = $ret[2];
+ $disable_cache = $ret[3];
+ $vgroup_last_feed = $ret[4];
- case "title":
- $override_order = "updated DESC";
- break;
+ print "]]></headlines>";
- case "score":
- $override_order = "score DESC";
- break;
- }
+ print "<headlines-count value=\"$headlines_count\"/>";
+ print "<vgroup-last-feed value=\"$vgroup_last_feed\"/>";
- $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);
- $headlines_unread = getFeedUnread($link, $returned_feed);
-
- 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);
+ print "<headlines-unread value=\"$headlines_unread\"/>";
+ printf("<disable-cache value=\"%d\"/>", $disable_cache);
- $viewfeed_ctr_interval = 300;
+ if ($_REQUEST["debug"]) $timing_info = print_checkpoint("10", $timing_info);
- if ($csync || $_SESSION["bw_limit"]) {
- $viewfeed_ctr_interval = 60;
+ 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_pref($link, "SYNC_COUNTERS") ||
- time() - $_SESSION["get_all_counters_stamp"] > $viewfeed_ctr_interval) {
- print "<counters>";
- getAllCounters($link, $omode, $feed);
- print "</counters>";
+ if ($_REQUEST["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"] > 5) {
+ 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);
+ if ($_REQUEST["debug"]) $timing_info = print_checkpoint("30", $timing_info);
print_runtime_info($link);
update_daemon_common($link, 0, true, true);
print " -->";
- // FIXME : old feed update way. To be removed.
- //$result = db_query($link, "SELECT id FROM ttrss_users");
-
- //while ($line = db_fetch_assoc($result)) {
- // $user_id = $line["id"];
- // print "<!-- updating feeds of uid $user_id -->";
- // update_all_feeds($link, false, $user_id);
- //}
-
print "<rpc-reply>
<message msg=\"All feeds updated\"/>
</rpc-reply>";
break; // pref-feed-browser
case "publish":
- $key = db_escape_string($_GET["key"]);
+ $key = db_escape_string($_REQUEST["key"]);
+ $limit = (int)db_escape_string($_REQUEST["limit"]);
$result = db_query($link, "SELECT login, owner_uid
FROM ttrss_user_prefs, ttrss_users WHERE
$owner = db_fetch_result($result, 0, "owner_uid");
$login = db_fetch_result($result, 0, "login");
- generate_syndicated_feed($link, $owner, -2, false);
+ generate_syndicated_feed($link, $owner, -2, false, $limit);
} else {
print "<error>User not found</error>";
break; // publish
case "rss":
- $feed = db_escape_string($_GET["id"]);
- $user = db_escape_string($_GET["user"]);
- $pass = db_escape_string($_GET["pass"]);
- $is_cat = $_GET["is_cat"] != false;
-
- $search = db_escape_string($_GET["q"]);
- $match_on = db_escape_string($_GET["m"]);
- $search_mode = db_escape_string($_GET["smode"]);
+ $feed = db_escape_string($_REQUEST["id"]);
+ $user = db_escape_string($_REQUEST["user"]);
+ $pass = db_escape_string($_REQUEST["pass"]);
+ $is_cat = $_REQUEST["is_cat"] != false;
+ $limit = (int)db_escape_string($_REQUEST["limit"]);
+
+ $search = db_escape_string($_REQUEST["q"]);
+ $match_on = db_escape_string($_REQUEST["m"]);
+ $search_mode = db_escape_string($_REQUEST["smode"]);
+
+ if (SINGLE_USER_MODE) {
+ authenticate_user($link, "admin", null);
+ }
if (!$_SESSION["uid"] && $user && $pass) {
authenticate_user($link, $user, $pass);
if ($_SESSION["uid"] ||
http_authenticate_user($link)) {
- generate_syndicated_feed($link, 0, $feed, $is_cat,
+ generate_syndicated_feed($link, 0, $feed, $is_cat, $limit,
$search, $search_mode, $match_on);
}
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"]);
+ $login = db_escape_string($_REQUEST["login"]);
header("Content-Type: text/plain; charset=utf-8");