2 require_once "colors.php";
4 class Feeds
extends Handler_Protected
{
8 function csrf_ignore($method) {
9 $csrf_ignored = array("index", "feedbrowser", "quickaddfeed", "search");
11 return array_search($method, $csrf_ignored) !== false;
14 private function format_headline_subtoolbar($feed_site_url, $feed_title,
15 $feed_id, $is_cat, $search,
16 $error, $feed_last_updated) {
18 $catchup_sel_link = "catchupSelection()";
20 $archive_sel_link = "archiveSelection()";
21 $delete_sel_link = "deleteSelection()";
23 $sel_all_link = "selectArticles('all')";
24 $sel_unread_link = "selectArticles('unread')";
25 $sel_none_link = "selectArticles('none')";
26 $sel_inv_link = "selectArticles('invert')";
28 $tog_unread_link = "selectionToggleUnread()";
29 $tog_marked_link = "selectionToggleMarked()";
30 $tog_published_link = "selectionTogglePublished()";
32 $set_score_link = "setSelectionScore()";
34 if ($is_cat) $cat_q = "&is_cat=$is_cat";
37 $search_q = "&q=$search";
42 $reply = "<span class=\"holder\">";
44 $rss_link = htmlspecialchars(get_self_url_prefix() .
45 "/public.php?op=rss&id=$feed_id$cat_q$search_q");
49 $error_class = $error ?
"error" : "";
51 $reply .= "<span class='r'>
53 title=\"".__("View as RSS feed")."\"
54 onclick=\"displayDlg('".__("View as RSS")."','generatedFeed', '$feed_id:$is_cat:$rss_link')\">
55 <img class=\"noborder\" src=\"images/pub_set.png\"></a>";
59 $reply .= "<span id='feed_title' class='$error_class'>";
62 $last_updated = T_sprintf("Last updated: %s",
65 $target = "target=\"_blank\"";
66 $reply .= "<a title=\"$last_updated\" $target href=\"$feed_site_url\">".
67 truncate_string(strip_tags($feed_title), 30)."</a>";
70 $error = htmlspecialchars($error);
71 $reply .= " <img title=\"$error\" src='images/error.png' alt='error' class=\"noborder\">";
75 $reply .= strip_tags($feed_title);
82 # $reply .= "</span>";
86 $reply .= "<span class=\"main\">";
87 $reply .= "<span id='selected_prompt'></span>";
89 /*$reply .= "<span class=\"sel_links\">
90 <a href=\"#\" onclick=\"$sel_all_link\">".__('All')."</a>,
91 <a href=\"#\" onclick=\"$sel_unread_link\">".__('Unread')."</a>,
92 <a href=\"#\" onclick=\"$sel_inv_link\">".__('Invert')."</a>,
93 <a href=\"#\" onclick=\"$sel_none_link\">".__('None')."</a></li>";
95 $reply .= "</span> "; */
97 $reply .= "<select dojoType=\"dijit.form.Select\"
98 onchange=\"headlineActionsChange(this)\">";
100 $reply .= "<option value=\"0\" disabled='1'>".__('Select...')."</option>";
102 $reply .= "<option value=\"$sel_all_link\">".__('All')."</option>";
103 $reply .= "<option value=\"$sel_unread_link\">".__('Unread')."</option>";
104 $reply .= "<option value=\"$sel_inv_link\">".__('Invert')."</option>";
105 $reply .= "<option value=\"$sel_none_link\">".__('None')."</option>";
107 $reply .= "<option value=\"0\" disabled=\"1\">".__('Selection toggle:')."</option>";
109 $reply .= "<option value=\"$tog_unread_link\">".__('Unread')."</option>
110 <option value=\"$tog_marked_link\">".__('Starred')."</option>
111 <option value=\"$tog_published_link\">".__('Published')."</option>";
113 $reply .= "<option value=\"0\" disabled=\"1\">".__('Selection:')."</option>";
115 $reply .= "<option value=\"$catchup_sel_link\">".__('Mark as read')."</option>";
116 $reply .= "<option value=\"$set_score_link\">".__('Set score')."</option>";
118 if ($feed_id != "0") {
119 $reply .= "<option value=\"$archive_sel_link\">".__('Archive')."</option>";
121 $reply .= "<option value=\"$archive_sel_link\">".__('Move back')."</option>";
122 $reply .= "<option value=\"$delete_sel_link\">".__('Delete')."</option>";
126 if (PluginHost
::getInstance()->get_plugin("mail")) {
127 $reply .= "<option value=\"emailArticle(false)\">".__('Forward by email').
131 if (PluginHost
::getInstance()->get_plugin("mailto")) {
132 $reply .= "<option value=\"mailtoArticle(false)\">".__('Forward by email').
136 $reply .= "<option value=\"0\" disabled=\"1\">".__('Feed:')."</option>";
138 //$reply .= "<option value=\"catchupPage()\">".__('Mark as read')."</option>";
140 $reply .= "<option value=\"displayDlg('".__("View as RSS")."','generatedFeed', '$feed_id:$is_cat:$rss_link')\">".__('View as RSS')."</option>";
142 $reply .= "</select>";
146 foreach (PluginHost
::getInstance()->get_hooks(PluginHost
::HOOK_HEADLINE_TOOLBAR_BUTTON
) as $p) {
147 $reply .= $p->hook_headline_toolbar_button($feed_id, $is_cat);
150 $reply .= "</span></span>";
155 private function format_headlines_list($feed, $method, $view_mode, $limit, $cat_view,
156 $offset, $vgr_last_feed = false,
157 $override_order = false, $include_children = false, $check_first_id = false,
158 $skip_first_id_check = false) {
160 $disable_cache = false;
164 $rgba_cache = array();
166 $timing_info = microtime(true);
168 $topmost_article_ids = array();
170 if (!$offset) $offset = 0;
171 if ($method == "undefined") $method = "";
173 $method_split = explode(":", $method);
175 if ($method == "ForceUpdate" && $feed > 0 && is_numeric($feed)) {
176 // Update the feed if required with some basic flood control
178 $any_needs_curl = false;
180 if (ini_get("open_basedir")) {
181 $pluginhost = PluginHost
::getInstance();
182 foreach ($pluginhost->get_plugins() as $plugin) {
183 $flags = $plugin->flags();
185 if (isset($flags["needs_curl"]) && $flags["needs_curl"]) {
186 $any_needs_curl = true;
192 //if ($_REQUEST["debug"]) print "<!-- any_needs_curl: $any_needs_curl -->";
194 if (!$any_needs_curl) {
196 $sth = $this->pdo
->prepare("SELECT cache_images," . SUBSTRING_FOR_DATE
. "(last_updated,1,19) AS last_updated
197 FROM ttrss_feeds WHERE id = ?");
198 $sth->execute([$feed]);
200 if ($row = $sth->fetch()) {
201 $last_updated = strtotime($row["last_updated"]);
202 $cache_images = $row["cache_images"];
204 if (!$cache_images && time() - $last_updated > 120) {
205 RSSUtils
::update_rss_feed($feed, true);
207 $sth = $this->pdo
->prepare("UPDATE ttrss_feeds
208 SET last_updated = '1970-01-01', last_update_started = '1970-01-01'
210 $sth->execute([$feed]);
214 $sth = $this->pdo
->prepare("UPDATE ttrss_feeds
215 SET last_updated = '1970-01-01', last_update_started = '1970-01-01'
217 $sth->execute([$feed]);
221 if ($method_split[0] == "MarkAllReadGR") {
222 $this->catchup_feed($method_split[1], false);
225 // FIXME: might break tag display?
227 if (is_numeric($feed) && $feed > 0 && !$cat_view) {
228 $sth = $this->pdo
->prepare("SELECT id FROM ttrss_feeds WHERE id = ? LIMIT 1");
229 $sth->execute([$feed]);
231 if (!$sth->fetch()) {
232 $reply['content'] = "<div align='center'>".__('Feed not found.')."</div>";
236 @$search = $_REQUEST["query"];
237 @$search_language = $_REQUEST["search_language"]; // PGSQL only
240 $disable_cache = true;
243 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("H0", $timing_info);
245 if (!$cat_view && is_numeric($feed) && $feed < PLUGIN_FEED_BASE_INDEX
&& $feed > LABEL_BASE_INDEX
) {
246 $handler = PluginHost
::getInstance()->get_feed_handler(
247 PluginHost
::feed_to_pfeed_id($feed));
252 "view_mode" => $view_mode,
253 "cat_view" => $cat_view,
255 "override_order" => $override_order,
257 "owner_uid" => $_SESSION["uid"],
260 "include_children" => $include_children);
262 $qfh_ret = $handler->get_headlines(PluginHost
::feed_to_pfeed_id($feed),
271 "view_mode" => $view_mode,
272 "cat_view" => $cat_view,
274 "search_language" => $search_language,
275 "override_order" => $override_order,
277 "include_children" => $include_children,
278 "check_first_id" => $check_first_id,
279 "skip_first_id_check" => $skip_first_id_check
282 $qfh_ret = $this->queryFeedHeadlines($params);
285 $vfeed_group_enabled = get_pref("VFEED_GROUP_BY_FEED") && $feed != -6;
287 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("H1", $timing_info);
289 $result = $qfh_ret[0]; // this could be either a PDO query result or a -1 if first id changed
290 $feed_title = $qfh_ret[1];
291 $feed_site_url = $qfh_ret[2];
292 $last_error = $qfh_ret[3];
293 $last_updated = strpos($qfh_ret[4], '1970-') === FALSE ?
294 make_local_datetime($qfh_ret[4], false) : __("Never");
295 $highlight_words = $qfh_ret[5];
296 $reply['first_id'] = $qfh_ret[6];
297 $reply['search_query'] = [$search, $search_language];
299 $vgroup_last_feed = $vgr_last_feed;
301 $reply['toolbar'] = $this->format_headline_subtoolbar($feed_site_url,
303 $feed, $cat_view, $search,
304 $last_error, $last_updated);
307 foreach (PluginHost
::getInstance()->get_hooks(PluginHost
::HOOK_HEADLINES_BEFORE
) as $p) {
308 $reply['content'] .= $p->hook_headlines_before($feed, $cat_view, $qfh_ret);
312 $reply['content'] = '';
314 $headlines_count = 0;
318 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("PS", $timing_info);
319 $expand_cdm = get_pref('CDM_EXPANDED');
321 if (is_object($result)) {
323 while ($line = $result->fetch()) {
327 $line["content_preview"] = "— " . truncate_string(strip_tags($line["content"]), 250);
329 foreach (PluginHost
::getInstance()->get_hooks(PluginHost
::HOOK_QUERY_HEADLINES
) as $p) {
330 $line = $p->hook_query_headlines($line, 250, false);
333 if (get_pref('SHOW_CONTENT_PREVIEW')) {
334 $content_preview = $line["content_preview"];
338 $feed_id = $line["feed_id"];
339 $label_cache = $line["label_cache"];
342 $mouseover_attrs = "onmouseover='postMouseIn(event, $id)' onmouseout='postMouseOut($id)'";
345 $label_cache = json_decode($label_cache, true);
348 if ($label_cache["no-labels"] == 1)
351 $labels = $label_cache;
355 if (!is_array($labels)) $labels = Article
::get_article_labels($id);
357 $labels_str = "<span class=\"HLLCTR-$id\">";
358 $labels_str .= Article
::format_article_labels($labels);
359 $labels_str .= "</span>";
361 if (count($topmost_article_ids) < 3) {
362 array_push($topmost_article_ids, $id);
367 if ($line["unread"]) {
372 $marked_pic_src = $line["marked"] ?
"mark_set.png" : "mark_unset.png";
373 $class .= $line["marked"] ?
" marked" : "";
374 $marked_pic = "<img src=\"images/$marked_pic_src\" class=\"markedPic\" onclick='toggleMark($id)'>";
376 $published_pic_src = $line["published"] ?
"pub_set.png" : "pub_unset.png";
377 $class .= $line["published"] ?
" published" : "";
378 $published_pic = "<img src=\"images/$published_pic_src\" class=\"pubPic\" onclick='togglePub($id)'>";
380 $updated_fmt = make_local_datetime($line["updated"], false, false, false, true);
381 $date_entered_fmt = T_sprintf("Imported at %s",
382 make_local_datetime($line["date_entered"], false));
384 $score = $line["score"];
386 $score_pic = "images/" . get_score_pic($score);
388 $score_pic = "<img class='hlScorePic' score='$score' onclick='changeScore($id, this)' src=\"$score_pic\"
392 $hlc_suffix = "high";
393 } else if ($score < -100) {
399 $entry_author = $line["author"];
402 $entry_author = " — $entry_author";
405 $has_feed_icon = feeds
::feedHasIcon($feed_id);
407 if ($has_feed_icon) {
408 $feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"".ICONS_URL
."/$feed_id.ico\" alt=\"\">";
410 $feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"images/pub_set.png\" alt=\"\">";
413 $entry_site_url = $line["site_url"];
415 //setting feed headline background color, needs to change text color based on dark/light
416 $fav_color = $line['favicon_avg_color'];
418 require_once "colors.php";
420 if ($fav_color && $fav_color != 'fail') {
421 if (!isset($rgba_cache[$feed_id])) {
422 $rgba_cache[$feed_id] = join(",", _color_unpack($fav_color));
426 if (!get_pref('COMBINED_DISPLAY_MODE')) {
428 if ($vfeed_group_enabled) {
429 if ($feed_id != $vgroup_last_feed && $line["feed_title"]) {
431 $vgroup_last_feed = $feed_id;
433 $vf_catchup_link = "<a class='catchup' onclick='catchupFeedInGroup($feed_id);' href='#'>".__('mark feed as read')."</a>";
435 $reply['content'] .= "<div data-feed-id='$feed_id' id='FTITLE-$feed_id' class='cdmFeedTitle'>".
436 "<div style='float : right'>$feed_icon_img</div>".
437 "<a class='title' href=\"#\" onclick=\"viewfeed({feed:$feed_id})\">".
438 $line["feed_title"]."</a>
439 $vf_catchup_link</div>";
445 $reply['content'] .= "<div class='hl hlMenuAttach $class' data-orig-feed-id='$feed_id' data-article-id='$id' id='RROW-$id' $mouseover_attrs>";
447 $reply['content'] .= "<div class='hlLeft'>";
449 $reply['content'] .= "<input dojoType=\"dijit.form.CheckBox\"
450 type=\"checkbox\" onclick=\"toggleSelectRow2(this)\"
453 $reply['content'] .= "$marked_pic";
454 $reply['content'] .= "$published_pic";
456 $reply['content'] .= "</div>";
458 $reply['content'] .= "<div onclick='return hlClicked(event, $id)'
459 class=\"hlTitle\"><span class='hlContent $hlc_suffix'>";
460 $reply['content'] .= "<a id=\"RTITLE-$id\" class=\"title $hlc_suffix\"
461 href=\"" . htmlspecialchars($line["link"]) . "\"
463 truncate_string($line["title"], 200);
465 if (get_pref('SHOW_CONTENT_PREVIEW')) {
466 $reply['content'] .= "<span class=\"contentPreview\">" . $line["content_preview"] . "</span>";
469 $reply['content'] .= "</a></span>";
471 $reply['content'] .= $labels_str;
473 $reply['content'] .= "</div>";
475 if (!$vfeed_group_enabled) {
476 if (@$line["feed_title"]) {
477 $rgba = @$rgba_cache[$feed_id];
479 $reply['content'] .= "<span class=\"hlFeed\"><a style=\"background : rgba($rgba, 0.3)\" href=\"#\" onclick=\"viewfeed({feed:$feed_id})\">".
480 truncate_string($line["feed_title"],30)."</a></span>";
485 $reply['content'] .= "<span class=\"hlUpdated\">";
487 $reply['content'] .= "<div title='$date_entered_fmt'>$updated_fmt</div>
490 $reply['content'] .= "<div class=\"hlRight\">";
492 $reply['content'] .= $score_pic;
494 if ($line["feed_title"] && !$vfeed_group_enabled) {
496 $reply['content'] .= "<span onclick=\"viewfeed({feed:$feed_id})\"
497 style=\"cursor : pointer\"
498 title=\"".htmlspecialchars($line['feed_title'])."\">
499 $feed_icon_img</span>";
502 $reply['content'] .= "</div>";
503 $reply['content'] .= "</div>";
507 if ($line["tag_cache"])
508 $tags = explode(",", $line["tag_cache"]);
512 $line["content"] = sanitize($line["content"],
513 $line['hide_images'], false, $entry_site_url, $highlight_words, $line["id"]);
515 foreach (PluginHost
::getInstance()->get_hooks(PluginHost
::HOOK_RENDER_ARTICLE_CDM
) as $p) {
516 $line = $p->hook_render_article_cdm($line);
519 if ($vfeed_group_enabled && $line["feed_title"]) {
520 if ($feed_id != $vgroup_last_feed) {
522 $vgroup_last_feed = $feed_id;
524 $vf_catchup_link = "<a class='catchup' onclick='catchupFeedInGroup($feed_id);' href='#'>".__('mark feed as read')."</a>";
526 $feed_icon_src = Feeds
::getFeedIcon($feed_id);
527 $feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"$feed_icon_src\">";
529 $reply['content'] .= "<div data-feed-id='$feed_id' id='FTITLE-$feed_id' class='cdmFeedTitle'>".
530 "<div style=\"float : right\">$feed_icon_img</div>".
531 "<a href=\"#\" class='title' onclick=\"viewfeed({feed:$feed_id})\">".
532 $line["feed_title"]."</a> $vf_catchup_link</div>";
537 $expanded_class = $expand_cdm ?
"expanded" : "expandable";
539 $tmp_content = "<div class=\"cdm $hlc_suffix $expanded_class $class\"
540 id=\"RROW-$id\" data-article-id='$id' data-orig-feed-id='$feed_id' $mouseover_attrs>";
542 $tmp_content .= "<div class=\"cdmHeader\">";
543 $tmp_content .= "<div style=\"vertical-align : middle\">";
545 $tmp_content .= "<input dojoType=\"dijit.form.CheckBox\"
546 type=\"checkbox\" onclick=\"toggleSelectRow2(this, false, true)\"
549 $tmp_content .= "$marked_pic";
550 $tmp_content .= "$published_pic";
552 $tmp_content .= "</div>";
554 if ($highlight_words && count($highlight_words) > 0) {
555 foreach ($highlight_words as $word) {
556 $line["title"] = preg_replace("/(\Q$word\E)/i",
557 "<span class=\"highlight\">$1</span>", $line["title"]);
561 // data-article-id included for context menu
562 $tmp_content .= "<span id=\"RTITLE-$id\"
563 onclick=\"return cdmClicked(event, $id);\"
564 data-article-id=\"$id\"
565 class=\"titleWrap hlMenuAttach $hlc_suffix\">
566 <a class=\"title $hlc_suffix\"
567 title=\"".htmlspecialchars($line["title"])."\"
568 target=\"_blank\" rel=\"noopener noreferrer\" href=\"".
569 htmlspecialchars($line["link"])."\">".
571 "</a> <span class=\"author\">$entry_author</span>";
573 $tmp_content .= $labels_str;
575 $tmp_content .= "<span class='collapseBtn' style='display : none'>
576 <img src=\"images/collapse.png\" onclick=\"cdmCollapseArticle(event, $id)\"
577 title=\"".__("Collapse article")."\"/></span>";
580 $content_hidden = "style=\"display : none\"";
582 $excerpt_hidden = "style=\"display : none\"";
584 $tmp_content .= "<span $excerpt_hidden id=\"CEXC-$id\" class=\"cdmExcerpt\">" . $content_preview . "</span>";
586 $tmp_content .= "</span>";
588 if (!$vfeed_group_enabled) {
589 if (@$line["feed_title"]) {
590 $rgba = @$rgba_cache[$feed_id];
592 $tmp_content .= "<div class=\"hlFeed\">
593 <a href=\"#\" style=\"background-color: rgba($rgba,0.3)\"
594 onclick=\"viewfeed({feed:$feed_id})\">".
595 truncate_string($line["feed_title"],30)."</a>
600 $tmp_content .= "<span class='updated' title='$date_entered_fmt'>$updated_fmt</span>";
602 $tmp_content .= "<div class='scoreWrap' style=\"vertical-align : middle\">";
603 $tmp_content .= "$score_pic";
605 if (!get_pref("VFEED_GROUP_BY_FEED") && $line["feed_title"]) {
606 $tmp_content .= "<span style=\"cursor : pointer\"
607 title=\"".htmlspecialchars($line["feed_title"])."\"
608 onclick=\"viewfeed({feed:$feed_id})\">$feed_icon_img</span>";
610 $tmp_content .= "</div>"; //scoreWrap
612 $tmp_content .= "</div>"; //cdmHeader
614 $tmp_content .= "<div class=\"cdmContent\" $content_hidden
615 onclick=\"return cdmClicked(event, $id, true);\"
618 $tmp_content .= "<div id=\"POSTNOTE-$id\">";
620 $tmp_content .= Article
::format_article_note($id, $line['note']);
622 $tmp_content .= "</div>"; //POSTNOTE
624 if (!$line['lang']) $line['lang'] = 'en';
626 $tmp_content .= "<div class=\"cdmContentInner\" lang=\"".$line['lang']."\">";
628 if ($line["orig_feed_id"]) {
630 $ofgh = $this->pdo
->prepare("SELECT * FROM ttrss_archived_feeds
631 WHERE id = ? AND owner_uid = ?");
632 $ofgh->execute([$line["orig_feed_id"], $_SESSION['uid']]);
634 if ($tmp_line = $ofgh->fetch()) {
636 $tmp_content .= "<div clear='both'>";
637 $tmp_content .= __("Originally from:");
639 $tmp_content .= " ";
641 $tmp_content .= "<a target='_blank' rel='noopener noreferrer'
642 href=' " . htmlspecialchars($tmp_line['site_url']) . "'>" .
643 $tmp_line['title'] . "</a>";
645 $tmp_content .= " ";
647 $tmp_content .= "<a target='_blank' rel='noopener noreferrer' href='" . htmlspecialchars($tmp_line['feed_url']) . "'>";
648 $tmp_content .= "<img title='".__('Feed URL')."'class='tinyFeedIcon' src='images/pub_unset.png'></a>";
650 $tmp_content .= "</div>";
654 $tmp_content .= "<span id=\"CWRAP-$id\">";
655 $tmp_content .= "<span id=\"CENCW-$id\" class=\"cencw\" style=\"display : none\">";
656 $tmp_content .= htmlspecialchars($line["content"]);
657 $tmp_content .= "</span>";
658 $tmp_content .= "</span>";
660 $tmp_content .= "</div>"; //cdmContentInner
662 $tmp_content .= "<div class=\"cdmIntermediate\">";
664 $always_display_enclosures = $line["always_display_enclosures"];
665 $tmp_content .= Article
::format_article_enclosures($id, $always_display_enclosures,
666 $line["content"], $line["hide_images"]);
668 $tmp_content .= "</div>"; // cdmIntermediate
670 $tmp_content .= "<div class=\"cdmFooter\" onclick=\"cdmFooterClick(event)\">";
672 foreach (PluginHost
::getInstance()->get_hooks(PluginHost
::HOOK_ARTICLE_LEFT_BUTTON
) as $p) {
673 $tmp_content .= $p->hook_article_left_button($line);
676 $tags_str = Article
::format_tags_string($tags, $id);
678 $tmp_content .= "<span class='left'>";
680 $tmp_content .= "<img src='images/tag.png' alt='Tags' title='Tags'>
681 <span id=\"ATSTR-$id\">$tags_str</span>
682 <a title=\"".__('Edit tags for this article')."\"
683 href=\"#\" onclick=\"editArticleTags($id)\">(+)</a>";
685 $num_comments = (int) $line["num_comments"];
686 $entry_comments = "";
688 if ($num_comments > 0) {
689 if ($line["comments"]) {
690 $comments_url = htmlspecialchars($line["comments"]);
692 $comments_url = htmlspecialchars($line["link"]);
694 $entry_comments = "<a class=\"postComments\"
695 target='_blank' rel='noopener noreferrer' href=\"$comments_url\">$num_comments ".
696 _ngettext("comment", "comments", $num_comments)."</a>";
699 if ($line["comments"] && $line["link"] != $line["comments"]) {
700 $entry_comments = "<a class=\"postComments\" target='_blank' rel='noopener noreferrer' href=\"".htmlspecialchars($line["comments"])."\">".__("comments")."</a>";
704 if ($entry_comments) $tmp_content .= " ($entry_comments)";
706 $tmp_content .= "</span>";
707 $tmp_content .= "<div>";
709 foreach (PluginHost
::getInstance()->get_hooks(PluginHost
::HOOK_ARTICLE_BUTTON
) as $p) {
710 $tmp_content .= $p->hook_article_button($line);
713 $tmp_content .= "</div>"; // buttons
715 $tmp_content .= "</div>"; // cdmFooter
716 $tmp_content .= "</div>"; // cdmContent
717 $tmp_content .= "</div>"; // RROW.cdm
719 foreach (PluginHost
::getInstance()->get_hooks(PluginHost
::HOOK_FORMAT_ARTICLE_CDM
) as $p) {
720 $tmp_content = $p->hook_format_article_cdm($tmp_content, $line);
723 $reply['content'] .= $tmp_content;
730 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("PE", $timing_info);
732 if (!$headlines_count) {
734 if (!is_numeric($result)) {
736 switch ($view_mode) {
738 $message = __("No unread articles found to display.");
741 $message = __("No updated articles found to display.");
744 $message = __("No starred articles found to display.");
747 if ($feed < LABEL_BASE_INDEX
) {
748 $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.");
750 $message = __("No articles found to display.");
754 if (!$offset && $message) {
755 $reply['content'] = "<div class='whiteBox'>$message";
757 $reply['content'] .= "<p><span class=\"insensitive\">";
759 $sth = $this->pdo
->prepare("SELECT " . SUBSTRING_FOR_DATE
. "(MAX(last_updated), 1, 19) AS last_updated FROM ttrss_feeds
760 WHERE owner_uid = ?");
761 $sth->execute([$_SESSION['uid']]);
762 $row = $sth->fetch();
764 $last_updated = make_local_datetime($row["last_updated"], false);
766 $reply['content'] .= sprintf(__("Feeds last updated at %s"), $last_updated);
768 $sth = $this->pdo
->prepare("SELECT COUNT(id) AS num_errors
769 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ?");
770 $sth->execute([$_SESSION['uid']]);
771 $row = $sth->fetch();
773 $num_errors = $row["num_errors"];
775 if ($num_errors > 0) {
776 $reply['content'] .= "<br/>";
777 $reply['content'] .= "<a class=\"insensitive\" href=\"#\" onclick=\"showFeedsWithErrors()\">" .
778 __('Some feeds have update errors (click for details)') . "</a>";
780 $reply['content'] .= "</span></p></div>";
783 } else if (is_numeric($result) && $result == -1) {
784 $reply['first_id_changed'] = true;
788 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("H2", $timing_info);
790 return array($topmost_article_ids, $headlines_count, $feed, $disable_cache,
791 $vgroup_last_feed, $reply);
794 function catchupAll() {
795 $sth = $this->pdo
->prepare("UPDATE ttrss_user_entries SET
796 last_read = NOW(), unread = false WHERE unread = true AND owner_uid = ?");
797 $sth->execute([$_SESSION['uid']]);
799 CCache
::zero_all($_SESSION["uid"]);
803 $timing_info = microtime(true);
807 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("0", $timing_info);
809 $feed = $_REQUEST["feed"];
810 $method = $_REQUEST["m"];
811 $view_mode = $_REQUEST["view_mode"];
813 @$cat_view = $_REQUEST["cat"] == "true";
814 @$next_unread_feed = $_REQUEST["nuf"];
815 @$offset = $_REQUEST["skip"];
816 @$vgroup_last_feed = $_REQUEST["vgrlf"];
817 $order_by = $_REQUEST["order_by"];
818 $check_first_id = $_REQUEST["fid"];
820 if (is_numeric($feed)) $feed = (int) $feed;
822 /* Feed -5 is a special case: it is used to display auxiliary information
823 * when there's nothing to load - e.g. no stuff in fresh feed */
826 print json_encode($this->generate_dashboard_feed());
831 if ($feed < LABEL_BASE_INDEX
) {
833 $label_feed = Labels
::feed_to_label_id($feed);
835 $sth = $this->pdo
->prepare("SELECT id FROM ttrss_labels2 WHERE
836 id = ? AND owner_uid = ?");
837 $sth->execute([$label_feed, $_SESSION['uid']]);
839 } else if (!$cat_view && is_numeric($feed) && $feed > 0) {
841 $sth = $this->pdo
->prepare("SELECT id FROM ttrss_feeds WHERE
842 id = ? AND owner_uid = ?");
843 $sth->execute([$feed, $_SESSION['uid']]);
845 } else if ($cat_view && is_numeric($feed) && $feed > 0) {
847 $sth = $this->pdo
->prepare("SELECT id FROM ttrss_feed_categories WHERE
848 id = ? AND owner_uid = ?");
850 $sth->execute([$feed, $_SESSION['uid']]);
853 if ($sth && !$sth->fetch()) {
854 print json_encode($this->generate_error_feed(__("Feed not found.")));
858 /* Updating a label ccache means recalculating all of the caches
859 * so for performance reasons we don't do that here */
862 CCache
::update($feed, $_SESSION["uid"], $cat_view);
865 set_pref("_DEFAULT_VIEW_MODE", $view_mode);
866 set_pref("_DEFAULT_VIEW_ORDER_BY", $order_by);
868 /* bump login timestamp if needed */
869 if (time() - $_SESSION["last_login_update"] > 3600) {
870 $sth = $this->pdo
->prepare("UPDATE ttrss_users SET last_login = NOW() WHERE id = ?");
871 $sth->execute([$_SESSION['uid']]);
873 $_SESSION["last_login_update"] = time();
876 if (!$cat_view && is_numeric($feed) && $feed > 0) {
877 $sth = $this->pdo
->prepare("UPDATE ttrss_feeds SET last_viewed = NOW()
878 WHERE id = ? AND owner_uid = ?");
879 $sth->execute([$feed, $_SESSION['uid']]);
882 $reply['headlines'] = array();
884 $override_order = false;
885 $skip_first_id_check = false;
889 $override_order = "ttrss_entries.title, date_entered, updated";
892 $override_order = "score DESC, date_entered, updated";
893 $skip_first_id_check = true;
896 $override_order = "updated DESC";
900 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("04", $timing_info);
902 $ret = $this->format_headlines_list($feed, $method,
903 $view_mode, $limit, $cat_view, $offset,
904 $vgroup_last_feed, $override_order, true, $check_first_id, $skip_first_id_check);
906 //$topmost_article_ids = $ret[0];
907 $headlines_count = $ret[1];
908 /* $returned_feed = $ret[2]; */
909 $disable_cache = $ret[3];
910 $vgroup_last_feed = $ret[4];
912 //$reply['headlines']['content'] =& $ret[5]['content'];
913 //$reply['headlines']['toolbar'] =& $ret[5]['toolbar'];
915 $reply['headlines'] = $ret[5];
917 if (!$next_unread_feed)
918 $reply['headlines']['id'] = $feed;
920 $reply['headlines']['id'] = $next_unread_feed;
922 $reply['headlines']['is_cat'] = (bool) $cat_view;
924 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("05", $timing_info);
926 $reply['headlines-info'] = array("count" => (int) $headlines_count,
927 "vgroup_last_feed" => $vgroup_last_feed,
928 "disable_cache" => (bool) $disable_cache);
930 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("30", $timing_info);
932 $reply['runtime-info'] = make_runtime_info();
934 print json_encode($reply);
938 private function generate_dashboard_feed() {
941 $reply['headlines']['id'] = -5;
942 $reply['headlines']['is_cat'] = false;
944 $reply['headlines']['toolbar'] = '';
946 $reply['headlines']['content'] = "<div class='whiteBox'>".__('No feed selected.');
948 $reply['headlines']['content'] .= "<p><span class=\"insensitive\">";
950 $sth = $this->pdo
->prepare("SELECT ".SUBSTRING_FOR_DATE
."(MAX(last_updated), 1, 19) AS last_updated FROM ttrss_feeds
951 WHERE owner_uid = ?");
952 $sth->execute([$_SESSION['uid']]);
953 $row = $sth->fetch();
955 $last_updated = make_local_datetime($row["last_updated"], false);
957 $reply['headlines']['content'] .= sprintf(__("Feeds last updated at %s"), $last_updated);
959 $sth = $this->pdo
->prepare("SELECT COUNT(id) AS num_errors
960 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ?");
961 $sth->execute([$_SESSION['uid']]);
962 $row = $sth->fetch();
964 $num_errors = $row["num_errors"];
966 if ($num_errors > 0) {
967 $reply['headlines']['content'] .= "<br/>";
968 $reply['headlines']['content'] .= "<a class=\"insensitive\" href=\"#\" onclick=\"showFeedsWithErrors()\">".
969 __('Some feeds have update errors (click for details)')."</a>";
971 $reply['headlines']['content'] .= "</span></p>";
973 $reply['headlines-info'] = array("count" => 0,
974 "vgroup_last_feed" => '',
976 "disable_cache" => true);
981 private function generate_error_feed($error) {
984 $reply['headlines']['id'] = -7;
985 $reply['headlines']['is_cat'] = false;
987 $reply['headlines']['toolbar'] = '';
988 $reply['headlines']['content'] = "<div class='whiteBox'>". $error . "</div>";
990 $reply['headlines-info'] = array("count" => 0,
991 "vgroup_last_feed" => '',
993 "disable_cache" => true);
998 function quickAddFeed() {
999 print_hidden("op", "rpc");
1000 print_hidden("method", "addfeed");
1002 print "<div id='fadd_error_message' style='display : none' class='alert alert-danger'></div>";
1004 print "<div id='fadd_multiple_notify' style='display : none'>";
1005 print_notice("Provided URL is a HTML page referencing multiple feeds, please select required feed from the dropdown menu below.");
1008 print "<div class=\"dlgSec\">".__("Feed or site URL")."</div>";
1009 print "<div class=\"dlgSecCont\">";
1011 print "<div style='float : right'>
1012 <img style='display : none'
1013 id='feed_add_spinner' src='images/indicator_white.gif'></div>";
1015 print "<input style=\"font-size : 16px; width : 20em;\"
1016 placeHolder=\"".__("Feed or site URL")."\"
1017 dojoType=\"dijit.form.ValidationTextBox\" required=\"1\" name=\"feed\" id=\"feedDlg_feedUrl\">";
1021 if (get_pref('ENABLE_FEED_CATS')) {
1022 print __('Place in category:') . " ";
1023 print_feed_cat_select("cat", false, 'dojoType="dijit.form.Select"');
1028 print '<div id="feedDlg_feedsContainer" style="display : none">
1030 <div class="dlgSec">' . __('Available feeds') . '</div>
1031 <div class="dlgSecCont">'.
1032 '<select id="feedDlg_feedContainerSelect"
1033 dojoType="dijit.form.Select" size="3">
1034 <script type="dojo/method" event="onChange" args="value">
1035 dijit.byId("feedDlg_feedUrl").attr("value", value);
1040 print "<div id='feedDlg_loginContainer' style='display : none'>
1042 <div class=\"dlgSec\">".__("Authentication")."</div>
1043 <div class=\"dlgSecCont\">".
1045 " <input dojoType=\"dijit.form.TextBox\" name='login'\"
1046 placeHolder=\"".__("Login")."\"
1047 autocomplete=\"new-password\"
1048 style=\"width : 10em;\"> ".
1050 placeHolder=\"".__("Password")."\"
1051 dojoType=\"dijit.form.TextBox\" type='password'
1052 autocomplete=\"new-password\"
1053 style=\"width : 10em;\" name='pass'\">
1057 print "<div style=\"clear : both\">
1058 <input type=\"checkbox\" name=\"need_auth\" dojoType=\"dijit.form.CheckBox\" id=\"feedDlg_loginCheck\"
1059 onclick='checkboxToggleElement(this, \"feedDlg_loginContainer\")'>
1060 <label for=\"feedDlg_loginCheck\">".
1061 __('This feed requires authentication.')."</div>";
1065 print "<div class=\"dlgButtons\">
1066 <button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('feedAddDlg').execute()\">".__('Subscribe')."</button>";
1068 if (!(defined('_DISABLE_FEED_BROWSER') && _DISABLE_FEED_BROWSER
)) {
1069 print "<button dojoType=\"dijit.form.Button\" onclick=\"return feedBrowser()\">".__('More feeds')."</button>";
1072 print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('feedAddDlg').hide()\">".__('Cancel')."</button>
1078 function feedBrowser() {
1079 if (defined('_DISABLE_FEED_BROWSER') && _DISABLE_FEED_BROWSER
) return;
1081 $browser_search = $_REQUEST["search"];
1083 print_hidden("op", "rpc");
1084 print_hidden("method", "updateFeedBrowser");
1086 print "<div dojoType=\"dijit.Toolbar\">
1087 <div style='float : right'>
1088 <img style='display : none'
1089 id='feed_browser_spinner' src='images/indicator_white.gif'>
1090 <input name=\"search\" dojoType=\"dijit.form.TextBox\" size=\"20\" type=\"search\"
1091 onchange=\"dijit.byId('feedBrowserDlg').update()\" value=\"$browser_search\">
1092 <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('feedBrowserDlg').update()\">".__('Search')."</button>
1095 print " <select name=\"mode\" dojoType=\"dijit.form.Select\" onchange=\"dijit.byId('feedBrowserDlg').update()\">
1096 <option value='1'>" . __('Popular feeds') . "</option>
1097 <option value='2'>" . __('Feed archive') . "</option>
1102 print " <select dojoType=\"dijit.form.Select\" name=\"limit\" onchange=\"dijit.byId('feedBrowserDlg').update()\">";
1104 foreach (array(25, 50, 100, 200) as $l) {
1105 //$issel = ($l == $limit) ? "selected=\"1\"" : "";
1106 print "<option value=\"$l\">$l</option>";
1113 require_once "feedbrowser.php";
1115 print "<ul class='browseFeedList' id='browseFeedList'>";
1116 print make_feed_browser("", 25);
1119 print "<div align='center'>
1120 <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('feedBrowserDlg').execute()\">".__('Subscribe')."</button>
1121 <button dojoType=\"dijit.form.Button\" style='display : none' id='feed_archive_remove' onclick=\"dijit.byId('feedBrowserDlg').removeFromArchive()\">".__('Remove')."</button>
1122 <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('feedBrowserDlg').hide()\" >".__('Cancel')."</button></div>";
1127 $this->params
= explode(":", $_REQUEST["param"], 2);
1129 $active_feed_id = sprintf("%d", $this->params
[0]);
1130 $is_cat = $this->params
[1] != "false";
1132 print "<div class=\"dlgSec\">".__('Look for')."</div>";
1134 print "<div class=\"dlgSecCont\">";
1136 print "<input dojoType=\"dijit.form.ValidationTextBox\"
1137 style=\"font-size : 16px; width : 20em;\"
1138 required=\"1\" name=\"query\" type=\"search\" value=''>";
1140 print "<hr/><span style='float : right'>".T_sprintf('in %s', $this->getFeedTitle($active_feed_id, $is_cat))."</span>";
1142 if (DB_TYPE
== "pgsql") {
1144 print_select("search_language", "", Pref_Feeds
::$feed_languages,
1145 "dojoType='dijit.form.Select' title=\"".__('Used for word stemming')."\"");
1150 print "<div class=\"dlgButtons\">";
1152 if (count(PluginHost
::getInstance()->get_hooks(PluginHost
::HOOK_SEARCH
)) == 0) {
1153 print "<div style=\"float : left\">
1154 <a class=\"visibleLink\" target=\"_blank\" href=\"http://tt-rss.org/wiki/SearchSyntax\">".__("Search syntax")."</a>
1158 print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('searchDlg').execute()\">".__('Search')."</button>
1159 <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('searchDlg').hide()\">".__('Cancel')."</button>
1163 function update_debugger() {
1164 header("Content-type: text/html");
1166 $feed_id = (int)$_REQUEST["feed_id"];
1167 @$do_update = $_REQUEST["action"] == "do_update";
1168 $csrf_token = $_REQUEST["csrf_token"];
1170 $sth = $this->pdo
->prepare("SELECT id FROM ttrss_feeds WHERE id = ? AND owner_uid = ?");
1171 $sth->execute([$feed_id, $_SESSION['uid']]);
1173 if (!$sth->fetch()) {
1174 print "Access denied.";
1178 $refetch_checked = isset($_REQUEST["force_refetch"]) ?
"checked" : "";
1179 $rehash_checked = isset($_REQUEST["force_rehash"]) ?
"checked" : "";
1184 <?php
echo stylesheet_tag("css/default.css") ?
>
1185 <title
>Feed Debugger
</title
>
1187 <body
class="small_margins ttrss_utility claro">
1188 <h1
>Feed Debugger
: <?php
echo "$feed_id: " . $this->getFeedTitle($feed_id) ?
></h1
>
1189 <form method
="GET" action
="">
1190 <input type
="hidden" name
="op" value
="feeds">
1191 <input type
="hidden" name
="method" value
="update_debugger">
1192 <input type
="hidden" name
="xdebug" value
="1">
1193 <input type
="hidden" name
="csrf_token" value
="<?php echo $csrf_token ?>">
1194 <input type
="hidden" name
="action" value
="do_update">
1195 <input type
="hidden" name
="feed_id" value
="<?php echo $feed_id ?>">
1196 <input type
="checkbox" name
="force_refetch" value
="1" <?php
echo $refetch_checked ?
>> Force refetch
<br
/>
1197 <input type
="checkbox" name
="force_rehash" value
="1" <?php
echo $rehash_checked ?
>> Force rehash
<br
/>
1199 <p
/><button type
="submit">Continue</button
>
1207 RSSUtils
::update_rss_feed($feed_id, true);
1218 static function catchup_feed($feed, $cat_view, $owner_uid = false, $mode = 'all', $search = false) {
1220 if (!$owner_uid) $owner_uid = $_SESSION['uid'];
1224 // Todo: all this interval stuff needs some generic generator function
1226 $search_qpart = is_array($search) && $search[0] ?
search_to_sql($search[0], $search[1])[0] : 'true';
1230 if (DB_TYPE
== "pgsql") {
1231 $date_qpart = "date_entered < NOW() - INTERVAL '1 day' ";
1233 $date_qpart = "date_entered < DATE_SUB(NOW(), INTERVAL 1 DAY) ";
1237 if (DB_TYPE
== "pgsql") {
1238 $date_qpart = "date_entered < NOW() - INTERVAL '1 week' ";
1240 $date_qpart = "date_entered < DATE_SUB(NOW(), INTERVAL 1 WEEK) ";
1244 if (DB_TYPE
== "pgsql") {
1245 $date_qpart = "date_entered < NOW() - INTERVAL '2 week' ";
1247 $date_qpart = "date_entered < DATE_SUB(NOW(), INTERVAL 2 WEEK) ";
1251 $date_qpart = "true";
1254 if (is_numeric($feed)) {
1260 $children = Feeds
::getChildCategories($feed, $owner_uid);
1261 array_push($children, $feed);
1263 $children = join(",", $children);
1265 $cat_qpart = "cat_id IN ($children)";
1267 $cat_qpart = "cat_id IS NULL";
1270 $sth = $pdo->prepare("UPDATE ttrss_user_entries
1271 SET unread = false, last_read = NOW() WHERE ref_id IN
1273 (SELECT DISTINCT id FROM ttrss_entries, ttrss_user_entries WHERE ref_id = id
1274 AND owner_uid = ? AND unread = true AND feed_id IN
1275 (SELECT id FROM ttrss_feeds WHERE $cat_qpart) AND $date_qpart AND $search_qpart) as tmp)");
1276 $sth->execute([$owner_uid]);
1278 } else if ($feed == -2) {
1280 $sth = $pdo->prepare("UPDATE ttrss_user_entries
1281 SET unread = false,last_read = NOW() WHERE (SELECT COUNT(*)
1282 FROM ttrss_user_labels2, ttrss_entries WHERE article_id = ref_id AND id = ref_id AND $date_qpart AND $search_qpart) > 0
1283 AND unread = true AND owner_uid = ?");
1284 $sth->execute([$owner_uid]);
1287 } else if ($feed > 0) {
1289 $sth = $pdo->prepare("UPDATE ttrss_user_entries
1290 SET unread = false, last_read = NOW() WHERE ref_id IN
1292 (SELECT DISTINCT id FROM ttrss_entries, ttrss_user_entries WHERE ref_id = id
1293 AND owner_uid = ? AND unread = true AND feed_id = ? AND $date_qpart AND $search_qpart) as tmp)");
1294 $sth->execute([$owner_uid, $feed]);
1296 } else if ($feed < 0 && $feed > LABEL_BASE_INDEX
) { // special, like starred
1299 $sth = $pdo->prepare("UPDATE ttrss_user_entries
1300 SET unread = false, last_read = NOW() WHERE ref_id IN
1302 (SELECT DISTINCT id FROM ttrss_entries, ttrss_user_entries WHERE ref_id = id
1303 AND owner_uid = ? AND unread = true AND marked = true AND $date_qpart AND $search_qpart) as tmp)");
1304 $sth->execute([$owner_uid]);
1308 $sth = $pdo->prepare("UPDATE ttrss_user_entries
1309 SET unread = false, last_read = NOW() WHERE ref_id IN
1311 (SELECT DISTINCT id FROM ttrss_entries, ttrss_user_entries WHERE ref_id = id
1312 AND owner_uid = ? AND unread = true AND published = true AND $date_qpart AND $search_qpart) as tmp)");
1313 $sth->execute([$owner_uid]);
1318 $intl = (int) get_pref("FRESH_ARTICLE_MAX_AGE");
1320 if (DB_TYPE
== "pgsql") {
1321 $match_part = "date_entered > NOW() - INTERVAL '$intl hour' ";
1323 $match_part = "date_entered > DATE_SUB(NOW(),
1324 INTERVAL $intl HOUR) ";
1327 $sth = $pdo->prepare("UPDATE ttrss_user_entries
1328 SET unread = false, last_read = NOW() WHERE ref_id IN
1330 (SELECT DISTINCT id FROM ttrss_entries, ttrss_user_entries WHERE ref_id = id
1331 AND owner_uid = ? AND score >= 0 AND unread = true AND $date_qpart AND $match_part AND $search_qpart) as tmp)");
1332 $sth->execute([$owner_uid]);
1336 $sth = $pdo->prepare("UPDATE ttrss_user_entries
1337 SET unread = false, last_read = NOW() WHERE ref_id IN
1339 (SELECT DISTINCT id FROM ttrss_entries, ttrss_user_entries WHERE ref_id = id
1340 AND owner_uid = ? AND unread = true AND $date_qpart AND $search_qpart) as tmp)");
1341 $sth->execute([$owner_uid]);
1344 } else if ($feed < LABEL_BASE_INDEX
) { // label
1346 $label_id = Labels
::feed_to_label_id($feed);
1348 $sth = $pdo->prepare("UPDATE ttrss_user_entries
1349 SET unread = false, last_read = NOW() WHERE ref_id IN
1351 (SELECT DISTINCT ttrss_entries.id FROM ttrss_entries, ttrss_user_entries, ttrss_user_labels2 WHERE ref_id = id
1352 AND label_id = ? AND ref_id = article_id
1353 AND owner_uid = ? AND unread = true AND $date_qpart AND $search_qpart) as tmp)");
1354 $sth->execute([$label_id, $owner_uid]);
1358 CCache
::update($feed, $owner_uid, $cat_view);
1361 $sth = $pdo->prepare("UPDATE ttrss_user_entries
1362 SET unread = false, last_read = NOW() WHERE ref_id IN
1364 (SELECT DISTINCT ttrss_entries.id FROM ttrss_entries, ttrss_user_entries, ttrss_tags WHERE ref_id = ttrss_entries.id
1365 AND post_int_id = int_id AND tag_name = ?
1366 AND ttrss_user_entries.owner_uid = ? AND unread = true AND $date_qpart AND $search_qpart) as tmp)");
1367 $sth->execute([$feed, $owner_uid]);
1372 static function getFeedArticles($feed, $is_cat = false, $unread_only = false,
1373 $owner_uid = false) {
1375 $n_feed = (int) $feed;
1376 $need_entries = false;
1380 if (!$owner_uid) $owner_uid = $_SESSION["uid"];
1383 $unread_qpart = "unread = true";
1385 $unread_qpart = "true";
1391 return Feeds
::getCategoryUnread($n_feed, $owner_uid);
1392 } else if ($n_feed == -6) {
1394 } else if ($feed != "0" && $n_feed == 0) {
1396 $sth = $pdo->prepare("SELECT SUM((SELECT COUNT(int_id)
1397 FROM ttrss_user_entries,ttrss_entries WHERE int_id = post_int_id
1398 AND ref_id = id AND $unread_qpart)) AS count FROM ttrss_tags
1399 WHERE owner_uid = ? AND tag_name = ?");
1401 $sth->execute([$owner_uid, $feed]);
1402 $row = $sth->fetch();
1404 return $row["count"];
1406 } else if ($n_feed == -1) {
1407 $match_part = "marked = true";
1408 } else if ($n_feed == -2) {
1409 $match_part = "published = true";
1410 } else if ($n_feed == -3) {
1411 $match_part = "unread = true AND score >= 0";
1413 $intl = (int) get_pref("FRESH_ARTICLE_MAX_AGE", $owner_uid);
1415 if (DB_TYPE
== "pgsql") {
1416 $match_part .= " AND date_entered > NOW() - INTERVAL '$intl hour' ";
1418 $match_part .= " AND date_entered > DATE_SUB(NOW(), INTERVAL $intl HOUR) ";
1421 $need_entries = true;
1423 } else if ($n_feed == -4) {
1424 $match_part = "true";
1425 } else if ($n_feed >= 0) {
1428 $match_part = "feed_id = '$n_feed'";
1430 $match_part = "feed_id IS NULL";
1433 } else if ($feed < LABEL_BASE_INDEX
) {
1435 $label_id = Labels
::feed_to_label_id($feed);
1437 return Feeds
::getLabelUnread($label_id, $owner_uid);
1442 if ($need_entries) {
1443 $from_qpart = "ttrss_user_entries,ttrss_entries";
1444 $from_where = "ttrss_entries.id = ttrss_user_entries.ref_id AND";
1446 $from_qpart = "ttrss_user_entries";
1450 $sth = $pdo->prepare("SELECT count(int_id) AS unread
1451 FROM $from_qpart WHERE
1452 $unread_qpart AND $from_where ($match_part) AND ttrss_user_entries.owner_uid = ?");
1453 $sth->execute([$owner_uid]);
1454 $row = $sth->fetch();
1456 return $row["unread"];
1460 $sth = $pdo->prepare("SELECT COUNT(post_int_id) AS unread
1461 FROM ttrss_tags,ttrss_user_entries,ttrss_entries
1462 WHERE tag_name = ? AND post_int_id = int_id AND ref_id = ttrss_entries.id
1463 AND $unread_qpart AND ttrss_tags.owner_uid = ,");
1465 $sth->execute([$feed, $owner_uid]);
1466 $row = $sth->fetch();
1468 return $row["unread"];
1473 * @return array (code => Status code, message => error message if available)
1475 * 0 - OK, Feed already exists
1476 * 1 - OK, Feed added
1478 * 3 - URL content is HTML, no feeds available
1479 * 4 - URL content is HTML which contains multiple feeds.
1480 * Here you should call extractfeedurls in rpc-backend
1481 * to get all possible feeds.
1482 * 5 - Couldn't download the URL content.
1483 * 6 - Content is an invalid XML.
1485 static function subscribe_to_feed($url, $cat_id = 0,
1486 $auth_login = '', $auth_pass = '') {
1488 global $fetch_last_error;
1489 global $fetch_last_error_content;
1493 $url = fix_url($url);
1495 if (!$url ||
!validate_feed_url($url)) return array("code" => 2);
1497 $contents = @fetch_file_contents
($url, false, $auth_login, $auth_pass);
1500 if (preg_match("/cloudflare\.com/", $fetch_last_error_content)) {
1501 $fetch_last_error .= " (feed behind Cloudflare)";
1504 return array("code" => 5, "message" => $fetch_last_error);
1507 foreach (PluginHost
::getInstance()->get_hooks(PluginHost
::HOOK_SUBSCRIBE_FEED
) as $plugin) {
1508 $contents = $plugin->hook_subscribe_feed($contents, $url, $auth_login, $auth_pass);
1511 if (is_html($contents)) {
1512 $feedUrls = get_feeds_from_html($url, $contents);
1514 if (count($feedUrls) == 0) {
1515 return array("code" => 3);
1516 } else if (count($feedUrls) > 1) {
1517 return array("code" => 4, "feeds" => $feedUrls);
1519 //use feed url as new URL
1520 $url = key($feedUrls);
1523 if (!$cat_id) $cat_id = null;
1525 $sth = $pdo->prepare("SELECT id FROM ttrss_feeds
1526 WHERE feed_url = ? AND owner_uid = ?");
1527 $sth->execute([$url, $_SESSION['uid']]);
1529 if ($row = $sth->fetch()) {
1530 return array("code" => 0, "feed_id" => (int) $row["id"]);
1532 $sth = $pdo->prepare(
1533 "INSERT INTO ttrss_feeds
1534 (owner_uid,feed_url,title,cat_id, auth_login,auth_pass,update_method,auth_pass_encrypted)
1535 VALUES (?, ?, ?, ?, ?, ?, 0, false)");
1537 $sth->execute([$_SESSION['uid'], $url, "[Unknown]", $cat_id, $auth_login, $auth_pass]);
1539 $sth = $pdo->prepare("SELECT id FROM ttrss_feeds WHERE feed_url = ?
1540 AND owner_uid = ?");
1541 $sth->execute([$url, $_SESSION['uid']]);
1542 $row = $sth->fetch();
1544 $feed_id = $row["id"];
1547 RSSUtils
::set_basic_feed_info($feed_id);
1550 return array("code" => 1, "feed_id" => (int) $feed_id);
1555 static function getIconFile($feed_id) {
1556 return ICONS_DIR
. "/$feed_id.ico";
1559 static function feedHasIcon($id) {
1560 return is_file(ICONS_DIR
. "/$id.ico") && filesize(ICONS_DIR
. "/$id.ico") > 0;
1563 static function getFeedIcon($id) {
1566 return "images/archive.png";
1569 return "images/star.png";
1572 return "images/feed.png";
1575 return "images/fresh.png";
1578 return "images/folder.png";
1581 return "images/time.png";
1584 if ($id < LABEL_BASE_INDEX
) {
1585 return "images/label.png";
1587 $icon = self
::getIconFile($id);
1589 if ($icon && file_exists($icon)) {
1590 return ICONS_URL
. "/" . basename($icon) . "?" . filemtime($icon);
1599 static function getFeedTitle($id, $cat = false) {
1603 return Feeds
::getCategoryTitle($id);
1604 } else if ($id == -1) {
1605 return __("Starred articles");
1606 } else if ($id == -2) {
1607 return __("Published articles");
1608 } else if ($id == -3) {
1609 return __("Fresh articles");
1610 } else if ($id == -4) {
1611 return __("All articles");
1612 } else if ($id === 0 ||
$id === "0") {
1613 return __("Archived articles");
1614 } else if ($id == -6) {
1615 return __("Recently read");
1616 } else if ($id < LABEL_BASE_INDEX
) {
1618 $label_id = Labels
::feed_to_label_id($id);
1620 $sth = $pdo->prepare("SELECT caption FROM ttrss_labels2 WHERE id = ?");
1621 $sth->execute([$label_id]);
1623 if ($row = $sth->fetch()) {
1624 return $row["caption"];
1626 return "Unknown label ($label_id)";
1629 } else if (is_numeric($id) && $id > 0) {
1631 $sth = $pdo->prepare("SELECT title FROM ttrss_feeds WHERE id = ?");
1632 $sth->execute([$id]);
1634 if ($row = $sth->fetch()) {
1635 return $row["title"];
1637 return "Unknown feed ($id)";
1645 static function getCategoryUnread($cat, $owner_uid = false) {
1647 if (!$owner_uid) $owner_uid = $_SESSION["uid"];
1653 if (!$cat) $cat = null;
1655 $sth = $pdo->prepare("SELECT id FROM ttrss_feeds
1656 WHERE (cat_id = :cat OR (:cat IS NULL AND cat_id IS NULL))
1657 AND owner_uid = :uid");
1659 $sth->execute([":cat" => $cat, ":uid" => $owner_uid]);
1661 $cat_feeds = array();
1662 while ($line = $sth->fetch()) {
1663 array_push($cat_feeds, "feed_id = " . $line["id"]);
1666 if (count($cat_feeds) == 0) return 0;
1668 $match_part = implode(" OR ", $cat_feeds);
1670 $sth = $pdo->prepare("SELECT COUNT(int_id) AS unread
1671 FROM ttrss_user_entries
1672 WHERE unread = true AND ($match_part)
1673 AND owner_uid = ?");
1674 $sth->execute([$owner_uid]);
1678 # this needs to be rewritten
1679 while ($line = $sth->fetch()) {
1680 $unread +
= $line["unread"];
1684 } else if ($cat == -1) {
1685 return getFeedUnread(-1) +
getFeedUnread(-2) +
getFeedUnread(-3) +
getFeedUnread(0);
1686 } else if ($cat == -2) {
1688 $sth = $pdo->prepare("SELECT COUNT(unread) AS unread FROM
1689 ttrss_user_entries, ttrss_user_labels2
1690 WHERE article_id = ref_id AND unread = true
1691 AND ttrss_user_entries.owner_uid = ?");
1692 $sth->execute([$owner_uid]);
1693 $row = $sth->fetch();
1695 return $row["unread"];
1699 // only accepts real cats (>= 0)
1700 static function getCategoryChildrenUnread($cat, $owner_uid = false) {
1701 if (!$owner_uid) $owner_uid = $_SESSION["uid"];
1705 $sth = $pdo->prepare("SELECT id FROM ttrss_feed_categories WHERE parent_cat = ?
1706 AND owner_uid = ?");
1707 $sth->execute([$cat, $owner_uid]);
1711 while ($line = $sth->fetch()) {
1712 $unread +
= Feeds
::getCategoryUnread($line["id"], $owner_uid);
1713 $unread +
= Feeds
::getCategoryChildrenUnread($line["id"], $owner_uid);
1719 static function getGlobalUnread($user_id = false) {
1721 if (!$user_id) $user_id = $_SESSION["uid"];
1725 $sth = $pdo->prepare("SELECT SUM(value) AS c_id FROM ttrss_counters_cache
1726 WHERE owner_uid = ? AND feed_id > 0");
1727 $sth->execute([$user_id]);
1728 $row = $sth->fetch();
1730 return $row["c_id"];
1733 static function getCategoryTitle($cat_id) {
1735 if ($cat_id == -1) {
1736 return __("Special");
1737 } else if ($cat_id == -2) {
1738 return __("Labels");
1743 $sth = $pdo->prepare("SELECT title FROM ttrss_feed_categories WHERE
1745 $sth->execute([$cat_id]);
1747 if ($row = $sth->fetch()) {
1748 return $row["title"];
1750 return __("Uncategorized");
1755 static function getLabelUnread($label_id, $owner_uid = false) {
1756 if (!$owner_uid) $owner_uid = $_SESSION["uid"];
1760 $sth = $pdo->prepare("SELECT COUNT(ref_id) AS unread FROM ttrss_user_entries, ttrss_user_labels2
1761 WHERE owner_uid = ? AND unread = true AND label_id = ? AND article_id = ref_id");
1763 $sth->execute([$owner_uid, $label_id]);
1765 if ($row = $sth->fetch()) {
1766 return $row["unread"];
1772 static function queryFeedHeadlines($params) {
1776 // WARNING: due to highly dynamic nature of this query its going to quote parameters
1777 // right before adding them to SQL part
1779 $feed = $params["feed"];
1780 $limit = isset($params["limit"]) ?
$params["limit"] : 30;
1781 $view_mode = $params["view_mode"];
1782 $cat_view = isset($params["cat_view"]) ?
$params["cat_view"] : false;
1783 $search = isset($params["search"]) ?
$params["search"] : false;
1784 $search_language = isset($params["search_language"]) ?
$params["search_language"] : "";
1785 $override_order = isset($params["override_order"]) ?
$params["override_order"] : false;
1786 $offset = isset($params["offset"]) ?
$params["offset"] : 0;
1787 $owner_uid = isset($params["owner_uid"]) ?
$params["owner_uid"] : $_SESSION["uid"];
1788 $since_id = isset($params["since_id"]) ?
$params["since_id"] : 0;
1789 $include_children = isset($params["include_children"]) ?
$params["include_children"] : false;
1790 $ignore_vfeed_group = isset($params["ignore_vfeed_group"]) ?
$params["ignore_vfeed_group"] : false;
1791 $override_strategy = isset($params["override_strategy"]) ?
$params["override_strategy"] : false;
1792 $override_vfeed = isset($params["override_vfeed"]) ?
$params["override_vfeed"] : false;
1793 $start_ts = isset($params["start_ts"]) ?
$params["start_ts"] : false;
1794 $check_first_id = isset($params["check_first_id"]) ?
$params["check_first_id"] : false;
1795 $skip_first_id_check = isset($params["skip_first_id_check"]) ?
$params["skip_first_id_check"] : false;
1797 $ext_tables_part = "";
1798 $limit_query_part = "";
1800 $search_words = array();
1803 foreach (PluginHost
::getInstance()->get_hooks(PluginHost
::HOOK_SEARCH
) as $plugin) {
1804 list($search_query_part, $search_words) = $plugin->hook_search($search);
1808 // fall back in case of no plugins
1809 if (!$search_query_part) {
1810 list($search_query_part, $search_words) = search_to_sql($search, $search_language);
1812 $search_query_part .= " AND ";
1814 $search_query_part = "";
1818 $since_id_part = "ttrss_entries.id > ".$pdo->quote($since_id)." AND ";
1820 $since_id_part = "";
1823 $view_query_part = "";
1825 if ($view_mode == "adaptive") {
1827 $view_query_part = " ";
1828 } else if ($feed != -1) {
1830 $unread = getFeedUnread($feed, $cat_view);
1832 if ($cat_view && $feed > 0 && $include_children)
1833 $unread +
= Feeds
::getCategoryChildrenUnread($feed);
1836 $view_query_part = " unread = true AND ";
1841 if ($view_mode == "marked") {
1842 $view_query_part = " marked = true AND ";
1845 if ($view_mode == "has_note") {
1846 $view_query_part = " (note IS NOT NULL AND note != '') AND ";
1849 if ($view_mode == "published") {
1850 $view_query_part = " published = true AND ";
1853 if ($view_mode == "unread" && $feed != -6) {
1854 $view_query_part = " unread = true AND ";
1858 $limit_query_part = "LIMIT " . (int)$limit;
1861 $allow_archived = false;
1863 $vfeed_query_part = "";
1866 if (!is_numeric($feed)) {
1867 $query_strategy_part = "true";
1868 $vfeed_query_part = "(SELECT title FROM ttrss_feeds WHERE
1869 id = feed_id) as feed_title,";
1870 } else if ($feed > 0) {
1875 if ($include_children) {
1877 $subcats = Feeds
::getChildCategories($feed, $owner_uid);
1879 array_push($subcats, $feed);
1880 $query_strategy_part = "cat_id IN (".
1881 implode(",", $subcats).")";
1884 $query_strategy_part = "cat_id = " . $pdo->quote($feed);
1888 $query_strategy_part = "cat_id IS NULL";
1891 $vfeed_query_part = "ttrss_feeds.title AS feed_title,";
1894 $query_strategy_part = "feed_id = " . $pdo->quote($feed);
1896 } else if ($feed == 0 && !$cat_view) { // archive virtual feed
1897 $query_strategy_part = "feed_id IS NULL";
1898 $allow_archived = true;
1899 } else if ($feed == 0 && $cat_view) { // uncategorized
1900 $query_strategy_part = "cat_id IS NULL AND feed_id IS NOT NULL";
1901 $vfeed_query_part = "ttrss_feeds.title AS feed_title,";
1902 } else if ($feed == -1) { // starred virtual feed
1903 $query_strategy_part = "marked = true";
1904 $vfeed_query_part = "ttrss_feeds.title AS feed_title,";
1905 $allow_archived = true;
1907 if (!$override_order) {
1908 $override_order = "last_marked DESC, date_entered DESC, updated DESC";
1911 } else if ($feed == -2) { // published virtual feed OR labels category
1914 $query_strategy_part = "published = true";
1915 $vfeed_query_part = "ttrss_feeds.title AS feed_title,";
1916 $allow_archived = true;
1918 if (!$override_order) {
1919 $override_order = "last_published DESC, date_entered DESC, updated DESC";
1923 $vfeed_query_part = "ttrss_feeds.title AS feed_title,";
1925 $ext_tables_part = "ttrss_labels2,ttrss_user_labels2,";
1927 $query_strategy_part = "ttrss_labels2.id = ttrss_user_labels2.label_id AND
1928 ttrss_user_labels2.article_id = ref_id";
1931 } else if ($feed == -6) { // recently read
1932 $query_strategy_part = "unread = false AND last_read IS NOT NULL";
1934 if (DB_TYPE
== "pgsql") {
1935 $query_strategy_part .= " AND last_read > NOW() - INTERVAL '1 DAY' ";
1937 $query_strategy_part .= " AND last_read > DATE_SUB(NOW(), INTERVAL 1 DAY) ";
1940 $vfeed_query_part = "ttrss_feeds.title AS feed_title,";
1941 $allow_archived = true;
1942 $ignore_vfeed_group = true;
1944 if (!$override_order) $override_order = "last_read DESC";
1946 } else if ($feed == -3) { // fresh virtual feed
1947 $query_strategy_part = "unread = true AND score >= 0";
1949 $intl = (int) get_pref("FRESH_ARTICLE_MAX_AGE", $owner_uid);
1951 if (DB_TYPE
== "pgsql") {
1952 $query_strategy_part .= " AND date_entered > NOW() - INTERVAL '$intl hour' ";
1954 $query_strategy_part .= " AND date_entered > DATE_SUB(NOW(), INTERVAL $intl HOUR) ";
1957 $vfeed_query_part = "ttrss_feeds.title AS feed_title,";
1958 } else if ($feed == -4) { // all articles virtual feed
1959 $allow_archived = true;
1960 $query_strategy_part = "true";
1961 $vfeed_query_part = "ttrss_feeds.title AS feed_title,";
1962 } else if ($feed <= LABEL_BASE_INDEX
) { // labels
1963 $label_id = Labels
::feed_to_label_id($feed);
1965 $query_strategy_part = "label_id = ".$pdo->quote($label_id)." AND
1966 ttrss_labels2.id = ttrss_user_labels2.label_id AND
1967 ttrss_user_labels2.article_id = ref_id";
1969 $vfeed_query_part = "ttrss_feeds.title AS feed_title,";
1970 $ext_tables_part = "ttrss_labels2,ttrss_user_labels2,";
1971 $allow_archived = true;
1974 $query_strategy_part = "true";
1977 $order_by = "score DESC, date_entered DESC, updated DESC";
1979 if ($override_order) {
1980 $order_by = $override_order;
1983 if ($override_strategy) {
1984 $query_strategy_part = $override_strategy;
1987 if ($override_vfeed) {
1988 $vfeed_query_part = $override_vfeed;
1992 $feed_title = T_sprintf("Search results: %s", $search);
1995 $feed_title = Feeds
::getCategoryTitle($feed);
1997 if (is_numeric($feed) && $feed > 0) {
1998 $ssth = $pdo->prepare("SELECT title,site_url,last_error,last_updated
1999 FROM ttrss_feeds WHERE id = ? AND owner_uid = ?");
2000 $ssth->execute([$feed, $owner_uid]);
2001 $row = $ssth->fetch();
2003 $feed_title = $row["title"];
2004 $feed_site_url = $row["site_url"];
2005 $last_error = $row["last_error"];
2006 $last_updated = $row["last_updated"];
2008 $feed_title = Feeds
::getFeedTitle($feed);
2013 $content_query_part = "content, ";
2015 if ($limit_query_part) {
2016 $offset_query_part = "OFFSET " . (int)$offset;
2018 $offset_query_part = "";
2021 if (is_numeric($feed)) {
2022 // proper override_order applied above
2023 if ($vfeed_query_part && !$ignore_vfeed_group && get_pref('VFEED_GROUP_BY_FEED', $owner_uid)) {
2024 if (!$override_order) {
2025 $order_by = "ttrss_feeds.title, ".$order_by;
2027 $order_by = "ttrss_feeds.title, ".$override_order;
2031 if (!$allow_archived) {
2032 $from_qpart = "${ext_tables_part}ttrss_entries LEFT JOIN ttrss_user_entries ON (ref_id = ttrss_entries.id),ttrss_feeds";
2033 $feed_check_qpart = "ttrss_user_entries.feed_id = ttrss_feeds.id AND";
2036 $from_qpart = "${ext_tables_part}ttrss_entries LEFT JOIN ttrss_user_entries ON (ref_id = ttrss_entries.id)
2037 LEFT JOIN ttrss_feeds ON (feed_id = ttrss_feeds.id)";
2040 if ($vfeed_query_part) $vfeed_query_part .= "favicon_avg_color,";
2043 $start_ts_formatted = date("Y/m/d H:i:s", strtotime($start_ts));
2044 $start_ts_query_part = "date_entered >= '$start_ts_formatted' AND";
2046 $start_ts_query_part = "";
2050 $first_id_query_strategy_part = $query_strategy_part;
2053 $first_id_query_strategy_part = "true";
2055 if (DB_TYPE
== "pgsql") {
2056 $sanity_interval_qpart = "date_entered >= NOW() - INTERVAL '1 hour' AND";
2058 $sanity_interval_qpart = "date_entered >= DATE_SUB(NOW(), INTERVAL 1 hour) AND";
2061 if (!$search && !$skip_first_id_check) {
2062 // if previous topmost article id changed that means our current pagination is no longer valid
2063 $query = "SELECT DISTINCT
2068 ttrss_entries.title,
2080 ttrss_user_entries.owner_uid = ".$pdo->quote($owner_uid)." AND
2082 $start_ts_query_part
2084 $sanity_interval_qpart
2085 $first_id_query_strategy_part ORDER BY $order_by LIMIT 1";
2087 if ($_REQUEST["debug"]) {
2091 $res = $pdo->query($query);
2093 if ($row = $res->fetch()) {
2094 $first_id = (int)$row["id"];
2096 if ($offset > 0 && $first_id && $check_first_id && $first_id != $check_first_id) {
2097 return array(-1, $feed_title, $feed_site_url, $last_error, $last_updated, $search_words, $first_id);
2102 $query = "SELECT DISTINCT
2105 ttrss_entries.id,ttrss_entries.title,
2109 always_display_enclosures,
2118 unread,feed_id,marked,published,link,last_read,orig_feed_id,
2119 last_marked, last_published,
2127 ttrss_user_entries.owner_uid = ".$pdo->quote($owner_uid)." AND
2129 $start_ts_query_part
2132 $query_strategy_part ORDER BY $order_by
2133 $limit_query_part $offset_query_part";
2135 if ($_REQUEST["debug"]) print $query;
2137 $res = $pdo->query($query);
2142 $query = "SELECT DISTINCT
2146 ttrss_entries.id as id,
2162 (SELECT hide_images FROM ttrss_feeds WHERE id = feed_id) AS hide_images,
2163 last_marked, last_published,
2168 FROM ttrss_entries, ttrss_user_entries, ttrss_tags
2170 ref_id = ttrss_entries.id AND
2171 ttrss_user_entries.owner_uid = ".$pdo->quote($owner_uid)." AND
2172 post_int_id = int_id AND
2173 tag_name = ".$pdo->quote($feed)." AND
2176 $query_strategy_part ORDER BY $order_by
2177 $limit_query_part $offset_query_part";
2179 if ($_REQUEST["debug"]) print $query;
2181 $res = $pdo->query($query);
2184 return array($res, $feed_title, $feed_site_url, $last_error, $last_updated, $search_words, $first_id);
2188 static function getParentCategories($cat, $owner_uid) {
2193 $sth = $pdo->prepare("SELECT parent_cat FROM ttrss_feed_categories
2194 WHERE id = ? AND parent_cat IS NOT NULL AND owner_uid = ?");
2195 $sth->execute([$cat, $owner_uid]);
2197 while ($line = $sth->fetch()) {
2198 array_push($rv, $line["parent_cat"]);
2199 $rv = array_merge($rv, Feeds
::getParentCategories($line["parent_cat"], $owner_uid));
2205 static function getChildCategories($cat, $owner_uid) {
2210 $sth = $pdo->prepare("SELECT id FROM ttrss_feed_categories
2211 WHERE parent_cat = ? AND owner_uid = ?");
2212 $sth->execute([$cat, $owner_uid]);
2214 while ($line = $sth->fetch()) {
2215 array_push($rv, $line["id"]);
2216 $rv = array_merge($rv, Feeds
::getChildCategories($line["id"], $owner_uid));
2222 static function getFeedCategory($feed) {
2225 $sth = $pdo->prepare("SELECT cat_id FROM ttrss_feeds
2227 $sth->execute([$feed]);
2229 if ($row = $sth->fetch()) {
2230 return $row["cat_id"];