rpc.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638
  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 ($seq) $reply['seq'] = $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. $reply = array();
  249. $reply['error'] = sanity_check();
  250. if ($reply['error']['code'] == 0) {
  251. $reply['init-params'] = make_init_params();
  252. $reply['runtime-info'] = make_runtime_info();
  253. }
  254. print json_encode($reply);
  255. }
  256. function completeLabels() {
  257. $search = $this->dbh->escape_string($_REQUEST["search"]);
  258. $result = $this->dbh->query("SELECT DISTINCT caption FROM
  259. ttrss_labels2
  260. WHERE owner_uid = '".$_SESSION["uid"]."' AND
  261. LOWER(caption) LIKE LOWER('$search%') ORDER BY caption
  262. LIMIT 5");
  263. print "<ul>";
  264. while ($line = $this->dbh->fetch_assoc($result)) {
  265. print "<li>" . $line["caption"] . "</li>";
  266. }
  267. print "</ul>";
  268. }
  269. function purge() {
  270. $ids = explode(",", $this->dbh->escape_string($_REQUEST["ids"]));
  271. $days = sprintf("%d", $_REQUEST["days"]);
  272. foreach ($ids as $id) {
  273. $result = $this->dbh->query("SELECT id FROM ttrss_feeds WHERE
  274. id = '$id' AND owner_uid = ".$_SESSION["uid"]);
  275. if ($this->dbh->num_rows($result) == 1) {
  276. purge_feed($id, $days);
  277. }
  278. }
  279. }
  280. function updateFeedBrowser() {
  281. $search = $this->dbh->escape_string($_REQUEST["search"]);
  282. $limit = $this->dbh->escape_string($_REQUEST["limit"]);
  283. $mode = (int) $this->dbh->escape_string($_REQUEST["mode"]);
  284. require_once "feedbrowser.php";
  285. print json_encode(array("content" =>
  286. make_feed_browser($search, $limit, $mode),
  287. "mode" => $mode));
  288. }
  289. // Silent
  290. function massSubscribe() {
  291. $payload = json_decode($_REQUEST["payload"], false);
  292. $mode = $_REQUEST["mode"];
  293. if (!$payload || !is_array($payload)) return;
  294. if ($mode == 1) {
  295. foreach ($payload as $feed) {
  296. $title = $this->dbh->escape_string($feed[0]);
  297. $feed_url = $this->dbh->escape_string($feed[1]);
  298. $result = $this->dbh->query("SELECT id FROM ttrss_feeds WHERE
  299. feed_url = '$feed_url' AND owner_uid = " . $_SESSION["uid"]);
  300. if ($this->dbh->num_rows($result) == 0) {
  301. $result = $this->dbh->query("INSERT INTO ttrss_feeds
  302. (owner_uid,feed_url,title,cat_id,site_url)
  303. VALUES ('".$_SESSION["uid"]."',
  304. '$feed_url', '$title', NULL, '')");
  305. }
  306. }
  307. } else if ($mode == 2) {
  308. // feed archive
  309. foreach ($payload as $id) {
  310. $result = $this->dbh->query("SELECT * FROM ttrss_archived_feeds
  311. WHERE id = '$id' AND owner_uid = " . $_SESSION["uid"]);
  312. if ($this->dbh->num_rows($result) != 0) {
  313. $site_url = $this->dbh->escape_string(db_fetch_result($result, 0, "site_url"));
  314. $feed_url = $this->dbh->escape_string(db_fetch_result($result, 0, "feed_url"));
  315. $title = $this->dbh->escape_string(db_fetch_result($result, 0, "title"));
  316. $result = $this->dbh->query("SELECT id FROM ttrss_feeds WHERE
  317. feed_url = '$feed_url' AND owner_uid = " . $_SESSION["uid"]);
  318. if ($this->dbh->num_rows($result) == 0) {
  319. $result = $this->dbh->query("INSERT INTO ttrss_feeds
  320. (owner_uid,feed_url,title,cat_id,site_url)
  321. VALUES ('$id','".$_SESSION["uid"]."',
  322. '$feed_url', '$title', NULL, '$site_url')");
  323. }
  324. }
  325. }
  326. }
  327. }
  328. function catchupFeed() {
  329. $feed_id = $this->dbh->escape_string($_REQUEST['feed_id']);
  330. $is_cat = $this->dbh->escape_string($_REQUEST['is_cat']) == "true";
  331. $mode = $this->dbh->escape_string($_REQUEST['mode']);
  332. catchup_feed($feed_id, $is_cat, false, false, $mode);
  333. print json_encode(array("message" => "UPDATE_COUNTERS"));
  334. }
  335. function quickAddCat() {
  336. $cat = $this->dbh->escape_string($_REQUEST["cat"]);
  337. add_feed_category($cat);
  338. $result = $this->dbh->query("SELECT id FROM ttrss_feed_categories WHERE
  339. title = '$cat' AND owner_uid = " . $_SESSION["uid"]);
  340. if ($this->dbh->num_rows($result) == 1) {
  341. $id = $this->dbh->fetch_result($result, 0, "id");
  342. } else {
  343. $id = 0;
  344. }
  345. print_feed_cat_select("cat_id", $id);
  346. }
  347. // Silent
  348. function clearArticleKeys() {
  349. $this->dbh->query("UPDATE ttrss_user_entries SET uuid = '' WHERE
  350. owner_uid = " . $_SESSION["uid"]);
  351. return;
  352. }
  353. function setpanelmode() {
  354. $wide = (int) $_REQUEST["wide"];
  355. setcookie("ttrss_widescreen", $wide,
  356. time() + SESSION_COOKIE_LIFETIME);
  357. print json_encode(array("wide" => $wide));
  358. }
  359. function updaterandomfeed() {
  360. // Test if the feed need a update (update interval exceded).
  361. if (DB_TYPE == "pgsql") {
  362. $update_limit_qpart = "AND ((
  363. ttrss_feeds.update_interval = 0
  364. AND ttrss_feeds.last_updated < NOW() - CAST((ttrss_user_prefs.value || ' minutes') AS INTERVAL)
  365. ) OR (
  366. ttrss_feeds.update_interval > 0
  367. AND ttrss_feeds.last_updated < NOW() - CAST((ttrss_feeds.update_interval || ' minutes') AS INTERVAL)
  368. ) OR ttrss_feeds.last_updated IS NULL
  369. OR last_updated = '1970-01-01 00:00:00')";
  370. } else {
  371. $update_limit_qpart = "AND ((
  372. ttrss_feeds.update_interval = 0
  373. AND ttrss_feeds.last_updated < DATE_SUB(NOW(), INTERVAL CONVERT(ttrss_user_prefs.value, SIGNED INTEGER) MINUTE)
  374. ) OR (
  375. ttrss_feeds.update_interval > 0
  376. AND ttrss_feeds.last_updated < DATE_SUB(NOW(), INTERVAL ttrss_feeds.update_interval MINUTE)
  377. ) OR ttrss_feeds.last_updated IS NULL
  378. OR last_updated = '1970-01-01 00:00:00')";
  379. }
  380. // Test if feed is currently being updated by another process.
  381. if (DB_TYPE == "pgsql") {
  382. $updstart_thresh_qpart = "AND (ttrss_feeds.last_update_started IS NULL OR ttrss_feeds.last_update_started < NOW() - INTERVAL '5 minutes')";
  383. } else {
  384. $updstart_thresh_qpart = "AND (ttrss_feeds.last_update_started IS NULL OR ttrss_feeds.last_update_started < DATE_SUB(NOW(), INTERVAL 5 MINUTE))";
  385. }
  386. $random_qpart = sql_random_function();
  387. // We search for feed needing update.
  388. $result = $this->dbh->query("SELECT ttrss_feeds.feed_url,ttrss_feeds.id
  389. FROM
  390. ttrss_feeds, ttrss_users, ttrss_user_prefs
  391. WHERE
  392. ttrss_feeds.owner_uid = ttrss_users.id
  393. AND ttrss_users.id = ttrss_user_prefs.owner_uid
  394. AND ttrss_user_prefs.pref_name = 'DEFAULT_UPDATE_INTERVAL'
  395. AND ttrss_feeds.owner_uid = ".$_SESSION["uid"]."
  396. $update_limit_qpart $updstart_thresh_qpart
  397. ORDER BY $random_qpart LIMIT 30");
  398. $feed_id = -1;
  399. require_once "rssfuncs.php";
  400. $num_updated = 0;
  401. $tstart = time();
  402. while ($line = $this->dbh->fetch_assoc($result)) {
  403. $feed_id = $line["id"];
  404. if (time() - $tstart < ini_get("max_execution_time") * 0.7) {
  405. update_rss_feed($feed_id, true);
  406. ++$num_updated;
  407. } else {
  408. break;
  409. }
  410. }
  411. // Purge orphans and cleanup tags
  412. purge_orphans();
  413. cleanup_tags(14, 50000);
  414. if ($num_updated > 0) {
  415. print json_encode(array("message" => "UPDATE_COUNTERS",
  416. "num_updated" => $num_updated));
  417. } else {
  418. print json_encode(array("message" => "NOTHING_TO_UPDATE"));
  419. }
  420. }
  421. private function markArticlesById($ids, $cmode) {
  422. $tmp_ids = array();
  423. foreach ($ids as $id) {
  424. array_push($tmp_ids, "ref_id = '$id'");
  425. }
  426. $ids_qpart = join(" OR ", $tmp_ids);
  427. if ($cmode == 0) {
  428. $this->dbh->query("UPDATE ttrss_user_entries SET
  429. marked = false, last_marked = NOW()
  430. WHERE ($ids_qpart) AND owner_uid = " . $_SESSION["uid"]);
  431. } else if ($cmode == 1) {
  432. $this->dbh->query("UPDATE ttrss_user_entries SET
  433. marked = true, last_marked = NOW()
  434. WHERE ($ids_qpart) AND owner_uid = " . $_SESSION["uid"]);
  435. } else {
  436. $this->dbh->query("UPDATE ttrss_user_entries SET
  437. marked = NOT marked,last_marked = NOW()
  438. WHERE ($ids_qpart) AND owner_uid = " . $_SESSION["uid"]);
  439. }
  440. }
  441. private function publishArticlesById($ids, $cmode) {
  442. $tmp_ids = array();
  443. foreach ($ids as $id) {
  444. array_push($tmp_ids, "ref_id = '$id'");
  445. }
  446. $ids_qpart = join(" OR ", $tmp_ids);
  447. if ($cmode == 0) {
  448. $this->dbh->query("UPDATE ttrss_user_entries SET
  449. published = false,last_published = NOW()
  450. WHERE ($ids_qpart) AND owner_uid = " . $_SESSION["uid"]);
  451. } else if ($cmode == 1) {
  452. $this->dbh->query("UPDATE ttrss_user_entries SET
  453. published = true,last_published = NOW()
  454. WHERE ($ids_qpart) AND owner_uid = " . $_SESSION["uid"]);
  455. } else {
  456. $this->dbh->query("UPDATE ttrss_user_entries SET
  457. published = NOT published,last_published = NOW()
  458. WHERE ($ids_qpart) AND owner_uid = " . $_SESSION["uid"]);
  459. }
  460. if (PUBSUBHUBBUB_HUB) {
  461. $rss_link = get_self_url_prefix() .
  462. "/public.php?op=rss&id=-2&key=" .
  463. get_feed_access_key(-2, false);
  464. $p = new Publisher(PUBSUBHUBBUB_HUB);
  465. $pubsub_result = $p->publish_update($rss_link);
  466. }
  467. }
  468. function getlinktitlebyid() {
  469. $id = $this->dbh->escape_string($_REQUEST['id']);
  470. $result = $this->dbh->query("SELECT link, title FROM ttrss_entries, ttrss_user_entries
  471. WHERE ref_id = '$id' AND ref_id = id AND owner_uid = ". $_SESSION["uid"]);
  472. if ($this->dbh->num_rows($result) != 0) {
  473. $link = $this->dbh->fetch_result($result, 0, "link");
  474. $title = $this->dbh->fetch_result($result, 0, "title");
  475. echo json_encode(array("link" => $link, "title" => $title));
  476. } else {
  477. echo json_encode(array("error" => "ARTICLE_NOT_FOUND"));
  478. }
  479. }
  480. }
  481. ?>