]>
Commit | Line | Data |
---|---|---|
1d3a17c7 | 1 | <?php |
01b3e191 AD |
2 | function handle_rpc_request($link) { |
3 | ||
b4e75b2a | 4 | $subop = $_REQUEST["subop"]; |
01b3e191 | 5 | |
d9084cf2 AD |
6 | if ($subop == "setprofile") { |
7 | $id = db_escape_string($_REQUEST["id"]); | |
8 | ||
9 | $_SESSION["profile"] = $id; | |
10 | $_SESSION["prefs_cache"] = array(); | |
11 | return; | |
12 | } | |
13 | ||
14 | if ($subop == "remprofiles") { | |
15 | $ids = split(",", db_escape_string(trim($_REQUEST["ids"]))); | |
16 | ||
17 | foreach ($ids as $id) { | |
18 | if ($_SESSION["profile"] != $id) { | |
19 | db_query($link, "DELETE FROM ttrss_settings_profiles WHERE id = '$id' AND | |
20 | owner_uid = " . $_SESSION["uid"]); | |
21 | } | |
22 | } | |
23 | return; | |
24 | } | |
25 | ||
26 | if ($subop == "addprofile") { | |
27 | $title = db_escape_string(trim($_REQUEST["title"])); | |
28 | if ($title) { | |
29 | db_query($link, "BEGIN"); | |
30 | ||
31 | $result = db_query($link, "SELECT id FROM ttrss_settings_profiles | |
32 | WHERE title = '$title' AND owner_uid = " . $_SESSION["uid"]); | |
33 | ||
34 | if (db_num_rows($result) == 0) { | |
35 | ||
36 | db_query($link, "INSERT INTO ttrss_settings_profiles (title, owner_uid) | |
37 | VALUES ('$title', ".$_SESSION["uid"] .")"); | |
38 | ||
39 | $result = db_query($link, "SELECT id FROM ttrss_settings_profiles WHERE | |
40 | title = '$title'"); | |
41 | ||
42 | if (db_num_rows($result) != 0) { | |
43 | $profile_id = db_fetch_result($result, 0, "id"); | |
44 | ||
45 | if ($profile_id) { | |
46 | initialize_user_prefs($link, $_SESSION["uid"], $profile_id); | |
47 | } | |
48 | } | |
49 | } | |
50 | ||
51 | db_query($link, "COMMIT"); | |
52 | } | |
53 | return; | |
54 | } | |
55 | ||
56 | if ($subop == "saveprofile") { | |
57 | $id = db_escape_string($_REQUEST["id"]); | |
58 | $title = db_escape_string(trim($_REQUEST["value"])); | |
59 | ||
60 | if ($id == 0) { | |
61 | print __("Default profile"); | |
62 | return; | |
63 | } | |
64 | ||
65 | if ($title) { | |
66 | db_query($link, "BEGIN"); | |
67 | ||
68 | $result = db_query($link, "SELECT id FROM ttrss_settings_profiles | |
69 | WHERE title = '$title' AND owner_uid =" . $_SESSION["uid"]); | |
70 | ||
71 | if (db_num_rows($result) == 0) { | |
72 | db_query($link, "UPDATE ttrss_settings_profiles | |
73 | SET title = '$title' WHERE id = '$id' AND | |
74 | owner_uid = " . $_SESSION["uid"]); | |
75 | print $title; | |
76 | } else { | |
77 | $result = db_query($link, "SELECT title FROM ttrss_settings_profiles | |
78 | WHERE id = '$id' AND owner_uid =" . $_SESSION["uid"]); | |
79 | print db_fetch_result($result, 0, "title"); | |
80 | } | |
81 | ||
82 | db_query($link, "COMMIT"); | |
83 | } | |
84 | return; | |
85 | } | |
86 | ||
ef88b1cc AD |
87 | if ($subop == "remarchive") { |
88 | $ids = split(",", db_escape_string($_REQUEST["ids"])); | |
89 | ||
90 | print "<rpc-reply>"; | |
91 | ||
92 | foreach ($ids as $id) { | |
93 | $result = db_query($link, "DELETE FROM ttrss_archived_feeds WHERE | |
94 | (SELECT COUNT(*) FROM ttrss_user_entries | |
95 | WHERE orig_feed_id = '$id') = 0 AND | |
96 | id = '$id' AND owner_uid = ".$_SESSION["uid"]); | |
97 | ||
98 | $rc = db_affected_rows($link, $result); | |
99 | ||
100 | print "<feed id='$id' rc='$rc'/>"; | |
101 | ||
102 | } | |
103 | ||
104 | print "</rpc-reply>"; | |
105 | ||
106 | return; | |
107 | } | |
108 | ||
a5819bb3 AD |
109 | if ($subop == "addfeed") { |
110 | ||
111 | $feed = db_escape_string($_REQUEST['feed']); | |
112 | $cat = db_escape_string($_REQUEST['cat']); | |
113 | $login = db_escape_string($_REQUEST['login']); | |
114 | $pass = db_escape_string($_REQUEST['pass']); | |
115 | ||
116 | $rc = subscribe_to_feed($link, $feed, $cat, $login, $pass); | |
117 | ||
118 | print "<rpc-reply>"; | |
119 | print "<result code='$rc'/>"; | |
120 | print "</rpc-reply>"; | |
121 | ||
122 | return; | |
123 | ||
124 | } | |
125 | ||
8a3e0b1a AD |
126 | if ($subop == "togglepref") { |
127 | print "<rpc-reply>"; | |
128 | ||
129 | $key = db_escape_string($_REQUEST["key"]); | |
130 | ||
131 | set_pref($link, $key, !get_pref($link, $key)); | |
132 | ||
133 | $value = get_pref($link, $key); | |
01b3e191 | 134 | |
8a3e0b1a AD |
135 | print "<param-set key=\"$key\" value=\"$value\"/>"; |
136 | ||
137 | print "</rpc-reply>"; | |
138 | ||
139 | return; | |
140 | } | |
141 | ||
142 | if ($subop == "setpref") { | |
01b3e191 AD |
143 | print "<rpc-reply>"; |
144 | ||
b4e75b2a AD |
145 | $key = db_escape_string($_REQUEST["key"]); |
146 | $value = db_escape_string($_REQUEST["value"]); | |
01b3e191 AD |
147 | |
148 | set_pref($link, $key, $value); | |
149 | ||
150 | print "<param-set key=\"$key\" value=\"$value\"/>"; | |
151 | ||
152 | print "</rpc-reply>"; | |
153 | ||
85bd574b | 154 | return; |
01b3e191 AD |
155 | } |
156 | ||
01b3e191 | 157 | if ($subop == "getAllCounters") { |
cf4d339c | 158 | print "<rpc-reply>"; |
6a7817c1 | 159 | print "<counters><![CDATA["; |
cf4d339c | 160 | |
6a7817c1 | 161 | print json_encode(getAllCounters($link, $_REQUEST['omode'])); |
cf4d339c | 162 | |
6a7817c1 | 163 | print "]]></counters>"; |
f54f515f | 164 | print_runtime_info($link); |
01b3e191 | 165 | print "</rpc-reply>"; |
85bd574b AD |
166 | |
167 | return; | |
01b3e191 AD |
168 | } |
169 | ||
170 | if ($subop == "mark") { | |
b4e75b2a AD |
171 | $mark = $_REQUEST["mark"]; |
172 | $id = db_escape_string($_REQUEST["id"]); | |
01b3e191 AD |
173 | |
174 | if ($mark == "1") { | |
175 | $mark = "true"; | |
176 | } else { | |
177 | $mark = "false"; | |
178 | } | |
179 | ||
180 | // FIXME this needs collision testing | |
181 | ||
182 | $result = db_query($link, "UPDATE ttrss_user_entries SET marked = $mark | |
183 | WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]); | |
49aa6de9 | 184 | |
6a7817c1 AD |
185 | print "<rpc-reply><counters><![CDATA["; |
186 | print json_encode(getAllCounters($link)); | |
187 | print "]]></counters></rpc-reply>"; | |
49aa6de9 | 188 | |
85bd574b | 189 | return; |
01b3e191 AD |
190 | } |
191 | ||
e04c18a2 | 192 | if ($subop == "delete") { |
b4e75b2a | 193 | $ids = db_escape_string($_REQUEST["ids"]); |
e04c18a2 AD |
194 | |
195 | $result = db_query($link, "DELETE FROM ttrss_user_entries | |
196 | WHERE ref_id IN ($ids) AND owner_uid = " . $_SESSION["uid"]); | |
197 | ||
6a7817c1 AD |
198 | print "<rpc-reply><counters><![CDATA["; |
199 | print json_encode(getAllCounters($link)); | |
200 | print "]]></counters></rpc-reply>"; | |
e04c18a2 AD |
201 | |
202 | return; | |
203 | } | |
204 | ||
205 | if ($subop == "unarchive") { | |
b4e75b2a | 206 | $ids = db_escape_string($_REQUEST["ids"]); |
e04c18a2 AD |
207 | |
208 | $result = db_query($link, "UPDATE ttrss_user_entries | |
ef83538d | 209 | SET feed_id = orig_feed_id, orig_feed_id = NULL |
e04c18a2 AD |
210 | WHERE ref_id IN ($ids) AND owner_uid = " . $_SESSION["uid"]); |
211 | ||
6a7817c1 AD |
212 | print "<rpc-reply><counters><![CDATA["; |
213 | print json_encode(getAllCounters($link)); | |
214 | print "]]></counters></rpc-reply>"; | |
e04c18a2 AD |
215 | |
216 | return; | |
217 | } | |
218 | ||
219 | if ($subop == "archive") { | |
b4e75b2a | 220 | $ids = split(",", db_escape_string($_REQUEST["ids"])); |
e04c18a2 | 221 | |
16fdac16 AD |
222 | foreach ($ids as $id) { |
223 | archive_article($link, $id, $_SESSION["uid"]); | |
224 | } | |
e04c18a2 | 225 | |
6a7817c1 AD |
226 | print "<rpc-reply><counters><![CDATA["; |
227 | print json_encode(getAllCounters($link)); | |
228 | print "]]></counters></rpc-reply>"; | |
e04c18a2 AD |
229 | |
230 | return; | |
231 | } | |
232 | ||
233 | ||
e4f4b46f | 234 | if ($subop == "publ") { |
c7e51de1 AD |
235 | $pub = $_REQUEST["pub"]; |
236 | $id = db_escape_string($_REQUEST["id"]); | |
237 | $note = trim(strip_tags(db_escape_string($_REQUEST["note"]))); | |
e4f4b46f AD |
238 | |
239 | if ($pub == "1") { | |
0a8011eb | 240 | $pub = "true"; |
e4f4b46f AD |
241 | } else { |
242 | $pub = "false"; | |
243 | } | |
244 | ||
c7e51de1 AD |
245 | if ($note != 'undefined') { |
246 | $note_qpart = "note = '$note',"; | |
247 | } | |
248 | ||
e4f4b46f AD |
249 | // FIXME this needs collision testing |
250 | ||
c7e51de1 AD |
251 | $result = db_query($link, "UPDATE ttrss_user_entries SET |
252 | $note_qpart | |
253 | published = $pub | |
e4f4b46f | 254 | WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]); |
49aa6de9 | 255 | |
c7e51de1 AD |
256 | |
257 | print "<rpc-reply>"; | |
258 | ||
6a7817c1 AD |
259 | print "<counters><![CDATA["; |
260 | print json_encode(getAllCounters($link)); | |
261 | print "]]></counters>"; | |
c7e51de1 AD |
262 | |
263 | if ($note != 'undefined') { | |
264 | $note_size = strlen($note); | |
265 | print "<note id=\"$id\" size=\"$note_size\">"; | |
266 | print "<![CDATA[" . format_article_note($id, $note) . "]]>"; | |
267 | print "</note>"; | |
268 | } | |
269 | ||
270 | print "</rpc-reply>"; | |
49aa6de9 | 271 | |
85bd574b | 272 | return; |
e4f4b46f AD |
273 | } |
274 | ||
01b3e191 | 275 | if ($subop == "updateFeed") { |
b4e75b2a | 276 | $feed_id = db_escape_string($_REQUEST["feed"]); |
01b3e191 | 277 | |
c633e370 | 278 | update_rss_feed($link, $feed_id); |
01b3e191 | 279 | |
f54f515f | 280 | print "<rpc-reply>"; |
6a7817c1 AD |
281 | print "<counters><![CDATA["; |
282 | print json_encode(getFeedCounters($link, $feed_id)); | |
283 | print "]]></counters>"; | |
01b3e191 AD |
284 | print "</rpc-reply>"; |
285 | ||
286 | return; | |
287 | } | |
288 | ||
50eefedb | 289 | if ($subop == "updateAllFeeds") { |
01b3e191 | 290 | |
b4e75b2a | 291 | $global_unread_caller = sprintf("%d", $_REQUEST["uctr"]); |
01b3e191 AD |
292 | $global_unread = getGlobalUnread($link); |
293 | ||
294 | print "<rpc-reply>"; | |
295 | ||
a06d0e5a | 296 | if ($global_unread_caller != $global_unread) { |
a8f447f3 | 297 | print "<counters><![CDATA["; |
6a7817c1 AD |
298 | $omode = $_REQUEST["omode"]; |
299 | print json_encode(getAllCounters($link, $omode)); | |
a8f447f3 | 300 | print "]]></counters>"; |
a06d0e5a AD |
301 | } |
302 | ||
f54f515f AD |
303 | print_runtime_info($link); |
304 | ||
01b3e191 AD |
305 | print "</rpc-reply>"; |
306 | ||
85bd574b | 307 | return; |
01b3e191 | 308 | } |
472782e8 | 309 | |
01b3e191 AD |
310 | /* GET["cmode"] = 0 - mark as read, 1 - as unread, 2 - toggle */ |
311 | if ($subop == "catchupSelected") { | |
312 | ||
2855ee88 AD |
313 | $ids = split(",", db_escape_string($_REQUEST["ids"])); |
314 | $cmode = sprintf("%d", $_REQUEST["cmode"]); | |
01b3e191 | 315 | |
472782e8 | 316 | catchupArticlesById($link, $ids, $cmode); |
01b3e191 | 317 | |
01b3e191 | 318 | print "<rpc-reply>"; |
6a7817c1 AD |
319 | print "<counters><![CDATA["; |
320 | print json_encode(getAllCounters($link, $_REQUEST['omode'])); | |
321 | print "]]></counters>"; | |
322 | ||
f54f515f | 323 | print_runtime_info($link); |
01b3e191 | 324 | print "</rpc-reply>"; |
85bd574b AD |
325 | |
326 | return; | |
01b3e191 AD |
327 | } |
328 | ||
329 | if ($subop == "markSelected") { | |
330 | ||
b4e75b2a AD |
331 | $ids = split(",", db_escape_string($_REQUEST["ids"])); |
332 | $cmode = sprintf("%d", $_REQUEST["cmode"]); | |
01b3e191 | 333 | |
18eddb2c AD |
334 | markArticlesById($link, $ids, $cmode); |
335 | ||
01b3e191 | 336 | print "<rpc-reply>"; |
6a7817c1 AD |
337 | print "<counters><![CDATA["; |
338 | print json_encode(getAllCounters($link, $_REQUEST['omode'])); | |
339 | print "]]></counters>"; | |
f54f515f | 340 | print_runtime_info($link); |
01b3e191 | 341 | print "</rpc-reply>"; |
85bd574b AD |
342 | |
343 | return; | |
01b3e191 AD |
344 | } |
345 | ||
e4f4b46f AD |
346 | if ($subop == "publishSelected") { |
347 | ||
b4e75b2a AD |
348 | $ids = split(",", db_escape_string($_REQUEST["ids"])); |
349 | $cmode = sprintf("%d", $_REQUEST["cmode"]); | |
e4f4b46f AD |
350 | |
351 | publishArticlesById($link, $ids, $cmode); | |
352 | ||
353 | print "<rpc-reply>"; | |
6a7817c1 AD |
354 | print "<counters><![CDATA["; |
355 | print json_encode(getAllCounters($link, $_REQUEST['omode'])); | |
356 | print "]]></counters>"; | |
e4f4b46f AD |
357 | print_runtime_info($link); |
358 | print "</rpc-reply>"; | |
85bd574b AD |
359 | |
360 | return; | |
e4f4b46f AD |
361 | } |
362 | ||
01b3e191 | 363 | if ($subop == "sanityCheck") { |
3ac2b520 | 364 | print "<rpc-reply>"; |
01b3e191 AD |
365 | if (sanity_check($link)) { |
366 | print "<error error-code=\"0\"/>"; | |
d8221301 AD |
367 | |
368 | print "<init-params><![CDATA["; | |
369 | print json_encode(make_init_params($link)); | |
370 | print "]]></init-params>"; | |
371 | ||
f54f515f | 372 | print_runtime_info($link); |
4220d6b0 AD |
373 | |
374 | # assign client-passed params to session | |
b4e75b2a | 375 | $_SESSION["client.userAgent"] = $_REQUEST["ua"]; |
4220d6b0 | 376 | |
01b3e191 | 377 | } |
3ac2b520 | 378 | print "</rpc-reply>"; |
85bd574b AD |
379 | |
380 | return; | |
3ac2b520 | 381 | } |
01b3e191 AD |
382 | |
383 | if ($subop == "globalPurge") { | |
384 | ||
385 | print "<rpc-reply>"; | |
386 | global_purge_old_posts($link, true); | |
387 | print "</rpc-reply>"; | |
388 | ||
85bd574b | 389 | return; |
01b3e191 | 390 | } |
3ac2b520 | 391 | |
298f3f78 AD |
392 | if ($subop == "getArticleLink") { |
393 | ||
b4e75b2a | 394 | $id = db_escape_string($_REQUEST["id"]); |
298f3f78 AD |
395 | |
396 | $result = db_query($link, "SELECT link FROM ttrss_entries, ttrss_user_entries | |
397 | WHERE id = '$id' AND id = ref_id AND owner_uid = '".$_SESSION['uid']."'"); | |
398 | ||
399 | if (db_num_rows($result) == 1) { | |
06925d9e | 400 | $link = htmlspecialchars(strip_tags(db_fetch_result($result, 0, "link"))); |
e2ccbfab | 401 | print "<rpc-reply><link>$link</link><id>$id</id></rpc-reply>"; |
298f3f78 AD |
402 | } else { |
403 | print "<rpc-reply><error>Article not found</error></rpc-reply>"; | |
404 | } | |
85bd574b AD |
405 | |
406 | return; | |
298f3f78 AD |
407 | } |
408 | ||
0b126ac2 | 409 | if ($subop == "setArticleTags") { |
14b6c54b | 410 | |
bd3f2ade AD |
411 | global $memcache; |
412 | ||
b4e75b2a | 413 | $id = db_escape_string($_REQUEST["id"]); |
14b6c54b | 414 | |
b4e75b2a | 415 | $tags_str = db_escape_string($_REQUEST["tags_str"]); |
0b126ac2 | 416 | |
d62a3b63 | 417 | $tags = array_unique(trim_array(split(",", $tags_str))); |
0b126ac2 AD |
418 | |
419 | db_query($link, "BEGIN"); | |
420 | ||
421 | $result = db_query($link, "SELECT int_id FROM ttrss_user_entries WHERE | |
422 | ref_id = '$id' AND owner_uid = '".$_SESSION["uid"]."' LIMIT 1"); | |
423 | ||
424 | if (db_num_rows($result) == 1) { | |
425 | ||
426 | $int_id = db_fetch_result($result, 0, "int_id"); | |
427 | ||
428 | db_query($link, "DELETE FROM ttrss_tags WHERE | |
429 | post_int_id = $int_id AND owner_uid = '".$_SESSION["uid"]."'"); | |
430 | ||
431 | foreach ($tags as $tag) { | |
14b6c54b | 432 | $tag = sanitize_tag($tag); |
0b126ac2 | 433 | |
ef063748 AD |
434 | if (!tag_is_valid($tag)) { |
435 | continue; | |
436 | } | |
437 | ||
0b126ac2 AD |
438 | if (preg_match("/^[0-9]*$/", $tag)) { |
439 | continue; | |
440 | } | |
14b6c54b | 441 | |
307d187c | 442 | // print "<!-- $id : $int_id : $tag -->"; |
0b126ac2 AD |
443 | |
444 | if ($tag != '') { | |
445 | db_query($link, "INSERT INTO ttrss_tags | |
446 | (post_int_id, owner_uid, tag_name) VALUES ('$int_id', '".$_SESSION["uid"]."', '$tag')"); | |
447 | } | |
448 | } | |
449 | } | |
450 | ||
451 | db_query($link, "COMMIT"); | |
452 | ||
bd3f2ade AD |
453 | if ($memcache) { |
454 | $obj_id = md5("TAGS:".$_SESSION["uid"].":$id"); | |
455 | $memcache->delete($obj_id); | |
456 | } | |
457 | ||
307d187c AD |
458 | $tags_str = format_tags_string(get_article_tags($link, $id), $id); |
459 | ||
0b126ac2 | 460 | print "<rpc-reply> |
307d187c | 461 | <tags-str id=\"$id\"><![CDATA[$tags_str]]></tags-str> |
0b126ac2 AD |
462 | </rpc-reply>"; |
463 | ||
85bd574b | 464 | return; |
0b126ac2 | 465 | } |
01a87dff | 466 | |
ef7b7bbd MK |
467 | if ($subop == "regenOPMLKey") { |
468 | ||
469 | print "<rpc-reply>"; | |
8801fb01 AD |
470 | set_pref($link, " _PREFS_OPML_PUBLISH_KEY", |
471 | sha1(uniqid(rand(), true)), $_SESSION["uid"]); | |
ef7b7bbd MK |
472 | $new_link = opml_publish_url($link); |
473 | print "<link><![CDATA[$new_link]]></link>"; | |
474 | print "</rpc-reply>"; | |
475 | return; | |
476 | } | |
477 | ||
01a87dff AD |
478 | if ($subop == "logout") { |
479 | logout_user(); | |
480 | print_error_xml(6); | |
85bd574b | 481 | return; |
01a87dff AD |
482 | } |
483 | ||
05fcdf52 AD |
484 | if ($subop == "completeTags") { |
485 | ||
486 | $search = db_escape_string($_REQUEST["search"]); | |
487 | ||
488 | $result = db_query($link, "SELECT DISTINCT tag_name FROM ttrss_tags | |
489 | WHERE owner_uid = '".$_SESSION["uid"]."' AND | |
490 | tag_name LIKE '$search%' ORDER BY tag_name | |
491 | LIMIT 10"); | |
492 | ||
493 | print "<ul>"; | |
494 | while ($line = db_fetch_assoc($result)) { | |
495 | print "<li>" . $line["tag_name"] . "</li>"; | |
496 | } | |
497 | print "</ul>"; | |
498 | ||
85bd574b | 499 | return; |
05fcdf52 AD |
500 | } |
501 | ||
81cd6cac | 502 | if ($subop == "purge") { |
b4e75b2a AD |
503 | $ids = split(",", db_escape_string($_REQUEST["ids"])); |
504 | $days = sprintf("%d", $_REQUEST["days"]); | |
81cd6cac AD |
505 | |
506 | print "<rpc-reply>"; | |
507 | ||
508 | print "<message><![CDATA["; | |
509 | ||
510 | foreach ($ids as $id) { | |
511 | ||
512 | $result = db_query($link, "SELECT id FROM ttrss_feeds WHERE | |
513 | id = '$id' AND owner_uid = ".$_SESSION["uid"]); | |
514 | ||
515 | if (db_num_rows($result) == 1) { | |
516 | purge_feed($link, $id, $days, true); | |
517 | } | |
518 | } | |
519 | ||
520 | print "]]></message>"; | |
521 | ||
522 | print "</rpc-reply>"; | |
523 | ||
524 | return; | |
525 | } | |
526 | ||
9bf3f101 | 527 | /* if ($subop == "setScore") { |
546499a9 AD |
528 | $id = db_escape_string($_REQUEST["id"]); |
529 | $score = sprintf("%d", $_REQUEST["score"]); | |
530 | ||
531 | $result = db_query($link, "UPDATE ttrss_user_entries SET score = '$score' | |
532 | WHERE ref_id = '$id' AND owner_uid = ".$_SESSION["uid"]); | |
533 | ||
534 | print "<rpc-reply><message>Acknowledged.</message></rpc-reply>"; | |
535 | ||
536 | return; | |
537 | ||
9bf3f101 | 538 | } */ |
546499a9 | 539 | |
aa0fa9df AD |
540 | if ($subop == "getArticles") { |
541 | $ids = split(",", db_escape_string($_REQUEST["ids"])); | |
542 | ||
543 | print "<rpc-reply>"; | |
544 | ||
545 | foreach ($ids as $id) { | |
546 | if ($id) { | |
547 | outputArticleXML($link, $id, 0, false); | |
548 | } | |
549 | } | |
550 | print "</rpc-reply>"; | |
551 | ||
552 | return; | |
553 | } | |
554 | ||
d0da85c2 AD |
555 | if ($subop == "checkDate") { |
556 | ||
557 | $date = db_escape_string($_REQUEST["date"]); | |
558 | $date_parsed = strtotime($date); | |
559 | ||
560 | print "<rpc-reply>"; | |
561 | ||
562 | if ($date_parsed) { | |
563 | print "<result>1</result>"; | |
564 | } else { | |
565 | print "<result>0</result>"; | |
566 | } | |
567 | ||
568 | print "</rpc-reply>"; | |
569 | ||
570 | return; | |
571 | } | |
572 | ||
933ba4ee AD |
573 | if ($subop == "removeFromLabel") { |
574 | ||
575 | $ids = split(",", db_escape_string($_REQUEST["ids"])); | |
576 | $label_id = db_escape_string($_REQUEST["lid"]); | |
577 | ||
7a13338b AD |
578 | $label = db_escape_string(label_find_caption($link, $label_id, |
579 | $_SESSION["uid"])); | |
933ba4ee | 580 | |
1c9c6025 AD |
581 | print "<rpc-reply>"; |
582 | print "<info-for-headlines>"; | |
583 | ||
933ba4ee AD |
584 | if ($label) { |
585 | ||
586 | foreach ($ids as $id) { | |
587 | label_remove_article($link, $id, $label, $_SESSION["uid"]); | |
1c9c6025 AD |
588 | |
589 | print "<entry id=\"$id\"><![CDATA["; | |
590 | ||
591 | $labels = get_article_labels($link, $id, $_SESSION["uid"]); | |
2eb9c95c | 592 | print format_article_labels($labels, $id); |
1c9c6025 AD |
593 | |
594 | print "]]></entry>"; | |
595 | ||
933ba4ee AD |
596 | } |
597 | } | |
598 | ||
1c9c6025 AD |
599 | print "</info-for-headlines>"; |
600 | ||
6a7817c1 AD |
601 | print "<counters><![CDATA["; |
602 | print json_encode(getAllCounters($link, $_REQUEST['omode'])); | |
603 | print "]]></counters>"; | |
1c9c6025 | 604 | print "</rpc-reply>"; |
933ba4ee AD |
605 | |
606 | return; | |
607 | } | |
608 | ||
b8a637f3 AD |
609 | if ($subop == "assignToLabel") { |
610 | ||
611 | $ids = split(",", db_escape_string($_REQUEST["ids"])); | |
612 | $label_id = db_escape_string($_REQUEST["lid"]); | |
613 | ||
7a13338b AD |
614 | $label = db_escape_string(label_find_caption($link, $label_id, |
615 | $_SESSION["uid"])); | |
b8a637f3 | 616 | |
f9247195 AD |
617 | print "<rpc-reply>"; |
618 | ||
619 | print "<info-for-headlines>"; | |
620 | ||
b8a637f3 AD |
621 | if ($label) { |
622 | ||
623 | foreach ($ids as $id) { | |
624 | label_add_article($link, $id, $label, $_SESSION["uid"]); | |
f9247195 AD |
625 | |
626 | print "<entry id=\"$id\"><![CDATA["; | |
627 | ||
628 | $labels = get_article_labels($link, $id, $_SESSION["uid"]); | |
2eb9c95c | 629 | print format_article_labels($labels, $id); |
f9247195 AD |
630 | |
631 | print "]]></entry>"; | |
632 | ||
b8a637f3 AD |
633 | } |
634 | } | |
635 | ||
f9247195 AD |
636 | print "</info-for-headlines>"; |
637 | ||
6a7817c1 AD |
638 | print "<counters><![CDATA["; |
639 | print json_encode(getAllCounters($link, $_REQUEST['omode'])); | |
640 | print "]]></counters>"; | |
f9247195 | 641 | print "</rpc-reply>"; |
b8a637f3 AD |
642 | |
643 | return; | |
644 | } | |
645 | ||
ef88b1cc | 646 | if ($subop == "updateFeedBrowser") { |
c2913898 AD |
647 | |
648 | $search = db_escape_string($_REQUEST["search"]); | |
649 | $limit = db_escape_string($_REQUEST["limit"]); | |
082ae95b | 650 | $mode = db_escape_string($_REQUEST["mode"]); |
c2913898 AD |
651 | |
652 | print "<rpc-reply>"; | |
653 | print "<content>"; | |
654 | print "<![CDATA["; | |
082ae95b | 655 | $ctr = print_feed_browser($link, $search, $limit, $mode); |
c2913898 AD |
656 | print "]]>"; |
657 | print "</content>"; | |
658 | print "<num-results value=\"$ctr\"/>"; | |
ef88b1cc | 659 | print "<mode value=\"$mode\"/>"; |
c2913898 AD |
660 | print "</rpc-reply>"; |
661 | ||
662 | return; | |
663 | } | |
664 | ||
ef88b1cc AD |
665 | |
666 | if ($subop == "massSubscribe") { | |
667 | ||
668 | $ids = split(",", db_escape_string($_REQUEST["ids"])); | |
669 | $mode = $_REQUEST["mode"]; | |
670 | ||
671 | $subscribed = array(); | |
672 | ||
673 | foreach ($ids as $id) { | |
674 | ||
675 | if ($mode == 1) { | |
676 | $result = db_query($link, "SELECT feed_url,title FROM ttrss_feeds | |
677 | WHERE id = '$id'"); | |
678 | } else if ($mode == 2) { | |
679 | $result = db_query($link, "SELECT * FROM ttrss_archived_feeds | |
680 | WHERE id = '$id' AND owner_uid = " . $_SESSION["uid"]); | |
681 | $orig_id = db_escape_string(db_fetch_result($result, 0, "id")); | |
682 | $site_url = db_escape_string(db_fetch_result($result, 0, "site_url")); | |
683 | } | |
684 | ||
685 | $feed_url = db_escape_string(db_fetch_result($result, 0, "feed_url")); | |
686 | $title = db_escape_string(db_fetch_result($result, 0, "title")); | |
687 | ||
688 | $title_orig = db_fetch_result($result, 0, "title"); | |
689 | ||
690 | $result = db_query($link, "SELECT id FROM ttrss_feeds WHERE | |
691 | feed_url = '$feed_url' AND owner_uid = " . $_SESSION["uid"]); | |
692 | ||
693 | if (db_num_rows($result) == 0) { | |
694 | if ($mode == 1) { | |
695 | $result = db_query($link, | |
696 | "INSERT INTO ttrss_feeds (owner_uid,feed_url,title,cat_id) | |
697 | VALUES ('".$_SESSION["uid"]."', '$feed_url', '$title', NULL)"); | |
698 | } else if ($mode == 2) { | |
699 | $result = db_query($link, | |
700 | "INSERT INTO ttrss_feeds (id,owner_uid,feed_url,title,cat_id,site_url) | |
701 | VALUES ('$orig_id','".$_SESSION["uid"]."', '$feed_url', '$title', NULL, '$site_url')"); | |
702 | } | |
703 | array_push($subscribed, $title_orig); | |
704 | } | |
705 | } | |
706 | ||
707 | $num_feeds = count($subscribed); | |
708 | ||
709 | print "<rpc-reply>"; | |
710 | print "<num-feeds value='$num_feeds'/>"; | |
711 | print "</rpc-reply>"; | |
712 | ||
713 | return; | |
714 | } | |
715 | ||
87b16a0a AD |
716 | if ($subop == "download") { |
717 | $stage = (int) $_REQUEST["stage"]; | |
04870193 AD |
718 | $cidt = (int)db_escape_string($_REQUEST["cidt"]); |
719 | $cidb = (int)db_escape_string($_REQUEST["cidb"]); | |
badac687 | 720 | $sync = db_escape_string($_REQUEST["sync"]); |
51f6f917 AD |
721 | //$amount = (int) $_REQUEST["amount"]; |
722 | //$unread_only = db_escape_string($_REQUEST["unread_only"]); | |
723 | //if (!$amount) $amount = 50; | |
6a1cd591 | 724 | |
d9447516 AD |
725 | /* Amount is not used by the frontend offline.js anymore, it goes by |
726 | * date_qpart below + cidb/cidt IDs */ | |
727 | ||
04870193 | 728 | $amount = 2000; |
51f6f917 | 729 | $unread_only = true; |
87b16a0a AD |
730 | |
731 | print "<rpc-reply>"; | |
732 | ||
badac687 AD |
733 | $sync = split(";", $sync); |
734 | ||
735 | print "<sync>"; | |
736 | ||
737 | if (count($sync) > 0) { | |
738 | if (strtotime($sync[0])) { | |
739 | $last_online = db_escape_string($sync[0]); | |
740 | ||
741 | print "<sync-point><![CDATA[$last_online]]></sync-point>"; | |
742 | ||
743 | for ($i = 1; $i < count($sync); $i++) { | |
744 | $e = split(",", $sync[$i]); | |
745 | ||
746 | if (count($e) == 3) { | |
747 | ||
748 | $id = (int) $e[0]; | |
749 | $unread = bool_to_sql_bool((bool) $e[1]); | |
5b8444d3 AD |
750 | $marked = (bool)$e[2]; |
751 | ||
752 | if ($marked) { | |
753 | $marked = bool_to_sql_bool($marked); | |
754 | $marked_qpart = "marked = $marked,"; | |
755 | } | |
badac687 | 756 | |
badac687 | 757 | $query = "UPDATE ttrss_user_entries SET |
5b8444d3 | 758 | $marked_qpart |
badac687 AD |
759 | unread = $unread, |
760 | last_read = '$last_online' | |
761 | WHERE ref_id = '$id' AND | |
762 | (last_read IS NULL OR last_read < '$last_online') AND | |
763 | owner_uid = ".$_SESSION["uid"]; | |
764 | ||
765 | $result = db_query($link, $query); | |
766 | ||
492a4a6a | 767 | print "<sync-ok id=\"$id\"/>"; |
badac687 AD |
768 | |
769 | } | |
770 | } | |
7f4f9f4e AD |
771 | |
772 | /* Maybe we need to further update local DB for this client */ | |
773 | ||
492a4a6a | 774 | $query = "SELECT ref_id,unread,marked FROM ttrss_user_entries |
7f4f9f4e | 775 | WHERE last_read >= '$last_online' AND |
e6c611c5 | 776 | owner_uid = ".$_SESSION["uid"] . " LIMIT 1000"; |
7f4f9f4e AD |
777 | |
778 | $result = db_query($link, $query); | |
779 | ||
780 | while ($line = db_fetch_assoc($result)) { | |
492a4a6a AD |
781 | $unread = (int) sql_bool_to_bool($line["unread"]); |
782 | $marked = (int) sql_bool_to_bool($line["marked"]); | |
783 | ||
784 | print "<sync-ok unread=\"$unread\" marked=\"$marked\" | |
785 | id=\"".$line["ref_id"]."\"/>"; | |
7f4f9f4e AD |
786 | } |
787 | ||
badac687 AD |
788 | } |
789 | } | |
790 | ||
791 | print "</sync>"; | |
792 | ||
87b16a0a AD |
793 | if ($stage == 0) { |
794 | print "<feeds>"; | |
795 | ||
d8781c91 | 796 | $result = db_query($link, "SELECT id, title, cat_id FROM |
117335bf | 797 | ttrss_feeds WHERE owner_uid = ".$_SESSION["uid"]); |
87b16a0a AD |
798 | |
799 | while ($line = db_fetch_assoc($result)) { | |
36f78797 AD |
800 | |
801 | $has_icon = (int) feed_has_icon($line["id"]); | |
802 | ||
d8781c91 AD |
803 | print "<feed has_icon=\"$has_icon\" |
804 | cat_id=\"".(int)$line["cat_id"]."\" id=\"".$line["id"]."\"><![CDATA["; | |
87b16a0a AD |
805 | print $line["title"]; |
806 | print "]]></feed>"; | |
807 | } | |
808 | ||
809 | print "</feeds>"; | |
810 | ||
d8781c91 AD |
811 | print "<feed-categories>"; |
812 | ||
75aa83ec | 813 | $result = db_query($link, "SELECT id, title, collapsed FROM |
d8781c91 AD |
814 | ttrss_feed_categories WHERE owner_uid = ".$_SESSION["uid"]); |
815 | ||
75aa83ec | 816 | print "<category id=\"0\" collapsed=\"". |
57937c42 | 817 | (int)get_pref($link, "_COLLAPSED_UNCAT")."\"><![CDATA["; |
d8781c91 AD |
818 | print __("Uncategorized"); |
819 | print "]]></category>"; | |
820 | ||
d6416405 | 821 | print "<category id=\"-1\" collapsed=\"". |
57937c42 | 822 | (int)get_pref($link, "_COLLAPSED_SPECIAL")."\"><![CDATA["; |
d6416405 AD |
823 | print __("Special"); |
824 | print "]]></category>"; | |
825 | ||
c2726c96 | 826 | print "<category id=\"-2\" collapsed=\"". |
57937c42 | 827 | (int)get_pref($link, "_COLLAPSED_LABELS")."\"><![CDATA["; |
c2726c96 AD |
828 | print __("Labels"); |
829 | print "]]></category>"; | |
830 | ||
d8781c91 | 831 | while ($line = db_fetch_assoc($result)) { |
75aa83ec AD |
832 | print "<category |
833 | id=\"".$line["id"]."\" | |
834 | collapsed=\"".(int)sql_bool_to_bool($line["collapsed"])."\"><![CDATA["; | |
d8781c91 AD |
835 | print $line["title"]; |
836 | print "]]></category>"; | |
837 | } | |
838 | ||
839 | print "</feed-categories>"; | |
840 | ||
ed22888b AD |
841 | print "<labels>"; |
842 | ||
843 | $result = db_query($link, "SELECT * FROM | |
844 | ttrss_labels2 WHERE owner_uid = ".$_SESSION["uid"]); | |
845 | ||
846 | while ($line = db_fetch_assoc($result)) { | |
847 | print "<label | |
848 | id=\"".$line["id"]."\" | |
849 | fg_color=\"".$line["fg_color"]."\" | |
850 | bg_color=\"".$line["bg_color"]."\" | |
851 | ><![CDATA["; | |
852 | print $line["caption"]; | |
853 | print "]]></label>"; | |
854 | } | |
855 | ||
856 | ||
857 | print "</labels>"; | |
d8781c91 | 858 | |
87b16a0a AD |
859 | } |
860 | ||
6a1cd591 | 861 | if ($stage > 0) { |
6a1cd591 AD |
862 | print "<articles>"; |
863 | ||
d9447516 | 864 | $limit = 10; |
6a1cd591 AD |
865 | $skip = $limit*($stage-1); |
866 | ||
3e52ab08 AD |
867 | print "<limit value=\"$limit\"/>"; |
868 | ||
6a1cd591 AD |
869 | if ($amount > 0) $amount -= $skip; |
870 | ||
871 | if ($amount > 0) { | |
872 | ||
873 | $limit = min($limit, $amount); | |
874 | ||
875 | if ($unread_only) { | |
a400a562 | 876 | $unread_qpart = "(unread = true OR marked = true) AND "; |
6a1cd591 AD |
877 | } |
878 | ||
67eb2531 | 879 | if ($cidt && $cidb) { |
04870193 | 880 | $cid_qpart = "(ttrss_entries.id > $cidt OR ttrss_entries.id < $cidb) AND "; |
95f0c2c5 AD |
881 | } |
882 | ||
67eb2531 | 883 | if (DB_TYPE == "pgsql") { |
d9447516 | 884 | $date_qpart = "updated >= NOW() - INTERVAL '1 week' AND"; |
67eb2531 | 885 | } else { |
d9447516 | 886 | $date_qpart = "updated >= DATE_SUB(NOW(), INTERVAL 1 WEEK) AND"; |
67eb2531 AD |
887 | } |
888 | ||
6a1cd591 | 889 | $result = db_query($link, |
c1a0541a AD |
890 | "SELECT DISTINCT ttrss_entries.id,ttrss_entries.title, |
891 | guid,link,comments, | |
892 | feed_id,content,updated,unread,marked FROM | |
893 | ttrss_user_entries,ttrss_entries,ttrss_feeds | |
894 | WHERE $unread_qpart $cid_qpart $date_qpart | |
c1a0541a AD |
895 | ttrss_feeds.id = feed_id AND |
896 | ref_id = ttrss_entries.id AND | |
897 | ttrss_user_entries.owner_uid = ".$_SESSION["uid"]." | |
6a1cd591 | 898 | ORDER BY updated DESC LIMIT $limit OFFSET $skip"); |
fe8f2f0c | 899 | |
3034277a | 900 | if (function_exists('json_encode')) { |
6a2034f9 | 901 | |
3034277a AD |
902 | while ($line = db_fetch_assoc($result)) { |
903 | print "<article><![CDATA["; | |
904 | ||
905 | $line["marked"] = (int)sql_bool_to_bool($line["marked"]); | |
906 | $line["unread"] = (int)sql_bool_to_bool($line["unread"]); | |
3ab18266 | 907 | |
c2726c96 AD |
908 | $line["labels"] = get_article_labels($link, $line["id"]); |
909 | ||
3ab18266 AD |
910 | // too slow :( |
911 | // $line["tags"] = format_tags_string( | |
912 | // get_article_tags($link, $line["id"]), $line["id"]); | |
3034277a AD |
913 | |
914 | print json_encode($line); | |
915 | print "]]></article>"; | |
916 | } | |
6a1cd591 AD |
917 | } |
918 | ||
919 | } | |
920 | ||
921 | print "</articles>"; | |
922 | ||
923 | } | |
924 | ||
87b16a0a AD |
925 | print "</rpc-reply>"; |
926 | ||
927 | return; | |
928 | } | |
929 | ||
d8ea9902 AD |
930 | if ($subop == "digest-get-contents") { |
931 | $article_id = db_escape_string($_REQUEST['article_id']); | |
932 | ||
933 | $result = db_query($link, "SELECT content | |
934 | FROM ttrss_entries, ttrss_user_entries | |
935 | WHERE id = '$article_id' AND ref_id = id AND owner_uid = ".$_SESSION['uid']); | |
936 | ||
937 | print "<rpc-reply>"; | |
938 | ||
939 | print "<article id=\"$article_id\"><![CDATA["; | |
940 | ||
941 | $content = sanitize_rss($link, db_fetch_result($result, 0, "content")); | |
942 | ||
943 | print $content; | |
944 | ||
945 | print "]]></article>"; | |
946 | ||
947 | print "</rpc-reply>"; | |
948 | ||
949 | return; | |
950 | } | |
951 | ||
1ca8997b | 952 | if ($subop == "digest-update") { |
b41c2549 | 953 | $feed_id = db_escape_string($_REQUEST['feed_id']); |
1ca8997b | 954 | $offset = db_escape_string($_REQUEST['offset']); |
e4c530dc | 955 | $seq = db_escape_string($_REQUEST['seq']); |
1ca8997b | 956 | |
b41c2549 | 957 | if (!$feed_id) $feed_id = -4; |
1ca8997b | 958 | if (!$offset) $offset = 0; |
1ca8997b AD |
959 | print "<rpc-reply>"; |
960 | ||
e4c530dc AD |
961 | print "<seq>$seq</seq>"; |
962 | ||
1ca8997b | 963 | $headlines = api_get_headlines($link, $feed_id, 10, $offset, |
d8ea9902 | 964 | '', ($feed_id == -4), true, false, "unread", "updated DESC"); |
1ca8997b AD |
965 | |
966 | //function api_get_headlines($link, $feed_id, $limit, $offset, | |
967 | // $filter, $is_cat, $show_excerpt, $show_content, $view_mode) { | |
968 | ||
78ac6caf AD |
969 | print "<headlines-title><![CDATA[" . getFeedTitle($link, $feed_id) . |
970 | "]]></headlines-title>"; | |
971 | ||
1ca8997b AD |
972 | print "<headlines><![CDATA[" . json_encode($headlines) . "]]></headlines>"; |
973 | ||
974 | print "</rpc-reply>"; | |
975 | return; | |
976 | } | |
977 | ||
978 | if ($subop == "digest-init") { | |
911d4c08 AD |
979 | print "<rpc-reply>"; |
980 | ||
981 | $tmp_feeds = api_get_feeds($link, false, true, false, 0); | |
982 | $feeds = array(); | |
983 | ||
984 | foreach ($tmp_feeds as $f) { | |
b41c2549 | 985 | if ($f['id'] > 0 || $f['id'] == -4) array_push($feeds, $f); |
911d4c08 AD |
986 | } |
987 | ||
911d4c08 AD |
988 | print "<feeds><![CDATA[" . json_encode($feeds) . "]]></feeds>"; |
989 | ||
911d4c08 AD |
990 | print "</rpc-reply>"; |
991 | return; | |
992 | } | |
993 | ||
c1b5cd23 AD |
994 | if ($subop == "catchupFeed") { |
995 | ||
996 | $feed_id = db_escape_string($_REQUEST['feed_id']); | |
997 | $is_cat = db_escape_string($_REQUEST['is_cat']); | |
998 | ||
999 | print "<rpc-reply>"; | |
1000 | ||
1001 | catchup_feed($link, $feed_id, $is_cat); | |
1002 | ||
1003 | print "</rpc-reply>"; | |
1004 | ||
1005 | return; | |
1006 | } | |
1007 | ||
31a53903 AD |
1008 | if ($subop == "sendEmail") { |
1009 | $secretkey = $_REQUEST['secretkey']; | |
1010 | ||
1011 | print "<rpc-reply>"; | |
1012 | ||
1013 | if (DIGEST_ENABLE && $_SESSION['email_secretkey'] && | |
1014 | $secretkey == $_SESSION['email_secretkey']) { | |
1015 | ||
1016 | $_SESSION['email_secretkey'] = ''; | |
1017 | ||
1018 | $destination = $_REQUEST['destination']; | |
1019 | $subject = $_REQUEST['subject']; | |
1020 | $content = $_REQUEST['content']; | |
1021 | ||
1022 | $replyto = strip_tags($_SESSION['email_replyto']); | |
1023 | $fromname = strip_tags($_SESSION['email_fromname']); | |
1024 | ||
1025 | $mail = new PHPMailer(); | |
1026 | ||
1027 | $mail->PluginDir = "lib/phpmailer/"; | |
1028 | $mail->SetLanguage("en", "lib/phpmailer/language/"); | |
1029 | ||
1030 | $mail->CharSet = "UTF-8"; | |
1031 | ||
1032 | $mail->From = $replyto; | |
1033 | $mail->FromName = $fromname; | |
1034 | $mail->AddAddress($destination); | |
1035 | ||
1036 | if (DIGEST_SMTP_HOST) { | |
1037 | $mail->Host = DIGEST_SMTP_HOST; | |
1038 | $mail->Mailer = "smtp"; | |
1039 | $mail->SMTPAuth = DIGEST_SMTP_LOGIN != ''; | |
1040 | $mail->Username = DIGEST_SMTP_LOGIN; | |
1041 | $mail->Password = DIGEST_SMTP_PASSWORD; | |
1042 | } | |
1043 | ||
1044 | $mail->IsHTML(false); | |
1045 | $mail->Subject = $subject; | |
1046 | $mail->Body = $content; | |
1047 | ||
1048 | $rc = $mail->Send(); | |
1049 | ||
1050 | if (!$rc) { | |
1051 | print "<error><![CDATA[" . $mail->ErrorInfo . "]]></error>"; | |
1052 | } else { | |
1053 | save_email_address($link, db_escape_string($destination)); | |
1054 | print "<message>OK</message>"; | |
1055 | } | |
1056 | ||
1057 | } else { | |
1058 | print "<error>Not authorized.</error>"; | |
1059 | } | |
1060 | ||
1061 | print "</rpc-reply>"; | |
1062 | ||
1063 | return; | |
1064 | } | |
1065 | ||
1066 | if ($subop == "completeEmails") { | |
1067 | ||
1068 | $search = db_escape_string($_REQUEST["search"]); | |
1069 | ||
1070 | print "<ul>"; | |
1071 | ||
1072 | foreach ($_SESSION['stored_emails'] as $email) { | |
1073 | if (strpos($email, $search) !== false) { | |
1074 | print "<li>$email</li>"; | |
1075 | } | |
1076 | } | |
1077 | ||
1078 | print "</ul>"; | |
1079 | ||
1080 | return; | |
1081 | } | |
1082 | ||
5c7c7da9 AD |
1083 | if ($subop == "quickAddCat") { |
1084 | print "<rpc-reply>"; | |
1085 | ||
1086 | $cat = db_escape_string($_REQUEST["cat"]); | |
1087 | ||
1088 | add_feed_category($link, $cat); | |
1089 | ||
1090 | $result = db_query($link, "SELECT id FROM ttrss_feed_categories WHERE | |
1091 | title = '$cat' AND owner_uid = " . $_SESSION["uid"]); | |
1092 | ||
1093 | if (db_num_rows($result) == 1) { | |
1094 | $id = db_fetch_result($result, 0, "id"); | |
1095 | } else { | |
1096 | $id = 0; | |
1097 | } | |
1098 | ||
1099 | print "<payload><![CDATA["; | |
1100 | print_feed_cat_select($link, "cat_id", $id); | |
1101 | print "]]></payload>"; | |
1102 | ||
1103 | print "</rpc-reply>"; | |
1104 | ||
1105 | return; | |
1106 | } | |
1107 | ||
8801fb01 AD |
1108 | if ($subop == "regenFeedKey") { |
1109 | $feed_id = db_escape_string($_REQUEST['id']); | |
1110 | $is_cat = (bool) db_escape_string($_REQUEST['is_cat']); | |
1111 | ||
1112 | print "<rpc-reply>"; | |
1113 | ||
1114 | $new_key = update_feed_access_key($link, $feed_id, $is_cat); | |
1115 | ||
1116 | print "<link><![CDATA[$new_key]]></link>"; | |
1117 | ||
1118 | print "</rpc-reply>"; | |
1119 | ||
1120 | return; | |
1121 | } | |
1122 | ||
8d86f15f AD |
1123 | if ($subop == "clearKeys") { |
1124 | ||
1125 | db_query($link, "DELETE FROM ttrss_access_keys WHERE | |
1126 | owner_uid = " . $_SESSION["uid"]); | |
1127 | ||
1128 | print "<rpc-reply><message>OK</message></rpc-reply>"; | |
1129 | ||
1130 | return; | |
1131 | } | |
1132 | ||
85bd574b | 1133 | print "<rpc-reply><error>Unknown method: $subop</error></rpc-reply>"; |
01b3e191 AD |
1134 | } |
1135 | ?> |