]>
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") {
28 getLabelCounters($link);
30 getFeedCounter($link, $aid);
36 if ($subop == "getFeedCounters") {
39 getFeedCounters($link);
44 if ($subop == "getAllCounters") {
47 getAllCounters($link);
49 print_runtime_info($link);
53 if ($subop == "mark") {
54 $mark = $_GET["mark"];
55 $id = db_escape_string($_GET["id"]);
63 // FIXME this needs collision testing
65 $result = db_query($link, "UPDATE ttrss_user_entries SET marked = $mark
66 WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
69 if ($subop == "updateFeed") {
70 $feed_id = db_escape_string($_GET["feed"]);
72 $result = db_query($link,
73 "SELECT feed_url FROM ttrss_feeds WHERE id = '$feed_id'
74 AND owner_uid = " . $_SESSION["uid"]);
76 if (db_num_rows($result) > 0) {
77 $feed_url = db_fetch_result($result, 0, "feed_url");
78 update_rss_feed($link, $feed_url, $feed_id);
83 getFeedCounter($link, $feed_id);
90 if ($subop == "forceUpdateAllFeeds" ||
$subop == "updateAllFeeds") {
92 if (ENABLE_UPDATE_DAEMON
) {
94 if ($subop == "forceUpdateAllFeeds") {
96 $result = db_query($link, "SELECT count(id) AS cid FROM
97 ttrss_scheduled_updates WHERE feed_id IS NULL AND
98 owner_uid = " . $_SESSION["uid"]);
100 $cid = db_fetch_result($result, 0, "cid");
104 db_query($link, "INSERT INTO ttrss_scheduled_updates
105 (owner_uid, feed_id, entered) VALUES
106 (".$_SESSION["uid"].", NULL, NOW())");
112 update_all_feeds($link, $subop == "forceUpdateAllFeeds");
115 $global_unread_caller = sprintf("%d", $_GET["uctr"]);
116 $global_unread = getGlobalUnread($link);
122 if ($global_unread_caller != $global_unread) {
124 $omode = $_GET["omode"];
126 if (!$omode) $omode = "tflc";
128 if (strchr($omode, "l")) getLabelCounters($link);
129 if (strchr($omode, "f")) getFeedCounters($link);
130 if (strchr($omode, "t")) getTagCounters($link);
131 if (strchr($omode, "c")) {
132 if (get_pref($link, 'ENABLE_FEED_CATS')) {
133 getCategoryCounters($link);
138 getGlobalCounters($link, $global_unread);
142 print_runtime_info($link);
144 print "</rpc-reply>";
148 /* GET["cmode"] = 0 - mark as read, 1 - as unread, 2 - toggle */
149 if ($subop == "catchupSelected") {
151 $ids = split(",", db_escape_string($_GET["ids"]));
153 $cmode = sprintf("%d", $_GET["cmode"]);
155 foreach ($ids as $id) {
158 db_query($link, "UPDATE ttrss_user_entries SET
159 unread = false,last_read = NOW()
160 WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
161 } else if ($cmode == 1) {
162 db_query($link, "UPDATE ttrss_user_entries SET
164 WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
166 db_query($link, "UPDATE ttrss_user_entries SET
167 unread = NOT unread,last_read = NOW()
168 WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
173 getAllCounters($link);
175 print_runtime_info($link);
176 print "</rpc-reply>";
179 if ($subop == "markSelected") {
181 $ids = split(",", db_escape_string($_GET["ids"]));
183 $cmode = sprintf("%d", $_GET["cmode"]);
185 foreach ($ids as $id) {
188 db_query($link, "UPDATE ttrss_user_entries SET
190 WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
191 } else if ($cmode == 1) {
192 db_query($link, "UPDATE ttrss_user_entries SET
194 WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
196 db_query($link, "UPDATE ttrss_user_entries SET
198 WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
203 getAllCounters($link);
205 print_runtime_info($link);
206 print "</rpc-reply>";
209 if ($subop == "sanityCheck") {
211 if (sanity_check($link)) {
212 print "<error error-code=\"0\"/>";
213 print_init_params($link);
214 print_runtime_info($link);
216 print "</rpc-reply>";
219 if ($subop == "globalPurge") {
222 global_purge_old_posts($link, true);
223 print "</rpc-reply>";
227 if ($subop == "storeParam") {
229 $value = $_GET["value"];
230 $_SESSION["stored-params"][$key] = $value;