]>
git.wh0rd.org - tt-rss.git/blob - backend-rpc.php
2 function handle_rpc_request($link) {
4 $subop = $_GET["subop"];
6 if ($subop == "setpref") {
13 $key = db_escape_string($_GET["key"]);
14 $value = db_escape_string($_GET["value"]);
16 set_pref($link, $key, $value);
18 print "<param-set key=\"$key\" value=\"$value\"/>";
24 if ($subop == "getLabelCounters") {
27 getLabelCounters($link);
29 getFeedCounter($link, $aid);
34 if ($subop == "getFeedCounters") {
36 getFeedCounters($link);
40 if ($subop == "getAllCounters") {
42 getAllCounters($link);
46 if ($subop == "mark") {
47 $mark = $_GET["mark"];
48 $id = db_escape_string($_GET["id"]);
56 // FIXME this needs collision testing
58 $result = db_query($link, "UPDATE ttrss_user_entries SET marked = $mark
59 WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
62 if ($subop == "updateFeed") {
63 $feed_id = db_escape_string($_GET["feed"]);
65 $result = db_query($link,
66 "SELECT feed_url FROM ttrss_feeds WHERE id = '$feed_id'
67 AND owner_uid = " . $_SESSION["uid"]);
69 if (db_num_rows($result) > 0) {
70 $feed_url = db_fetch_result($result, 0, "feed_url");
71 update_rss_feed($link, $feed_url, $feed_id);
75 getFeedCounter($link, $feed_id);
81 if ($subop == "forceUpdateAllFeeds" ||
$subop == "updateAllFeeds") {
83 if (ENABLE_UPDATE_DAEMON
) {
85 if ($subop == "forceUpdateAllFeeds") {
87 $result = db_query($link, "SELECT count(id) AS cid FROM
88 ttrss_scheduled_updates WHERE feed_id IS NULL AND
89 owner_uid = " . $_SESSION["uid"]);
91 $cid = db_fetch_result($result, 0, "cid");
95 db_query($link, "INSERT INTO ttrss_scheduled_updates
96 (owner_uid, feed_id, entered) VALUES
97 (".$_SESSION["uid"].", NULL, NOW())");
103 update_all_feeds($link, $subop == "forceUpdateAllFeeds");
106 $global_unread_caller = sprintf("%d", $_GET["uctr"]);
107 $global_unread = getGlobalUnread($link);
111 if ($global_unread_caller != $global_unread) {
113 $omode = $_GET["omode"];
115 if (!$omode) $omode = "tflc";
117 if (strchr($omode, "l")) getLabelCounters($link);
118 if (strchr($omode, "f")) getFeedCounters($link);
119 if (strchr($omode, "t")) getTagCounters($link);
120 if (strchr($omode, "c")) {
121 if (get_pref($link, 'ENABLE_FEED_CATS')) {
122 getCategoryCounters($link);
127 getGlobalCounters($link, $global_unread);
129 print "</rpc-reply>";
133 /* GET["cmode"] = 0 - mark as read, 1 - as unread, 2 - toggle */
134 if ($subop == "catchupSelected") {
136 $ids = split(",", db_escape_string($_GET["ids"]));
138 $cmode = sprintf("%d", $_GET["cmode"]);
140 foreach ($ids as $id) {
143 db_query($link, "UPDATE ttrss_user_entries SET
144 unread = false,last_read = NOW()
145 WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
146 } else if ($cmode == 1) {
147 db_query($link, "UPDATE ttrss_user_entries SET
149 WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
151 db_query($link, "UPDATE ttrss_user_entries SET
152 unread = NOT unread,last_read = NOW()
153 WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
157 getAllCounters($link);
158 print "</rpc-reply>";
161 if ($subop == "markSelected") {
163 $ids = split(",", db_escape_string($_GET["ids"]));
165 $cmode = sprintf("%d", $_GET["cmode"]);
167 foreach ($ids as $id) {
170 db_query($link, "UPDATE ttrss_user_entries SET
172 WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
173 } else if ($cmode == 1) {
174 db_query($link, "UPDATE ttrss_user_entries SET
176 WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
178 db_query($link, "UPDATE ttrss_user_entries SET
180 WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
184 getAllCounters($link);
185 print "</rpc-reply>";
188 if ($subop == "sanityCheck") {
190 if (sanity_check($link)) {
191 print "<error error-code=\"0\"/>";
192 print_init_params($link);
194 print "</rpc-reply>";
197 if ($subop == "globalPurge") {
200 global_purge_old_posts($link, true);
201 print "</rpc-reply>";
205 if ($subop == "storeParam") {
207 $value = $_GET["value"];
208 $_SESSION["stored-params"][$key] = $value;