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($feed_title, 30)."</a>";
70 $error = htmlspecialchars($error);
71 $reply .= " <img title=\"$error\" src='images/error.png' alt='error' class=\"noborder\">";
75 $reply .= $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 $result = $this->dbh
->query(
197 "SELECT cache_images," . SUBSTRING_FOR_DATE
. "(last_updated,1,19) AS last_updated
198 FROM ttrss_feeds WHERE id = '$feed'");
200 if ($this->dbh
->num_rows($result) != 0) {
201 $last_updated = strtotime($this->dbh
->fetch_result($result, 0, "last_updated"));
202 $cache_images = sql_bool_to_bool($this->dbh
->fetch_result($result, 0, "cache_images"));
204 if (!$cache_images && time() - $last_updated > 120) {
205 RSSUtils
::update_rss_feed($feed, true);
207 $this->dbh
->query("UPDATE ttrss_feeds SET last_updated = '1970-01-01', last_update_started = '1970-01-01'
208 WHERE id = '$feed'");
212 $this->dbh
->query("UPDATE ttrss_feeds SET last_updated = '1970-01-01', last_update_started = '1970-01-01'
213 WHERE id = '$feed'");
217 if ($method_split[0] == "MarkAllReadGR") {
218 $this->catchup_feed($method_split[1], false);
221 // FIXME: might break tag display?
223 if (is_numeric($feed) && $feed > 0 && !$cat_view) {
224 $result = $this->dbh
->query(
225 "SELECT id FROM ttrss_feeds WHERE id = '$feed' LIMIT 1");
227 if ($this->dbh
->num_rows($result) == 0) {
228 $reply['content'] = "<div align='center'>".__('Feed not found.')."</div>";
232 @$search = $this->dbh
->escape_string($_REQUEST["query"]);
233 @$search_language = $this->dbh
->escape_string($_REQUEST["search_language"]); // PGSQL only
236 $disable_cache = true;
239 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("H0", $timing_info);
242 if (!$cat_view && is_numeric($feed) && $feed < PLUGIN_FEED_BASE_INDEX
&& $feed > LABEL_BASE_INDEX
) {
243 $handler = PluginHost
::getInstance()->get_feed_handler(
244 PluginHost
::feed_to_pfeed_id($feed));
249 "view_mode" => $view_mode,
250 "cat_view" => $cat_view,
252 "override_order" => $override_order,
254 "owner_uid" => $_SESSION["uid"],
257 "include_children" => $include_children);
259 $qfh_ret = $handler->get_headlines(PluginHost
::feed_to_pfeed_id($feed),
268 "view_mode" => $view_mode,
269 "cat_view" => $cat_view,
271 "search_language" => $search_language,
272 "override_order" => $override_order,
274 "include_children" => $include_children,
275 "check_first_id" => $check_first_id,
276 "skip_first_id_check" => $skip_first_id_check
279 $qfh_ret = $this->queryFeedHeadlines($params);
282 $vfeed_group_enabled = get_pref("VFEED_GROUP_BY_FEED") && $feed != -6;
284 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("H1", $timing_info);
286 $result = $qfh_ret[0];
287 $feed_title = $qfh_ret[1];
288 $feed_site_url = $qfh_ret[2];
289 $last_error = $qfh_ret[3];
290 $last_updated = strpos($qfh_ret[4], '1970-') === FALSE ?
291 make_local_datetime($qfh_ret[4], false) : __("Never");
292 $highlight_words = $qfh_ret[5];
293 $reply['first_id'] = $qfh_ret[6];
294 $reply['search_query'] = [$search, $search_language];
296 $vgroup_last_feed = $vgr_last_feed;
298 $reply['toolbar'] = $this->format_headline_subtoolbar($feed_site_url,
300 $feed, $cat_view, $search,
301 $last_error, $last_updated);
303 $headlines_count = is_numeric($result) ?
0 : $this->dbh
->num_rows($result);
306 foreach (PluginHost
::getInstance()->get_hooks(PluginHost
::HOOK_HEADLINES_BEFORE
) as $p) {
307 $reply['content'] .= $p->hook_headlines_before($feed, $cat_view, $qfh_ret);
311 $reply['content'] = '';
313 if ($headlines_count > 0) {
318 $cur_feed_title = '';
320 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("PS", $timing_info);
322 $expand_cdm = get_pref('CDM_EXPANDED');
324 while ($line = $this->dbh
->fetch_assoc($result)) {
326 $line["content_preview"] = "— " . truncate_string(strip_tags($line["content"]), 250);
328 foreach (PluginHost
::getInstance()->get_hooks(PluginHost
::HOOK_QUERY_HEADLINES
) as $p) {
329 $line = $p->hook_query_headlines($line, 250, false);
332 if (get_pref('SHOW_CONTENT_PREVIEW')) {
333 $content_preview = $line["content_preview"];
337 $feed_id = $line["feed_id"];
338 $label_cache = $line["label_cache"];
342 $label_cache = json_decode($label_cache, true);
345 if ($label_cache["no-labels"] == 1)
348 $labels = $label_cache;
352 if (!is_array($labels)) $labels = Article
::get_article_labels($id);
354 $labels_str = "<span class=\"HLLCTR-$id\">";
355 $labels_str .= Article
::format_article_labels($labels);
356 $labels_str .= "</span>";
358 if (count($topmost_article_ids) < 3) {
359 array_push($topmost_article_ids, $id);
364 if (sql_bool_to_bool($line["unread"])) {
369 if (sql_bool_to_bool($line["marked"])) {
371 src=\"images/mark_set.png\"
372 class=\"markedPic\" alt=\"Unstar article\"
373 onclick='toggleMark($id)'>";
377 src=\"images/mark_unset.png\"
378 class=\"markedPic\" alt=\"Star article\"
379 onclick='toggleMark($id)'>";
382 if (sql_bool_to_bool($line["published"])) {
383 $published_pic = "<img src=\"images/pub_set.png\"
385 alt=\"Unpublish article\" onclick='togglePub($id)'>";
386 $class .= " published";
388 $published_pic = "<img src=\"images/pub_unset.png\"
390 alt=\"Publish article\" onclick='togglePub($id)'>";
393 # $content_link = "<a target=\"_blank\" rel=\"noopener noreferrer\" href=\"".$line["link"]."\">" .
394 # $line["title"] . "</a>";
396 # $content_link = "<a
397 # href=\"" . htmlspecialchars($line["link"]) . "\"
398 # onclick=\"view($id,$feed_id);\">" .
399 # $line["title"] . "</a>";
401 # $content_link = "<a href=\"javascript:viewContentUrl('".$line["link"]."');\">" .
402 # $line["title"] . "</a>";
404 $updated_fmt = make_local_datetime($line["updated"], false, false, false, true);
405 $date_entered_fmt = T_sprintf("Imported at %s",
406 make_local_datetime($line["date_entered"], false));
408 $score = $line["score"];
410 $score_pic = "images/" . get_score_pic($score);
412 /* $score_title = __("(Click to change)");
413 $score_pic = "<img class='hlScorePic' src=\"images/$score_pic\"
414 onclick=\"adjustArticleScore($id, $score)\" title=\"$score $score_title\">"; */
416 $score_pic = "<img class='hlScorePic' score='$score' onclick='changeScore($id, this)' src=\"$score_pic\"
420 $hlc_suffix = "high";
421 } else if ($score < -100) {
427 $entry_author = $line["author"];
430 $entry_author = " — $entry_author";
433 $has_feed_icon = feed_has_icon($feed_id);
435 if ($has_feed_icon) {
436 $feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"".ICONS_URL
."/$feed_id.ico\" alt=\"\">";
438 $feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"images/pub_set.png\" alt=\"\">";
441 $entry_site_url = $line["site_url"];
443 //setting feed headline background color, needs to change text color based on dark/light
444 $fav_color = $line['favicon_avg_color'];
446 require_once "colors.php";
448 if ($fav_color && $fav_color != 'fail') {
449 if (!isset($rgba_cache[$feed_id])) {
450 $rgba_cache[$feed_id] = join(",", _color_unpack($fav_color));
454 if (!get_pref('COMBINED_DISPLAY_MODE')) {
456 if ($vfeed_group_enabled) {
457 if ($feed_id != $vgroup_last_feed && $line["feed_title"]) {
459 $cur_feed_title = $line["feed_title"];
460 $vgroup_last_feed = $feed_id;
462 $cur_feed_title = htmlspecialchars($cur_feed_title);
464 $vf_catchup_link = "<a class='catchup' onclick='catchupFeedInGroup($feed_id);' href='#'>".__('mark feed as read')."</a>";
466 $reply['content'] .= "<div data-feed-id='$feed_id' id='FTITLE-$feed_id' class='cdmFeedTitle'>".
467 "<div style='float : right'>$feed_icon_img</div>".
468 "<a class='title' href=\"#\" onclick=\"viewfeed({feed:$feed_id})\">".
469 $line["feed_title"]."</a>
470 $vf_catchup_link</div>";
476 $mouseover_attrs = "onmouseover='postMouseIn(event, $id)'
477 onmouseout='postMouseOut($id)'";
479 $reply['content'] .= "<div class='hl hlMenuAttach $class' data-orig-feed-id='$feed_id' data-article-id='$id' id='RROW-$id' $mouseover_attrs>";
481 $reply['content'] .= "<div class='hlLeft'>";
483 $reply['content'] .= "<input dojoType=\"dijit.form.CheckBox\"
484 type=\"checkbox\" onclick=\"toggleSelectRow2(this)\"
487 $reply['content'] .= "$marked_pic";
488 $reply['content'] .= "$published_pic";
490 $reply['content'] .= "</div>";
492 $reply['content'] .= "<div onclick='return hlClicked(event, $id)'
493 class=\"hlTitle\"><span class='hlContent $hlc_suffix'>";
494 $reply['content'] .= "<a id=\"RTITLE-$id\" class=\"title $hlc_suffix\"
495 href=\"" . htmlspecialchars($line["link"]) . "\"
497 truncate_string($line["title"], 200);
499 if (get_pref('SHOW_CONTENT_PREVIEW')) {
500 $reply['content'] .= "<span class=\"contentPreview\">" . $line["content_preview"] . "</span>";
503 $reply['content'] .= "</a></span>";
505 $reply['content'] .= $labels_str;
507 $reply['content'] .= "</div>";
509 if (!$vfeed_group_enabled) {
510 if (@$line["feed_title"]) {
511 $rgba = @$rgba_cache[$feed_id];
513 $reply['content'] .= "<span class=\"hlFeed\"><a style=\"background : rgba($rgba, 0.3)\" href=\"#\" onclick=\"viewfeed({feed:$feed_id})\">".
514 truncate_string($line["feed_title"],30)."</a></span>";
519 $reply['content'] .= "<span class=\"hlUpdated\">";
521 $reply['content'] .= "<div title='$date_entered_fmt'>$updated_fmt</div>
524 $reply['content'] .= "<div class=\"hlRight\">";
526 $reply['content'] .= $score_pic;
528 if ($line["feed_title"] && !$vfeed_group_enabled) {
530 $reply['content'] .= "<span onclick=\"viewfeed({feed:$feed_id})\"
531 style=\"cursor : pointer\"
532 title=\"".htmlspecialchars($line['feed_title'])."\">
533 $feed_icon_img</span>";
536 $reply['content'] .= "</div>";
537 $reply['content'] .= "</div>";
541 if ($line["tag_cache"])
542 $tags = explode(",", $line["tag_cache"]);
546 $line["content"] = sanitize($line["content"],
547 sql_bool_to_bool($line['hide_images']), false, $entry_site_url, $highlight_words, $line["id"]);
549 foreach (PluginHost
::getInstance()->get_hooks(PluginHost
::HOOK_RENDER_ARTICLE_CDM
) as $p) {
550 $line = $p->hook_render_article_cdm($line);
553 if ($vfeed_group_enabled && $line["feed_title"]) {
554 if ($feed_id != $vgroup_last_feed) {
556 $cur_feed_title = $line["feed_title"];
557 $vgroup_last_feed = $feed_id;
559 $cur_feed_title = htmlspecialchars($cur_feed_title);
561 $vf_catchup_link = "<a class='catchup' onclick='catchupFeedInGroup($feed_id);' href='#'>".__('mark feed as read')."</a>";
563 $has_feed_icon = feed_has_icon($feed_id);
565 if ($has_feed_icon) {
566 $feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"".ICONS_URL
."/$feed_id.ico\" alt=\"\">";
568 //$feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\" alt=\"\">";
571 $reply['content'] .= "<div data-feed-id='$feed_id' id='FTITLE-$feed_id' class='cdmFeedTitle'>".
572 "<div style=\"float : right\">$feed_icon_img</div>".
573 "<a href=\"#\" class='title' onclick=\"viewfeed({feed:$feed_id})\">".
574 $line["feed_title"]."</a> $vf_catchup_link</div>";
579 $mouseover_attrs = "onmouseover='postMouseIn(event, $id)'
580 onmouseout='postMouseOut($id)'";
582 $expanded_class = $expand_cdm ?
"expanded" : "expandable";
584 $tmp_content = "<div class=\"cdm $hlc_suffix $expanded_class $class\"
585 id=\"RROW-$id\" data-article-id='$id' data-orig-feed-id='$feed_id' $mouseover_attrs>";
587 $tmp_content .= "<div class=\"cdmHeader\">";
588 $tmp_content .= "<div style=\"vertical-align : middle\">";
590 $tmp_content .= "<input dojoType=\"dijit.form.CheckBox\"
591 type=\"checkbox\" onclick=\"toggleSelectRow2(this, false, true)\"
594 $tmp_content .= "$marked_pic";
595 $tmp_content .= "$published_pic";
597 $tmp_content .= "</div>";
599 if ($highlight_words && count($highlight_words > 0)) {
600 foreach ($highlight_words as $word) {
601 $line["title"] = preg_replace("/(\Q$word\E)/i",
602 "<span class=\"highlight\">$1</span>", $line["title"]);
606 // data-article-id included for context menu
607 $tmp_content .= "<span id=\"RTITLE-$id\"
608 onclick=\"return cdmClicked(event, $id);\"
609 data-article-id=\"$id\"
610 class=\"titleWrap hlMenuAttach $hlc_suffix\">
611 <a class=\"title $hlc_suffix\"
612 title=\"".htmlspecialchars($line["title"])."\"
613 target=\"_blank\" rel=\"noopener noreferrer\" href=\"".
614 htmlspecialchars($line["link"])."\">".
616 "</a> <span class=\"author\">$entry_author</span>";
618 $tmp_content .= $labels_str;
620 $tmp_content .= "<span class='collapseBtn' style='display : none'>
621 <img src=\"images/collapse.png\" onclick=\"cdmCollapseArticle(event, $id)\"
622 title=\"".__("Collapse article")."\"/></span>";
625 $content_hidden = "style=\"display : none\"";
627 $excerpt_hidden = "style=\"display : none\"";
629 $tmp_content .= "<span $excerpt_hidden id=\"CEXC-$id\" class=\"cdmExcerpt\">" . $content_preview . "</span>";
631 $tmp_content .= "</span>";
633 if (!$vfeed_group_enabled) {
634 if (@$line["feed_title"]) {
635 $rgba = @$rgba_cache[$feed_id];
637 $tmp_content .= "<div class=\"hlFeed\">
638 <a href=\"#\" style=\"background-color: rgba($rgba,0.3)\"
639 onclick=\"viewfeed({feed:$feed_id})\">".
640 truncate_string($line["feed_title"],30)."</a>
645 $tmp_content .= "<span class='updated' title='$date_entered_fmt'>$updated_fmt</span>";
647 $tmp_content .= "<div class='scoreWrap' style=\"vertical-align : middle\">";
648 $tmp_content .= "$score_pic";
650 if (!get_pref("VFEED_GROUP_BY_FEED") && $line["feed_title"]) {
651 $tmp_content .= "<span style=\"cursor : pointer\"
652 title=\"".htmlspecialchars($line["feed_title"])."\"
653 onclick=\"viewfeed({feed:$feed_id})\">$feed_icon_img</span>";
655 $tmp_content .= "</div>"; //scoreWrap
657 $tmp_content .= "</div>"; //cdmHeader
659 $tmp_content .= "<div class=\"cdmContent\" $content_hidden
660 onclick=\"return cdmClicked(event, $id, true);\"
663 $tmp_content .= "<div id=\"POSTNOTE-$id\">";
665 $tmp_content .= Article
::format_article_note($id, $line['note']);
667 $tmp_content .= "</div>"; //POSTNOTE
669 if (!$line['lang']) $line['lang'] = 'en';
671 $tmp_content .= "<div class=\"cdmContentInner\" lang=\"".$line['lang']."\">";
673 if ($line["orig_feed_id"]) {
675 $tmp_result = $this->dbh
->query("SELECT * FROM ttrss_archived_feeds
676 WHERE id = ".$line["orig_feed_id"] . " AND owner_uid = " . $_SESSION["uid"]);
678 if ($this->dbh
->num_rows($tmp_result) != 0) {
680 $tmp_content .= "<div clear='both'>";
681 $tmp_content .= __("Originally from:");
683 $tmp_content .= " ";
685 $tmp_line = $this->dbh
->fetch_assoc($tmp_result);
687 $tmp_content .= "<a target='_blank' rel='noopener noreferrer'
688 href=' " . htmlspecialchars($tmp_line['site_url']) . "'>" .
689 $tmp_line['title'] . "</a>";
691 $tmp_content .= " ";
693 $tmp_content .= "<a target='_blank' rel='noopener noreferrer' href='" . htmlspecialchars($tmp_line['feed_url']) . "'>";
694 $tmp_content .= "<img title='".__('Feed URL')."'class='tinyFeedIcon' src='images/pub_unset.png'></a>";
696 $tmp_content .= "</div>";
700 $tmp_content .= "<span id=\"CWRAP-$id\">";
701 $tmp_content .= "<span id=\"CENCW-$id\" class=\"cencw\" style=\"display : none\">";
702 $tmp_content .= htmlspecialchars($line["content"]);
703 $tmp_content .= "</span>";
704 $tmp_content .= "</span>";
706 $tmp_content .= "</div>"; //cdmContentInner
708 $tmp_content .= "<div class=\"cdmIntermediate\">";
710 $always_display_enclosures = sql_bool_to_bool($line["always_display_enclosures"]);
711 $tmp_content .= Article
::format_article_enclosures($id, $always_display_enclosures, $line["content"], sql_bool_to_bool($line["hide_images"]));
713 $tmp_content .= "</div>"; // cdmIntermediate
715 $tmp_content .= "<div class=\"cdmFooter\" onclick=\"cdmFooterClick(event)\">";
717 foreach (PluginHost
::getInstance()->get_hooks(PluginHost
::HOOK_ARTICLE_LEFT_BUTTON
) as $p) {
718 $tmp_content .= $p->hook_article_left_button($line);
721 $tags_str = Article
::format_tags_string($tags, $id);
723 $tmp_content .= "<span class='left'>";
725 $tmp_content .= "<img src='images/tag.png' alt='Tags' title='Tags'>
726 <span id=\"ATSTR-$id\">$tags_str</span>
727 <a title=\"".__('Edit tags for this article')."\"
728 href=\"#\" onclick=\"editArticleTags($id)\">(+)</a>";
730 $num_comments = (int) $line["num_comments"];
731 $entry_comments = "";
733 if ($num_comments > 0) {
734 if ($line["comments"]) {
735 $comments_url = htmlspecialchars($line["comments"]);
737 $comments_url = htmlspecialchars($line["link"]);
739 $entry_comments = "<a class=\"postComments\"
740 target='_blank' rel='noopener noreferrer' href=\"$comments_url\">$num_comments ".
741 _ngettext("comment", "comments", $num_comments)."</a>";
744 if ($line["comments"] && $line["link"] != $line["comments"]) {
745 $entry_comments = "<a class=\"postComments\" target='_blank' rel='noopener noreferrer' href=\"".htmlspecialchars($line["comments"])."\">".__("comments")."</a>";
749 if ($entry_comments) $tmp_content .= " ($entry_comments)";
751 $tmp_content .= "</span>";
752 $tmp_content .= "<div>";
754 // $tmp_content .= "$marked_pic";
755 // $tmp_content .= "$published_pic";
757 foreach (PluginHost
::getInstance()->get_hooks(PluginHost
::HOOK_ARTICLE_BUTTON
) as $p) {
758 $tmp_content .= $p->hook_article_button($line);
761 $tmp_content .= "</div>"; // buttons
763 $tmp_content .= "</div>"; // cdmFooter
764 $tmp_content .= "</div>"; // cdmContent
765 $tmp_content .= "</div>"; // RROW.cdm
767 foreach (PluginHost
::getInstance()->get_hooks(PluginHost
::HOOK_FORMAT_ARTICLE_CDM
) as $p) {
768 $tmp_content = $p->hook_format_article_cdm($tmp_content, $line);
771 $reply['content'] .= $tmp_content;
777 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("PE", $timing_info);
779 } else if (!is_numeric($result)) {
782 switch ($view_mode) {
784 $message = __("No unread articles found to display.");
787 $message = __("No updated articles found to display.");
790 $message = __("No starred articles found to display.");
793 if ($feed < LABEL_BASE_INDEX
) {
794 $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.");
796 $message = __("No articles found to display.");
800 if (!$offset && $message) {
801 $reply['content'] = "<div class='whiteBox'>$message";
803 $reply['content'] .= "<p><span class=\"insensitive\">";
805 $result = $this->dbh
->query("SELECT ".SUBSTRING_FOR_DATE
."(MAX(last_updated), 1, 19) AS last_updated FROM ttrss_feeds
806 WHERE owner_uid = " . $_SESSION['uid']);
808 $last_updated = $this->dbh
->fetch_result($result, 0, "last_updated");
809 $last_updated = make_local_datetime($last_updated, false);
811 $reply['content'] .= sprintf(__("Feeds last updated at %s"), $last_updated);
813 $result = $this->dbh
->query("SELECT COUNT(id) AS num_errors
814 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]);
816 $num_errors = $this->dbh
->fetch_result($result, 0, "num_errors");
818 if ($num_errors > 0) {
819 $reply['content'] .= "<br/>";
820 $reply['content'] .= "<a class=\"insensitive\" href=\"#\" onclick=\"showFeedsWithErrors()\">".
821 __('Some feeds have update errors (click for details)')."</a>";
823 $reply['content'] .= "</span></p></div>";
826 } else if (is_numeric($result) && $result == -1) {
827 $reply['first_id_changed'] = true;
830 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("H2", $timing_info);
832 return array($topmost_article_ids, $headlines_count, $feed, $disable_cache,
833 $vgroup_last_feed, $reply);
836 function catchupAll() {
837 $this->dbh
->query("UPDATE ttrss_user_entries SET
838 last_read = NOW(), unread = false WHERE unread = true AND owner_uid = " . $_SESSION["uid"]);
839 CCache
::zero_all($_SESSION["uid"]);
843 $timing_info = microtime(true);
847 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("0", $timing_info);
849 $feed = $this->dbh
->escape_string($_REQUEST["feed"]);
850 $method = $this->dbh
->escape_string($_REQUEST["m"]);
851 $view_mode = $this->dbh
->escape_string($_REQUEST["view_mode"]);
853 @$cat_view = $_REQUEST["cat"] == "true";
854 @$next_unread_feed = $this->dbh
->escape_string($_REQUEST["nuf"]);
855 @$offset = $this->dbh
->escape_string($_REQUEST["skip"]);
856 @$vgroup_last_feed = $this->dbh
->escape_string($_REQUEST["vgrlf"]);
857 $order_by = $this->dbh
->escape_string($_REQUEST["order_by"]);
858 $check_first_id = $this->dbh
->escape_string($_REQUEST["fid"]);
860 if (is_numeric($feed)) $feed = (int) $feed;
862 /* Feed -5 is a special case: it is used to display auxiliary information
863 * when there's nothing to load - e.g. no stuff in fresh feed */
866 print json_encode($this->generate_dashboard_feed());
872 if ($feed < LABEL_BASE_INDEX
) {
873 $label_feed = Labels
::feed_to_label_id($feed);
874 $result = $this->dbh
->query("SELECT id FROM ttrss_labels2 WHERE
875 id = '$label_feed' AND owner_uid = " . $_SESSION['uid']);
876 } else if (!$cat_view && is_numeric($feed) && $feed > 0) {
877 $result = $this->dbh
->query("SELECT id FROM ttrss_feeds WHERE
878 id = '$feed' AND owner_uid = " . $_SESSION['uid']);
879 } else if ($cat_view && is_numeric($feed) && $feed > 0) {
880 $result = $this->dbh
->query("SELECT id FROM ttrss_feed_categories WHERE
881 id = '$feed' AND owner_uid = " . $_SESSION['uid']);
884 if ($result && $this->dbh
->num_rows($result) == 0) {
885 print json_encode($this->generate_error_feed(__("Feed not found.")));
889 /* Updating a label ccache means recalculating all of the caches
890 * so for performance reasons we don't do that here */
893 CCache
::update($feed, $_SESSION["uid"], $cat_view);
896 set_pref("_DEFAULT_VIEW_MODE", $view_mode);
897 set_pref("_DEFAULT_VIEW_ORDER_BY", $order_by);
899 /* bump login timestamp if needed */
900 if (time() - $_SESSION["last_login_update"] > 3600) {
901 $this->dbh
->query("UPDATE ttrss_users SET last_login = NOW() WHERE id = " .
903 $_SESSION["last_login_update"] = time();
906 if (!$cat_view && is_numeric($feed) && $feed > 0) {
907 $this->dbh
->query("UPDATE ttrss_feeds SET last_viewed = NOW()
908 WHERE id = '$feed' AND owner_uid = ".$_SESSION["uid"]);
911 $reply['headlines'] = array();
913 $override_order = false;
914 $skip_first_id_check = false;
918 $override_order = "ttrss_entries.title, date_entered, updated";
921 $override_order = "score DESC, date_entered, updated";
922 $skip_first_id_check = true;
925 $override_order = "updated DESC";
929 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("04", $timing_info);
931 $ret = $this->format_headlines_list($feed, $method,
932 $view_mode, $limit, $cat_view, $offset,
933 $vgroup_last_feed, $override_order, true, $check_first_id, $skip_first_id_check);
935 //$topmost_article_ids = $ret[0];
936 $headlines_count = $ret[1];
937 /* $returned_feed = $ret[2]; */
938 $disable_cache = $ret[3];
939 $vgroup_last_feed = $ret[4];
941 //$reply['headlines']['content'] =& $ret[5]['content'];
942 //$reply['headlines']['toolbar'] =& $ret[5]['toolbar'];
944 $reply['headlines'] = $ret[5];
946 if (!$next_unread_feed)
947 $reply['headlines']['id'] = $feed;
949 $reply['headlines']['id'] = $next_unread_feed;
951 $reply['headlines']['is_cat'] = (bool) $cat_view;
953 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("05", $timing_info);
955 $reply['headlines-info'] = array("count" => (int) $headlines_count,
956 "vgroup_last_feed" => $vgroup_last_feed,
957 "disable_cache" => (bool) $disable_cache);
959 if ($_REQUEST["debug"]) $timing_info = print_checkpoint("30", $timing_info);
961 $reply['runtime-info'] = make_runtime_info();
963 print json_encode($reply);
967 private function generate_dashboard_feed() {
970 $reply['headlines']['id'] = -5;
971 $reply['headlines']['is_cat'] = false;
973 $reply['headlines']['toolbar'] = '';
975 $reply['headlines']['content'] = "<div class='whiteBox'>".__('No feed selected.');
977 $reply['headlines']['content'] .= "<p><span class=\"insensitive\">";
979 $result = $this->dbh
->query("SELECT ".SUBSTRING_FOR_DATE
."(MAX(last_updated), 1, 19) AS last_updated FROM ttrss_feeds
980 WHERE owner_uid = " . $_SESSION['uid']);
982 $last_updated = $this->dbh
->fetch_result($result, 0, "last_updated");
983 $last_updated = make_local_datetime($last_updated, false);
985 $reply['headlines']['content'] .= sprintf(__("Feeds last updated at %s"), $last_updated);
987 $result = $this->dbh
->query("SELECT COUNT(id) AS num_errors
988 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]);
990 $num_errors = $this->dbh
->fetch_result($result, 0, "num_errors");
992 if ($num_errors > 0) {
993 $reply['headlines']['content'] .= "<br/>";
994 $reply['headlines']['content'] .= "<a class=\"insensitive\" href=\"#\" onclick=\"showFeedsWithErrors()\">".
995 __('Some feeds have update errors (click for details)')."</a>";
997 $reply['headlines']['content'] .= "</span></p>";
999 $reply['headlines-info'] = array("count" => 0,
1000 "vgroup_last_feed" => '',
1002 "disable_cache" => true);
1007 private function generate_error_feed($error) {
1010 $reply['headlines']['id'] = -7;
1011 $reply['headlines']['is_cat'] = false;
1013 $reply['headlines']['toolbar'] = '';
1014 $reply['headlines']['content'] = "<div class='whiteBox'>". $error . "</div>";
1016 $reply['headlines-info'] = array("count" => 0,
1017 "vgroup_last_feed" => '',
1019 "disable_cache" => true);
1024 function quickAddFeed() {
1025 print_hidden("op", "rpc");
1026 print_hidden("method", "addfeed");
1028 print "<div id='fadd_error_message' style='display : none' class='alert alert-danger'></div>";
1030 print "<div id='fadd_multiple_notify' style='display : none'>";
1031 print_notice("Provided URL is a HTML page referencing multiple feeds, please select required feed from the dropdown menu below.");
1034 print "<div class=\"dlgSec\">".__("Feed or site URL")."</div>";
1035 print "<div class=\"dlgSecCont\">";
1037 print "<div style='float : right'>
1038 <img style='display : none'
1039 id='feed_add_spinner' src='images/indicator_white.gif'></div>";
1041 print "<input style=\"font-size : 16px; width : 20em;\"
1042 placeHolder=\"".__("Feed or site URL")."\"
1043 dojoType=\"dijit.form.ValidationTextBox\" required=\"1\" name=\"feed\" id=\"feedDlg_feedUrl\">";
1047 if (get_pref('ENABLE_FEED_CATS')) {
1048 print __('Place in category:') . " ";
1049 print_feed_cat_select("cat", false, 'dojoType="dijit.form.Select"');
1054 print '<div id="feedDlg_feedsContainer" style="display : none">
1056 <div class="dlgSec">' . __('Available feeds') . '</div>
1057 <div class="dlgSecCont">'.
1058 '<select id="feedDlg_feedContainerSelect"
1059 dojoType="dijit.form.Select" size="3">
1060 <script type="dojo/method" event="onChange" args="value">
1061 dijit.byId("feedDlg_feedUrl").attr("value", value);
1066 print "<div id='feedDlg_loginContainer' style='display : none'>
1068 <div class=\"dlgSec\">".__("Authentication")."</div>
1069 <div class=\"dlgSecCont\">".
1071 " <input dojoType=\"dijit.form.TextBox\" name='login'\"
1072 placeHolder=\"".__("Login")."\"
1073 autocomplete=\"new-password\"
1074 style=\"width : 10em;\"> ".
1076 placeHolder=\"".__("Password")."\"
1077 dojoType=\"dijit.form.TextBox\" type='password'
1078 autocomplete=\"new-password\"
1079 style=\"width : 10em;\" name='pass'\">
1083 print "<div style=\"clear : both\">
1084 <input type=\"checkbox\" name=\"need_auth\" dojoType=\"dijit.form.CheckBox\" id=\"feedDlg_loginCheck\"
1085 onclick='checkboxToggleElement(this, \"feedDlg_loginContainer\")'>
1086 <label for=\"feedDlg_loginCheck\">".
1087 __('This feed requires authentication.')."</div>";
1091 print "<div class=\"dlgButtons\">
1092 <button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('feedAddDlg').execute()\">".__('Subscribe')."</button>";
1094 if (!(defined('_DISABLE_FEED_BROWSER') && _DISABLE_FEED_BROWSER
)) {
1095 print "<button dojoType=\"dijit.form.Button\" onclick=\"return feedBrowser()\">".__('More feeds')."</button>";
1098 print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('feedAddDlg').hide()\">".__('Cancel')."</button>
1104 function feedBrowser() {
1105 if (defined('_DISABLE_FEED_BROWSER') && _DISABLE_FEED_BROWSER
) return;
1107 $browser_search = $this->dbh
->escape_string($_REQUEST["search"]);
1109 print_hidden("op", "rpc");
1110 print_hidden("method", "updateFeedBrowser");
1112 print "<div dojoType=\"dijit.Toolbar\">
1113 <div style='float : right'>
1114 <img style='display : none'
1115 id='feed_browser_spinner' src='images/indicator_white.gif'>
1116 <input name=\"search\" dojoType=\"dijit.form.TextBox\" size=\"20\" type=\"search\"
1117 onchange=\"dijit.byId('feedBrowserDlg').update()\" value=\"$browser_search\">
1118 <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('feedBrowserDlg').update()\">".__('Search')."</button>
1121 print " <select name=\"mode\" dojoType=\"dijit.form.Select\" onchange=\"dijit.byId('feedBrowserDlg').update()\">
1122 <option value='1'>" . __('Popular feeds') . "</option>
1123 <option value='2'>" . __('Feed archive') . "</option>
1128 print " <select dojoType=\"dijit.form.Select\" name=\"limit\" onchange=\"dijit.byId('feedBrowserDlg').update()\">";
1130 foreach (array(25, 50, 100, 200) as $l) {
1131 //$issel = ($l == $limit) ? "selected=\"1\"" : "";
1132 print "<option value=\"$l\">$l</option>";
1139 require_once "feedbrowser.php";
1141 print "<ul class='browseFeedList' id='browseFeedList'>";
1142 print make_feed_browser("", 25);
1145 print "<div align='center'>
1146 <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('feedBrowserDlg').execute()\">".__('Subscribe')."</button>
1147 <button dojoType=\"dijit.form.Button\" style='display : none' id='feed_archive_remove' onclick=\"dijit.byId('feedBrowserDlg').removeFromArchive()\">".__('Remove')."</button>
1148 <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('feedBrowserDlg').hide()\" >".__('Cancel')."</button></div>";
1153 $this->params
= explode(":", $this->dbh
->escape_string($_REQUEST["param"]), 2);
1155 $active_feed_id = sprintf("%d", $this->params
[0]);
1156 $is_cat = $this->params
[1] != "false";
1158 print "<div class=\"dlgSec\">".__('Look for')."</div>";
1160 print "<div class=\"dlgSecCont\">";
1162 print "<input dojoType=\"dijit.form.ValidationTextBox\"
1163 style=\"font-size : 16px; width : 20em;\"
1164 required=\"1\" name=\"query\" type=\"search\" value=''>";
1166 print "<hr/><span style='float : right'>".T_sprintf('in %s', $this->getFeedTitle($active_feed_id, $is_cat))."</span>";
1168 if (DB_TYPE
== "pgsql") {
1170 print_select("search_language", "", Pref_Feeds
::$feed_languages,
1171 "dojoType='dijit.form.Select' title=\"".__('Used for word stemming')."\"");
1176 print "<div class=\"dlgButtons\">";
1178 if (count(PluginHost
::getInstance()->get_hooks(PluginHost
::HOOK_SEARCH
)) == 0) {
1179 print "<div style=\"float : left\">
1180 <a class=\"visibleLink\" target=\"_blank\" href=\"http://tt-rss.org/wiki/SearchSyntax\">".__("Search syntax")."</a>
1184 print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('searchDlg').execute()\">".__('Search')."</button>
1185 <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('searchDlg').hide()\">".__('Cancel')."</button>
1189 function update_debugger() {
1190 header("Content-type: text/html");
1192 $feed_id = (int)$_REQUEST["feed_id"];
1193 @$do_update = $_REQUEST["action"] == "do_update";
1194 $csrf_token = $_REQUEST["csrf_token"];
1196 $refetch_checked = isset($_REQUEST["force_refetch"]) ?
"checked" : "";
1197 $rehash_checked = isset($_REQUEST["force_rehash"]) ?
"checked" : "";
1202 <link rel
="stylesheet" type
="text/css" href
="css/utility.css">
1203 <title
>Feed Debugger
</title
>
1205 <body
class="small_margins">
1206 <h1
>Feed Debugger
: <?php
echo "$feed_id: " . $this->getFeedTitle($feed_id) ?
></h1
>
1207 <form method
="GET" action
="">
1208 <input type
="hidden" name
="op" value
="feeds">
1209 <input type
="hidden" name
="method" value
="update_debugger">
1210 <input type
="hidden" name
="xdebug" value
="1">
1211 <input type
="hidden" name
="csrf_token" value
="<?php echo $csrf_token ?>">
1212 <input type
="hidden" name
="action" value
="do_update">
1213 <input type
="hidden" name
="feed_id" value
="<?php echo $feed_id ?>">
1214 <input type
="checkbox" name
="force_refetch" value
="1" <?php
echo $refetch_checked ?
>> Force refetch
<br
/>
1215 <input type
="checkbox" name
="force_rehash" value
="1" <?php
echo $rehash_checked ?
>> Force rehash
<br
/>
1217 <p
/><button type
="submit">Continue</button
>
1225 RSSUtils
::update_rss_feed($feed_id, true);
1236 static function catchup_feed($feed, $cat_view, $owner_uid = false, $mode = 'all', $search = false) {
1238 if (!$owner_uid) $owner_uid = $_SESSION['uid'];
1240 // Todo: all this interval stuff needs some generic generator function
1242 $date_qpart = "false";
1243 $search_qpart = is_array($search) && $search[0] ?
search_to_sql($search[0], $search[1])[0] : 'true';
1247 if (DB_TYPE
== "pgsql") {
1248 $date_qpart = "date_entered < NOW() - INTERVAL '1 day' ";
1250 $date_qpart = "date_entered < DATE_SUB(NOW(), INTERVAL 1 DAY) ";
1254 if (DB_TYPE
== "pgsql") {
1255 $date_qpart = "date_entered < NOW() - INTERVAL '1 week' ";
1257 $date_qpart = "date_entered < DATE_SUB(NOW(), INTERVAL 1 WEEK) ";
1261 if (DB_TYPE
== "pgsql") {
1262 $date_qpart = "date_entered < NOW() - INTERVAL '2 week' ";
1264 $date_qpart = "date_entered < DATE_SUB(NOW(), INTERVAL 2 WEEK) ";
1268 $date_qpart = "true";
1271 if (is_numeric($feed)) {
1277 $children = Feeds
::getChildCategories($feed, $owner_uid);
1278 array_push($children, $feed);
1280 $children = join(",", $children);
1282 $cat_qpart = "cat_id IN ($children)";
1284 $cat_qpart = "cat_id IS NULL";
1287 db_query("UPDATE ttrss_user_entries
1288 SET unread = false, last_read = NOW() WHERE ref_id IN
1290 (SELECT DISTINCT id FROM ttrss_entries, ttrss_user_entries WHERE ref_id = id
1291 AND owner_uid = $owner_uid AND unread = true AND feed_id IN
1292 (SELECT id FROM ttrss_feeds WHERE $cat_qpart) AND $date_qpart AND $search_qpart) as tmp)");
1294 } else if ($feed == -2) {
1296 db_query("UPDATE ttrss_user_entries
1297 SET unread = false,last_read = NOW() WHERE (SELECT COUNT(*)
1298 FROM ttrss_user_labels2, ttrss_entries WHERE article_id = ref_id AND id = ref_id AND $date_qpart AND $search_qpart) > 0
1299 AND unread = true AND owner_uid = $owner_uid");
1302 } else if ($feed > 0) {
1304 db_query("UPDATE ttrss_user_entries
1305 SET unread = false, last_read = NOW() WHERE ref_id IN
1307 (SELECT DISTINCT id FROM ttrss_entries, ttrss_user_entries WHERE ref_id = id
1308 AND owner_uid = $owner_uid AND unread = true AND feed_id = $feed AND $date_qpart AND $search_qpart) as tmp)");
1310 } else if ($feed < 0 && $feed > LABEL_BASE_INDEX
) { // special, like starred
1313 db_query("UPDATE ttrss_user_entries
1314 SET unread = false, last_read = NOW() WHERE ref_id IN
1316 (SELECT DISTINCT id FROM ttrss_entries, ttrss_user_entries WHERE ref_id = id
1317 AND owner_uid = $owner_uid AND unread = true AND marked = true AND $date_qpart AND $search_qpart) as tmp)");
1321 db_query("UPDATE ttrss_user_entries
1322 SET unread = false, last_read = NOW() WHERE ref_id IN
1324 (SELECT DISTINCT id FROM ttrss_entries, ttrss_user_entries WHERE ref_id = id
1325 AND owner_uid = $owner_uid AND unread = true AND published = true AND $date_qpart AND $search_qpart) as tmp)");
1330 $intl = get_pref("FRESH_ARTICLE_MAX_AGE");
1332 if (DB_TYPE
== "pgsql") {
1333 $match_part = "date_entered > NOW() - INTERVAL '$intl hour' ";
1335 $match_part = "date_entered > DATE_SUB(NOW(),
1336 INTERVAL $intl HOUR) ";
1339 db_query("UPDATE ttrss_user_entries
1340 SET unread = false, last_read = NOW() WHERE ref_id IN
1342 (SELECT DISTINCT id FROM ttrss_entries, ttrss_user_entries WHERE ref_id = id
1343 AND owner_uid = $owner_uid AND score >= 0 AND unread = true AND $date_qpart AND $match_part AND $search_qpart) as tmp)");
1347 db_query("UPDATE ttrss_user_entries
1348 SET unread = false, last_read = NOW() WHERE ref_id IN
1350 (SELECT DISTINCT id FROM ttrss_entries, ttrss_user_entries WHERE ref_id = id
1351 AND owner_uid = $owner_uid AND unread = true AND $date_qpart AND $search_qpart) as tmp)");
1354 } else if ($feed < LABEL_BASE_INDEX
) { // label
1356 $label_id = Labels
::feed_to_label_id($feed);
1358 db_query("UPDATE ttrss_user_entries
1359 SET unread = false, last_read = NOW() WHERE ref_id IN
1361 (SELECT DISTINCT ttrss_entries.id FROM ttrss_entries, ttrss_user_entries, ttrss_user_labels2 WHERE ref_id = id
1362 AND label_id = '$label_id' AND ref_id = article_id
1363 AND owner_uid = $owner_uid AND unread = true AND $date_qpart AND $search_qpart) as tmp)");
1367 CCache
::update($feed, $owner_uid, $cat_view);
1370 db_query("UPDATE ttrss_user_entries
1371 SET unread = false, last_read = NOW() WHERE ref_id IN
1373 (SELECT DISTINCT ttrss_entries.id FROM ttrss_entries, ttrss_user_entries, ttrss_tags WHERE ref_id = ttrss_entries.id
1374 AND post_int_id = int_id AND tag_name = '$feed'
1375 AND ttrss_user_entries.owner_uid = $owner_uid AND unread = true AND $date_qpart AND $search_qpart) as tmp)");
1380 static function getFeedArticles($feed, $is_cat = false, $unread_only = false,
1381 $owner_uid = false) {
1383 $n_feed = (int) $feed;
1384 $need_entries = false;
1386 if (!$owner_uid) $owner_uid = $_SESSION["uid"];
1389 $unread_qpart = "unread = true";
1391 $unread_qpart = "true";
1395 return Feeds
::getCategoryUnread($n_feed, $owner_uid);
1396 } else if ($n_feed == -6) {
1398 } else if ($feed != "0" && $n_feed == 0) {
1400 $feed = db_escape_string($feed);
1402 $result = db_query("SELECT SUM((SELECT COUNT(int_id)
1403 FROM ttrss_user_entries,ttrss_entries WHERE int_id = post_int_id
1404 AND ref_id = id AND $unread_qpart)) AS count FROM ttrss_tags
1405 WHERE owner_uid = $owner_uid AND tag_name = '$feed'");
1406 return db_fetch_result($result, 0, "count");
1408 } else if ($n_feed == -1) {
1409 $match_part = "marked = true";
1410 } else if ($n_feed == -2) {
1411 $match_part = "published = true";
1412 } else if ($n_feed == -3) {
1413 $match_part = "unread = true AND score >= 0";
1415 $intl = get_pref("FRESH_ARTICLE_MAX_AGE", $owner_uid);
1417 if (DB_TYPE
== "pgsql") {
1418 $match_part .= " AND date_entered > NOW() - INTERVAL '$intl hour' ";
1420 $match_part .= " AND date_entered > DATE_SUB(NOW(), INTERVAL $intl HOUR) ";
1423 $need_entries = true;
1425 } else if ($n_feed == -4) {
1426 $match_part = "true";
1427 } else if ($n_feed >= 0) {
1430 $match_part = "feed_id = '$n_feed'";
1432 $match_part = "feed_id IS NULL";
1435 } else if ($feed < LABEL_BASE_INDEX
) {
1437 $label_id = Labels
::feed_to_label_id($feed);
1439 return Feeds
::getLabelUnread($label_id, $owner_uid);
1445 if ($need_entries) {
1446 $from_qpart = "ttrss_user_entries,ttrss_entries";
1447 $from_where = "ttrss_entries.id = ttrss_user_entries.ref_id AND";
1449 $from_qpart = "ttrss_user_entries";
1453 $query = "SELECT count(int_id) AS unread
1454 FROM $from_qpart WHERE
1455 $unread_qpart AND $from_where ($match_part) AND ttrss_user_entries.owner_uid = $owner_uid";
1457 //echo "[$feed/$query]\n";
1459 $result = db_query($query);
1463 $result = db_query("SELECT COUNT(post_int_id) AS unread
1464 FROM ttrss_tags,ttrss_user_entries,ttrss_entries
1465 WHERE tag_name = '$feed' AND post_int_id = int_id AND ref_id = ttrss_entries.id
1466 AND $unread_qpart AND ttrss_tags.owner_uid = " . $owner_uid);
1469 $unread = db_fetch_result($result, 0, "unread");
1475 * @return array (code => Status code, message => error message if available)
1477 * 0 - OK, Feed already exists
1478 * 1 - OK, Feed added
1480 * 3 - URL content is HTML, no feeds available
1481 * 4 - URL content is HTML which contains multiple feeds.
1482 * Here you should call extractfeedurls in rpc-backend
1483 * to get all possible feeds.
1484 * 5 - Couldn't download the URL content.
1485 * 6 - Content is an invalid XML.
1487 static function subscribe_to_feed($url, $cat_id = 0,
1488 $auth_login = '', $auth_pass = '') {
1490 global $fetch_last_error;
1491 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 == "0" ||
!$cat_id) {
1524 $cat_qpart = "NULL";
1526 $cat_qpart = "'$cat_id'";
1530 "SELECT id FROM ttrss_feeds
1531 WHERE feed_url = '$url' AND owner_uid = ".$_SESSION["uid"]);
1533 $auth_pass = db_escape_string($auth_pass);
1535 if (db_num_rows($result) == 0) {
1537 "INSERT INTO ttrss_feeds
1538 (owner_uid,feed_url,title,cat_id, auth_login,auth_pass,update_method,auth_pass_encrypted)
1539 VALUES ('".$_SESSION["uid"]."', '$url',
1540 '[Unknown]', $cat_qpart, '$auth_login', '$auth_pass', 0, false)");
1543 "SELECT id FROM ttrss_feeds WHERE feed_url = '$url'
1544 AND owner_uid = " . $_SESSION["uid"]);
1546 $feed_id = db_fetch_result($result, 0, "id");
1549 RSSUtils
::set_basic_feed_info($feed_id);
1552 return array("code" => 1, "feed_id" => (int) $feed_id);
1554 return array("code" => 0, "feed_id" => (int) db_fetch_result($result, 0, "id"));
1558 static function getFeedIcon($id) {
1561 return "images/archive.png";
1564 return "images/star.png";
1567 return "images/feed.png";
1570 return "images/fresh.png";
1573 return "images/folder.png";
1576 return "images/time.png";
1579 if ($id < LABEL_BASE_INDEX
) {
1580 return "images/label.png";
1582 if (file_exists(ICONS_DIR
. "/$id.ico"))
1583 return ICONS_URL
. "/$id.ico";
1591 static function getFeedTitle($id, $cat = false) {
1593 return Feeds
::getCategoryTitle($id);
1594 } else if ($id == -1) {
1595 return __("Starred articles");
1596 } else if ($id == -2) {
1597 return __("Published articles");
1598 } else if ($id == -3) {
1599 return __("Fresh articles");
1600 } else if ($id == -4) {
1601 return __("All articles");
1602 } else if ($id === 0 ||
$id === "0") {
1603 return __("Archived articles");
1604 } else if ($id == -6) {
1605 return __("Recently read");
1606 } else if ($id < LABEL_BASE_INDEX
) {
1607 $label_id = Labels
::feed_to_label_id($id);
1608 $result = db_query("SELECT caption FROM ttrss_labels2 WHERE id = '$label_id'");
1609 if (db_num_rows($result) == 1) {
1610 return db_fetch_result($result, 0, "caption");
1612 return "Unknown label ($label_id)";
1615 } else if (is_numeric($id) && $id > 0) {
1616 $result = db_query("SELECT title FROM ttrss_feeds WHERE id = '$id'");
1617 if (db_num_rows($result) == 1) {
1618 return db_fetch_result($result, 0, "title");
1620 return "Unknown feed ($id)";
1627 static function getCategoryUnread($cat, $owner_uid = false) {
1629 if (!$owner_uid) $owner_uid = $_SESSION["uid"];
1634 $cat_query = "cat_id = '$cat'";
1636 $cat_query = "cat_id IS NULL";
1639 $result = db_query("SELECT id FROM ttrss_feeds WHERE $cat_query
1640 AND owner_uid = " . $owner_uid);
1642 $cat_feeds = array();
1643 while ($line = db_fetch_assoc($result)) {
1644 array_push($cat_feeds, "feed_id = " . $line["id"]);
1647 if (count($cat_feeds) == 0) return 0;
1649 $match_part = implode(" OR ", $cat_feeds);
1651 $result = db_query("SELECT COUNT(int_id) AS unread
1652 FROM ttrss_user_entries
1653 WHERE unread = true AND ($match_part)
1654 AND owner_uid = " . $owner_uid);
1658 # this needs to be rewritten
1659 while ($line = db_fetch_assoc($result)) {
1660 $unread +
= $line["unread"];
1664 } else if ($cat == -1) {
1665 return getFeedUnread(-1) +
getFeedUnread(-2) +
getFeedUnread(-3) +
getFeedUnread(0);
1666 } else if ($cat == -2) {
1668 $result = db_query("
1669 SELECT COUNT(unread) AS unread FROM
1670 ttrss_user_entries, ttrss_user_labels2
1671 WHERE article_id = ref_id AND unread = true
1672 AND ttrss_user_entries.owner_uid = '$owner_uid'");
1674 $unread = db_fetch_result($result, 0, "unread");
1681 // only accepts real cats (>= 0)
1682 static function getCategoryChildrenUnread($cat, $owner_uid = false) {
1683 if (!$owner_uid) $owner_uid = $_SESSION["uid"];
1685 $result = db_query("SELECT id FROM ttrss_feed_categories WHERE parent_cat = '$cat'
1686 AND owner_uid = $owner_uid");
1690 while ($line = db_fetch_assoc($result)) {
1691 $unread +
= Feeds
::getCategoryUnread($line["id"], $owner_uid);
1692 $unread +
= Feeds
::getCategoryChildrenUnread($line["id"], $owner_uid);
1698 static function getGlobalUnread($user_id = false) {
1701 $user_id = $_SESSION["uid"];
1704 $result = db_query("SELECT SUM(value) AS c_id FROM ttrss_counters_cache
1705 WHERE owner_uid = '$user_id' AND feed_id > 0");
1707 $c_id = db_fetch_result($result, 0, "c_id");
1712 static function getCategoryTitle($cat_id) {
1714 if ($cat_id == -1) {
1715 return __("Special");
1716 } else if ($cat_id == -2) {
1717 return __("Labels");
1720 $result = db_query("SELECT title FROM ttrss_feed_categories WHERE
1723 if (db_num_rows($result) == 1) {
1724 return db_fetch_result($result, 0, "title");
1726 return __("Uncategorized");
1731 static function getLabelUnread($label_id, $owner_uid = false) {
1732 if (!$owner_uid) $owner_uid = $_SESSION["uid"];
1734 $result = db_query("SELECT COUNT(ref_id) AS unread FROM ttrss_user_entries, ttrss_user_labels2
1735 WHERE owner_uid = '$owner_uid' AND unread = true AND label_id = '$label_id' AND article_id = ref_id");
1737 if (db_num_rows($result) != 0) {
1738 return db_fetch_result($result, 0, "unread");
1744 static function queryFeedHeadlines($params) {
1746 $feed = $params["feed"];
1747 $limit = isset($params["limit"]) ?
$params["limit"] : 30;
1748 $view_mode = $params["view_mode"];
1749 $cat_view = isset($params["cat_view"]) ?
$params["cat_view"] : false;
1750 $search = isset($params["search"]) ?
$params["search"] : false;
1751 $search_language = isset($params["search_language"]) ?
$params["search_language"] : "";
1752 $override_order = isset($params["override_order"]) ?
$params["override_order"] : false;
1753 $offset = isset($params["offset"]) ?
$params["offset"] : 0;
1754 $owner_uid = isset($params["owner_uid"]) ?
$params["owner_uid"] : $_SESSION["uid"];
1755 $since_id = isset($params["since_id"]) ?
$params["since_id"] : 0;
1756 $include_children = isset($params["include_children"]) ?
$params["include_children"] : false;
1757 $ignore_vfeed_group = isset($params["ignore_vfeed_group"]) ?
$params["ignore_vfeed_group"] : false;
1758 $override_strategy = isset($params["override_strategy"]) ?
$params["override_strategy"] : false;
1759 $override_vfeed = isset($params["override_vfeed"]) ?
$params["override_vfeed"] : false;
1760 $start_ts = isset($params["start_ts"]) ?
$params["start_ts"] : false;
1761 $check_first_id = isset($params["check_first_id"]) ?
$params["check_first_id"] : false;
1762 $skip_first_id_check = isset($params["skip_first_id_check"]) ?
$params["skip_first_id_check"] : false;
1764 $ext_tables_part = "";
1765 $query_strategy_part = "";
1767 $search_words = array();
1770 foreach (PluginHost
::getInstance()->get_hooks(PluginHost
::HOOK_SEARCH
) as $plugin) {
1771 list($search_query_part, $search_words) = $plugin->hook_search($search);
1775 // fall back in case of no plugins
1776 if (!$search_query_part) {
1777 list($search_query_part, $search_words) = search_to_sql($search, $search_language);
1779 $search_query_part .= " AND ";
1781 $search_query_part = "";
1785 $since_id_part = "ttrss_entries.id > $since_id AND ";
1787 $since_id_part = "";
1790 $view_query_part = "";
1792 if ($view_mode == "adaptive") {
1794 $view_query_part = " ";
1795 } else if ($feed != -1) {
1797 $unread = getFeedUnread($feed, $cat_view);
1799 if ($cat_view && $feed > 0 && $include_children)
1800 $unread +
= Feeds
::getCategoryChildrenUnread($feed);
1803 $view_query_part = " unread = true AND ";
1808 if ($view_mode == "marked") {
1809 $view_query_part = " marked = true AND ";
1812 if ($view_mode == "has_note") {
1813 $view_query_part = " (note IS NOT NULL AND note != '') AND ";
1816 if ($view_mode == "published") {
1817 $view_query_part = " published = true AND ";
1820 if ($view_mode == "unread" && $feed != -6) {
1821 $view_query_part = " unread = true AND ";
1825 $limit_query_part = "LIMIT " . $limit;
1828 $allow_archived = false;
1830 $vfeed_query_part = "";
1833 if (!is_numeric($feed)) {
1834 $query_strategy_part = "true";
1835 $vfeed_query_part = "(SELECT title FROM ttrss_feeds WHERE
1836 id = feed_id) as feed_title,";
1837 } else if ($feed > 0) {
1842 if ($include_children) {
1844 $subcats = Feeds
::getChildCategories($feed, $owner_uid);
1846 array_push($subcats, $feed);
1847 $query_strategy_part = "cat_id IN (".
1848 implode(",", $subcats).")";
1851 $query_strategy_part = "cat_id = '$feed'";
1855 $query_strategy_part = "cat_id IS NULL";
1858 $vfeed_query_part = "ttrss_feeds.title AS feed_title,";
1861 $query_strategy_part = "feed_id = '$feed'";
1863 } else if ($feed == 0 && !$cat_view) { // archive virtual feed
1864 $query_strategy_part = "feed_id IS NULL";
1865 $allow_archived = true;
1866 } else if ($feed == 0 && $cat_view) { // uncategorized
1867 $query_strategy_part = "cat_id IS NULL AND feed_id IS NOT NULL";
1868 $vfeed_query_part = "ttrss_feeds.title AS feed_title,";
1869 } else if ($feed == -1) { // starred virtual feed
1870 $query_strategy_part = "marked = true";
1871 $vfeed_query_part = "ttrss_feeds.title AS feed_title,";
1872 $allow_archived = true;
1874 if (!$override_order) {
1875 $override_order = "last_marked DESC, date_entered DESC, updated DESC";
1878 } else if ($feed == -2) { // published virtual feed OR labels category
1881 $query_strategy_part = "published = true";
1882 $vfeed_query_part = "ttrss_feeds.title AS feed_title,";
1883 $allow_archived = true;
1885 if (!$override_order) {
1886 $override_order = "last_published DESC, date_entered DESC, updated DESC";
1890 $vfeed_query_part = "ttrss_feeds.title AS feed_title,";
1892 $ext_tables_part = "ttrss_labels2,ttrss_user_labels2,";
1894 $query_strategy_part = "ttrss_labels2.id = ttrss_user_labels2.label_id AND
1895 ttrss_user_labels2.article_id = ref_id";
1898 } else if ($feed == -6) { // recently read
1899 $query_strategy_part = "unread = false AND last_read IS NOT NULL";
1901 if (DB_TYPE
== "pgsql") {
1902 $query_strategy_part .= " AND last_read > NOW() - INTERVAL '1 DAY' ";
1904 $query_strategy_part .= " AND last_read > DATE_SUB(NOW(), INTERVAL 1 DAY) ";
1907 $vfeed_query_part = "ttrss_feeds.title AS feed_title,";
1908 $allow_archived = true;
1909 $ignore_vfeed_group = true;
1911 if (!$override_order) $override_order = "last_read DESC";
1913 } else if ($feed == -3) { // fresh virtual feed
1914 $query_strategy_part = "unread = true AND score >= 0";
1916 $intl = get_pref("FRESH_ARTICLE_MAX_AGE", $owner_uid);
1918 if (DB_TYPE
== "pgsql") {
1919 $query_strategy_part .= " AND date_entered > NOW() - INTERVAL '$intl hour' ";
1921 $query_strategy_part .= " AND date_entered > DATE_SUB(NOW(), INTERVAL $intl HOUR) ";
1924 $vfeed_query_part = "ttrss_feeds.title AS feed_title,";
1925 } else if ($feed == -4) { // all articles virtual feed
1926 $allow_archived = true;
1927 $query_strategy_part = "true";
1928 $vfeed_query_part = "ttrss_feeds.title AS feed_title,";
1929 } else if ($feed <= LABEL_BASE_INDEX
) { // labels
1930 $label_id = Labels
::feed_to_label_id($feed);
1932 $query_strategy_part = "label_id = '$label_id' AND
1933 ttrss_labels2.id = ttrss_user_labels2.label_id AND
1934 ttrss_user_labels2.article_id = ref_id";
1936 $vfeed_query_part = "ttrss_feeds.title AS feed_title,";
1937 $ext_tables_part = "ttrss_labels2,ttrss_user_labels2,";
1938 $allow_archived = true;
1941 $query_strategy_part = "true";
1944 $order_by = "score DESC, date_entered DESC, updated DESC";
1946 if ($override_order) {
1947 $order_by = $override_order;
1950 if ($override_strategy) {
1951 $query_strategy_part = $override_strategy;
1954 if ($override_vfeed) {
1955 $vfeed_query_part = $override_vfeed;
1961 $feed_title = T_sprintf("Search results: %s", $search);
1964 $feed_title = Feeds
::getCategoryTitle($feed);
1966 if (is_numeric($feed) && $feed > 0) {
1967 $result = db_query("SELECT title,site_url,last_error,last_updated
1968 FROM ttrss_feeds WHERE id = '$feed' AND owner_uid = $owner_uid");
1970 $feed_title = db_fetch_result($result, 0, "title");
1971 $feed_site_url = db_fetch_result($result, 0, "site_url");
1972 $last_error = db_fetch_result($result, 0, "last_error");
1973 $last_updated = db_fetch_result($result, 0, "last_updated");
1975 $feed_title = Feeds
::getFeedTitle($feed);
1981 $content_query_part = "content, ";
1983 if ($limit_query_part) {
1984 $offset_query_part = "OFFSET $offset";
1986 $offset_query_part = "";
1989 if (is_numeric($feed)) {
1990 // proper override_order applied above
1991 if ($vfeed_query_part && !$ignore_vfeed_group && get_pref('VFEED_GROUP_BY_FEED', $owner_uid)) {
1992 if (!$override_order) {
1993 $order_by = "ttrss_feeds.title, $order_by";
1995 $order_by = "ttrss_feeds.title, $override_order";
1999 if (!$allow_archived) {
2000 $from_qpart = "${ext_tables_part}ttrss_entries LEFT JOIN ttrss_user_entries ON (ref_id = ttrss_entries.id),ttrss_feeds";
2001 $feed_check_qpart = "ttrss_user_entries.feed_id = ttrss_feeds.id AND";
2004 $from_qpart = "${ext_tables_part}ttrss_entries LEFT JOIN ttrss_user_entries ON (ref_id = ttrss_entries.id)
2005 LEFT JOIN ttrss_feeds ON (feed_id = ttrss_feeds.id)";
2008 if ($vfeed_query_part) $vfeed_query_part .= "favicon_avg_color,";
2011 $start_ts_formatted = date("Y/m/d H:i:s", strtotime($start_ts));
2012 $start_ts_query_part = "date_entered >= '$start_ts_formatted' AND";
2014 $start_ts_query_part = "";
2018 $first_id_query_strategy_part = $query_strategy_part;
2021 $first_id_query_strategy_part = "true";
2023 if (DB_TYPE
== "pgsql") {
2024 $sanity_interval_qpart = "date_entered >= NOW() - INTERVAL '1 hour' AND";
2026 $sanity_interval_qpart = "date_entered >= DATE_SUB(NOW(), INTERVAL 1 hour) AND";
2029 if (!$search && !$skip_first_id_check) {
2030 // if previous topmost article id changed that means our current pagination is no longer valid
2031 $query = "SELECT DISTINCT
2036 ttrss_entries.title,
2048 ttrss_user_entries.owner_uid = '$owner_uid' AND
2050 $start_ts_query_part
2052 $sanity_interval_qpart
2053 $first_id_query_strategy_part ORDER BY $order_by LIMIT 1";
2055 if ($_REQUEST["debug"]) {
2059 $result = db_query($query);
2060 if ($result && db_num_rows($result) > 0) {
2061 $first_id = (int)db_fetch_result($result, 0, "id");
2063 if ($offset > 0 && $first_id && $check_first_id && $first_id != $check_first_id) {
2064 return array(-1, $feed_title, $feed_site_url, $last_error, $last_updated, $search_words, $first_id);
2069 $query = "SELECT DISTINCT
2072 ttrss_entries.id,ttrss_entries.title,
2076 always_display_enclosures,
2085 unread,feed_id,marked,published,link,last_read,orig_feed_id,
2086 last_marked, last_published,
2094 ttrss_user_entries.owner_uid = '$owner_uid' AND
2096 $start_ts_query_part
2099 $query_strategy_part ORDER BY $order_by
2100 $limit_query_part $offset_query_part";
2102 if ($_REQUEST["debug"]) print $query;
2104 $result = db_query($query);
2109 $query = "SELECT DISTINCT
2113 ttrss_entries.id as id,
2129 (SELECT hide_images FROM ttrss_feeds WHERE id = feed_id) AS hide_images,
2130 last_marked, last_published,
2135 FROM ttrss_entries, ttrss_user_entries, ttrss_tags
2137 ref_id = ttrss_entries.id AND
2138 ttrss_user_entries.owner_uid = $owner_uid AND
2139 post_int_id = int_id AND
2140 tag_name = '$feed' AND
2143 $query_strategy_part ORDER BY $order_by
2144 $limit_query_part $offset_query_part";
2146 if ($_REQUEST["debug"]) print $query;
2148 $result = db_query($query);
2151 return array($result, $feed_title, $feed_site_url, $last_error, $last_updated, $search_words, $first_id);
2155 static function getParentCategories($cat, $owner_uid) {
2158 $result = db_query("SELECT parent_cat FROM ttrss_feed_categories
2159 WHERE id = '$cat' AND parent_cat IS NOT NULL AND owner_uid = $owner_uid");
2161 while ($line = db_fetch_assoc($result)) {
2162 array_push($rv, $line["parent_cat"]);
2163 $rv = array_merge($rv, Feeds
::getParentCategories($line["parent_cat"], $owner_uid));
2169 static function getChildCategories($cat, $owner_uid) {
2172 $result = db_query("SELECT id FROM ttrss_feed_categories
2173 WHERE parent_cat = '$cat' AND owner_uid = $owner_uid");
2175 while ($line = db_fetch_assoc($result)) {
2176 array_push($rv, $line["id"]);
2177 $rv = array_merge($rv, Feeds
::getChildCategories($line["id"], $owner_uid));
2183 static function getFeedCategory($feed) {
2184 $result = db_query("SELECT cat_id FROM ttrss_feeds
2185 WHERE id = '$feed'");
2187 if (db_num_rows($result) > 0) {
2188 return db_fetch_result($result, 0, "cat_id");