feeds.php 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245
  1. <?php
  2. require_once "colors.php";
  3. class Feeds extends Handler_Protected {
  4. private $params;
  5. function csrf_ignore($method) {
  6. $csrf_ignored = array("index", "feedbrowser", "quickaddfeed", "search");
  7. return array_search($method, $csrf_ignored) !== false;
  8. }
  9. private function format_headline_subtoolbar($feed_site_url, $feed_title,
  10. $feed_id, $is_cat, $search,
  11. $view_mode, $error, $feed_last_updated) {
  12. $catchup_sel_link = "catchupSelection()";
  13. $archive_sel_link = "archiveSelection()";
  14. $delete_sel_link = "deleteSelection()";
  15. $sel_all_link = "selectArticles('all')";
  16. $sel_unread_link = "selectArticles('unread')";
  17. $sel_none_link = "selectArticles('none')";
  18. $sel_inv_link = "selectArticles('invert')";
  19. $tog_unread_link = "selectionToggleUnread()";
  20. $tog_marked_link = "selectionToggleMarked()";
  21. $tog_published_link = "selectionTogglePublished()";
  22. $set_score_link = "setSelectionScore()";
  23. if ($is_cat) $cat_q = "&is_cat=$is_cat";
  24. if ($search) {
  25. $search_q = "&q=$search";
  26. } else {
  27. $search_q = "";
  28. }
  29. $reply .= "<span class=\"holder\">";
  30. $rss_link = htmlspecialchars(get_self_url_prefix() .
  31. "/public.php?op=rss&id=$feed_id$cat_q$search_q");
  32. // right part
  33. $error_class = $error ? "error" : "";
  34. $reply .= "<span class='r'>
  35. <a href=\"#\"
  36. title=\"".__("View as RSS feed")."\"
  37. onclick=\"displayDlg('".__("View as RSS")."','generatedFeed', '$feed_id:$is_cat:$rss_link')\">
  38. <img class=\"noborder\" src=\"images/pub_set.png\"></a>";
  39. # $reply .= "<span>";
  40. $reply .= "<span id='feed_title' class='$error_class'>";
  41. if ($feed_site_url) {
  42. $last_updated = T_sprintf("Last updated: %s",
  43. $feed_last_updated);
  44. $target = "target=\"_blank\"";
  45. $reply .= "<a title=\"$last_updated\" $target href=\"$feed_site_url\">".
  46. truncate_string($feed_title, 30)."</a>";
  47. if ($error) {
  48. $error = htmlspecialchars($error);
  49. $reply .= "&nbsp;<img title=\"$error\" src='images/error.png' alt='error' class=\"noborder\">";
  50. }
  51. } else {
  52. $reply .= $feed_title;
  53. }
  54. $reply .= "</span>";
  55. $reply .= "</span>";
  56. # $reply .= "</span>";
  57. // left part
  58. $reply .= "<span class=\"main\">";
  59. $reply .= "<span id='selected_prompt'></span>";
  60. /*$reply .= "<span class=\"sel_links\">
  61. <a href=\"#\" onclick=\"$sel_all_link\">".__('All')."</a>,
  62. <a href=\"#\" onclick=\"$sel_unread_link\">".__('Unread')."</a>,
  63. <a href=\"#\" onclick=\"$sel_inv_link\">".__('Invert')."</a>,
  64. <a href=\"#\" onclick=\"$sel_none_link\">".__('None')."</a></li>";
  65. $reply .= "</span> "; */
  66. $reply .= "<select dojoType=\"dijit.form.Select\"
  67. onchange=\"headlineActionsChange(this)\">";
  68. $reply .= "<option value=\"0\" disabled='1'>".__('Select...')."</option>";
  69. $reply .= "<option value=\"$sel_all_link\">".__('All')."</option>";
  70. $reply .= "<option value=\"$sel_unread_link\">".__('Unread')."</option>";
  71. $reply .= "<option value=\"$sel_inv_link\">".__('Invert')."</option>";
  72. $reply .= "<option value=\"$sel_none_link\">".__('None')."</option>";
  73. $reply .= "<option value=\"0\" disabled=\"1\">".__('Selection toggle:')."</option>";
  74. $reply .= "<option value=\"$tog_unread_link\">".__('Unread')."</option>
  75. <option value=\"$tog_marked_link\">".__('Starred')."</option>
  76. <option value=\"$tog_published_link\">".__('Published')."</option>";
  77. $reply .= "<option value=\"0\" disabled=\"1\">".__('Selection:')."</option>";
  78. $reply .= "<option value=\"$catchup_sel_link\">".__('Mark as read')."</option>";
  79. $reply .= "<option value=\"$set_score_link\">".__('Set score')."</option>";
  80. if ($feed_id != "0") {
  81. $reply .= "<option value=\"$archive_sel_link\">".__('Archive')."</option>";
  82. } else {
  83. $reply .= "<option value=\"$archive_sel_link\">".__('Move back')."</option>";
  84. $reply .= "<option value=\"$delete_sel_link\">".__('Delete')."</option>";
  85. }
  86. if (PluginHost::getInstance()->get_plugin("mail")) {
  87. $reply .= "<option value=\"emailArticle(false)\">".__('Forward by email').
  88. "</option>";
  89. }
  90. if (PluginHost::getInstance()->get_plugin("mailto")) {
  91. $reply .= "<option value=\"mailtoArticle(false)\">".__('Forward by email').
  92. "</option>";
  93. }
  94. $reply .= "<option value=\"0\" disabled=\"1\">".__('Feed:')."</option>";
  95. //$reply .= "<option value=\"catchupPage()\">".__('Mark as read')."</option>";
  96. $reply .= "<option value=\"displayDlg('".__("View as RSS")."','generatedFeed', '$feed_id:$is_cat:$rss_link')\">".__('View as RSS')."</option>";
  97. $reply .= "</select>";
  98. //$reply .= "</h2";
  99. foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_HEADLINE_TOOLBAR_BUTTON) as $p) {
  100. $reply .= $p->hook_headline_toolbar_button($feed_id, $is_cat);
  101. }
  102. $reply .= "</span></span>";
  103. return $reply;
  104. }
  105. private function format_headlines_list($feed, $method, $view_mode, $limit, $cat_view,
  106. $next_unread_feed, $offset, $vgr_last_feed = false,
  107. $override_order = false, $include_children = false, $check_first_id = false,
  108. $skip_first_id_check = false) {
  109. $disable_cache = false;
  110. $reply = array();
  111. $rgba_cache = array();
  112. $timing_info = microtime(true);
  113. $topmost_article_ids = array();
  114. if (!$offset) $offset = 0;
  115. if ($method == "undefined") $method = "";
  116. $method_split = explode(":", $method);
  117. if ($method == "ForceUpdate" && $feed > 0 && is_numeric($feed)) {
  118. // Update the feed if required with some basic flood control
  119. $any_needs_curl = false;
  120. if (ini_get("open_basedir")) {
  121. $pluginhost = PluginHost::getInstance();
  122. foreach ($pluginhost->get_plugins() as $plugin) {
  123. $flags = $plugin->flags();
  124. if (isset($flags["needs_curl"]) && $flags["needs_curl"]) {
  125. $any_needs_curl = true;
  126. break;
  127. }
  128. }
  129. }
  130. //if ($_REQUEST["debug"]) print "<!-- any_needs_curl: $any_needs_curl -->";
  131. if (!$any_needs_curl) {
  132. $result = $this->dbh->query(
  133. "SELECT cache_images," . SUBSTRING_FOR_DATE . "(last_updated,1,19) AS last_updated
  134. FROM ttrss_feeds WHERE id = '$feed'");
  135. if ($this->dbh->num_rows($result) != 0) {
  136. $last_updated = strtotime($this->dbh->fetch_result($result, 0, "last_updated"));
  137. $cache_images = sql_bool_to_bool($this->dbh->fetch_result($result, 0, "cache_images"));
  138. if (!$cache_images && time() - $last_updated > 120) {
  139. include "rssfuncs.php";
  140. update_rss_feed($feed, true, true);
  141. } else {
  142. $this->dbh->query("UPDATE ttrss_feeds SET last_updated = '1970-01-01', last_update_started = '1970-01-01'
  143. WHERE id = '$feed'");
  144. }
  145. }
  146. } else {
  147. $this->dbh->query("UPDATE ttrss_feeds SET last_updated = '1970-01-01', last_update_started = '1970-01-01'
  148. WHERE id = '$feed'");
  149. }
  150. }
  151. if ($method_split[0] == "MarkAllReadGR") {
  152. catchup_feed($method_split[1], false);
  153. }
  154. // FIXME: might break tag display?
  155. if (is_numeric($feed) && $feed > 0 && !$cat_view) {
  156. $result = $this->dbh->query(
  157. "SELECT id FROM ttrss_feeds WHERE id = '$feed' LIMIT 1");
  158. if ($this->dbh->num_rows($result) == 0) {
  159. $reply['content'] = "<div align='center'>".__('Feed not found.')."</div>";
  160. }
  161. }
  162. @$search = $this->dbh->escape_string($_REQUEST["query"]);
  163. @$search_language = $this->dbh->escape_string($_REQUEST["search_language"]); // PGSQL only
  164. if ($search) {
  165. $disable_cache = true;
  166. }
  167. if ($_REQUEST["debug"]) $timing_info = print_checkpoint("H0", $timing_info);
  168. if (!$cat_view && is_numeric($feed) && $feed < PLUGIN_FEED_BASE_INDEX && $feed > LABEL_BASE_INDEX) {
  169. $handler = PluginHost::getInstance()->get_feed_handler(
  170. PluginHost::feed_to_pfeed_id($feed));
  171. if ($handler) {
  172. $options = array(
  173. "limit" => $limit,
  174. "view_mode" => $view_mode,
  175. "cat_view" => $cat_view,
  176. "search" => $search,
  177. "override_order" => $override_order,
  178. "offset" => $offset,
  179. "owner_uid" => $_SESSION["uid"],
  180. "filter" => false,
  181. "since_id" => 0,
  182. "include_children" => $include_children);
  183. $qfh_ret = $handler->get_headlines(PluginHost::feed_to_pfeed_id($feed),
  184. $options);
  185. }
  186. } else {
  187. /*$qfh_ret = queryFeedHeadlines($feed, $limit, $view_mode, $cat_view,
  188. $search, false, $override_order, $offset, 0,
  189. false, 0, $include_children, $topid);*/
  190. //function queryFeedHeadlines($feed, $limit,
  191. // $view_mode, $cat_view, $search, $search_mode,
  192. // $override_order = false, $offset = 0, $owner_uid = 0, $filter = false, $since_id = 0, $include_children = false,
  193. // $ignore_vfeed_group = false, $override_strategy = false, $override_vfeed = false, $start_ts = false, $check_top_id = false) {
  194. $params = array(
  195. "feed" => $feed,
  196. "limit" => $limit,
  197. "view_mode" => $view_mode,
  198. "cat_view" => $cat_view,
  199. "search" => $search,
  200. "search_language" => $search_language,
  201. "override_order" => $override_order,
  202. "offset" => $offset,
  203. "include_children" => $include_children,
  204. "check_first_id" => $check_first_id,
  205. "skip_first_id_check" => $skip_first_id_check
  206. );
  207. $qfh_ret = queryFeedHeadlines($params);
  208. }
  209. $vfeed_group_enabled = get_pref("VFEED_GROUP_BY_FEED") && $feed != -6;
  210. if ($_REQUEST["debug"]) $timing_info = print_checkpoint("H1", $timing_info);
  211. $result = $qfh_ret[0];
  212. $feed_title = $qfh_ret[1];
  213. $feed_site_url = $qfh_ret[2];
  214. $last_error = $qfh_ret[3];
  215. $last_updated = strpos($qfh_ret[4], '1970-') === FALSE ?
  216. make_local_datetime($qfh_ret[4], false) : __("Never");
  217. $highlight_words = $qfh_ret[5];
  218. $reply['first_id'] = $qfh_ret[6];
  219. $reply['search_query'] = [$search, $search_language];
  220. $vgroup_last_feed = $vgr_last_feed;
  221. $reply['toolbar'] = $this->format_headline_subtoolbar($feed_site_url,
  222. $feed_title,
  223. $feed, $cat_view, $search, $view_mode,
  224. $last_error, $last_updated);
  225. $headlines_count = is_numeric($result) ? 0 : $this->dbh->num_rows($result);
  226. if ($offset == 0) {
  227. foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_HEADLINES_BEFORE) as $p) {
  228. $reply['content'] .= $p->hook_headlines_before($feed, $cat_view, $qfh_ret);
  229. }
  230. }
  231. $reply['content'] = '';
  232. if ($headlines_count > 0) {
  233. $lnum = $offset;
  234. $num_unread = 0;
  235. $cur_feed_title = '';
  236. if ($_REQUEST["debug"]) $timing_info = print_checkpoint("PS", $timing_info);
  237. $expand_cdm = get_pref('CDM_EXPANDED');
  238. while ($line = $this->dbh->fetch_assoc($result)) {
  239. $line["content_preview"] = "&mdash; " . truncate_string(strip_tags($line["content"]), 250);
  240. foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) {
  241. $line = $p->hook_query_headlines($line, 250, false);
  242. }
  243. if (get_pref('SHOW_CONTENT_PREVIEW')) {
  244. $content_preview = $line["content_preview"];
  245. }
  246. $id = $line["id"];
  247. $feed_id = $line["feed_id"];
  248. $label_cache = $line["label_cache"];
  249. $labels = false;
  250. if ($label_cache) {
  251. $label_cache = json_decode($label_cache, true);
  252. if ($label_cache) {
  253. if ($label_cache["no-labels"] == 1)
  254. $labels = array();
  255. else
  256. $labels = $label_cache;
  257. }
  258. }
  259. if (!is_array($labels)) $labels = get_article_labels($id);
  260. $labels_str = "<span class=\"HLLCTR-$id\">";
  261. $labels_str .= format_article_labels($labels, $id);
  262. $labels_str .= "</span>";
  263. if (count($topmost_article_ids) < 3) {
  264. array_push($topmost_article_ids, $id);
  265. }
  266. $class = "";
  267. if (sql_bool_to_bool($line["unread"])) {
  268. $class .= " Unread";
  269. ++$num_unread;
  270. }
  271. if (sql_bool_to_bool($line["marked"])) {
  272. $marked_pic = "<img
  273. src=\"images/mark_set.png\"
  274. class=\"markedPic\" alt=\"Unstar article\"
  275. onclick='toggleMark($id)'>";
  276. $class .= " marked";
  277. } else {
  278. $marked_pic = "<img
  279. src=\"images/mark_unset.png\"
  280. class=\"markedPic\" alt=\"Star article\"
  281. onclick='toggleMark($id)'>";
  282. }
  283. if (sql_bool_to_bool($line["published"])) {
  284. $published_pic = "<img src=\"images/pub_set.png\"
  285. class=\"pubPic\"
  286. alt=\"Unpublish article\" onclick='togglePub($id)'>";
  287. $class .= " published";
  288. } else {
  289. $published_pic = "<img src=\"images/pub_unset.png\"
  290. class=\"pubPic\"
  291. alt=\"Publish article\" onclick='togglePub($id)'>";
  292. }
  293. # $content_link = "<a target=\"_blank\" rel=\"noopener noreferrer\" href=\"".$line["link"]."\">" .
  294. # $line["title"] . "</a>";
  295. # $content_link = "<a
  296. # href=\"" . htmlspecialchars($line["link"]) . "\"
  297. # onclick=\"view($id,$feed_id);\">" .
  298. # $line["title"] . "</a>";
  299. # $content_link = "<a href=\"javascript:viewContentUrl('".$line["link"]."');\">" .
  300. # $line["title"] . "</a>";
  301. $updated_fmt = make_local_datetime($line["updated"], false, false, false, true);
  302. $date_entered_fmt = T_sprintf("Imported at %s",
  303. make_local_datetime($line["date_entered"], false));
  304. $score = $line["score"];
  305. $score_pic = "images/" . get_score_pic($score);
  306. /* $score_title = __("(Click to change)");
  307. $score_pic = "<img class='hlScorePic' src=\"images/$score_pic\"
  308. onclick=\"adjustArticleScore($id, $score)\" title=\"$score $score_title\">"; */
  309. $score_pic = "<img class='hlScorePic' score='$score' onclick='changeScore($id, this)' src=\"$score_pic\"
  310. title=\"$score\">";
  311. if ($score > 500) {
  312. $hlc_suffix = "high";
  313. } else if ($score < -100) {
  314. $hlc_suffix = "low";
  315. } else {
  316. $hlc_suffix = "";
  317. }
  318. $entry_author = $line["author"];
  319. if ($entry_author) {
  320. $entry_author = " &mdash; $entry_author";
  321. }
  322. $has_feed_icon = feed_has_icon($feed_id);
  323. if ($has_feed_icon) {
  324. $feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"".ICONS_URL."/$feed_id.ico\" alt=\"\">";
  325. } else {
  326. $feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"images/pub_set.png\" alt=\"\">";
  327. }
  328. $entry_site_url = $line["site_url"];
  329. //setting feed headline background color, needs to change text color based on dark/light
  330. $fav_color = $line['favicon_avg_color'];
  331. require_once "colors.php";
  332. if ($fav_color && $fav_color != 'fail') {
  333. if (!isset($rgba_cache[$feed_id])) {
  334. $rgba_cache[$feed_id] = join(",", _color_unpack($fav_color));
  335. }
  336. }
  337. if (!get_pref('COMBINED_DISPLAY_MODE')) {
  338. if ($vfeed_group_enabled) {
  339. if ($feed_id != $vgroup_last_feed && $line["feed_title"]) {
  340. $cur_feed_title = $line["feed_title"];
  341. $vgroup_last_feed = $feed_id;
  342. $cur_feed_title = htmlspecialchars($cur_feed_title);
  343. $vf_catchup_link = "<a class='catchup' onclick='catchupFeedInGroup($feed_id);' href='#'>".__('mark feed as read')."</a>";
  344. $reply['content'] .= "<div data-feed-id='$feed_id' id='FTITLE-$feed_id' class='cdmFeedTitle'>".
  345. "<div style='float : right'>$feed_icon_img</div>".
  346. "<a class='title' href=\"#\" onclick=\"viewfeed({feed:$feed_id})\">".
  347. $line["feed_title"]."</a>
  348. $vf_catchup_link</div>";
  349. }
  350. }
  351. $mouseover_attrs = "onmouseover='postMouseIn(event, $id)'
  352. onmouseout='postMouseOut($id)'";
  353. $reply['content'] .= "<div class='hl hlMenuAttach $class' data-orig-feed-id='$feed_id' data-article-id='$id' id='RROW-$id' $mouseover_attrs>";
  354. $reply['content'] .= "<div class='hlLeft'>";
  355. $reply['content'] .= "<input dojoType=\"dijit.form.CheckBox\"
  356. type=\"checkbox\" onclick=\"toggleSelectRow2(this)\"
  357. class='rchk'>";
  358. $reply['content'] .= "$marked_pic";
  359. $reply['content'] .= "$published_pic";
  360. $reply['content'] .= "</div>";
  361. $reply['content'] .= "<div onclick='return hlClicked(event, $id)'
  362. class=\"hlTitle\"><span class='hlContent $hlc_suffix'>";
  363. $reply['content'] .= "<a id=\"RTITLE-$id\" class=\"title $hlc_suffix\"
  364. href=\"" . htmlspecialchars($line["link"]) . "\"
  365. onclick=\"\">" .
  366. truncate_string($line["title"], 200);
  367. if (get_pref('SHOW_CONTENT_PREVIEW')) {
  368. $reply['content'] .= "<span class=\"contentPreview\">" . $line["content_preview"] . "</span>";
  369. }
  370. $reply['content'] .= "</a></span>";
  371. $reply['content'] .= $labels_str;
  372. $reply['content'] .= "</div>";
  373. if (!$vfeed_group_enabled) {
  374. if (@$line["feed_title"]) {
  375. $rgba = @$rgba_cache[$feed_id];
  376. $reply['content'] .= "<span class=\"hlFeed\"><a style=\"background : rgba($rgba, 0.3)\" href=\"#\" onclick=\"viewfeed({feed:$feed_id})\">".
  377. truncate_string($line["feed_title"],30)."</a></span>";
  378. }
  379. }
  380. $reply['content'] .= "<span class=\"hlUpdated\">";
  381. $reply['content'] .= "<div title='$date_entered_fmt'>$updated_fmt</div>
  382. </span>";
  383. $reply['content'] .= "<div class=\"hlRight\">";
  384. $reply['content'] .= $score_pic;
  385. if ($line["feed_title"] && !$vfeed_group_enabled) {
  386. $reply['content'] .= "<span onclick=\"viewfeed({feed:$feed_id})\"
  387. style=\"cursor : pointer\"
  388. title=\"".htmlspecialchars($line['feed_title'])."\">
  389. $feed_icon_img</span>";
  390. }
  391. $reply['content'] .= "</div>";
  392. $reply['content'] .= "</div>";
  393. } else {
  394. if ($line["tag_cache"])
  395. $tags = explode(",", $line["tag_cache"]);
  396. else
  397. $tags = false;
  398. $line["content"] = sanitize($line["content"],
  399. sql_bool_to_bool($line['hide_images']), false, $entry_site_url, $highlight_words, $line["id"]);
  400. foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ARTICLE_CDM) as $p) {
  401. $line = $p->hook_render_article_cdm($line);
  402. }
  403. if ($vfeed_group_enabled && $line["feed_title"]) {
  404. if ($feed_id != $vgroup_last_feed) {
  405. $cur_feed_title = $line["feed_title"];
  406. $vgroup_last_feed = $feed_id;
  407. $cur_feed_title = htmlspecialchars($cur_feed_title);
  408. $vf_catchup_link = "<a class='catchup' onclick='catchupFeedInGroup($feed_id);' href='#'>".__('mark feed as read')."</a>";
  409. $has_feed_icon = feed_has_icon($feed_id);
  410. if ($has_feed_icon) {
  411. $feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"".ICONS_URL."/$feed_id.ico\" alt=\"\">";
  412. } else {
  413. //$feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\" alt=\"\">";
  414. }
  415. $reply['content'] .= "<div data-feed-id='$feed_id' id='FTITLE-$feed_id' class='cdmFeedTitle'>".
  416. "<div style=\"float : right\">$feed_icon_img</div>".
  417. "<a href=\"#\" class='title' onclick=\"viewfeed({feed:$feed_id})\">".
  418. $line["feed_title"]."</a> $vf_catchup_link</div>";
  419. }
  420. }
  421. $mouseover_attrs = "onmouseover='postMouseIn(event, $id)'
  422. onmouseout='postMouseOut($id)'";
  423. $expanded_class = $expand_cdm ? "expanded" : "expandable";
  424. $reply['content'] .= "<div class=\"cdm $hlc_suffix $expanded_class $class\"
  425. id=\"RROW-$id\" data-article-id='$id' data-orig-feed-id='$feed_id' $mouseover_attrs>";
  426. $reply['content'] .= "<div class=\"cdmHeader\">";
  427. $reply['content'] .= "<div style=\"vertical-align : middle\">";
  428. $reply['content'] .= "<input dojoType=\"dijit.form.CheckBox\"
  429. type=\"checkbox\" onclick=\"toggleSelectRow2(this, false, true)\"
  430. class='rchk'>";
  431. $reply['content'] .= "$marked_pic";
  432. $reply['content'] .= "$published_pic";
  433. $reply['content'] .= "</div>";
  434. if ($highlight_words && count($highlight_words > 0)) {
  435. foreach ($highlight_words as $word) {
  436. $line["title"] = preg_replace("/(\Q$word\E)/i",
  437. "<span class=\"highlight\">$1</span>", $line["title"]);
  438. }
  439. }
  440. // data-article-id included for context menu
  441. $reply['content'] .= "<span id=\"RTITLE-$id\"
  442. onclick=\"return cdmClicked(event, $id);\"
  443. data-article-id=\"$id\"
  444. class=\"titleWrap hlMenuAttach $hlc_suffix\">
  445. <a class=\"title $hlc_suffix\"
  446. title=\"".htmlspecialchars($line["title"])."\"
  447. target=\"_blank\" rel=\"noopener noreferrer\" href=\"".
  448. htmlspecialchars($line["link"])."\">".
  449. $line["title"] .
  450. "</a> <span class=\"author\">$entry_author</span>";
  451. $reply['content'] .= $labels_str;
  452. $reply['content'] .= "<span class='collapseBtn' style='display : none'>
  453. <img src=\"images/collapse.png\" onclick=\"cdmCollapseArticle(event, $id)\"
  454. title=\"".__("Collapse article")."\"/></span>";
  455. if (!$expand_cdm)
  456. $content_hidden = "style=\"display : none\"";
  457. else
  458. $excerpt_hidden = "style=\"display : none\"";
  459. $reply['content'] .= "<span $excerpt_hidden id=\"CEXC-$id\" class=\"cdmExcerpt\">" . $content_preview . "</span>";
  460. $reply['content'] .= "</span>";
  461. if (!$vfeed_group_enabled) {
  462. if (@$line["feed_title"]) {
  463. $rgba = @$rgba_cache[$feed_id];
  464. $reply['content'] .= "<div class=\"hlFeed\">
  465. <a href=\"#\" style=\"background-color: rgba($rgba,0.3)\"
  466. onclick=\"viewfeed({feed:$feed_id})\">".
  467. truncate_string($line["feed_title"],30)."</a>
  468. </div>";
  469. }
  470. }
  471. $reply['content'] .= "<span class='updated' title='$date_entered_fmt'>
  472. $updated_fmt</span>";
  473. $reply['content'] .= "<div class='scoreWrap' style=\"vertical-align : middle\">";
  474. $reply['content'] .= "$score_pic";
  475. if (!get_pref("VFEED_GROUP_BY_FEED") && $line["feed_title"]) {
  476. $reply['content'] .= "<span style=\"cursor : pointer\"
  477. title=\"".htmlspecialchars($line["feed_title"])."\"
  478. onclick=\"viewfeed({feed:$feed_id})\">$feed_icon_img</span>";
  479. }
  480. $reply['content'] .= "</div>";
  481. $reply['content'] .= "</div>";
  482. $reply['content'] .= "<div class=\"cdmContent\" $content_hidden
  483. onclick=\"return cdmClicked(event, $id, true);\"
  484. id=\"CICD-$id\">";
  485. $reply['content'] .= "<div id=\"POSTNOTE-$id\">";
  486. if ($line['note']) {
  487. $reply['content'] .= format_article_note($id, $line['note']);
  488. }
  489. $reply['content'] .= "</div>";
  490. if (!$line['lang']) $line['lang'] = 'en';
  491. $reply['content'] .= "<div class=\"cdmContentInner\" lang=\"".$line['lang']."\">";
  492. if ($line["orig_feed_id"]) {
  493. $tmp_result = $this->dbh->query("SELECT * FROM ttrss_archived_feeds
  494. WHERE id = ".$line["orig_feed_id"] . " AND owner_uid = " . $_SESSION["uid"]);
  495. if ($this->dbh->num_rows($tmp_result) != 0) {
  496. $reply['content'] .= "<div clear='both'>";
  497. $reply['content'] .= __("Originally from:");
  498. $reply['content'] .= "&nbsp;";
  499. $tmp_line = $this->dbh->fetch_assoc($tmp_result);
  500. $reply['content'] .= "<a target='_blank' rel='noopener noreferrer'
  501. href=' " . htmlspecialchars($tmp_line['site_url']) . "'>" .
  502. $tmp_line['title'] . "</a>";
  503. $reply['content'] .= "&nbsp;";
  504. $reply['content'] .= "<a target='_blank' rel='noopener noreferrer' href='" . htmlspecialchars($tmp_line['feed_url']) . "'>";
  505. $reply['content'] .= "<img title='".__('Feed URL')."'class='tinyFeedIcon' src='images/pub_unset.png'></a>";
  506. $reply['content'] .= "</div>";
  507. }
  508. }
  509. $reply['content'] .= "<span id=\"CWRAP-$id\">";
  510. $reply['content'] .= "<span id=\"CENCW-$id\" class=\"cencw\" style=\"display : none\">";
  511. $reply['content'] .= htmlspecialchars($line["content"]);
  512. $reply['content'] .= "</span>";
  513. $reply['content'] .= "</span>";
  514. $reply['content'] .= "</div>";
  515. $reply['content'] .= "<div class=\"cdmIntermediate\">";
  516. $always_display_enclosures = sql_bool_to_bool($line["always_display_enclosures"]);
  517. $reply['content'] .= format_article_enclosures($id, $always_display_enclosures, $line["content"], sql_bool_to_bool($line["hide_images"]));
  518. $reply['content'] .= "</div>";
  519. $reply['content'] .= "<div class=\"cdmFooter\" onclick=\"cdmFooterClick(event)\">";
  520. foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_LEFT_BUTTON) as $p) {
  521. $reply['content'] .= $p->hook_article_left_button($line);
  522. }
  523. $tags_str = format_tags_string($tags, $id);
  524. $reply['content'] .= "<span class='left'>";
  525. $reply['content'] .= "<img src='images/tag.png' alt='Tags' title='Tags'>
  526. <span id=\"ATSTR-$id\">$tags_str</span>
  527. <a title=\"".__('Edit tags for this article')."\"
  528. href=\"#\" onclick=\"editArticleTags($id)\">(+)</a>";
  529. $num_comments = (int) $line["num_comments"];
  530. $entry_comments = "";
  531. if ($num_comments > 0) {
  532. if ($line["comments"]) {
  533. $comments_url = htmlspecialchars($line["comments"]);
  534. } else {
  535. $comments_url = htmlspecialchars($line["link"]);
  536. }
  537. $entry_comments = "<a class=\"postComments\"
  538. target='_blank' rel='noopener noreferrer' href=\"$comments_url\">$num_comments ".
  539. _ngettext("comment", "comments", $num_comments)."</a>";
  540. } else {
  541. if ($line["comments"] && $line["link"] != $line["comments"]) {
  542. $entry_comments = "<a class=\"postComments\" target='_blank' rel='noopener noreferrer' href=\"".htmlspecialchars($line["comments"])."\">".__("comments")."</a>";
  543. }
  544. }
  545. if ($entry_comments) $reply['content'] .= "&nbsp;($entry_comments)";
  546. $reply['content'] .= "</span>";
  547. $reply['content'] .= "<div>";
  548. // $reply['content'] .= "$marked_pic";
  549. // $reply['content'] .= "$published_pic";
  550. foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_BUTTON) as $p) {
  551. $reply['content'] .= $p->hook_article_button($line);
  552. }
  553. $reply['content'] .= "</div>";
  554. $reply['content'] .= "</div>";
  555. $reply['content'] .= "</div>";
  556. $reply['content'] .= "</div>";
  557. }
  558. ++$lnum;
  559. }
  560. if ($_REQUEST["debug"]) $timing_info = print_checkpoint("PE", $timing_info);
  561. } else if (!is_numeric($result)) {
  562. $message = "";
  563. switch ($view_mode) {
  564. case "unread":
  565. $message = __("No unread articles found to display.");
  566. break;
  567. case "updated":
  568. $message = __("No updated articles found to display.");
  569. break;
  570. case "marked":
  571. $message = __("No starred articles found to display.");
  572. break;
  573. default:
  574. if ($feed < LABEL_BASE_INDEX) {
  575. $message = __("No articles found to display. You can assign articles to labels manually from article header context menu (applies to all selected articles) or use a filter.");
  576. } else {
  577. $message = __("No articles found to display.");
  578. }
  579. }
  580. if (!$offset && $message) {
  581. $reply['content'] = "<div class='whiteBox'>$message";
  582. $reply['content'] .= "<p><span class=\"insensitive\">";
  583. $result = $this->dbh->query("SELECT ".SUBSTRING_FOR_DATE."(MAX(last_updated), 1, 19) AS last_updated FROM ttrss_feeds
  584. WHERE owner_uid = " . $_SESSION['uid']);
  585. $last_updated = $this->dbh->fetch_result($result, 0, "last_updated");
  586. $last_updated = make_local_datetime($last_updated, false);
  587. $reply['content'] .= sprintf(__("Feeds last updated at %s"), $last_updated);
  588. $result = $this->dbh->query("SELECT COUNT(id) AS num_errors
  589. FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]);
  590. $num_errors = $this->dbh->fetch_result($result, 0, "num_errors");
  591. if ($num_errors > 0) {
  592. $reply['content'] .= "<br/>";
  593. $reply['content'] .= "<a class=\"insensitive\" href=\"#\" onclick=\"showFeedsWithErrors()\">".
  594. __('Some feeds have update errors (click for details)')."</a>";
  595. }
  596. $reply['content'] .= "</span></p></div>";
  597. }
  598. } else if (is_numeric($result) && $result == -1) {
  599. $reply['first_id_changed'] = true;
  600. }
  601. if ($_REQUEST["debug"]) $timing_info = print_checkpoint("H2", $timing_info);
  602. return array($topmost_article_ids, $headlines_count, $feed, $disable_cache,
  603. $vgroup_last_feed, $reply);
  604. }
  605. function catchupAll() {
  606. $this->dbh->query("UPDATE ttrss_user_entries SET
  607. last_read = NOW(), unread = false WHERE unread = true AND owner_uid = " . $_SESSION["uid"]);
  608. ccache_zero_all($_SESSION["uid"]);
  609. }
  610. function view() {
  611. $timing_info = microtime(true);
  612. $reply = array();
  613. if ($_REQUEST["debug"]) $timing_info = print_checkpoint("0", $timing_info);
  614. $feed = $this->dbh->escape_string($_REQUEST["feed"]);
  615. $method = $this->dbh->escape_string($_REQUEST["m"]);
  616. $view_mode = $this->dbh->escape_string($_REQUEST["view_mode"]);
  617. $limit = 30;
  618. @$cat_view = $_REQUEST["cat"] == "true";
  619. @$next_unread_feed = $this->dbh->escape_string($_REQUEST["nuf"]);
  620. @$offset = $this->dbh->escape_string($_REQUEST["skip"]);
  621. @$vgroup_last_feed = $this->dbh->escape_string($_REQUEST["vgrlf"]);
  622. $order_by = $this->dbh->escape_string($_REQUEST["order_by"]);
  623. $check_first_id = $this->dbh->escape_string($_REQUEST["fid"]);
  624. if (is_numeric($feed)) $feed = (int) $feed;
  625. /* Feed -5 is a special case: it is used to display auxiliary information
  626. * when there's nothing to load - e.g. no stuff in fresh feed */
  627. if ($feed == -5) {
  628. print json_encode($this->generate_dashboard_feed());
  629. return;
  630. }
  631. $result = false;
  632. if ($feed < LABEL_BASE_INDEX) {
  633. $label_feed = feed_to_label_id($feed);
  634. $result = $this->dbh->query("SELECT id FROM ttrss_labels2 WHERE
  635. id = '$label_feed' AND owner_uid = " . $_SESSION['uid']);
  636. } else if (!$cat_view && is_numeric($feed) && $feed > 0) {
  637. $result = $this->dbh->query("SELECT id FROM ttrss_feeds WHERE
  638. id = '$feed' AND owner_uid = " . $_SESSION['uid']);
  639. } else if ($cat_view && is_numeric($feed) && $feed > 0) {
  640. $result = $this->dbh->query("SELECT id FROM ttrss_feed_categories WHERE
  641. id = '$feed' AND owner_uid = " . $_SESSION['uid']);
  642. }
  643. if ($result && $this->dbh->num_rows($result) == 0) {
  644. print json_encode($this->generate_error_feed(__("Feed not found.")));
  645. return;
  646. }
  647. /* Updating a label ccache means recalculating all of the caches
  648. * so for performance reasons we don't do that here */
  649. if ($feed >= 0) {
  650. ccache_update($feed, $_SESSION["uid"], $cat_view);
  651. }
  652. set_pref("_DEFAULT_VIEW_MODE", $view_mode);
  653. set_pref("_DEFAULT_VIEW_ORDER_BY", $order_by);
  654. /* bump login timestamp if needed */
  655. if (time() - $_SESSION["last_login_update"] > 3600) {
  656. $this->dbh->query("UPDATE ttrss_users SET last_login = NOW() WHERE id = " .
  657. $_SESSION["uid"]);
  658. $_SESSION["last_login_update"] = time();
  659. }
  660. if (!$cat_view && is_numeric($feed) && $feed > 0) {
  661. $this->dbh->query("UPDATE ttrss_feeds SET last_viewed = NOW()
  662. WHERE id = '$feed' AND owner_uid = ".$_SESSION["uid"]);
  663. }
  664. $reply['headlines'] = array();
  665. $override_order = false;
  666. $skip_first_id_check = false;
  667. switch ($order_by) {
  668. case "title":
  669. $override_order = "ttrss_entries.title";
  670. break;
  671. case "date_reverse":
  672. $override_order = "score DESC, date_entered, updated";
  673. $skip_first_id_check = true;
  674. break;
  675. case "feed_dates":
  676. $override_order = "updated DESC";
  677. break;
  678. }
  679. if ($_REQUEST["debug"]) $timing_info = print_checkpoint("04", $timing_info);
  680. $ret = $this->format_headlines_list($feed, $method,
  681. $view_mode, $limit, $cat_view, $next_unread_feed, $offset,
  682. $vgroup_last_feed, $override_order, true, $check_first_id, $skip_first_id_check);
  683. //$topmost_article_ids = $ret[0];
  684. $headlines_count = $ret[1];
  685. /* $returned_feed = $ret[2]; */
  686. $disable_cache = $ret[3];
  687. $vgroup_last_feed = $ret[4];
  688. //$reply['headlines']['content'] =& $ret[5]['content'];
  689. //$reply['headlines']['toolbar'] =& $ret[5]['toolbar'];
  690. $reply['headlines'] = $ret[5];
  691. if (!$next_unread_feed)
  692. $reply['headlines']['id'] = $feed;
  693. else
  694. $reply['headlines']['id'] = $next_unread_feed;
  695. $reply['headlines']['is_cat'] = (bool) $cat_view;
  696. if ($_REQUEST["debug"]) $timing_info = print_checkpoint("05", $timing_info);
  697. $reply['headlines-info'] = array("count" => (int) $headlines_count,
  698. "vgroup_last_feed" => $vgroup_last_feed,
  699. "disable_cache" => (bool) $disable_cache);
  700. if ($_REQUEST["debug"]) $timing_info = print_checkpoint("30", $timing_info);
  701. $reply['runtime-info'] = make_runtime_info();
  702. print json_encode($reply);
  703. }
  704. private function generate_dashboard_feed() {
  705. $reply = array();
  706. $reply['headlines']['id'] = -5;
  707. $reply['headlines']['is_cat'] = false;
  708. $reply['headlines']['toolbar'] = '';
  709. $reply['headlines']['content'] = "<div class='whiteBox'>".__('No feed selected.');
  710. $reply['headlines']['content'] .= "<p><span class=\"insensitive\">";
  711. $result = $this->dbh->query("SELECT ".SUBSTRING_FOR_DATE."(MAX(last_updated), 1, 19) AS last_updated FROM ttrss_feeds
  712. WHERE owner_uid = " . $_SESSION['uid']);
  713. $last_updated = $this->dbh->fetch_result($result, 0, "last_updated");
  714. $last_updated = make_local_datetime($last_updated, false);
  715. $reply['headlines']['content'] .= sprintf(__("Feeds last updated at %s"), $last_updated);
  716. $result = $this->dbh->query("SELECT COUNT(id) AS num_errors
  717. FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]);
  718. $num_errors = $this->dbh->fetch_result($result, 0, "num_errors");
  719. if ($num_errors > 0) {
  720. $reply['headlines']['content'] .= "<br/>";
  721. $reply['headlines']['content'] .= "<a class=\"insensitive\" href=\"#\" onclick=\"showFeedsWithErrors()\">".
  722. __('Some feeds have update errors (click for details)')."</a>";
  723. }
  724. $reply['headlines']['content'] .= "</span></p>";
  725. $reply['headlines-info'] = array("count" => 0,
  726. "vgroup_last_feed" => '',
  727. "unread" => 0,
  728. "disable_cache" => true);
  729. return $reply;
  730. }
  731. private function generate_error_feed($error) {
  732. $reply = array();
  733. $reply['headlines']['id'] = -7;
  734. $reply['headlines']['is_cat'] = false;
  735. $reply['headlines']['toolbar'] = '';
  736. $reply['headlines']['content'] = "<div class='whiteBox'>". $error . "</div>";
  737. $reply['headlines-info'] = array("count" => 0,
  738. "vgroup_last_feed" => '',
  739. "unread" => 0,
  740. "disable_cache" => true);
  741. return $reply;
  742. }
  743. function quickAddFeed() {
  744. print_hidden("op", "rpc");
  745. print_hidden("method", "addfeed");
  746. print "<div id='fadd_error_message' style='display : none' class='alert alert-danger'></div>";
  747. print "<div id='fadd_multiple_notify' style='display : none'>";
  748. print_notice("Provided URL is a HTML page referencing multiple feeds, please select required feed from the dropdown menu below.");
  749. print "<p></div>";
  750. print "<div class=\"dlgSec\">".__("Feed or site URL")."</div>";
  751. print "<div class=\"dlgSecCont\">";
  752. print "<div style='float : right'>
  753. <img style='display : none'
  754. id='feed_add_spinner' src='images/indicator_white.gif'></div>";
  755. print "<input style=\"font-size : 16px; width : 20em;\"
  756. placeHolder=\"".__("Feed or site URL")."\"
  757. dojoType=\"dijit.form.ValidationTextBox\" required=\"1\" name=\"feed\" id=\"feedDlg_feedUrl\">";
  758. print "<hr/>";
  759. if (get_pref('ENABLE_FEED_CATS')) {
  760. print __('Place in category:') . " ";
  761. print_feed_cat_select("cat", false, 'dojoType="dijit.form.Select"');
  762. }
  763. print "</div>";
  764. print '<div id="feedDlg_feedsContainer" style="display : none">
  765. <div class="dlgSec">' . __('Available feeds') . '</div>
  766. <div class="dlgSecCont">'.
  767. '<select id="feedDlg_feedContainerSelect"
  768. dojoType="dijit.form.Select" size="3">
  769. <script type="dojo/method" event="onChange" args="value">
  770. dijit.byId("feedDlg_feedUrl").attr("value", value);
  771. </script>
  772. </select>'.
  773. '</div></div>';
  774. print "<div id='feedDlg_loginContainer' style='display : none'>
  775. <div class=\"dlgSec\">".__("Authentication")."</div>
  776. <div class=\"dlgSecCont\">".
  777. " <input dojoType=\"dijit.form.TextBox\" name='login'\"
  778. placeHolder=\"".__("Login")."\"
  779. autocomplete=\"new-password\"
  780. style=\"width : 10em;\"> ".
  781. " <input
  782. placeHolder=\"".__("Password")."\"
  783. dojoType=\"dijit.form.TextBox\" type='password'
  784. autocomplete=\"new-password\"
  785. style=\"width : 10em;\" name='pass'\">
  786. </div></div>";
  787. print "<div style=\"clear : both\">
  788. <input type=\"checkbox\" name=\"need_auth\" dojoType=\"dijit.form.CheckBox\" id=\"feedDlg_loginCheck\"
  789. onclick='checkboxToggleElement(this, \"feedDlg_loginContainer\")'>
  790. <label for=\"feedDlg_loginCheck\">".
  791. __('This feed requires authentication.')."</div>";
  792. print "</form>";
  793. print "<div class=\"dlgButtons\">
  794. <button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('feedAddDlg').execute()\">".__('Subscribe')."</button>";
  795. if (!(defined('_DISABLE_FEED_BROWSER') && _DISABLE_FEED_BROWSER)) {
  796. print "<button dojoType=\"dijit.form.Button\" onclick=\"return feedBrowser()\">".__('More feeds')."</button>";
  797. }
  798. print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('feedAddDlg').hide()\">".__('Cancel')."</button>
  799. </div>";
  800. //return;
  801. }
  802. function feedBrowser() {
  803. if (defined('_DISABLE_FEED_BROWSER') && _DISABLE_FEED_BROWSER) return;
  804. $browser_search = $this->dbh->escape_string($_REQUEST["search"]);
  805. print_hidden("op", "rpc");
  806. print_hidden("method", "updateFeedBrowser");
  807. print "<div dojoType=\"dijit.Toolbar\">
  808. <div style='float : right'>
  809. <img style='display : none'
  810. id='feed_browser_spinner' src='images/indicator_white.gif'>
  811. <input name=\"search\" dojoType=\"dijit.form.TextBox\" size=\"20\" type=\"search\"
  812. onchange=\"dijit.byId('feedBrowserDlg').update()\" value=\"$browser_search\">
  813. <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('feedBrowserDlg').update()\">".__('Search')."</button>
  814. </div>";
  815. print " <select name=\"mode\" dojoType=\"dijit.form.Select\" onchange=\"dijit.byId('feedBrowserDlg').update()\">
  816. <option value='1'>" . __('Popular feeds') . "</option>
  817. <option value='2'>" . __('Feed archive') . "</option>
  818. </select> ";
  819. print __("limit:");
  820. print " <select dojoType=\"dijit.form.Select\" name=\"limit\" onchange=\"dijit.byId('feedBrowserDlg').update()\">";
  821. foreach (array(25, 50, 100, 200) as $l) {
  822. //$issel = ($l == $limit) ? "selected=\"1\"" : "";
  823. print "<option value=\"$l\">$l</option>";
  824. }
  825. print "</select> ";
  826. print "</div>";
  827. require_once "feedbrowser.php";
  828. print "<ul class='browseFeedList' id='browseFeedList'>";
  829. print make_feed_browser("", 25);
  830. print "</ul>";
  831. print "<div align='center'>
  832. <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('feedBrowserDlg').execute()\">".__('Subscribe')."</button>
  833. <button dojoType=\"dijit.form.Button\" style='display : none' id='feed_archive_remove' onclick=\"dijit.byId('feedBrowserDlg').removeFromArchive()\">".__('Remove')."</button>
  834. <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('feedBrowserDlg').hide()\" >".__('Cancel')."</button></div>";
  835. }
  836. function search() {
  837. $this->params = explode(":", $this->dbh->escape_string($_REQUEST["param"]), 2);
  838. $active_feed_id = sprintf("%d", $this->params[0]);
  839. $is_cat = $this->params[1] != "false";
  840. print "<div class=\"dlgSec\">".__('Look for')."</div>";
  841. print "<div class=\"dlgSecCont\">";
  842. print "<input dojoType=\"dijit.form.ValidationTextBox\"
  843. style=\"font-size : 16px; width : 20em;\"
  844. required=\"1\" name=\"query\" type=\"search\" value=''>";
  845. print "<hr/><span style='float : right'>".T_sprintf('in %s', getFeedTitle($active_feed_id, $is_cat))."</span>";
  846. if (DB_TYPE == "pgsql") {
  847. print "<hr/>";
  848. print_select("search_language", "", Pref_Feeds::$feed_languages,
  849. "dojoType='dijit.form.Select' title=\"".__('Used for word stemming')."\"");
  850. }
  851. print "</div>";
  852. print "<div class=\"dlgButtons\">";
  853. if (count(PluginHost::getInstance()->get_hooks(PluginHost::HOOK_SEARCH)) == 0) {
  854. print "<div style=\"float : left\">
  855. <a class=\"visibleLink\" target=\"_blank\" href=\"http://tt-rss.org/wiki/SearchSyntax\">".__("Search syntax")."</a>
  856. </div>";
  857. }
  858. print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('searchDlg').execute()\">".__('Search')."</button>
  859. <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('searchDlg').hide()\">".__('Cancel')."</button>
  860. </div>";
  861. }
  862. function update_debugger() {
  863. header("Content-type: text/html");
  864. $feed_id = (int)$_REQUEST["feed_id"];
  865. @$do_update = $_REQUEST["action"] == "do_update";
  866. $csrf_token = $_REQUEST["csrf_token"];
  867. $refetch_checked = isset($_REQUEST["force_refetch"]) ? "checked" : "";
  868. $rehash_checked = isset($_REQUEST["force_rehash"]) ? "checked" : "";
  869. ?>
  870. <html>
  871. <head>
  872. <link rel="stylesheet" type="text/css" href="css/utility.css">
  873. <title>Feed Debugger</title>
  874. </head>
  875. <body class="small_margins">
  876. <h1>Feed Debugger: <?php echo "$feed_id: " . getFeedTitle($feed_id) ?></h1>
  877. <form method="GET" action="">
  878. <input type="hidden" name="op" value="feeds">
  879. <input type="hidden" name="method" value="update_debugger">
  880. <input type="hidden" name="xdebug" value="1">
  881. <input type="hidden" name="csrf_token" value="<?php echo $csrf_token ?>">
  882. <input type="hidden" name="action" value="do_update">
  883. <input type="hidden" name="feed_id" value="<?php echo $feed_id ?>">
  884. <input type="checkbox" name="force_refetch" value="1" <?php echo $refetch_checked ?>> Force refetch<br/>
  885. <input type="checkbox" name="force_rehash" value="1" <?php echo $rehash_checked ?>> Force rehash<br/>
  886. <p/><button type="submit">Continue</button>
  887. </form>
  888. <hr>
  889. <pre><?php
  890. if ($do_update) {
  891. include "rssfuncs.php";
  892. update_rss_feed($feed_id, true, true);
  893. }
  894. ?></pre>
  895. </body>
  896. </html>
  897. <?php
  898. }
  899. }
  900. ?>