rpc.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642
  1. <?php
  2. class RPC extends Handler_Protected {
  3. function csrf_ignore($method) {
  4. $csrf_ignored = array("sanitycheck", "completelabels");
  5. return array_search($method, $csrf_ignored) !== false;
  6. }
  7. function setprofile() {
  8. $id = $this->dbh->escape_string($_REQUEST["id"]);
  9. $_SESSION["profile"] = $id;
  10. }
  11. function remprofiles() {
  12. $ids = explode(",", $this->dbh->escape_string(trim($_REQUEST["ids"])));
  13. foreach ($ids as $id) {
  14. if ($_SESSION["profile"] != $id) {
  15. $this->dbh->query("DELETE FROM ttrss_settings_profiles WHERE id = '$id' AND
  16. owner_uid = " . $_SESSION["uid"]);
  17. }
  18. }
  19. }
  20. // Silent
  21. function addprofile() {
  22. $title = $this->dbh->escape_string(trim($_REQUEST["title"]));
  23. if ($title) {
  24. $this->dbh->query("BEGIN");
  25. $result = $this->dbh->query("SELECT id FROM ttrss_settings_profiles
  26. WHERE title = '$title' AND owner_uid = " . $_SESSION["uid"]);
  27. if ($this->dbh->num_rows($result) == 0) {
  28. $this->dbh->query("INSERT INTO ttrss_settings_profiles (title, owner_uid)
  29. VALUES ('$title', ".$_SESSION["uid"] .")");
  30. $result = $this->dbh->query("SELECT id FROM ttrss_settings_profiles WHERE
  31. title = '$title'");
  32. if ($this->dbh->num_rows($result) != 0) {
  33. $profile_id = $this->dbh->fetch_result($result, 0, "id");
  34. if ($profile_id) {
  35. initialize_user_prefs($_SESSION["uid"], $profile_id);
  36. }
  37. }
  38. }
  39. $this->dbh->query("COMMIT");
  40. }
  41. }
  42. // Silent
  43. function saveprofile() {
  44. $id = $this->dbh->escape_string($_REQUEST["id"]);
  45. $title = $this->dbh->escape_string(trim($_REQUEST["value"]));
  46. if ($id == 0) {
  47. print __("Default profile");
  48. return;
  49. }
  50. if ($title) {
  51. $this->dbh->query("BEGIN");
  52. $result = $this->dbh->query("SELECT id FROM ttrss_settings_profiles
  53. WHERE title = '$title' AND owner_uid =" . $_SESSION["uid"]);
  54. if ($this->dbh->num_rows($result) == 0) {
  55. $this->dbh->query("UPDATE ttrss_settings_profiles
  56. SET title = '$title' WHERE id = '$id' AND
  57. owner_uid = " . $_SESSION["uid"]);
  58. print $title;
  59. } else {
  60. $result = $this->dbh->query("SELECT title FROM ttrss_settings_profiles
  61. WHERE id = '$id' AND owner_uid =" . $_SESSION["uid"]);
  62. print $this->dbh->fetch_result($result, 0, "title");
  63. }
  64. $this->dbh->query("COMMIT");
  65. }
  66. }
  67. // Silent
  68. function remarchive() {
  69. $ids = explode(",", $this->dbh->escape_string($_REQUEST["ids"]));
  70. foreach ($ids as $id) {
  71. $result = $this->dbh->query("DELETE FROM ttrss_archived_feeds WHERE
  72. (SELECT COUNT(*) FROM ttrss_user_entries
  73. WHERE orig_feed_id = '$id') = 0 AND
  74. id = '$id' AND owner_uid = ".$_SESSION["uid"]);
  75. $rc = $this->dbh->affected_rows($result);
  76. }
  77. }
  78. function addfeed() {
  79. $feed = $this->dbh->escape_string($_REQUEST['feed']);
  80. $cat = $this->dbh->escape_string($_REQUEST['cat']);
  81. $login = $this->dbh->escape_string($_REQUEST['login']);
  82. $pass = trim($_REQUEST['pass']); // escaped later
  83. $rc = subscribe_to_feed($feed, $cat, $login, $pass);
  84. print json_encode(array("result" => $rc));
  85. }
  86. function togglepref() {
  87. $key = $this->dbh->escape_string($_REQUEST["key"]);
  88. set_pref($key, !get_pref($key));
  89. $value = get_pref($key);
  90. print json_encode(array("param" =>$key, "value" => $value));
  91. }
  92. function setpref() {
  93. // set_pref escapes input, so no need to double escape it here
  94. $key = $_REQUEST['key'];
  95. $value = str_replace("\n", "<br/>", $_REQUEST['value']);
  96. set_pref($key, $value, $_SESSION['uid'], $key != 'USER_STYLESHEET');
  97. print json_encode(array("param" =>$key, "value" => $value));
  98. }
  99. function mark() {
  100. $mark = $_REQUEST["mark"];
  101. $id = $this->dbh->escape_string($_REQUEST["id"]);
  102. if ($mark == "1") {
  103. $mark = "true";
  104. } else {
  105. $mark = "false";
  106. }
  107. $result = $this->dbh->query("UPDATE ttrss_user_entries SET marked = $mark,
  108. last_marked = NOW()
  109. WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
  110. print json_encode(array("message" => "UPDATE_COUNTERS"));
  111. }
  112. function delete() {
  113. $ids = $this->dbh->escape_string($_REQUEST["ids"]);
  114. $result = $this->dbh->query("DELETE FROM ttrss_user_entries
  115. WHERE ref_id IN ($ids) AND owner_uid = " . $_SESSION["uid"]);
  116. purge_orphans();
  117. print json_encode(array("message" => "UPDATE_COUNTERS"));
  118. }
  119. function unarchive() {
  120. $ids = explode(",", $_REQUEST["ids"]);
  121. foreach ($ids as $id) {
  122. $id = $this->dbh->escape_string(trim($id));
  123. $this->dbh->query("BEGIN");
  124. $result = $this->dbh->query("SELECT feed_url,site_url,title FROM ttrss_archived_feeds
  125. WHERE id = (SELECT orig_feed_id FROM ttrss_user_entries WHERE ref_id = $id
  126. AND owner_uid = ".$_SESSION["uid"].")");
  127. if ($this->dbh->num_rows($result) != 0) {
  128. $feed_url = $this->dbh->escape_string(db_fetch_result($result, 0, "feed_url"));
  129. $site_url = $this->dbh->escape_string(db_fetch_result($result, 0, "site_url"));
  130. $title = $this->dbh->escape_string(db_fetch_result($result, 0, "title"));
  131. $result = $this->dbh->query("SELECT id FROM ttrss_feeds WHERE feed_url = '$feed_url'
  132. AND owner_uid = " .$_SESSION["uid"]);
  133. if ($this->dbh->num_rows($result) == 0) {
  134. if (!$title) $title = '[Unknown]';
  135. $result = $this->dbh->query(
  136. "INSERT INTO ttrss_feeds
  137. (owner_uid,feed_url,site_url,title,cat_id,auth_login,auth_pass,update_method)
  138. VALUES (".$_SESSION["uid"].",
  139. '$feed_url',
  140. '$site_url',
  141. '$title',
  142. NULL, '', '', 0)");
  143. $result = $this->dbh->query(
  144. "SELECT id FROM ttrss_feeds WHERE feed_url = '$feed_url'
  145. AND owner_uid = ".$_SESSION["uid"]);
  146. if ($this->dbh->num_rows($result) != 0) {
  147. $feed_id = $this->dbh->fetch_result($result, 0, "id");
  148. }
  149. } else {
  150. $feed_id = $this->dbh->fetch_result($result, 0, "id");
  151. }
  152. if ($feed_id) {
  153. $result = $this->dbh->query("UPDATE ttrss_user_entries
  154. SET feed_id = '$feed_id', orig_feed_id = NULL
  155. WHERE ref_id = $id AND owner_uid = " . $_SESSION["uid"]);
  156. }
  157. }
  158. $this->dbh->query("COMMIT");
  159. }
  160. print json_encode(array("message" => "UPDATE_COUNTERS"));
  161. }
  162. function archive() {
  163. $ids = explode(",", $this->dbh->escape_string($_REQUEST["ids"]));
  164. foreach ($ids as $id) {
  165. $this->archive_article($id, $_SESSION["uid"]);
  166. }
  167. print json_encode(array("message" => "UPDATE_COUNTERS"));
  168. }
  169. private function archive_article($id, $owner_uid) {
  170. $this->dbh->query("BEGIN");
  171. $result = $this->dbh->query("SELECT feed_id FROM ttrss_user_entries
  172. WHERE ref_id = '$id' AND owner_uid = $owner_uid");
  173. if ($this->dbh->num_rows($result) != 0) {
  174. /* prepare the archived table */
  175. $feed_id = (int) $this->dbh->fetch_result($result, 0, "feed_id");
  176. if ($feed_id) {
  177. $result = $this->dbh->query("SELECT id FROM ttrss_archived_feeds
  178. WHERE id = '$feed_id'");
  179. if ($this->dbh->num_rows($result) == 0) {
  180. $this->dbh->query("INSERT INTO ttrss_archived_feeds
  181. (id, owner_uid, title, feed_url, site_url)
  182. SELECT id, owner_uid, title, feed_url, site_url from ttrss_feeds
  183. WHERE id = '$feed_id'");
  184. }
  185. $this->dbh->query("UPDATE ttrss_user_entries
  186. SET orig_feed_id = feed_id, feed_id = NULL
  187. WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
  188. }
  189. }
  190. $this->dbh->query("COMMIT");
  191. }
  192. function publ() {
  193. $pub = $_REQUEST["pub"];
  194. $id = $this->dbh->escape_string($_REQUEST["id"]);
  195. $note = trim(strip_tags($this->dbh->escape_string($_REQUEST["note"])));
  196. if ($pub == "1") {
  197. $pub = "true";
  198. } else {
  199. $pub = "false";
  200. }
  201. $result = $this->dbh->query("UPDATE ttrss_user_entries SET
  202. published = $pub, last_published = NOW()
  203. WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
  204. $pubsub_result = false;
  205. if (PUBSUBHUBBUB_HUB) {
  206. $rss_link = get_self_url_prefix() .
  207. "/public.php?op=rss&id=-2&key=" .
  208. get_feed_access_key(-2, false);
  209. $p = new Publisher(PUBSUBHUBBUB_HUB);
  210. $pubsub_result = $p->publish_update($rss_link);
  211. }
  212. print json_encode(array("message" => "UPDATE_COUNTERS",
  213. "pubsub_result" => $pubsub_result));
  214. }
  215. function getAllCounters() {
  216. $last_article_id = (int) $_REQUEST["last_article_id"];
  217. $reply = array();
  218. if (!empty($_REQUEST['seq'])) $reply['seq'] = (int) $_REQUEST['seq'];
  219. if ($last_article_id != getLastArticleId()) {
  220. $reply['counters'] = getAllCounters();
  221. }
  222. $reply['runtime-info'] = make_runtime_info();
  223. print json_encode($reply);
  224. }
  225. /* GET["cmode"] = 0 - mark as read, 1 - as unread, 2 - toggle */
  226. function catchupSelected() {
  227. $ids = explode(",", $this->dbh->escape_string($_REQUEST["ids"]));
  228. $cmode = sprintf("%d", $_REQUEST["cmode"]);
  229. catchupArticlesById($ids, $cmode);
  230. print json_encode(array("message" => "UPDATE_COUNTERS", "ids" => $ids));
  231. }
  232. function markSelected() {
  233. $ids = explode(",", $this->dbh->escape_string($_REQUEST["ids"]));
  234. $cmode = sprintf("%d", $_REQUEST["cmode"]);
  235. $this->markArticlesById($ids, $cmode);
  236. print json_encode(array("message" => "UPDATE_COUNTERS"));
  237. }
  238. function publishSelected() {
  239. $ids = explode(",", $this->dbh->escape_string($_REQUEST["ids"]));
  240. $cmode = sprintf("%d", $_REQUEST["cmode"]);
  241. $this->publishArticlesById($ids, $cmode);
  242. print json_encode(array("message" => "UPDATE_COUNTERS"));
  243. }
  244. function sanityCheck() {
  245. $_SESSION["hasAudio"] = $_REQUEST["hasAudio"] === "true";
  246. $_SESSION["hasSandbox"] = $_REQUEST["hasSandbox"] === "true";
  247. $_SESSION["hasMp3"] = $_REQUEST["hasMp3"] === "true";
  248. $_SESSION["clientTzOffset"] = $_REQUEST["clientTzOffset"];
  249. $reply = array();
  250. $reply['error'] = sanity_check();
  251. if ($reply['error']['code'] == 0) {
  252. $reply['init-params'] = make_init_params();
  253. $reply['runtime-info'] = make_runtime_info();
  254. }
  255. print json_encode($reply);
  256. }
  257. function completeLabels() {
  258. $search = $this->dbh->escape_string($_REQUEST["search"]);
  259. $result = $this->dbh->query("SELECT DISTINCT caption FROM
  260. ttrss_labels2
  261. WHERE owner_uid = '".$_SESSION["uid"]."' AND
  262. LOWER(caption) LIKE LOWER('$search%') ORDER BY caption
  263. LIMIT 5");
  264. print "<ul>";
  265. while ($line = $this->dbh->fetch_assoc($result)) {
  266. print "<li>" . $line["caption"] . "</li>";
  267. }
  268. print "</ul>";
  269. }
  270. function purge() {
  271. $ids = explode(",", $this->dbh->escape_string($_REQUEST["ids"]));
  272. $days = sprintf("%d", $_REQUEST["days"]);
  273. foreach ($ids as $id) {
  274. $result = $this->dbh->query("SELECT id FROM ttrss_feeds WHERE
  275. id = '$id' AND owner_uid = ".$_SESSION["uid"]);
  276. if ($this->dbh->num_rows($result) == 1) {
  277. purge_feed($id, $days);
  278. }
  279. }
  280. }
  281. function updateFeedBrowser() {
  282. $search = $this->dbh->escape_string($_REQUEST["search"]);
  283. $limit = $this->dbh->escape_string($_REQUEST["limit"]);
  284. $mode = (int) $this->dbh->escape_string($_REQUEST["mode"]);
  285. require_once "feedbrowser.php";
  286. print json_encode(array("content" =>
  287. make_feed_browser($search, $limit, $mode),
  288. "mode" => $mode));
  289. }
  290. // Silent
  291. function massSubscribe() {
  292. $payload = json_decode($_REQUEST["payload"], false);
  293. $mode = $_REQUEST["mode"];
  294. if (!$payload || !is_array($payload)) return;
  295. if ($mode == 1) {
  296. foreach ($payload as $feed) {
  297. $title = $this->dbh->escape_string($feed[0]);
  298. $feed_url = $this->dbh->escape_string($feed[1]);
  299. $result = $this->dbh->query("SELECT id FROM ttrss_feeds WHERE
  300. feed_url = '$feed_url' AND owner_uid = " . $_SESSION["uid"]);
  301. if ($this->dbh->num_rows($result) == 0) {
  302. $result = $this->dbh->query("INSERT INTO ttrss_feeds
  303. (owner_uid,feed_url,title,cat_id,site_url)
  304. VALUES ('".$_SESSION["uid"]."',
  305. '$feed_url', '$title', NULL, '')");
  306. }
  307. }
  308. } else if ($mode == 2) {
  309. // feed archive
  310. foreach ($payload as $id) {
  311. $result = $this->dbh->query("SELECT * FROM ttrss_archived_feeds
  312. WHERE id = '$id' AND owner_uid = " . $_SESSION["uid"]);
  313. if ($this->dbh->num_rows($result) != 0) {
  314. $site_url = $this->dbh->escape_string(db_fetch_result($result, 0, "site_url"));
  315. $feed_url = $this->dbh->escape_string(db_fetch_result($result, 0, "feed_url"));
  316. $title = $this->dbh->escape_string(db_fetch_result($result, 0, "title"));
  317. $result = $this->dbh->query("SELECT id FROM ttrss_feeds WHERE
  318. feed_url = '$feed_url' AND owner_uid = " . $_SESSION["uid"]);
  319. if ($this->dbh->num_rows($result) == 0) {
  320. $result = $this->dbh->query("INSERT INTO ttrss_feeds
  321. (owner_uid,feed_url,title,cat_id,site_url)
  322. VALUES ('$id','".$_SESSION["uid"]."',
  323. '$feed_url', '$title', NULL, '$site_url')");
  324. }
  325. }
  326. }
  327. }
  328. }
  329. function catchupFeed() {
  330. $feed_id = $this->dbh->escape_string($_REQUEST['feed_id']);
  331. $is_cat = $this->dbh->escape_string($_REQUEST['is_cat']) == "true";
  332. $mode = $this->dbh->escape_string($_REQUEST['mode']);
  333. catchup_feed($feed_id, $is_cat, false, false, $mode);
  334. print json_encode(array("message" => "UPDATE_COUNTERS"));
  335. }
  336. function quickAddCat() {
  337. $cat = $this->dbh->escape_string($_REQUEST["cat"]);
  338. add_feed_category($cat);
  339. $result = $this->dbh->query("SELECT id FROM ttrss_feed_categories WHERE
  340. title = '$cat' AND owner_uid = " . $_SESSION["uid"]);
  341. if ($this->dbh->num_rows($result) == 1) {
  342. $id = $this->dbh->fetch_result($result, 0, "id");
  343. } else {
  344. $id = 0;
  345. }
  346. print_feed_cat_select("cat_id", $id, '');
  347. }
  348. function setpanelmode() {
  349. $wide = (int) $_REQUEST["wide"];
  350. setcookie("ttrss_widescreen", $wide,
  351. time() + COOKIE_LIFETIME_LONG);
  352. print json_encode(array("wide" => $wide));
  353. }
  354. function updaterandomfeed() {
  355. // Test if the feed need a update (update interval exceded).
  356. if (DB_TYPE == "pgsql") {
  357. $update_limit_qpart = "AND ((
  358. ttrss_feeds.update_interval = 0
  359. AND ttrss_feeds.last_updated < NOW() - CAST((ttrss_user_prefs.value || ' minutes') AS INTERVAL)
  360. ) OR (
  361. ttrss_feeds.update_interval > 0
  362. AND ttrss_feeds.last_updated < NOW() - CAST((ttrss_feeds.update_interval || ' minutes') AS INTERVAL)
  363. ) OR ttrss_feeds.last_updated IS NULL
  364. OR last_updated = '1970-01-01 00:00:00')";
  365. } else {
  366. $update_limit_qpart = "AND ((
  367. ttrss_feeds.update_interval = 0
  368. AND ttrss_feeds.last_updated < DATE_SUB(NOW(), INTERVAL CONVERT(ttrss_user_prefs.value, SIGNED INTEGER) MINUTE)
  369. ) OR (
  370. ttrss_feeds.update_interval > 0
  371. AND ttrss_feeds.last_updated < DATE_SUB(NOW(), INTERVAL ttrss_feeds.update_interval MINUTE)
  372. ) OR ttrss_feeds.last_updated IS NULL
  373. OR last_updated = '1970-01-01 00:00:00')";
  374. }
  375. // Test if feed is currently being updated by another process.
  376. if (DB_TYPE == "pgsql") {
  377. $updstart_thresh_qpart = "AND (ttrss_feeds.last_update_started IS NULL OR ttrss_feeds.last_update_started < NOW() - INTERVAL '5 minutes')";
  378. } else {
  379. $updstart_thresh_qpart = "AND (ttrss_feeds.last_update_started IS NULL OR ttrss_feeds.last_update_started < DATE_SUB(NOW(), INTERVAL 5 MINUTE))";
  380. }
  381. $random_qpart = sql_random_function();
  382. // We search for feed needing update.
  383. $result = $this->dbh->query("SELECT ttrss_feeds.feed_url,ttrss_feeds.id
  384. FROM
  385. ttrss_feeds, ttrss_users, ttrss_user_prefs
  386. WHERE
  387. ttrss_feeds.owner_uid = ttrss_users.id
  388. AND ttrss_users.id = ttrss_user_prefs.owner_uid
  389. AND ttrss_user_prefs.pref_name = 'DEFAULT_UPDATE_INTERVAL'
  390. AND ttrss_feeds.owner_uid = ".$_SESSION["uid"]."
  391. $update_limit_qpart $updstart_thresh_qpart
  392. ORDER BY $random_qpart LIMIT 30");
  393. $feed_id = -1;
  394. require_once "rssfuncs.php";
  395. $num_updated = 0;
  396. $tstart = time();
  397. while ($line = $this->dbh->fetch_assoc($result)) {
  398. $feed_id = $line["id"];
  399. if (time() - $tstart < ini_get("max_execution_time") * 0.7) {
  400. update_rss_feed($feed_id, true);
  401. ++$num_updated;
  402. } else {
  403. break;
  404. }
  405. }
  406. // Purge orphans and cleanup tags
  407. purge_orphans();
  408. cleanup_tags(14, 50000);
  409. if ($num_updated > 0) {
  410. print json_encode(array("message" => "UPDATE_COUNTERS",
  411. "num_updated" => $num_updated));
  412. } else {
  413. print json_encode(array("message" => "NOTHING_TO_UPDATE"));
  414. }
  415. }
  416. private function markArticlesById($ids, $cmode) {
  417. $tmp_ids = array();
  418. foreach ($ids as $id) {
  419. array_push($tmp_ids, "ref_id = '$id'");
  420. }
  421. $ids_qpart = join(" OR ", $tmp_ids);
  422. if ($cmode == 0) {
  423. $this->dbh->query("UPDATE ttrss_user_entries SET
  424. marked = false, last_marked = NOW()
  425. WHERE ($ids_qpart) AND owner_uid = " . $_SESSION["uid"]);
  426. } else if ($cmode == 1) {
  427. $this->dbh->query("UPDATE ttrss_user_entries SET
  428. marked = true, last_marked = NOW()
  429. WHERE ($ids_qpart) AND owner_uid = " . $_SESSION["uid"]);
  430. } else {
  431. $this->dbh->query("UPDATE ttrss_user_entries SET
  432. marked = NOT marked,last_marked = NOW()
  433. WHERE ($ids_qpart) AND owner_uid = " . $_SESSION["uid"]);
  434. }
  435. }
  436. private function publishArticlesById($ids, $cmode) {
  437. $tmp_ids = array();
  438. foreach ($ids as $id) {
  439. array_push($tmp_ids, "ref_id = '$id'");
  440. }
  441. $ids_qpart = join(" OR ", $tmp_ids);
  442. if ($cmode == 0) {
  443. $this->dbh->query("UPDATE ttrss_user_entries SET
  444. published = false,last_published = NOW()
  445. WHERE ($ids_qpart) AND owner_uid = " . $_SESSION["uid"]);
  446. } else if ($cmode == 1) {
  447. $this->dbh->query("UPDATE ttrss_user_entries SET
  448. published = true,last_published = NOW()
  449. WHERE ($ids_qpart) AND owner_uid = " . $_SESSION["uid"]);
  450. } else {
  451. $this->dbh->query("UPDATE ttrss_user_entries SET
  452. published = NOT published,last_published = NOW()
  453. WHERE ($ids_qpart) AND owner_uid = " . $_SESSION["uid"]);
  454. }
  455. if (PUBSUBHUBBUB_HUB) {
  456. $rss_link = get_self_url_prefix() .
  457. "/public.php?op=rss&id=-2&key=" .
  458. get_feed_access_key(-2, false);
  459. $p = new Publisher(PUBSUBHUBBUB_HUB);
  460. $pubsub_result = $p->publish_update($rss_link);
  461. }
  462. }
  463. function getlinktitlebyid() {
  464. $id = $this->dbh->escape_string($_REQUEST['id']);
  465. $result = $this->dbh->query("SELECT link, title FROM ttrss_entries, ttrss_user_entries
  466. WHERE ref_id = '$id' AND ref_id = id AND owner_uid = ". $_SESSION["uid"]);
  467. if ($this->dbh->num_rows($result) != 0) {
  468. $link = $this->dbh->fetch_result($result, 0, "link");
  469. $title = $this->dbh->fetch_result($result, 0, "title");
  470. echo json_encode(array("link" => $link, "title" => $title));
  471. } else {
  472. echo json_encode(array("error" => "ARTICLE_NOT_FOUND"));
  473. }
  474. }
  475. function log() {
  476. $logmsg = $this->dbh->escape_string($_REQUEST['logmsg']);
  477. if ($logmsg) {
  478. Logger::get()->log_error(E_USER_WARNING,
  479. $logmsg, '[client-js]', 0, false);
  480. }
  481. echo json_encode(array("message" => "HOST_ERROR_LOGGED"));
  482. }
  483. }
  484. ?>