feeds.php 40 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244
  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. $vgroup_last_feed = $vgr_last_feed;
  220. $reply['toolbar'] = $this->format_headline_subtoolbar($feed_site_url,
  221. $feed_title,
  222. $feed, $cat_view, $search, $view_mode,
  223. $last_error, $last_updated);
  224. $headlines_count = is_numeric($result) ? 0 : $this->dbh->num_rows($result);
  225. if ($offset == 0) {
  226. foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_HEADLINES_BEFORE) as $p) {
  227. $reply['content'] .= $p->hook_headlines_before($feed, $cat_view, $qfh_ret);
  228. }
  229. }
  230. $reply['content'] = '';
  231. if ($headlines_count > 0) {
  232. $lnum = $offset;
  233. $num_unread = 0;
  234. $cur_feed_title = '';
  235. if ($_REQUEST["debug"]) $timing_info = print_checkpoint("PS", $timing_info);
  236. $expand_cdm = get_pref('CDM_EXPANDED');
  237. while ($line = $this->dbh->fetch_assoc($result)) {
  238. $line["content_preview"] = "&mdash; " . truncate_string(strip_tags($line["content"]), 250);
  239. foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) {
  240. $line = $p->hook_query_headlines($line, 250, false);
  241. }
  242. if (get_pref('SHOW_CONTENT_PREVIEW')) {
  243. $content_preview = $line["content_preview"];
  244. }
  245. $id = $line["id"];
  246. $feed_id = $line["feed_id"];
  247. $label_cache = $line["label_cache"];
  248. $labels = false;
  249. if ($label_cache) {
  250. $label_cache = json_decode($label_cache, true);
  251. if ($label_cache) {
  252. if ($label_cache["no-labels"] == 1)
  253. $labels = array();
  254. else
  255. $labels = $label_cache;
  256. }
  257. }
  258. if (!is_array($labels)) $labels = get_article_labels($id);
  259. $labels_str = "<span class=\"HLLCTR-$id\">";
  260. $labels_str .= format_article_labels($labels, $id);
  261. $labels_str .= "</span>";
  262. if (count($topmost_article_ids) < 3) {
  263. array_push($topmost_article_ids, $id);
  264. }
  265. $class = "";
  266. if (sql_bool_to_bool($line["unread"])) {
  267. $class .= " Unread";
  268. ++$num_unread;
  269. }
  270. if (sql_bool_to_bool($line["marked"])) {
  271. $marked_pic = "<img
  272. src=\"images/mark_set.png\"
  273. class=\"markedPic\" alt=\"Unstar article\"
  274. onclick='toggleMark($id)'>";
  275. $class .= " marked";
  276. } else {
  277. $marked_pic = "<img
  278. src=\"images/mark_unset.png\"
  279. class=\"markedPic\" alt=\"Star article\"
  280. onclick='toggleMark($id)'>";
  281. }
  282. if (sql_bool_to_bool($line["published"])) {
  283. $published_pic = "<img src=\"images/pub_set.png\"
  284. class=\"pubPic\"
  285. alt=\"Unpublish article\" onclick='togglePub($id)'>";
  286. $class .= " published";
  287. } else {
  288. $published_pic = "<img src=\"images/pub_unset.png\"
  289. class=\"pubPic\"
  290. alt=\"Publish article\" onclick='togglePub($id)'>";
  291. }
  292. # $content_link = "<a target=\"_blank\" rel=\"noopener noreferrer\" href=\"".$line["link"]."\">" .
  293. # $line["title"] . "</a>";
  294. # $content_link = "<a
  295. # href=\"" . htmlspecialchars($line["link"]) . "\"
  296. # onclick=\"view($id,$feed_id);\">" .
  297. # $line["title"] . "</a>";
  298. # $content_link = "<a href=\"javascript:viewContentUrl('".$line["link"]."');\">" .
  299. # $line["title"] . "</a>";
  300. $updated_fmt = make_local_datetime($line["updated"], false, false, false, true);
  301. $date_entered_fmt = T_sprintf("Imported at %s",
  302. make_local_datetime($line["date_entered"], false));
  303. $score = $line["score"];
  304. $score_pic = "images/" . get_score_pic($score);
  305. /* $score_title = __("(Click to change)");
  306. $score_pic = "<img class='hlScorePic' src=\"images/$score_pic\"
  307. onclick=\"adjustArticleScore($id, $score)\" title=\"$score $score_title\">"; */
  308. $score_pic = "<img class='hlScorePic' score='$score' onclick='changeScore($id, this)' src=\"$score_pic\"
  309. title=\"$score\">";
  310. if ($score > 500) {
  311. $hlc_suffix = "high";
  312. } else if ($score < -100) {
  313. $hlc_suffix = "low";
  314. } else {
  315. $hlc_suffix = "";
  316. }
  317. $entry_author = $line["author"];
  318. if ($entry_author) {
  319. $entry_author = " &mdash; $entry_author";
  320. }
  321. $has_feed_icon = feed_has_icon($feed_id);
  322. if ($has_feed_icon) {
  323. $feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"".ICONS_URL."/$feed_id.ico\" alt=\"\">";
  324. } else {
  325. $feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"images/pub_set.png\" alt=\"\">";
  326. }
  327. $entry_site_url = $line["site_url"];
  328. //setting feed headline background color, needs to change text color based on dark/light
  329. $fav_color = $line['favicon_avg_color'];
  330. require_once "colors.php";
  331. if ($fav_color && $fav_color != 'fail') {
  332. if (!isset($rgba_cache[$feed_id])) {
  333. $rgba_cache[$feed_id] = join(",", _color_unpack($fav_color));
  334. }
  335. }
  336. if (!get_pref('COMBINED_DISPLAY_MODE')) {
  337. if ($vfeed_group_enabled) {
  338. if ($feed_id != $vgroup_last_feed && $line["feed_title"]) {
  339. $cur_feed_title = $line["feed_title"];
  340. $vgroup_last_feed = $feed_id;
  341. $cur_feed_title = htmlspecialchars($cur_feed_title);
  342. $vf_catchup_link = "<a class='catchup' onclick='catchupFeedInGroup($feed_id);' href='#'>".__('mark feed as read')."</a>";
  343. $reply['content'] .= "<div data-feed-id='$feed_id' id='FTITLE-$feed_id' class='cdmFeedTitle'>".
  344. "<div style='float : right'>$feed_icon_img</div>".
  345. "<a class='title' href=\"#\" onclick=\"viewfeed({feed:$feed_id})\">".
  346. $line["feed_title"]."</a>
  347. $vf_catchup_link</div>";
  348. }
  349. }
  350. $mouseover_attrs = "onmouseover='postMouseIn(event, $id)'
  351. onmouseout='postMouseOut($id)'";
  352. $reply['content'] .= "<div class='hl hlMenuAttach $class' data-orig-feed-id='$feed_id' data-article-id='$id' id='RROW-$id' $mouseover_attrs>";
  353. $reply['content'] .= "<div class='hlLeft'>";
  354. $reply['content'] .= "<input dojoType=\"dijit.form.CheckBox\"
  355. type=\"checkbox\" onclick=\"toggleSelectRow2(this)\"
  356. class='rchk'>";
  357. $reply['content'] .= "$marked_pic";
  358. $reply['content'] .= "$published_pic";
  359. $reply['content'] .= "</div>";
  360. $reply['content'] .= "<div onclick='return hlClicked(event, $id)'
  361. class=\"hlTitle\"><span class='hlContent $hlc_suffix'>";
  362. $reply['content'] .= "<a id=\"RTITLE-$id\" class=\"title $hlc_suffix\"
  363. href=\"" . htmlspecialchars($line["link"]) . "\"
  364. onclick=\"\">" .
  365. truncate_string($line["title"], 200);
  366. if (get_pref('SHOW_CONTENT_PREVIEW')) {
  367. $reply['content'] .= "<span class=\"contentPreview\">" . $line["content_preview"] . "</span>";
  368. }
  369. $reply['content'] .= "</a></span>";
  370. $reply['content'] .= $labels_str;
  371. $reply['content'] .= "</div>";
  372. if (!$vfeed_group_enabled) {
  373. if (@$line["feed_title"]) {
  374. $rgba = @$rgba_cache[$feed_id];
  375. $reply['content'] .= "<span class=\"hlFeed\"><a style=\"background : rgba($rgba, 0.3)\" href=\"#\" onclick=\"viewfeed({feed:$feed_id})\">".
  376. truncate_string($line["feed_title"],30)."</a></span>";
  377. }
  378. }
  379. $reply['content'] .= "<span class=\"hlUpdated\">";
  380. $reply['content'] .= "<div title='$date_entered_fmt'>$updated_fmt</div>
  381. </span>";
  382. $reply['content'] .= "<div class=\"hlRight\">";
  383. $reply['content'] .= $score_pic;
  384. if ($line["feed_title"] && !$vfeed_group_enabled) {
  385. $reply['content'] .= "<span onclick=\"viewfeed({feed:$feed_id})\"
  386. style=\"cursor : pointer\"
  387. title=\"".htmlspecialchars($line['feed_title'])."\">
  388. $feed_icon_img</span>";
  389. }
  390. $reply['content'] .= "</div>";
  391. $reply['content'] .= "</div>";
  392. } else {
  393. if ($line["tag_cache"])
  394. $tags = explode(",", $line["tag_cache"]);
  395. else
  396. $tags = false;
  397. $line["content"] = sanitize($line["content"],
  398. sql_bool_to_bool($line['hide_images']), false, $entry_site_url, $highlight_words, $line["id"]);
  399. foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ARTICLE_CDM) as $p) {
  400. $line = $p->hook_render_article_cdm($line);
  401. }
  402. if ($vfeed_group_enabled && $line["feed_title"]) {
  403. if ($feed_id != $vgroup_last_feed) {
  404. $cur_feed_title = $line["feed_title"];
  405. $vgroup_last_feed = $feed_id;
  406. $cur_feed_title = htmlspecialchars($cur_feed_title);
  407. $vf_catchup_link = "<a class='catchup' onclick='catchupFeedInGroup($feed_id);' href='#'>".__('mark feed as read')."</a>";
  408. $has_feed_icon = feed_has_icon($feed_id);
  409. if ($has_feed_icon) {
  410. $feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"".ICONS_URL."/$feed_id.ico\" alt=\"\">";
  411. } else {
  412. //$feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\" alt=\"\">";
  413. }
  414. $reply['content'] .= "<div data-feed-id='$feed_id' id='FTITLE-$feed_id' class='cdmFeedTitle'>".
  415. "<div style=\"float : right\">$feed_icon_img</div>".
  416. "<a href=\"#\" class='title' onclick=\"viewfeed({feed:$feed_id})\">".
  417. $line["feed_title"]."</a> $vf_catchup_link</div>";
  418. }
  419. }
  420. $mouseover_attrs = "onmouseover='postMouseIn(event, $id)'
  421. onmouseout='postMouseOut($id)'";
  422. $expanded_class = $expand_cdm ? "expanded" : "expandable";
  423. $reply['content'] .= "<div class=\"cdm $hlc_suffix $expanded_class $class\"
  424. id=\"RROW-$id\" data-article-id='$id' data-orig-feed-id='$feed_id' $mouseover_attrs>";
  425. $reply['content'] .= "<div class=\"cdmHeader\">";
  426. $reply['content'] .= "<div style=\"vertical-align : middle\">";
  427. $reply['content'] .= "<input dojoType=\"dijit.form.CheckBox\"
  428. type=\"checkbox\" onclick=\"toggleSelectRow2(this, false, true)\"
  429. class='rchk'>";
  430. $reply['content'] .= "$marked_pic";
  431. $reply['content'] .= "$published_pic";
  432. $reply['content'] .= "</div>";
  433. if ($highlight_words && count($highlight_words > 0)) {
  434. foreach ($highlight_words as $word) {
  435. $line["title"] = preg_replace("/(\Q$word\E)/i",
  436. "<span class=\"highlight\">$1</span>", $line["title"]);
  437. }
  438. }
  439. // data-article-id included for context menu
  440. $reply['content'] .= "<span id=\"RTITLE-$id\"
  441. onclick=\"return cdmClicked(event, $id);\"
  442. data-article-id=\"$id\"
  443. class=\"titleWrap hlMenuAttach $hlc_suffix\">
  444. <a class=\"title $hlc_suffix\"
  445. title=\"".htmlspecialchars($line["title"])."\"
  446. target=\"_blank\" rel=\"noopener noreferrer\" href=\"".
  447. htmlspecialchars($line["link"])."\">".
  448. $line["title"] .
  449. "</a> <span class=\"author\">$entry_author</span>";
  450. $reply['content'] .= $labels_str;
  451. $reply['content'] .= "<span class='collapseBtn' style='display : none'>
  452. <img src=\"images/collapse.png\" onclick=\"cdmCollapseArticle(event, $id)\"
  453. title=\"".__("Collapse article")."\"/></span>";
  454. if (!$expand_cdm)
  455. $content_hidden = "style=\"display : none\"";
  456. else
  457. $excerpt_hidden = "style=\"display : none\"";
  458. $reply['content'] .= "<span $excerpt_hidden id=\"CEXC-$id\" class=\"cdmExcerpt\">" . $content_preview . "</span>";
  459. $reply['content'] .= "</span>";
  460. if (!$vfeed_group_enabled) {
  461. if (@$line["feed_title"]) {
  462. $rgba = @$rgba_cache[$feed_id];
  463. $reply['content'] .= "<div class=\"hlFeed\">
  464. <a href=\"#\" style=\"background-color: rgba($rgba,0.3)\"
  465. onclick=\"viewfeed({feed:$feed_id})\">".
  466. truncate_string($line["feed_title"],30)."</a>
  467. </div>";
  468. }
  469. }
  470. $reply['content'] .= "<span class='updated' title='$date_entered_fmt'>
  471. $updated_fmt</span>";
  472. $reply['content'] .= "<div class='scoreWrap' style=\"vertical-align : middle\">";
  473. $reply['content'] .= "$score_pic";
  474. if (!get_pref("VFEED_GROUP_BY_FEED") && $line["feed_title"]) {
  475. $reply['content'] .= "<span style=\"cursor : pointer\"
  476. title=\"".htmlspecialchars($line["feed_title"])."\"
  477. onclick=\"viewfeed({feed:$feed_id})\">$feed_icon_img</span>";
  478. }
  479. $reply['content'] .= "</div>";
  480. $reply['content'] .= "</div>";
  481. $reply['content'] .= "<div class=\"cdmContent\" $content_hidden
  482. onclick=\"return cdmClicked(event, $id, true);\"
  483. id=\"CICD-$id\">";
  484. $reply['content'] .= "<div id=\"POSTNOTE-$id\">";
  485. if ($line['note']) {
  486. $reply['content'] .= format_article_note($id, $line['note']);
  487. }
  488. $reply['content'] .= "</div>";
  489. if (!$line['lang']) $line['lang'] = 'en';
  490. $reply['content'] .= "<div class=\"cdmContentInner\" lang=\"".$line['lang']."\">";
  491. if ($line["orig_feed_id"]) {
  492. $tmp_result = $this->dbh->query("SELECT * FROM ttrss_archived_feeds
  493. WHERE id = ".$line["orig_feed_id"] . " AND owner_uid = " . $_SESSION["uid"]);
  494. if ($this->dbh->num_rows($tmp_result) != 0) {
  495. $reply['content'] .= "<div clear='both'>";
  496. $reply['content'] .= __("Originally from:");
  497. $reply['content'] .= "&nbsp;";
  498. $tmp_line = $this->dbh->fetch_assoc($tmp_result);
  499. $reply['content'] .= "<a target='_blank' rel='noopener noreferrer'
  500. href=' " . htmlspecialchars($tmp_line['site_url']) . "'>" .
  501. $tmp_line['title'] . "</a>";
  502. $reply['content'] .= "&nbsp;";
  503. $reply['content'] .= "<a target='_blank' rel='noopener noreferrer' href='" . htmlspecialchars($tmp_line['feed_url']) . "'>";
  504. $reply['content'] .= "<img title='".__('Feed URL')."'class='tinyFeedIcon' src='images/pub_unset.png'></a>";
  505. $reply['content'] .= "</div>";
  506. }
  507. }
  508. $reply['content'] .= "<span id=\"CWRAP-$id\">";
  509. $reply['content'] .= "<span id=\"CENCW-$id\" class=\"cencw\" style=\"display : none\">";
  510. $reply['content'] .= htmlspecialchars($line["content"]);
  511. $reply['content'] .= "</span>";
  512. $reply['content'] .= "</span>";
  513. $reply['content'] .= "</div>";
  514. $reply['content'] .= "<div class=\"cdmIntermediate\">";
  515. $always_display_enclosures = sql_bool_to_bool($line["always_display_enclosures"]);
  516. $reply['content'] .= format_article_enclosures($id, $always_display_enclosures, $line["content"], sql_bool_to_bool($line["hide_images"]));
  517. $reply['content'] .= "</div>";
  518. $reply['content'] .= "<div class=\"cdmFooter\" onclick=\"cdmFooterClick(event)\">";
  519. foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_LEFT_BUTTON) as $p) {
  520. $reply['content'] .= $p->hook_article_left_button($line);
  521. }
  522. $tags_str = format_tags_string($tags, $id);
  523. $reply['content'] .= "<span class='left'>";
  524. $reply['content'] .= "<img src='images/tag.png' alt='Tags' title='Tags'>
  525. <span id=\"ATSTR-$id\">$tags_str</span>
  526. <a title=\"".__('Edit tags for this article')."\"
  527. href=\"#\" onclick=\"editArticleTags($id)\">(+)</a>";
  528. $num_comments = (int) $line["num_comments"];
  529. $entry_comments = "";
  530. if ($num_comments > 0) {
  531. if ($line["comments"]) {
  532. $comments_url = htmlspecialchars($line["comments"]);
  533. } else {
  534. $comments_url = htmlspecialchars($line["link"]);
  535. }
  536. $entry_comments = "<a class=\"postComments\"
  537. target='_blank' rel='noopener noreferrer' href=\"$comments_url\">$num_comments ".
  538. _ngettext("comment", "comments", $num_comments)."</a>";
  539. } else {
  540. if ($line["comments"] && $line["link"] != $line["comments"]) {
  541. $entry_comments = "<a class=\"postComments\" target='_blank' rel='noopener noreferrer' href=\"".htmlspecialchars($line["comments"])."\">".__("comments")."</a>";
  542. }
  543. }
  544. if ($entry_comments) $reply['content'] .= "&nbsp;($entry_comments)";
  545. $reply['content'] .= "</span>";
  546. $reply['content'] .= "<div>";
  547. // $reply['content'] .= "$marked_pic";
  548. // $reply['content'] .= "$published_pic";
  549. foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_BUTTON) as $p) {
  550. $reply['content'] .= $p->hook_article_button($line);
  551. }
  552. $reply['content'] .= "</div>";
  553. $reply['content'] .= "</div>";
  554. $reply['content'] .= "</div>";
  555. $reply['content'] .= "</div>";
  556. }
  557. ++$lnum;
  558. }
  559. if ($_REQUEST["debug"]) $timing_info = print_checkpoint("PE", $timing_info);
  560. } else if (!is_numeric($result)) {
  561. $message = "";
  562. switch ($view_mode) {
  563. case "unread":
  564. $message = __("No unread articles found to display.");
  565. break;
  566. case "updated":
  567. $message = __("No updated articles found to display.");
  568. break;
  569. case "marked":
  570. $message = __("No starred articles found to display.");
  571. break;
  572. default:
  573. if ($feed < LABEL_BASE_INDEX) {
  574. $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.");
  575. } else {
  576. $message = __("No articles found to display.");
  577. }
  578. }
  579. if (!$offset && $message) {
  580. $reply['content'] = "<div class='whiteBox'>$message";
  581. $reply['content'] .= "<p><span class=\"insensitive\">";
  582. $result = $this->dbh->query("SELECT ".SUBSTRING_FOR_DATE."(MAX(last_updated), 1, 19) AS last_updated FROM ttrss_feeds
  583. WHERE owner_uid = " . $_SESSION['uid']);
  584. $last_updated = $this->dbh->fetch_result($result, 0, "last_updated");
  585. $last_updated = make_local_datetime($last_updated, false);
  586. $reply['content'] .= sprintf(__("Feeds last updated at %s"), $last_updated);
  587. $result = $this->dbh->query("SELECT COUNT(id) AS num_errors
  588. FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]);
  589. $num_errors = $this->dbh->fetch_result($result, 0, "num_errors");
  590. if ($num_errors > 0) {
  591. $reply['content'] .= "<br/>";
  592. $reply['content'] .= "<a class=\"insensitive\" href=\"#\" onclick=\"showFeedsWithErrors()\">".
  593. __('Some feeds have update errors (click for details)')."</a>";
  594. }
  595. $reply['content'] .= "</span></p></div>";
  596. }
  597. } else if (is_numeric($result) && $result == -1) {
  598. $reply['first_id_changed'] = true;
  599. }
  600. if ($_REQUEST["debug"]) $timing_info = print_checkpoint("H2", $timing_info);
  601. return array($topmost_article_ids, $headlines_count, $feed, $disable_cache,
  602. $vgroup_last_feed, $reply);
  603. }
  604. function catchupAll() {
  605. $this->dbh->query("UPDATE ttrss_user_entries SET
  606. last_read = NOW(), unread = false WHERE unread = true AND owner_uid = " . $_SESSION["uid"]);
  607. ccache_zero_all($_SESSION["uid"]);
  608. }
  609. function view() {
  610. $timing_info = microtime(true);
  611. $reply = array();
  612. if ($_REQUEST["debug"]) $timing_info = print_checkpoint("0", $timing_info);
  613. $feed = $this->dbh->escape_string($_REQUEST["feed"]);
  614. $method = $this->dbh->escape_string($_REQUEST["m"]);
  615. $view_mode = $this->dbh->escape_string($_REQUEST["view_mode"]);
  616. $limit = 30;
  617. @$cat_view = $_REQUEST["cat"] == "true";
  618. @$next_unread_feed = $this->dbh->escape_string($_REQUEST["nuf"]);
  619. @$offset = $this->dbh->escape_string($_REQUEST["skip"]);
  620. @$vgroup_last_feed = $this->dbh->escape_string($_REQUEST["vgrlf"]);
  621. $order_by = $this->dbh->escape_string($_REQUEST["order_by"]);
  622. $check_first_id = $this->dbh->escape_string($_REQUEST["fid"]);
  623. if (is_numeric($feed)) $feed = (int) $feed;
  624. /* Feed -5 is a special case: it is used to display auxiliary information
  625. * when there's nothing to load - e.g. no stuff in fresh feed */
  626. if ($feed == -5) {
  627. print json_encode($this->generate_dashboard_feed());
  628. return;
  629. }
  630. $result = false;
  631. if ($feed < LABEL_BASE_INDEX) {
  632. $label_feed = feed_to_label_id($feed);
  633. $result = $this->dbh->query("SELECT id FROM ttrss_labels2 WHERE
  634. id = '$label_feed' AND owner_uid = " . $_SESSION['uid']);
  635. } else if (!$cat_view && is_numeric($feed) && $feed > 0) {
  636. $result = $this->dbh->query("SELECT id FROM ttrss_feeds WHERE
  637. id = '$feed' AND owner_uid = " . $_SESSION['uid']);
  638. } else if ($cat_view && is_numeric($feed) && $feed > 0) {
  639. $result = $this->dbh->query("SELECT id FROM ttrss_feed_categories WHERE
  640. id = '$feed' AND owner_uid = " . $_SESSION['uid']);
  641. }
  642. if ($result && $this->dbh->num_rows($result) == 0) {
  643. print json_encode($this->generate_error_feed(__("Feed not found.")));
  644. return;
  645. }
  646. /* Updating a label ccache means recalculating all of the caches
  647. * so for performance reasons we don't do that here */
  648. if ($feed >= 0) {
  649. ccache_update($feed, $_SESSION["uid"], $cat_view);
  650. }
  651. set_pref("_DEFAULT_VIEW_MODE", $view_mode);
  652. set_pref("_DEFAULT_VIEW_ORDER_BY", $order_by);
  653. /* bump login timestamp if needed */
  654. if (time() - $_SESSION["last_login_update"] > 3600) {
  655. $this->dbh->query("UPDATE ttrss_users SET last_login = NOW() WHERE id = " .
  656. $_SESSION["uid"]);
  657. $_SESSION["last_login_update"] = time();
  658. }
  659. if (!$cat_view && is_numeric($feed) && $feed > 0) {
  660. $this->dbh->query("UPDATE ttrss_feeds SET last_viewed = NOW()
  661. WHERE id = '$feed' AND owner_uid = ".$_SESSION["uid"]);
  662. }
  663. $reply['headlines'] = array();
  664. $override_order = false;
  665. $skip_first_id_check = false;
  666. switch ($order_by) {
  667. case "title":
  668. $override_order = "ttrss_entries.title";
  669. break;
  670. case "date_reverse":
  671. $override_order = "score DESC, date_entered, updated";
  672. $skip_first_id_check = true;
  673. break;
  674. case "feed_dates":
  675. $override_order = "updated DESC";
  676. break;
  677. }
  678. if ($_REQUEST["debug"]) $timing_info = print_checkpoint("04", $timing_info);
  679. $ret = $this->format_headlines_list($feed, $method,
  680. $view_mode, $limit, $cat_view, $next_unread_feed, $offset,
  681. $vgroup_last_feed, $override_order, true, $check_first_id, $skip_first_id_check);
  682. //$topmost_article_ids = $ret[0];
  683. $headlines_count = $ret[1];
  684. /* $returned_feed = $ret[2]; */
  685. $disable_cache = $ret[3];
  686. $vgroup_last_feed = $ret[4];
  687. //$reply['headlines']['content'] =& $ret[5]['content'];
  688. //$reply['headlines']['toolbar'] =& $ret[5]['toolbar'];
  689. $reply['headlines'] = $ret[5];
  690. if (!$next_unread_feed)
  691. $reply['headlines']['id'] = $feed;
  692. else
  693. $reply['headlines']['id'] = $next_unread_feed;
  694. $reply['headlines']['is_cat'] = (bool) $cat_view;
  695. if ($_REQUEST["debug"]) $timing_info = print_checkpoint("05", $timing_info);
  696. $reply['headlines-info'] = array("count" => (int) $headlines_count,
  697. "vgroup_last_feed" => $vgroup_last_feed,
  698. "disable_cache" => (bool) $disable_cache);
  699. if ($_REQUEST["debug"]) $timing_info = print_checkpoint("30", $timing_info);
  700. $reply['runtime-info'] = make_runtime_info();
  701. print json_encode($reply);
  702. }
  703. private function generate_dashboard_feed() {
  704. $reply = array();
  705. $reply['headlines']['id'] = -5;
  706. $reply['headlines']['is_cat'] = false;
  707. $reply['headlines']['toolbar'] = '';
  708. $reply['headlines']['content'] = "<div class='whiteBox'>".__('No feed selected.');
  709. $reply['headlines']['content'] .= "<p><span class=\"insensitive\">";
  710. $result = $this->dbh->query("SELECT ".SUBSTRING_FOR_DATE."(MAX(last_updated), 1, 19) AS last_updated FROM ttrss_feeds
  711. WHERE owner_uid = " . $_SESSION['uid']);
  712. $last_updated = $this->dbh->fetch_result($result, 0, "last_updated");
  713. $last_updated = make_local_datetime($last_updated, false);
  714. $reply['headlines']['content'] .= sprintf(__("Feeds last updated at %s"), $last_updated);
  715. $result = $this->dbh->query("SELECT COUNT(id) AS num_errors
  716. FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]);
  717. $num_errors = $this->dbh->fetch_result($result, 0, "num_errors");
  718. if ($num_errors > 0) {
  719. $reply['headlines']['content'] .= "<br/>";
  720. $reply['headlines']['content'] .= "<a class=\"insensitive\" href=\"#\" onclick=\"showFeedsWithErrors()\">".
  721. __('Some feeds have update errors (click for details)')."</a>";
  722. }
  723. $reply['headlines']['content'] .= "</span></p>";
  724. $reply['headlines-info'] = array("count" => 0,
  725. "vgroup_last_feed" => '',
  726. "unread" => 0,
  727. "disable_cache" => true);
  728. return $reply;
  729. }
  730. private function generate_error_feed($error) {
  731. $reply = array();
  732. $reply['headlines']['id'] = -7;
  733. $reply['headlines']['is_cat'] = false;
  734. $reply['headlines']['toolbar'] = '';
  735. $reply['headlines']['content'] = "<div class='whiteBox'>". $error . "</div>";
  736. $reply['headlines-info'] = array("count" => 0,
  737. "vgroup_last_feed" => '',
  738. "unread" => 0,
  739. "disable_cache" => true);
  740. return $reply;
  741. }
  742. function quickAddFeed() {
  743. print_hidden("op", "rpc");
  744. print_hidden("method", "addfeed");
  745. print "<div id='fadd_error_message' style='display : none' class='alert alert-danger'></div>";
  746. print "<div id='fadd_multiple_notify' style='display : none'>";
  747. print_notice("Provided URL is a HTML page referencing multiple feeds, please select required feed from the dropdown menu below.");
  748. print "<p></div>";
  749. print "<div class=\"dlgSec\">".__("Feed or site URL")."</div>";
  750. print "<div class=\"dlgSecCont\">";
  751. print "<div style='float : right'>
  752. <img style='display : none'
  753. id='feed_add_spinner' src='images/indicator_white.gif'></div>";
  754. print "<input style=\"font-size : 16px; width : 20em;\"
  755. placeHolder=\"".__("Feed or site URL")."\"
  756. dojoType=\"dijit.form.ValidationTextBox\" required=\"1\" name=\"feed\" id=\"feedDlg_feedUrl\">";
  757. print "<hr/>";
  758. if (get_pref('ENABLE_FEED_CATS')) {
  759. print __('Place in category:') . " ";
  760. print_feed_cat_select("cat", false, 'dojoType="dijit.form.Select"');
  761. }
  762. print "</div>";
  763. print '<div id="feedDlg_feedsContainer" style="display : none">
  764. <div class="dlgSec">' . __('Available feeds') . '</div>
  765. <div class="dlgSecCont">'.
  766. '<select id="feedDlg_feedContainerSelect"
  767. dojoType="dijit.form.Select" size="3">
  768. <script type="dojo/method" event="onChange" args="value">
  769. dijit.byId("feedDlg_feedUrl").attr("value", value);
  770. </script>
  771. </select>'.
  772. '</div></div>';
  773. print "<div id='feedDlg_loginContainer' style='display : none'>
  774. <div class=\"dlgSec\">".__("Authentication")."</div>
  775. <div class=\"dlgSecCont\">".
  776. " <input dojoType=\"dijit.form.TextBox\" name='login'\"
  777. placeHolder=\"".__("Login")."\"
  778. autocomplete=\"new-password\"
  779. style=\"width : 10em;\"> ".
  780. " <input
  781. placeHolder=\"".__("Password")."\"
  782. dojoType=\"dijit.form.TextBox\" type='password'
  783. autocomplete=\"new-password\"
  784. style=\"width : 10em;\" name='pass'\">
  785. </div></div>";
  786. print "<div style=\"clear : both\">
  787. <input type=\"checkbox\" name=\"need_auth\" dojoType=\"dijit.form.CheckBox\" id=\"feedDlg_loginCheck\"
  788. onclick='checkboxToggleElement(this, \"feedDlg_loginContainer\")'>
  789. <label for=\"feedDlg_loginCheck\">".
  790. __('This feed requires authentication.')."</div>";
  791. print "</form>";
  792. print "<div class=\"dlgButtons\">
  793. <button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('feedAddDlg').execute()\">".__('Subscribe')."</button>";
  794. if (!(defined('_DISABLE_FEED_BROWSER') && _DISABLE_FEED_BROWSER)) {
  795. print "<button dojoType=\"dijit.form.Button\" onclick=\"return feedBrowser()\">".__('More feeds')."</button>";
  796. }
  797. print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('feedAddDlg').hide()\">".__('Cancel')."</button>
  798. </div>";
  799. //return;
  800. }
  801. function feedBrowser() {
  802. if (defined('_DISABLE_FEED_BROWSER') && _DISABLE_FEED_BROWSER) return;
  803. $browser_search = $this->dbh->escape_string($_REQUEST["search"]);
  804. print_hidden("op", "rpc");
  805. print_hidden("method", "updateFeedBrowser");
  806. print "<div dojoType=\"dijit.Toolbar\">
  807. <div style='float : right'>
  808. <img style='display : none'
  809. id='feed_browser_spinner' src='images/indicator_white.gif'>
  810. <input name=\"search\" dojoType=\"dijit.form.TextBox\" size=\"20\" type=\"search\"
  811. onchange=\"dijit.byId('feedBrowserDlg').update()\" value=\"$browser_search\">
  812. <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('feedBrowserDlg').update()\">".__('Search')."</button>
  813. </div>";
  814. print " <select name=\"mode\" dojoType=\"dijit.form.Select\" onchange=\"dijit.byId('feedBrowserDlg').update()\">
  815. <option value='1'>" . __('Popular feeds') . "</option>
  816. <option value='2'>" . __('Feed archive') . "</option>
  817. </select> ";
  818. print __("limit:");
  819. print " <select dojoType=\"dijit.form.Select\" name=\"limit\" onchange=\"dijit.byId('feedBrowserDlg').update()\">";
  820. foreach (array(25, 50, 100, 200) as $l) {
  821. //$issel = ($l == $limit) ? "selected=\"1\"" : "";
  822. print "<option value=\"$l\">$l</option>";
  823. }
  824. print "</select> ";
  825. print "</div>";
  826. require_once "feedbrowser.php";
  827. print "<ul class='browseFeedList' id='browseFeedList'>";
  828. print make_feed_browser("", 25);
  829. print "</ul>";
  830. print "<div align='center'>
  831. <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('feedBrowserDlg').execute()\">".__('Subscribe')."</button>
  832. <button dojoType=\"dijit.form.Button\" style='display : none' id='feed_archive_remove' onclick=\"dijit.byId('feedBrowserDlg').removeFromArchive()\">".__('Remove')."</button>
  833. <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('feedBrowserDlg').hide()\" >".__('Cancel')."</button></div>";
  834. }
  835. function search() {
  836. $this->params = explode(":", $this->dbh->escape_string($_REQUEST["param"]), 2);
  837. $active_feed_id = sprintf("%d", $this->params[0]);
  838. $is_cat = $this->params[1] != "false";
  839. print "<div class=\"dlgSec\">".__('Look for')."</div>";
  840. print "<div class=\"dlgSecCont\">";
  841. print "<input dojoType=\"dijit.form.ValidationTextBox\"
  842. style=\"font-size : 16px; width : 20em;\"
  843. required=\"1\" name=\"query\" type=\"search\" value=''>";
  844. print "<hr/><span style='float : right'>".T_sprintf('in %s', getFeedTitle($active_feed_id, $is_cat))."</span>";
  845. if (DB_TYPE == "pgsql") {
  846. print "<hr/>";
  847. print_select("search_language", "", Pref_Feeds::$feed_languages,
  848. "dojoType='dijit.form.Select' title=\"".__('Used for word stemming')."\"");
  849. }
  850. print "</div>";
  851. print "<div class=\"dlgButtons\">";
  852. if (count(PluginHost::getInstance()->get_hooks(PluginHost::HOOK_SEARCH)) == 0) {
  853. print "<div style=\"float : left\">
  854. <a class=\"visibleLink\" target=\"_blank\" href=\"http://tt-rss.org/wiki/SearchSyntax\">".__("Search syntax")."</a>
  855. </div>";
  856. }
  857. print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('searchDlg').execute()\">".__('Search')."</button>
  858. <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('searchDlg').hide()\">".__('Cancel')."</button>
  859. </div>";
  860. }
  861. function update_debugger() {
  862. header("Content-type: text/html");
  863. $feed_id = (int)$_REQUEST["feed_id"];
  864. @$do_update = $_REQUEST["action"] == "do_update";
  865. $csrf_token = $_REQUEST["csrf_token"];
  866. $refetch_checked = isset($_REQUEST["force_refetch"]) ? "checked" : "";
  867. $rehash_checked = isset($_REQUEST["force_rehash"]) ? "checked" : "";
  868. ?>
  869. <html>
  870. <head>
  871. <link rel="stylesheet" type="text/css" href="css/utility.css">
  872. <title>Feed Debugger</title>
  873. </head>
  874. <body class="small_margins">
  875. <h1>Feed Debugger: <?php echo "$feed_id: " . getFeedTitle($feed_id) ?></h1>
  876. <form method="GET" action="">
  877. <input type="hidden" name="op" value="feeds">
  878. <input type="hidden" name="method" value="update_debugger">
  879. <input type="hidden" name="xdebug" value="1">
  880. <input type="hidden" name="csrf_token" value="<?php echo $csrf_token ?>">
  881. <input type="hidden" name="action" value="do_update">
  882. <input type="hidden" name="feed_id" value="<?php echo $feed_id ?>">
  883. <input type="checkbox" name="force_refetch" value="1" <?php echo $refetch_checked ?>> Force refetch<br/>
  884. <input type="checkbox" name="force_rehash" value="1" <?php echo $rehash_checked ?>> Force rehash<br/>
  885. <p/><button type="submit">Continue</button>
  886. </form>
  887. <hr>
  888. <pre><?php
  889. if ($do_update) {
  890. include "rssfuncs.php";
  891. update_rss_feed($feed_id, true, true);
  892. }
  893. ?></pre>
  894. </body>
  895. </html>
  896. <?php
  897. }
  898. }
  899. ?>