]> git.wh0rd.org Git - tt-rss.git/blob - classes/rpc.php
fix globalUpdateFeeds failing when no active session exists
[tt-rss.git] / classes / rpc.php
1 <?php
2 class RPC extends Handler_Protected {
3
4         function csrf_ignore($method) {
5                 $csrf_ignored = array("sanitycheck", "completelabels");
6
7                 return array_search($method, $csrf_ignored) !== false;
8         }
9
10         function setprofile() {
11                 $id = $this->dbh->escape_string($_REQUEST["id"]);
12
13                 $_SESSION["profile"] = $id;
14         }
15
16         function remprofiles() {
17                 $ids = explode(",", $this->dbh->escape_string(trim($_REQUEST["ids"])));
18
19                 foreach ($ids as $id) {
20                         if ($_SESSION["profile"] != $id) {
21                                 $this->dbh->query("DELETE FROM ttrss_settings_profiles WHERE id = '$id' AND
22                                                         owner_uid = " . $_SESSION["uid"]);
23                         }
24                 }
25         }
26
27         // Silent
28         function addprofile() {
29                 $title = $this->dbh->escape_string(trim($_REQUEST["title"]));
30                 if ($title) {
31                         $this->dbh->query("BEGIN");
32
33                         $result = $this->dbh->query("SELECT id FROM ttrss_settings_profiles
34                                 WHERE title = '$title' AND owner_uid = " . $_SESSION["uid"]);
35
36                         if ($this->dbh->num_rows($result) == 0) {
37
38                                 $this->dbh->query("INSERT INTO ttrss_settings_profiles (title, owner_uid)
39                                                         VALUES ('$title', ".$_SESSION["uid"] .")");
40
41                                 $result = $this->dbh->query("SELECT id FROM ttrss_settings_profiles WHERE
42                                         title = '$title'");
43
44                                 if ($this->dbh->num_rows($result) != 0) {
45                                         $profile_id = $this->dbh->fetch_result($result, 0, "id");
46
47                                         if ($profile_id) {
48                                                 initialize_user_prefs($_SESSION["uid"], $profile_id);
49                                         }
50                                 }
51                         }
52
53                         $this->dbh->query("COMMIT");
54                 }
55         }
56
57         // Silent
58         function saveprofile() {
59                 $id = $this->dbh->escape_string($_REQUEST["id"]);
60                 $title = $this->dbh->escape_string(trim($_REQUEST["value"]));
61
62                 if ($id == 0) {
63                         print __("Default profile");
64                         return;
65                 }
66
67                 if ($title) {
68                         $this->dbh->query("BEGIN");
69
70                         $result = $this->dbh->query("SELECT id FROM ttrss_settings_profiles
71                                 WHERE title = '$title' AND owner_uid =" . $_SESSION["uid"]);
72
73                         if ($this->dbh->num_rows($result) == 0) {
74                                 $this->dbh->query("UPDATE ttrss_settings_profiles
75                                                         SET title = '$title' WHERE id = '$id' AND
76                                                         owner_uid = " . $_SESSION["uid"]);
77                                 print $title;
78                         } else {
79                                 $result = $this->dbh->query("SELECT title FROM ttrss_settings_profiles
80                                                         WHERE id = '$id' AND owner_uid =" . $_SESSION["uid"]);
81                                 print $this->dbh->fetch_result($result, 0, "title");
82                         }
83
84                         $this->dbh->query("COMMIT");
85                 }
86         }
87
88         // Silent
89         function remarchive() {
90                 $ids = explode(",", $this->dbh->escape_string($_REQUEST["ids"]));
91
92                 foreach ($ids as $id) {
93                         $result = $this->dbh->query("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 = $this->dbh->affected_rows($result);
99                 }
100         }
101
102         function addfeed() {
103                 $feed = $this->dbh->escape_string($_REQUEST['feed']);
104                 $cat = $this->dbh->escape_string($_REQUEST['cat']);
105                 $login = $this->dbh->escape_string($_REQUEST['login']);
106                 $pass = trim($_REQUEST['pass']); // escaped later
107
108                 $rc = subscribe_to_feed($feed, $cat, $login, $pass);
109
110                 print json_encode(array("result" => $rc));
111         }
112
113         function togglepref() {
114                 $key = $this->dbh->escape_string($_REQUEST["key"]);
115                 set_pref($key, !get_pref($key));
116                 $value = get_pref($key);
117
118                 print json_encode(array("param" =>$key, "value" => $value));
119         }
120
121         function setpref() {
122                 // set_pref escapes input, so no need to double escape it here
123                 $key = $_REQUEST['key'];
124                 $value = str_replace("\n", "<br/>", $_REQUEST['value']);
125
126                 set_pref($key, $value, $_SESSION['uid'], $key != 'USER_STYLESHEET');
127
128                 print json_encode(array("param" =>$key, "value" => $value));
129         }
130
131         function mark() {
132                 $mark = $_REQUEST["mark"];
133                 $id = $this->dbh->escape_string($_REQUEST["id"]);
134
135                 if ($mark == "1") {
136                         $mark = "true";
137                 } else {
138                         $mark = "false";
139                 }
140
141                 $result = $this->dbh->query("UPDATE ttrss_user_entries SET marked = $mark,
142                                         last_marked = NOW()
143                                         WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
144
145                 print json_encode(array("message" => "UPDATE_COUNTERS"));
146         }
147
148         function delete() {
149                 $ids = $this->dbh->escape_string($_REQUEST["ids"]);
150
151                 $result = $this->dbh->query("DELETE FROM ttrss_user_entries
152                 WHERE ref_id IN ($ids) AND owner_uid = " . $_SESSION["uid"]);
153
154                 purge_orphans();
155
156                 print json_encode(array("message" => "UPDATE_COUNTERS"));
157         }
158
159         function unarchive() {
160                 $ids = explode(",", $_REQUEST["ids"]);
161
162                 foreach ($ids as $id) {
163                         $id = $this->dbh->escape_string(trim($id));
164                         $this->dbh->query("BEGIN");
165
166                         $result = $this->dbh->query("SELECT feed_url,site_url,title FROM ttrss_archived_feeds
167                                 WHERE id = (SELECT orig_feed_id FROM ttrss_user_entries WHERE ref_id = $id
168                                 AND owner_uid = ".$_SESSION["uid"].")");
169
170                         if ($this->dbh->num_rows($result) != 0) {
171                                 $feed_url = $this->dbh->escape_string(db_fetch_result($result, 0, "feed_url"));
172                                 $site_url = $this->dbh->escape_string(db_fetch_result($result, 0, "site_url"));
173                                 $title = $this->dbh->escape_string(db_fetch_result($result, 0, "title"));
174
175                                 $result = $this->dbh->query("SELECT id FROM ttrss_feeds WHERE feed_url = '$feed_url'
176                                         AND owner_uid = " .$_SESSION["uid"]);
177
178                                 if ($this->dbh->num_rows($result) == 0) {
179
180                                         if (!$title) $title = '[Unknown]';
181
182                                         $result = $this->dbh->query(
183                                                 "INSERT INTO ttrss_feeds
184                                                         (owner_uid,feed_url,site_url,title,cat_id,auth_login,auth_pass,update_method)
185                                                         VALUES (".$_SESSION["uid"].",
186                                                         '$feed_url',
187                                                         '$site_url',
188                                                         '$title',
189                                                         NULL, '', '', 0)");
190
191                                         $result = $this->dbh->query(
192                                                 "SELECT id FROM ttrss_feeds WHERE feed_url = '$feed_url'
193                                                 AND owner_uid = ".$_SESSION["uid"]);
194
195                                         if ($this->dbh->num_rows($result) != 0) {
196                                                 $feed_id = $this->dbh->fetch_result($result, 0, "id");
197                                         }
198
199                                 } else {
200                                         $feed_id = $this->dbh->fetch_result($result, 0, "id");
201                                 }
202
203                                 if ($feed_id) {
204                                         $result = $this->dbh->query("UPDATE ttrss_user_entries
205                                                 SET feed_id = '$feed_id', orig_feed_id = NULL
206                                                 WHERE ref_id = $id AND owner_uid = " . $_SESSION["uid"]);
207                                 }
208                         }
209
210                         $this->dbh->query("COMMIT");
211                 }
212
213                 print json_encode(array("message" => "UPDATE_COUNTERS"));
214         }
215
216         function archive() {
217                 $ids = explode(",", $this->dbh->escape_string($_REQUEST["ids"]));
218
219                 foreach ($ids as $id) {
220                         $this->archive_article($id, $_SESSION["uid"]);
221                 }
222
223                 print json_encode(array("message" => "UPDATE_COUNTERS"));
224         }
225
226         private function archive_article($id, $owner_uid) {
227                 $this->dbh->query("BEGIN");
228
229                 $result = $this->dbh->query("SELECT feed_id FROM ttrss_user_entries
230                         WHERE ref_id = '$id' AND owner_uid = $owner_uid");
231
232                 if ($this->dbh->num_rows($result) != 0) {
233
234                         /* prepare the archived table */
235
236                         $feed_id = (int) $this->dbh->fetch_result($result, 0, "feed_id");
237
238                         if ($feed_id) {
239                                 $result = $this->dbh->query("SELECT id FROM ttrss_archived_feeds
240                                         WHERE id = '$feed_id'");
241
242                                 if ($this->dbh->num_rows($result) == 0) {
243                                         $this->dbh->query("INSERT INTO ttrss_archived_feeds
244                                                 (id, owner_uid, title, feed_url, site_url)
245                                         SELECT id, owner_uid, title, feed_url, site_url from ttrss_feeds
246                                         WHERE id = '$feed_id'");
247                                 }
248
249                                 $this->dbh->query("UPDATE ttrss_user_entries
250                                         SET orig_feed_id = feed_id, feed_id = NULL
251                                         WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
252                         }
253                 }
254
255                 $this->dbh->query("COMMIT");
256         }
257
258         function publ() {
259                 $pub = $_REQUEST["pub"];
260                 $id = $this->dbh->escape_string($_REQUEST["id"]);
261                 $note = trim(strip_tags($this->dbh->escape_string($_REQUEST["note"])));
262
263                 if ($pub == "1") {
264                         $pub = "true";
265                 } else {
266                         $pub = "false";
267                 }
268
269                 $result = $this->dbh->query("UPDATE ttrss_user_entries SET
270                         published = $pub, last_published = NOW()
271                         WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
272
273                 $pubsub_result = false;
274
275                 if (PUBSUBHUBBUB_HUB) {
276                         $rss_link = get_self_url_prefix() .
277                                 "/public.php?op=rss&id=-2&key=" .
278                                 get_feed_access_key(-2, false);
279
280                         $p = new Publisher(PUBSUBHUBBUB_HUB);
281
282                         $pubsub_result = $p->publish_update($rss_link);
283                 }
284
285                 print json_encode(array("message" => "UPDATE_COUNTERS",
286                         "pubsub_result" => $pubsub_result));
287         }
288
289         function getAllCounters() {
290                 $last_article_id = (int) $_REQUEST["last_article_id"];
291
292                 $reply = array();
293
294                 if (!empty($_REQUEST['seq'])) $reply['seq'] = (int) $_REQUEST['seq'];
295
296                 if ($last_article_id != getLastArticleId()) {
297                         $reply['counters'] = getAllCounters();
298                 }
299
300                 $reply['runtime-info'] = make_runtime_info();
301
302                 print json_encode($reply);
303         }
304
305         /* GET["cmode"] = 0 - mark as read, 1 - as unread, 2 - toggle */
306         function catchupSelected() {
307                 $ids = explode(",", $this->dbh->escape_string($_REQUEST["ids"]));
308                 $cmode = sprintf("%d", $_REQUEST["cmode"]);
309
310                 catchupArticlesById($ids, $cmode);
311
312                 print json_encode(array("message" => "UPDATE_COUNTERS", "ids" => $ids));
313         }
314
315         function markSelected() {
316                 $ids = explode(",", $this->dbh->escape_string($_REQUEST["ids"]));
317                 $cmode = sprintf("%d", $_REQUEST["cmode"]);
318
319                 $this->markArticlesById($ids, $cmode);
320
321                 print json_encode(array("message" => "UPDATE_COUNTERS"));
322         }
323
324         function publishSelected() {
325                 $ids = explode(",", $this->dbh->escape_string($_REQUEST["ids"]));
326                 $cmode = sprintf("%d", $_REQUEST["cmode"]);
327
328                 $this->publishArticlesById($ids, $cmode);
329
330                 print json_encode(array("message" => "UPDATE_COUNTERS"));
331         }
332
333         function sanityCheck() {
334                 $_SESSION["hasAudio"] = $_REQUEST["hasAudio"] === "true";
335                 $_SESSION["hasSandbox"] = $_REQUEST["hasSandbox"] === "true";
336                 $_SESSION["hasMp3"] = $_REQUEST["hasMp3"] === "true";
337                 $_SESSION["clientTzOffset"] = $_REQUEST["clientTzOffset"];
338
339                 $reply = array();
340
341                 $reply['error'] = sanity_check();
342
343                 if ($reply['error']['code'] == 0) {
344                         $reply['init-params'] = make_init_params();
345                         $reply['runtime-info'] = make_runtime_info();
346                 }
347
348                 print json_encode($reply);
349         }
350
351         function completeLabels() {
352                 $search = $this->dbh->escape_string($_REQUEST["search"]);
353
354                 $result = $this->dbh->query("SELECT DISTINCT caption FROM
355                                 ttrss_labels2
356                                 WHERE owner_uid = '".$_SESSION["uid"]."' AND
357                                 LOWER(caption) LIKE LOWER('$search%') ORDER BY caption
358                                 LIMIT 5");
359
360                 print "<ul>";
361                 while ($line = $this->dbh->fetch_assoc($result)) {
362                         print "<li>" . $line["caption"] . "</li>";
363                 }
364                 print "</ul>";
365         }
366
367         function purge() {
368                 $ids = explode(",", $this->dbh->escape_string($_REQUEST["ids"]));
369                 $days = sprintf("%d", $_REQUEST["days"]);
370
371                 foreach ($ids as $id) {
372
373                         $result = $this->dbh->query("SELECT id FROM ttrss_feeds WHERE
374                                 id = '$id' AND owner_uid = ".$_SESSION["uid"]);
375
376                         if ($this->dbh->num_rows($result) == 1) {
377                                 purge_feed($id, $days);
378                         }
379                 }
380         }
381
382         function updateFeedBrowser() {
383                 $search = $this->dbh->escape_string($_REQUEST["search"]);
384                 $limit = $this->dbh->escape_string($_REQUEST["limit"]);
385                 $mode = (int) $this->dbh->escape_string($_REQUEST["mode"]);
386
387                 require_once "feedbrowser.php";
388
389                 print json_encode(array("content" =>
390                         make_feed_browser($search, $limit, $mode),
391                                 "mode" => $mode));
392         }
393
394         // Silent
395         function massSubscribe() {
396
397                 $payload = json_decode($_REQUEST["payload"], false);
398                 $mode = $_REQUEST["mode"];
399
400                 if (!$payload || !is_array($payload)) return;
401
402                 if ($mode == 1) {
403                         foreach ($payload as $feed) {
404
405                                 $title = $this->dbh->escape_string($feed[0]);
406                                 $feed_url = $this->dbh->escape_string($feed[1]);
407
408                                 $result = $this->dbh->query("SELECT id FROM ttrss_feeds WHERE
409                                         feed_url = '$feed_url' AND owner_uid = " . $_SESSION["uid"]);
410
411                                 if ($this->dbh->num_rows($result) == 0) {
412                                         $result = $this->dbh->query("INSERT INTO ttrss_feeds
413                                                                         (owner_uid,feed_url,title,cat_id,site_url)
414                                                                         VALUES ('".$_SESSION["uid"]."',
415                                                                         '$feed_url', '$title', NULL, '')");
416                                 }
417                         }
418                 } else if ($mode == 2) {
419                         // feed archive
420                         foreach ($payload as $id) {
421                                 $result = $this->dbh->query("SELECT * FROM ttrss_archived_feeds
422                                         WHERE id = '$id' AND owner_uid = " . $_SESSION["uid"]);
423
424                                 if ($this->dbh->num_rows($result) != 0) {
425                                         $site_url = $this->dbh->escape_string(db_fetch_result($result, 0, "site_url"));
426                                         $feed_url = $this->dbh->escape_string(db_fetch_result($result, 0, "feed_url"));
427                                         $title = $this->dbh->escape_string(db_fetch_result($result, 0, "title"));
428
429                                         $result = $this->dbh->query("SELECT id FROM ttrss_feeds WHERE
430                                                 feed_url = '$feed_url' AND owner_uid = " . $_SESSION["uid"]);
431
432                                         if ($this->dbh->num_rows($result) == 0) {
433                                                 $result = $this->dbh->query("INSERT INTO ttrss_feeds
434                                                                                 (owner_uid,feed_url,title,cat_id,site_url)
435                                                                         VALUES ('$id','".$_SESSION["uid"]."',
436                                                                         '$feed_url', '$title', NULL, '$site_url')");
437                                         }
438                                 }
439                         }
440                 }
441         }
442
443         function catchupFeed() {
444                 $feed_id = $this->dbh->escape_string($_REQUEST['feed_id']);
445                 $is_cat = $this->dbh->escape_string($_REQUEST['is_cat']) == "true";
446                 $mode = $this->dbh->escape_string($_REQUEST['mode']);
447
448                 catchup_feed($feed_id, $is_cat, false, false, $mode);
449
450                 print json_encode(array("message" => "UPDATE_COUNTERS"));
451         }
452
453         function quickAddCat() {
454                 $cat = $this->dbh->escape_string($_REQUEST["cat"]);
455
456                 add_feed_category($cat);
457
458                 $result = $this->dbh->query("SELECT id FROM ttrss_feed_categories WHERE
459                         title = '$cat' AND owner_uid = " . $_SESSION["uid"]);
460
461                 if ($this->dbh->num_rows($result) == 1) {
462                         $id = $this->dbh->fetch_result($result, 0, "id");
463                 } else {
464                         $id = 0;
465                 }
466
467                 print_feed_cat_select("cat_id", $id, '');
468         }
469
470         function setpanelmode() {
471                 $wide = (int) $_REQUEST["wide"];
472
473                 setcookie("ttrss_widescreen", $wide,
474                         time() + COOKIE_LIFETIME_LONG);
475
476                 print json_encode(array("wide" => $wide));
477         }
478
479         static function updaterandomfeed_real($dbh) {
480
481                 // Test if the feed need a update (update interval exceded).
482                 if (DB_TYPE == "pgsql") {
483                         $update_limit_qpart = "AND ((
484                                         ttrss_feeds.update_interval = 0
485                                         AND ttrss_feeds.last_updated < NOW() - CAST((ttrss_user_prefs.value || ' minutes') AS INTERVAL)
486                                 ) OR (
487                                         ttrss_feeds.update_interval > 0
488                                         AND ttrss_feeds.last_updated < NOW() - CAST((ttrss_feeds.update_interval || ' minutes') AS INTERVAL)
489                                 ) OR ttrss_feeds.last_updated IS NULL
490                                 OR last_updated = '1970-01-01 00:00:00')";
491                 } else {
492                         $update_limit_qpart = "AND ((
493                                         ttrss_feeds.update_interval = 0
494                                         AND ttrss_feeds.last_updated < DATE_SUB(NOW(), INTERVAL CONVERT(ttrss_user_prefs.value, SIGNED INTEGER) MINUTE)
495                                 ) OR (
496                                         ttrss_feeds.update_interval > 0
497                                         AND ttrss_feeds.last_updated < DATE_SUB(NOW(), INTERVAL ttrss_feeds.update_interval MINUTE)
498                                 ) OR ttrss_feeds.last_updated IS NULL
499                                 OR last_updated = '1970-01-01 00:00:00')";
500                 }
501
502                 // Test if feed is currently being updated by another process.
503                 if (DB_TYPE == "pgsql") {
504                         $updstart_thresh_qpart = "AND (ttrss_feeds.last_update_started IS NULL OR ttrss_feeds.last_update_started < NOW() - INTERVAL '5 minutes')";
505                 } else {
506                         $updstart_thresh_qpart = "AND (ttrss_feeds.last_update_started IS NULL OR ttrss_feeds.last_update_started < DATE_SUB(NOW(), INTERVAL 5 MINUTE))";
507                 }
508
509                 $random_qpart = sql_random_function();
510
511                 // we could be invoked from public.php with no active session
512                 if ($_SESSION["uid"]) {
513                         $owner_check_qpart = "AND ttrss_feeds.owner_uid = '".$_SESSION["uid"]."'";
514                 } else {
515                         $owner_check_qpart = "";
516                 }
517
518                 // We search for feed needing update.
519                 $result = $dbh->query("SELECT ttrss_feeds.feed_url,ttrss_feeds.id
520                         FROM
521                                 ttrss_feeds, ttrss_users, ttrss_user_prefs
522                         WHERE
523                                 ttrss_feeds.owner_uid = ttrss_users.id
524                                 AND ttrss_users.id = ttrss_user_prefs.owner_uid
525                                 AND ttrss_user_prefs.pref_name = 'DEFAULT_UPDATE_INTERVAL'
526                                 $owner_check_qpart
527                                 $update_limit_qpart
528                                 $updstart_thresh_qpart
529                         ORDER BY $random_qpart LIMIT 30");
530
531                 $feed_id = -1;
532
533                 require_once "rssfuncs.php";
534
535                 $num_updated = 0;
536
537                 $tstart = time();
538
539                 while ($line = $dbh->fetch_assoc($result)) {
540                         $feed_id = $line["id"];
541
542                         if (time() - $tstart < ini_get("max_execution_time") * 0.7) {
543                                 update_rss_feed($feed_id, true);
544                                 ++$num_updated;
545                         } else {
546                                 break;
547                         }
548                 }
549
550                 // Purge orphans and cleanup tags
551                 purge_orphans();
552                 cleanup_tags(14, 50000);
553
554                 if ($num_updated > 0) {
555                         print json_encode(array("message" => "UPDATE_COUNTERS",
556                                 "num_updated" => $num_updated));
557                 } else {
558                         print json_encode(array("message" => "NOTHING_TO_UPDATE"));
559                 }
560
561         }
562
563         function updaterandomfeed() {
564                 RPC::updaterandomfeed_real($this->dbh);
565         }
566
567         private function markArticlesById($ids, $cmode) {
568
569                 $tmp_ids = array();
570
571                 foreach ($ids as $id) {
572                         array_push($tmp_ids, "ref_id = '$id'");
573                 }
574
575                 $ids_qpart = join(" OR ", $tmp_ids);
576
577                 if ($cmode == 0) {
578                         $this->dbh->query("UPDATE ttrss_user_entries SET
579                         marked = false, last_marked = NOW()
580                         WHERE ($ids_qpart) AND owner_uid = " . $_SESSION["uid"]);
581                 } else if ($cmode == 1) {
582                         $this->dbh->query("UPDATE ttrss_user_entries SET
583                         marked = true, last_marked = NOW()
584                         WHERE ($ids_qpart) AND owner_uid = " . $_SESSION["uid"]);
585                 } else {
586                         $this->dbh->query("UPDATE ttrss_user_entries SET
587                         marked = NOT marked,last_marked = NOW()
588                         WHERE ($ids_qpart) AND owner_uid = " . $_SESSION["uid"]);
589                 }
590         }
591
592         private function publishArticlesById($ids, $cmode) {
593
594                 $tmp_ids = array();
595
596                 foreach ($ids as $id) {
597                         array_push($tmp_ids, "ref_id = '$id'");
598                 }
599
600                 $ids_qpart = join(" OR ", $tmp_ids);
601
602                 if ($cmode == 0) {
603                         $this->dbh->query("UPDATE ttrss_user_entries SET
604                         published = false,last_published = NOW()
605                         WHERE ($ids_qpart) AND owner_uid = " . $_SESSION["uid"]);
606                 } else if ($cmode == 1) {
607                         $this->dbh->query("UPDATE ttrss_user_entries SET
608                         published = true,last_published = NOW()
609                         WHERE ($ids_qpart) AND owner_uid = " . $_SESSION["uid"]);
610                 } else {
611                         $this->dbh->query("UPDATE ttrss_user_entries SET
612                         published = NOT published,last_published = NOW()
613                         WHERE ($ids_qpart) AND owner_uid = " . $_SESSION["uid"]);
614                 }
615
616                 if (PUBSUBHUBBUB_HUB) {
617                         $rss_link = get_self_url_prefix() .
618                                 "/public.php?op=rss&id=-2&key=" .
619                                 get_feed_access_key(-2, false);
620
621                         $p = new Publisher(PUBSUBHUBBUB_HUB);
622
623                         $pubsub_result = $p->publish_update($rss_link);
624                 }
625         }
626
627         function getlinktitlebyid() {
628                 $id = $this->dbh->escape_string($_REQUEST['id']);
629
630                 $result = $this->dbh->query("SELECT link, title FROM ttrss_entries, ttrss_user_entries
631                         WHERE ref_id = '$id' AND ref_id = id AND owner_uid = ". $_SESSION["uid"]);
632
633                 if ($this->dbh->num_rows($result) != 0) {
634                         $link = $this->dbh->fetch_result($result, 0, "link");
635                         $title = $this->dbh->fetch_result($result, 0, "title");
636
637                         echo json_encode(array("link" => $link, "title" => $title));
638                 } else {
639                         echo json_encode(array("error" => "ARTICLE_NOT_FOUND"));
640                 }
641         }
642
643         function log() {
644                 $logmsg = $this->dbh->escape_string($_REQUEST['logmsg']);
645
646                 if ($logmsg) {
647                         Logger::get()->log_error(E_USER_WARNING,
648                                 $logmsg, '[client-js]', 0, false);
649                 }
650
651                 echo json_encode(array("message" => "HOST_ERROR_LOGGED"));
652
653         }
654 }
655 ?>