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