]> git.wh0rd.org - tt-rss.git/blobdiff - classes/feeds.php
minor css fixes (mostly for zoom mode)
[tt-rss.git] / classes / feeds.php
index 983a8551258938a85dd7fe422e3dcc370c8c755b..c8152b9e2f7898a446014c1ea30b608a38365e4c 100755 (executable)
@@ -173,49 +173,10 @@ class Feeds extends Handler_Protected {
                $method_split = explode(":", $method);
 
                if ($method == "ForceUpdate" && $feed > 0 && is_numeric($feed)) {
-                       // Update the feed if required with some basic flood control
-
-                       $any_needs_curl = false;
-
-                       if (ini_get("open_basedir")) {
-                               $pluginhost = PluginHost::getInstance();
-                               foreach ($pluginhost->get_plugins() as $plugin) {
-                                       $flags = $plugin->flags();
-
-                                       if (isset($flags["needs_curl"]) && $flags["needs_curl"]) {
-                                               $any_needs_curl = true;
-                                               break;
-                                       }
-                               }
-                       }
-
-                       //if ($_REQUEST["debug"]) print "<!-- any_needs_curl: $any_needs_curl -->";
-
-                       if (!$any_needs_curl) {
-
-                               $sth = $this->pdo->prepare("SELECT cache_images," . SUBSTRING_FOR_DATE . "(last_updated,1,19) AS last_updated
-                                               FROM ttrss_feeds WHERE id = ?");
-                               $sth->execute([$feed]);
-
-                               if ($row = $sth->fetch()) {
-                                       $last_updated = strtotime($row["last_updated"]);
-                                       $cache_images = $row["cache_images"];
-
-                                       if (!$cache_images && time() - $last_updated > 120) {
-                                               RSSUtils::update_rss_feed($feed, true);
-                                       } else {
-                                               $sth = $this->pdo->prepare("UPDATE ttrss_feeds 
-                                SET last_updated = '1970-01-01', last_update_started = '1970-01-01'
-                                                               WHERE id = ?");
-                                               $sth->execute([$feed]);
-                                       }
-                               }
-                       } else {
-                               $sth = $this->pdo->prepare("UPDATE ttrss_feeds 
-                                SET last_updated = '1970-01-01', last_update_started = '1970-01-01'
-                                                               WHERE id = ?");
-                               $sth->execute([$feed]);
-                       }
+            $sth = $this->pdo->prepare("UPDATE ttrss_feeds
+                            SET last_updated = '1970-01-01', last_update_started = '1970-01-01'
+                            WHERE id = ?");
+            $sth->execute([$feed]);
                }
 
                if ($method_split[0] == "MarkAllReadGR")  {
@@ -286,7 +247,7 @@ class Feeds extends Handler_Protected {
 
                if ($_REQUEST["debug"]) $timing_info = print_checkpoint("H1", $timing_info);
 
-               $result = $qfh_ret[0];
+               $result = $qfh_ret[0]; // this could be either a PDO query result or a -1 if first id changed
                $feed_title = $qfh_ret[1];
                $feed_site_url = $qfh_ret[2];
                $last_error = $qfh_ret[3];
@@ -316,432 +277,397 @@ class Feeds extends Handler_Protected {
         $lnum = $offset;
         $num_unread = 0;
         if ($_REQUEST["debug"]) $timing_info = print_checkpoint("PS", $timing_info);
-        $expand_cdm = get_pref('CDM_EXPANDED');
-
-        while ($line = $result->fetch()) {
-
-            ++$headlines_count;
-
-            $line["content_preview"] =  "&mdash; " . truncate_string(strip_tags($line["content"]), 250);
-
-            foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) {
-                $line = $p->hook_query_headlines($line, 250, false);
-            }
-
-            if (get_pref('SHOW_CONTENT_PREVIEW')) {
-                $content_preview =  $line["content_preview"];
-            }
-
-            $id = $line["id"];
-            $feed_id = $line["feed_id"];
-            $label_cache = $line["label_cache"];
-            $labels = false;
-
-            if ($label_cache) {
-                $label_cache = json_decode($label_cache, true);
-
-                if ($label_cache) {
-                    if ($label_cache["no-labels"] == 1)
-                        $labels = array();
-                    else
-                        $labels = $label_cache;
-                }
-            }
-
-            if (!is_array($labels)) $labels = Article::get_article_labels($id);
-
-            $labels_str = "<span class=\"HLLCTR-$id\">";
-            $labels_str .= Article::format_article_labels($labels);
-            $labels_str .= "</span>";
-
-            if (count($topmost_article_ids) < 3) {
-                array_push($topmost_article_ids, $id);
-            }
-
-            $class = "";
-
-            if ($line["unread"]) {
-                $class .= " Unread";
-                ++$num_unread;
-            }
-
-            if ($line["marked"]) {
-                $marked_pic = "<img
-                    src=\"images/mark_set.png\"
-                    class=\"markedPic\" alt=\"Unstar article\"
-                    onclick='toggleMark($id)'>";
-                $class .= " marked";
-            } else {
-                $marked_pic = "<img
-                    src=\"images/mark_unset.png\"
-                    class=\"markedPic\" alt=\"Star article\"
-                    onclick='toggleMark($id)'>";
-            }
-
-            if ($line["published"]) {
-                $published_pic = "<img src=\"images/pub_set.png\"
-                    class=\"pubPic\"
-                        alt=\"Unpublish article\" onclick='togglePub($id)'>";
-                $class .= " published";
-            } else {
-                $published_pic = "<img src=\"images/pub_unset.png\"
-                    class=\"pubPic\"
-                    alt=\"Publish article\" onclick='togglePub($id)'>";
-            }
-
-            $updated_fmt = make_local_datetime($line["updated"], false, false, false, true);
-            $date_entered_fmt = T_sprintf("Imported at %s",
-                make_local_datetime($line["date_entered"], false));
-
-            $score = $line["score"];
-
-            $score_pic = "images/" . get_score_pic($score);
-
-            $score_pic = "<img class='hlScorePic' score='$score' onclick='changeScore($id, this)' src=\"$score_pic\"
-                title=\"$score\">";
 
-            if ($score > 500) {
-                $hlc_suffix = "high";
-            } else if ($score < -100) {
-                $hlc_suffix = "low";
-            } else {
-                $hlc_suffix = "";
-            }
+        if (is_object($result)) {
 
-            $entry_author = $line["author"];
+                       while ($line = $result->fetch()) {
 
-            if ($entry_author) {
-                $entry_author = " &mdash; $entry_author";
-            }
+                               ++$headlines_count;
 
-            $has_feed_icon = feeds::feedHasIcon($feed_id);
+                               $line["content_preview"] =  "&mdash; " . truncate_string(strip_tags($line["content"]), 250);
 
-            if ($has_feed_icon) {
-                $feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"".ICONS_URL."/$feed_id.ico\" alt=\"\">";
-            } else {
-                $feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"images/pub_set.png\" alt=\"\">";
-            }
+                               foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) {
+                                       $line = $p->hook_query_headlines($line, 250, false);
+                               }
 
-            $entry_site_url = $line["site_url"];
+                               if (get_pref('SHOW_CONTENT_PREVIEW')) {
+                                       $content_preview =  $line["content_preview"];
+                               }
 
-            //setting feed headline background color, needs to change text color based on dark/light
-            $fav_color = $line['favicon_avg_color'];
+                               $id = $line["id"];
+                               $feed_id = $line["feed_id"];
+                               $label_cache = $line["label_cache"];
+                               $labels = false;
 
-            require_once "colors.php";
+                               $mouseover_attrs = "onmouseover='postMouseIn(event, $id)' onmouseout='postMouseOut($id)'";
 
-            if ($fav_color && $fav_color != 'fail') {
-                if (!isset($rgba_cache[$feed_id])) {
-                    $rgba_cache[$feed_id] = join(",", _color_unpack($fav_color));
-                }
-            }
+                               if ($label_cache) {
+                                       $label_cache = json_decode($label_cache, true);
 
-            if (!get_pref('COMBINED_DISPLAY_MODE')) {
+                                       if ($label_cache) {
+                                               if ($label_cache["no-labels"] == 1)
+                                                       $labels = array();
+                                               else
+                                                       $labels = $label_cache;
+                                       }
+                               }
 
-                if ($vfeed_group_enabled) {
-                    if ($feed_id != $vgroup_last_feed && $line["feed_title"]) {
+                               if (!is_array($labels)) $labels = Article::get_article_labels($id);
 
-                        $vgroup_last_feed = $feed_id;
+                               $labels_str = "<span class=\"HLLCTR-$id\">";
+                               $labels_str .= Article::format_article_labels($labels);
+                               $labels_str .= "</span>";
 
-                        $vf_catchup_link = "<a class='catchup' onclick='catchupFeedInGroup($feed_id);' href='#'>".__('mark feed as read')."</a>";
+                               if (count($topmost_article_ids) < 3) {
+                                       array_push($topmost_article_ids, $id);
+                               }
 
-                        $reply['content'] .= "<div data-feed-id='$feed_id' id='FTITLE-$feed_id' class='cdmFeedTitle'>".
-                            "<div style='float : right'>$feed_icon_img</div>".
-                            "<a class='title' href=\"#\" onclick=\"viewfeed({feed:$feed_id})\">".
-                            $line["feed_title"]."</a>
-                            $vf_catchup_link</div>";
+                               $class = "";
+
+                               if ($line["unread"]) {
+                                       $class .= " Unread";
+                                       ++$num_unread;
+                               }
+
+                               $marked_pic_src = $line["marked"] ? "mark_set.png" : "mark_unset.png";
+                               $class .= $line["marked"] ? " marked" : "";
+                               $marked_pic = "<img src=\"images/$marked_pic_src\" class=\"markedPic\" onclick='toggleMark($id)'>";
 
+                               $published_pic_src = $line["published"] ? "pub_set.png" : "pub_unset.png";
+                               $class .= $line["published"] ? " published" : "";
+                $published_pic = "<img src=\"images/$published_pic_src\" class=\"pubPic\" onclick='togglePub($id)'>";
 
-                    }
-                }
+                               $updated_fmt = make_local_datetime($line["updated"], false, false, false, true);
+                               $date_entered_fmt = T_sprintf("Imported at %s",
+                                       make_local_datetime($line["date_entered"], false));
 
-                $mouseover_attrs = "onmouseover='postMouseIn(event, $id)'
-                    onmouseout='postMouseOut($id)'";
+                               $score = $line["score"];
+
+                               $score_pic = "images/" . get_score_pic($score);
+
+                               $score_pic = "<img class='score-pic' score='$score' onclick='changeScore($id, this)' src=\"$score_pic\"
+                title=\"$score\">";
+
+                               if ($score > 500) {
+                                       $hlc_suffix = "high";
+                               } else if ($score < -100) {
+                                       $hlc_suffix = "low";
+                               } else {
+                                       $hlc_suffix = "";
+                               }
+
+                               $entry_author = $line["author"];
+
+                               if ($entry_author) {
+                                       $entry_author = " &mdash; $entry_author";
+                               }
+
+                               if (feeds::feedHasIcon($feed_id)) {
+                                       $feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"".ICONS_URL."/$feed_id.ico\" alt=\"\">";
+                               } else {
+                                       $feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"images/pub_set.png\" alt=\"\">";
+                               }
+
+                               $entry_site_url = $line["site_url"];
+
+                               //setting feed headline background color, needs to change text color based on dark/light
+                               $fav_color = $line['favicon_avg_color'];
+
+                               require_once "colors.php";
+
+                               if ($fav_color && $fav_color != 'fail') {
+                                       if (!isset($rgba_cache[$feed_id])) {
+                                               $rgba_cache[$feed_id] = join(",", _color_unpack($fav_color));
+                                       }
+                               }
+
+                               if (!get_pref('COMBINED_DISPLAY_MODE')) {
+
+                                       if ($vfeed_group_enabled) {
+                                               if ($feed_id != $vgroup_last_feed && $line["feed_title"]) {
+
+                                                       $vgroup_last_feed = $feed_id;
+
+                                                       $vf_catchup_link = "<a class='catchup' onclick='catchupFeedInGroup($feed_id);' href='#'>".__('mark feed as read')."</a>";
+
+                                                       $reply['content'] .= "<div data-feed-id='$feed_id' class='feed-titl'>".
+                                                               "<div style='float : right'>$feed_icon_img</div>".
+                                                               "<a class='title' href=\"#\" onclick=\"viewfeed({feed:$feed_id})\">".
+                                                               $line["feed_title"]."</a>
+                            $vf_catchup_link</div>";
+
+
+                                               }
+                                       }
 
-                $reply['content'] .= "<div class='hl hlMenuAttach $class' data-orig-feed-id='$feed_id' data-article-id='$id' id='RROW-$id' $mouseover_attrs>";
+                                       $reply['content'] .= "<div class='hl hlMenuAttach $class' data-orig-feed-id='$feed_id' data-article-id='$id' id='RROW-$id' $mouseover_attrs>";
 
-                $reply['content'] .= "<div class='hlLeft'>";
+                                       $reply['content'] .= "<div class='hlLeft'>";
 
-                $reply['content'] .= "<input dojoType=\"dijit.form.CheckBox\"
+                                       $reply['content'] .= "<input dojoType=\"dijit.form.CheckBox\"
                         type=\"checkbox\" onclick=\"toggleSelectRow2(this)\"
                         class='rchk'>";
 
-                $reply['content'] .= "$marked_pic";
-                $reply['content'] .= "$published_pic";
+                                       $reply['content'] .= "$marked_pic";
+                                       $reply['content'] .= "$published_pic";
 
-                $reply['content'] .= "</div>";
+                                       $reply['content'] .= "</div>";
 
-                $reply['content'] .= "<div onclick='return hlClicked(event, $id)'
-                    class=\"hlTitle\"><span class='hlContent $hlc_suffix'>";
-                $reply['content'] .= "<a id=\"RTITLE-$id\" class=\"title $hlc_suffix\"
+                                       $reply['content'] .= "<div onclick='return hlClicked(event, $id)'
+                    class=\"title\"><span class='hlContent $hlc_suffix'>";
+                                       $reply['content'] .= "<a class=\"title $hlc_suffix\"
                     href=\"" . htmlspecialchars($line["link"]) . "\"
                     onclick=\"\">" .
-                    truncate_string($line["title"], 200);
+                                               truncate_string($line["title"], 200);
 
-                if (get_pref('SHOW_CONTENT_PREVIEW')) {
-                        $reply['content'] .= "<span class=\"contentPreview\">" . $line["content_preview"] . "</span>";
-                }
+                                       if (get_pref('SHOW_CONTENT_PREVIEW')) {
+                                               $reply['content'] .= "<span class=\"contentPreview\">" . $line["content_preview"] . "</span>";
+                                       }
 
-                $reply['content'] .= "</a></span>";
+                                       $reply['content'] .= "</a></span>";
 
-                $reply['content'] .= $labels_str;
+                                       $reply['content'] .= $labels_str;
 
-                $reply['content'] .= "</div>";
+                                       $reply['content'] .= "</div>";
 
-                if (!$vfeed_group_enabled) {
-                    if (@$line["feed_title"]) {
-                        $rgba = @$rgba_cache[$feed_id];
+                                       if (!$vfeed_group_enabled) {
+                                               if (@$line["feed_title"]) {
+                                                       $rgba = @$rgba_cache[$feed_id];
 
-                        $reply['content'] .= "<span class=\"hlFeed\"><a style=\"background : rgba($rgba, 0.3)\" href=\"#\" onclick=\"viewfeed({feed:$feed_id})\">".
-                            truncate_string($line["feed_title"],30)."</a></span>";
-                    }
-                }
+                                                       $reply['content'] .= "<span class=\"feed\"><a style=\"background : rgba($rgba, 0.3)\" href=\"#\" onclick=\"viewfeed({feed:$feed_id})\">".
+                                                               truncate_string($line["feed_title"],30)."</a></span>";
+                                               }
+                                       }
 
 
-                $reply['content'] .= "<span class=\"hlUpdated\">";
+                                       $reply['content'] .= "<span class=\"hlUpdated\">";
 
-                $reply['content'] .= "<div title='$date_entered_fmt'>$updated_fmt</div>
+                                       $reply['content'] .= "<div title='$date_entered_fmt'>$updated_fmt</div>
                     </span>";
 
-                $reply['content'] .= "<div class=\"hlRight\">";
+                                       $reply['content'] .= "<div class=\"hlRight\">";
 
-                $reply['content'] .= $score_pic;
+                                       $reply['content'] .= $score_pic;
 
-                if ($line["feed_title"] && !$vfeed_group_enabled) {
+                                       if ($line["feed_title"] && !$vfeed_group_enabled) {
 
-                    $reply['content'] .= "<span onclick=\"viewfeed({feed:$feed_id})\"
+                                               $reply['content'] .= "<span onclick=\"viewfeed({feed:$feed_id})\"
                         style=\"cursor : pointer\"
                         title=\"".htmlspecialchars($line['feed_title'])."\">
                         $feed_icon_img</span>";
-                }
+                                       }
 
-                $reply['content'] .= "</div>";
-                $reply['content'] .= "</div>";
+                                       $reply['content'] .= "</div>";
+                                       $reply['content'] .= "</div>";
 
-            } else {
+                               } else {
 
-                if ($line["tag_cache"])
-                    $tags = explode(",", $line["tag_cache"]);
-                else
-                    $tags = false;
+                                       if ($line["tag_cache"])
+                                               $tags = explode(",", $line["tag_cache"]);
+                                       else
+                                               $tags = false;
 
-                $line["content"] = sanitize($line["content"],
-                        $line['hide_images'], false, $entry_site_url, $highlight_words, $line["id"]);
+                                       $line["content"] = sanitize($line["content"],
+                                               $line['hide_images'], false, $entry_site_url, $highlight_words, $line["id"]);
 
-                foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ARTICLE_CDM) as $p) {
-                    $line = $p->hook_render_article_cdm($line);
-                }
+                                       foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ARTICLE_CDM) as $p) {
+                                               $line = $p->hook_render_article_cdm($line);
+                                       }
 
-                if ($vfeed_group_enabled && $line["feed_title"]) {
-                    if ($feed_id != $vgroup_last_feed) {
+                                       $line['content'] = rewrite_cached_urls($line['content']);
 
-                        $vgroup_last_feed = $feed_id;
+                                       if ($vfeed_group_enabled && $line["feed_title"]) {
+                                               if ($feed_id != $vgroup_last_feed) {
 
-                        $vf_catchup_link = "<a class='catchup' onclick='catchupFeedInGroup($feed_id);' href='#'>".__('mark feed as read')."</a>";
+                                                       $vgroup_last_feed = $feed_id;
 
-                        $feed_icon_src = Feeds::getFeedIcon($feed_id);
-                        $feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"$feed_icon_src\">";
+                                                       $vf_catchup_link = "<a class='catchup' onclick='catchupFeedInGroup($feed_id);' href='#'>".__('mark feed as read')."</a>";
 
-                        $reply['content'] .= "<div data-feed-id='$feed_id' id='FTITLE-$feed_id' class='cdmFeedTitle'>".
-                            "<div style=\"float : right\">$feed_icon_img</div>".
-                            "<a href=\"#\" class='title' onclick=\"viewfeed({feed:$feed_id})\">".
-                            $line["feed_title"]."</a> $vf_catchup_link</div>";
+                                                       $feed_icon_src = Feeds::getFeedIcon($feed_id);
+                                                       $feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"$feed_icon_src\">";
 
-                    }
-                }
+                                                       $reply['content'] .= "<div data-feed-id='$feed_id' class='feed-title'>".
+                                                               "<div style=\"float : right\">$feed_icon_img</div>".
+                                                               "<a href=\"#\" class='title' onclick=\"viewfeed({feed:$feed_id})\">".
+                                                               $line["feed_title"]."</a> $vf_catchup_link</div>";
 
-                $mouseover_attrs = "onmouseover='postMouseIn(event, $id)'
-                    onmouseout='postMouseOut($id)'";
+                                               }
+                                       }
 
-                $expanded_class = $expand_cdm ? "expanded" : "expandable";
+                    $content_encoded = htmlspecialchars($line["content"]);
 
-                $tmp_content = "<div class=\"cdm $hlc_suffix $expanded_class $class\"
-                    id=\"RROW-$id\" data-article-id='$id' data-orig-feed-id='$feed_id' $mouseover_attrs>";
+                    $tmp_content = "<div class=\"cdm expanded $hlc_suffix $class\"
+                        id=\"RROW-$id\" data-content=\"$content_encoded\" data-article-id='$id' data-orig-feed-id='$feed_id' $mouseover_attrs>";
 
-                $tmp_content .= "<div class=\"cdmHeader\">";
-                $tmp_content .= "<div style=\"vertical-align : middle\">";
+                                       $tmp_content .= "<div class=\"header\">";
+                                       $tmp_content .= "<div style=\"vertical-align : middle\">";
 
-                $tmp_content .= "<input dojoType=\"dijit.form.CheckBox\"
+                                       $tmp_content .= "<input dojoType=\"dijit.form.CheckBox\"
                         type=\"checkbox\" onclick=\"toggleSelectRow2(this, false, true)\"
                         class='rchk'>";
 
-                $tmp_content .= "$marked_pic";
-                $tmp_content .= "$published_pic";
+                                       $tmp_content .= "$marked_pic";
+                                       $tmp_content .= "$published_pic";
 
-                $tmp_content .= "</div>";
+                                       $tmp_content .= "</div>";
 
-                if ($highlight_words && count($highlight_words) > 0) {
-                    foreach ($highlight_words as $word) {
-                        $line["title"] = preg_replace("/(\Q$word\E)/i",
-                            "<span class=\"highlight\">$1</span>", $line["title"]);
-                    }
-                }
+                                       if ($highlight_words && count($highlight_words) > 0) {
+                                               foreach ($highlight_words as $word) {
+                                                   $word = preg_quote($word, "/");
 
-                // data-article-id included for context menu
-                $tmp_content .= "<span id=\"RTITLE-$id\"
+                                                       $line["title"] = preg_replace("/($word)/i",
+                                                               "<span class=\"highlight\">$1</span>", $line["title"]);
+                                               }
+                                       }
+
+                                       // data-article-id included for context menu
+                                       $tmp_content .= "<span
                     onclick=\"return cdmClicked(event, $id);\"
                     data-article-id=\"$id\"
-                    class=\"titleWrap hlMenuAttach $hlc_suffix\">                                              
+                    class=\"titleWrap hlMenuAttach $hlc_suffix\">
                     <a class=\"title $hlc_suffix\"
                     title=\"".htmlspecialchars($line["title"])."\"
                     target=\"_blank\" rel=\"noopener noreferrer\" href=\"".
-                    htmlspecialchars($line["link"])."\">".
-                    $line["title"] .
-                    "</a> <span class=\"author\">$entry_author</span>";
-
-                $tmp_content .= $labels_str;
-
-                $tmp_content .= "<span class='collapseBtn' style='display : none'>
-                    <img src=\"images/collapse.png\" onclick=\"cdmCollapseArticle(event, $id)\"
-                    title=\"".__("Collapse article")."\"/></span>";
+                                               htmlspecialchars($line["link"])."\">".
+                                               $line["title"] .
+                                               "</a> <span class=\"author\">$entry_author</span>";
 
-                if (!$expand_cdm)
-                    $content_hidden = "style=\"display : none\"";
-                else
-                    $excerpt_hidden = "style=\"display : none\"";
+                                       $tmp_content .= $labels_str;
 
-                $tmp_content .= "<span $excerpt_hidden id=\"CEXC-$id\" class=\"cdmExcerpt\">" . $content_preview . "</span>";
+                                       $tmp_content .= "</span>";
 
-                $tmp_content .= "</span>";
+                                       if (!$vfeed_group_enabled) {
+                                               if (@$line["feed_title"]) {
+                                                       $rgba = @$rgba_cache[$feed_id];
 
-                if (!$vfeed_group_enabled) {
-                    if (@$line["feed_title"]) {
-                        $rgba = @$rgba_cache[$feed_id];
-
-                        $tmp_content .= "<div class=\"hlFeed\">
+                                                       $tmp_content .= "<div class=\"feed\">
                             <a href=\"#\" style=\"background-color: rgba($rgba,0.3)\"
                             onclick=\"viewfeed({feed:$feed_id})\">".
-                            truncate_string($line["feed_title"],30)."</a>
+                                                               truncate_string($line["feed_title"],30)."</a>
                         </div>";
-                    }
-                }
+                                               }
+                                       }
 
-                $tmp_content .= "<span class='updated' title='$date_entered_fmt'>$updated_fmt</span>";
+                                       $tmp_content .= "<span class='updated' title='$date_entered_fmt'>$updated_fmt</span>";
 
-                $tmp_content .= "<div class='scoreWrap' style=\"vertical-align : middle\">";
-                $tmp_content .= "$score_pic";
+                                       $tmp_content .= "<div style=\"vertical-align : middle\">";
+                                       $tmp_content .= "$score_pic";
 
-                if (!get_pref("VFEED_GROUP_BY_FEED") && $line["feed_title"]) {
-                    $tmp_content .= "<span style=\"cursor : pointer\"
+                                       if (!get_pref("VFEED_GROUP_BY_FEED") && $line["feed_title"]) {
+                                               $tmp_content .= "<span style=\"cursor : pointer\"
                         title=\"".htmlspecialchars($line["feed_title"])."\"
                         onclick=\"viewfeed({feed:$feed_id})\">$feed_icon_img</span>";
-                }
-                $tmp_content .= "</div>"; //scoreWrap
+                                       }
+                                       $tmp_content .= "</div>"; //score wrapper2
 
-                $tmp_content .= "</div>"; //cdmHeader
+                                       $tmp_content .= "</div>"; //header
 
-                $tmp_content .= "<div class=\"cdmContent\" $content_hidden
-                    onclick=\"return cdmClicked(event, $id, true);\"
-                    id=\"CICD-$id\">";
+                                       $tmp_content .= "<div class=\"content\" onclick=\"return cdmClicked(event, $id, true);\">";
 
-                $tmp_content .= "<div id=\"POSTNOTE-$id\">";
-                if ($line['note']) {
-                    $tmp_content .= Article::format_article_note($id, $line['note']);
-                }
-                $tmp_content .= "</div>"; //POSTNOTE
+                                       $tmp_content .= "<div id=\"POSTNOTE-$id\">";
+                                       if ($line['note']) {
+                                               $tmp_content .= Article::format_article_note($id, $line['note']);
+                                       }
+                                       $tmp_content .= "</div>"; //POSTNOTE
 
-                if (!$line['lang']) $line['lang'] = 'en';
+                                       if (!$line['lang']) $line['lang'] = 'en';
 
-                $tmp_content .= "<div class=\"cdmContentInner\" lang=\"".$line['lang']."\">";
+                                       // this is filled from RROW data-content
+                                       $tmp_content .= "<div class=\"content-inner\" lang=\"".$line['lang']."\">";
 
-                if ($line["orig_feed_id"]) {
+                                       if ($line["orig_feed_id"]) {
 
-                    $ofgh = $this->pdo->prepare("SELECT * FROM ttrss_archived_feeds
+                                               $ofgh = $this->pdo->prepare("SELECT * FROM ttrss_archived_feeds
                         WHERE id = ? AND owner_uid = ?");
-                    $ofgh->execute([$line["orig_feed_id"], $_SESSION['uid']]);
+                                               $ofgh->execute([$line["orig_feed_id"], $_SESSION['uid']]);
 
-                    if ($tmp_line = $ofgh->fetch()) {
+                                               if ($tmp_line = $ofgh->fetch()) {
 
-                        $tmp_content .= "<div clear='both'>";
-                        $tmp_content .= __("Originally from:");
+                                                       $tmp_content .= "<div clear='both'>";
+                                                       $tmp_content .= __("Originally from:");
 
-                        $tmp_content .= "&nbsp;";
+                                                       $tmp_content .= "&nbsp;";
 
-                        $tmp_content .= "<a target='_blank' rel='noopener noreferrer'
+                                                       $tmp_content .= "<a target='_blank' rel='noopener noreferrer'
                             href=' " . htmlspecialchars($tmp_line['site_url']) . "'>" .
-                            $tmp_line['title'] . "</a>";
-
-                        $tmp_content .= "&nbsp;";
-
-                        $tmp_content .= "<a target='_blank' rel='noopener noreferrer' href='" . htmlspecialchars($tmp_line['feed_url']) . "'>";
-                        $tmp_content .= "<img title='".__('Feed URL')."'class='tinyFeedIcon' src='images/pub_unset.png'></a>";
+                                                               $tmp_line['title'] . "</a>";
 
-                        $tmp_content .= "</div>";
-                    }
-                }
+                                                       $tmp_content .= "&nbsp;";
 
-                $tmp_content .= "<span id=\"CWRAP-$id\">";
-                $tmp_content .= "<span id=\"CENCW-$id\" class=\"cencw\" style=\"display : none\">";
-                $tmp_content .= htmlspecialchars($line["content"]);
-                $tmp_content .= "</span>";
-                $tmp_content .= "</span>";
+                                                       $tmp_content .= "<a target='_blank' rel='noopener noreferrer' href='" . htmlspecialchars($tmp_line['feed_url']) . "'>";
+                                                       $tmp_content .= "<img title='".__('Feed URL')."'class='tinyFeedIcon' src='images/pub_unset.png'></a>";
 
-                $tmp_content .= "</div>"; //cdmContentInner
+                                                       $tmp_content .= "</div>";
+                                               }
+                                       }
 
-                $tmp_content .= "<div class=\"cdmIntermediate\">";
+                                       $tmp_content .= "</div>"; //content-inner
+                                       $tmp_content .= "<div class=\"intermediate\">";
 
-                $always_display_enclosures = $line["always_display_enclosures"];
-                $tmp_content .= Article::format_article_enclosures($id, $always_display_enclosures,
-                    $line["content"], $line["hide_images"]);
+                                       $always_display_enclosures = $line["always_display_enclosures"];
+                                       $tmp_content .= Article::format_article_enclosures($id, $always_display_enclosures,
+                                               $line["content"], $line["hide_images"]);
 
-                $tmp_content .= "</div>"; // cdmIntermediate
+                                       $tmp_content .= "</div>"; // cdmIntermediate
 
-                $tmp_content .= "<div class=\"cdmFooter\" onclick=\"cdmFooterClick(event)\">";
+                                       $tmp_content .= "<div class=\"footer\" onclick=\"event.stopPropagation()\">";
 
-                foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_LEFT_BUTTON) as $p) {
-                    $tmp_content .= $p->hook_article_left_button($line);
-                }
+                                       foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_LEFT_BUTTON) as $p) {
+                                               $tmp_content .= $p->hook_article_left_button($line);
+                                       }
 
-                $tags_str = Article::format_tags_string($tags, $id);
+                                       $tags_str = Article::format_tags_string($tags, $id);
 
-                $tmp_content .= "<span class='left'>";
+                                       $tmp_content .= "<span class='left'>";
 
-                $tmp_content .= "<img src='images/tag.png' alt='Tags' title='Tags'>
+                                       $tmp_content .= "<img src='images/tag.png' alt='Tags' title='Tags'>
                     <span id=\"ATSTR-$id\">$tags_str</span>
                     <a title=\"".__('Edit tags for this article')."\"
                     href=\"#\" onclick=\"editArticleTags($id)\">(+)</a>";
 
-                $num_comments = (int) $line["num_comments"];
-                $entry_comments = "";
+                                       $num_comments = (int) $line["num_comments"];
+                                       $entry_comments = "";
 
-                if ($num_comments > 0) {
-                    if ($line["comments"]) {
-                        $comments_url = htmlspecialchars($line["comments"]);
-                    } else {
-                        $comments_url = htmlspecialchars($line["link"]);
-                    }
-                    $entry_comments = "<a class=\"postComments\"
+                                       if ($num_comments > 0) {
+                                               if ($line["comments"]) {
+                                                       $comments_url = htmlspecialchars($line["comments"]);
+                                               } else {
+                                                       $comments_url = htmlspecialchars($line["link"]);
+                                               }
+                                               $entry_comments = "<a class=\"comments\"
                         target='_blank' rel='noopener noreferrer' href=\"$comments_url\">$num_comments ".
-                        _ngettext("comment", "comments", $num_comments)."</a>";
+                                                       _ngettext("comment", "comments", $num_comments)."</a>";
 
-                } else {
-                    if ($line["comments"] && $line["link"] != $line["comments"]) {
-                        $entry_comments = "<a class=\"postComments\" target='_blank' rel='noopener noreferrer' href=\"".htmlspecialchars($line["comments"])."\">".__("comments")."</a>";
-                    }
-                }
+                                       } else {
+                                               if ($line["comments"] && $line["link"] != $line["comments"]) {
+                                                       $entry_comments = "<a class=\"comments\" target='_blank' rel='noopener noreferrer' href=\"".htmlspecialchars($line["comments"])."\">".__("comments")."</a>";
+                                               }
+                                       }
 
-                if ($entry_comments) $tmp_content .= "&nbsp;($entry_comments)";
+                                       if ($entry_comments) $tmp_content .= "&nbsp;($entry_comments)";
 
-                $tmp_content .= "</span>";
-                $tmp_content .= "<div>";
+                                       $tmp_content .= "</span>";
+                                       $tmp_content .= "<div>";
 
-                foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_BUTTON) as $p) {
-                    $tmp_content .= $p->hook_article_button($line);
-                }
+                                       foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_BUTTON) as $p) {
+                                               $tmp_content .= $p->hook_article_button($line);
+                                       }
 
-                $tmp_content .= "</div>"; // buttons
+                                       $tmp_content .= "</div>"; // buttons
 
-                $tmp_content .= "</div>"; // cdmFooter
-                $tmp_content .= "</div>"; // cdmContent
-                $tmp_content .= "</div>"; // RROW.cdm
+                                       $tmp_content .= "</div>"; // cdm footer
+                                       $tmp_content .= "</div>"; // cdmContent
+                                       $tmp_content .= "</div>"; // RROW.cdm
 
-                foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_FORMAT_ARTICLE_CDM) as $p) {
-                    $tmp_content = $p->hook_format_article_cdm($tmp_content, $line);
-                }
+                                       foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_FORMAT_ARTICLE_CDM) as $p) {
+                                               $tmp_content = $p->hook_format_article_cdm($tmp_content, $line);
+                                       }
 
-                $reply['content'] .= $tmp_content;
-            }
+                                       $reply['content'] .= $tmp_content;
+                               }
 
-            ++$lnum;
+                               ++$lnum;
+                       }
         }
 
         if ($_REQUEST["debug"]) $timing_info = print_checkpoint("PE", $timing_info);
@@ -1013,6 +939,8 @@ class Feeds extends Handler_Protected {
        }
 
        function quickAddFeed() {
+               print "<form onsubmit='return false'>";
+
                print_hidden("op", "rpc");
                print_hidden("method", "addfeed");
 
@@ -1077,10 +1005,8 @@ class Feeds extends Handler_Protected {
                                <label for=\"feedDlg_loginCheck\">".
                                __('This feed requires authentication.')."</div>";
 
-               print "</form>";
-
                print "<div class=\"dlgButtons\">
-                       <button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('feedAddDlg').execute()\">".__('Subscribe')."</button>";
+                       <button dojoType=\"dijit.form.Button\" class=\"btn-primary\" type=\"submit\" onclick=\"return dijit.byId('feedAddDlg').execute()\">".__('Subscribe')."</button>";
 
                if (!(defined('_DISABLE_FEED_BROWSER') && _DISABLE_FEED_BROWSER)) {
                        print "<button dojoType=\"dijit.form.Button\" onclick=\"return feedBrowser()\">".__('More feeds')."</button>";
@@ -1089,6 +1015,8 @@ class Feeds extends Handler_Protected {
                print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('feedAddDlg').hide()\">".__('Cancel')."</button>
                        </div>";
 
+               print "</form>";
+
                //return;
        }
 
@@ -1146,6 +1074,8 @@ class Feeds extends Handler_Protected {
                $active_feed_id = sprintf("%d", $this->params[0]);
                $is_cat = $this->params[1] != "false";
 
+               print "<form onsubmit='return false;'>";
+
                print "<div class=\"dlgSec\">".__('Look for')."</div>";
 
                print "<div class=\"dlgSecCont\">";
@@ -1172,14 +1102,19 @@ class Feeds extends Handler_Protected {
                                </div>";
                }
 
-               print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('searchDlg').execute()\">".__('Search')."</button>
+               print "<button dojoType=\"dijit.form.Button\" type=\"submit\" class=\"btn-primary\" onclick=\"dijit.byId('searchDlg').execute()\">".__('Search')."</button>
                <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('searchDlg').hide()\">".__('Cancel')."</button>
                </div>";
+
+               print "</form>";
        }
 
        function update_debugger() {
                header("Content-type: text/html");
 
+               Debug::set_enabled(true);
+               Debug::set_loglevel($_REQUEST["xdebug"]);
+
                $feed_id = (int)$_REQUEST["feed_id"];
                @$do_update = $_REQUEST["action"] == "do_update";
                $csrf_token = $_REQUEST["csrf_token"];
@@ -1276,6 +1211,7 @@ class Feeds extends Handler_Protected {
                                        if ($feed > 0) {
                                                $children = Feeds::getChildCategories($feed, $owner_uid);
                                                array_push($children, $feed);
+                                               $children = array_map("intval", $children);
 
                                                $children = join(",", $children);
 
@@ -1442,7 +1378,7 @@ class Feeds extends Handler_Protected {
                } else if ($n_feed >= 0) {
 
                        if ($n_feed != 0) {
-                               $match_part = "feed_id = '$n_feed'";
+                               $match_part = "feed_id = " . (int)$n_feed;
                        } else {
                                $match_part = "feed_id IS NULL";
                        }
@@ -1513,6 +1449,10 @@ class Feeds extends Handler_Protected {
 
                $contents = @fetch_file_contents($url, false, $auth_login, $auth_pass);
 
+               foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_SUBSCRIBE_FEED) as $plugin) {
+                       $contents = $plugin->hook_subscribe_feed($contents, $url, $auth_login, $auth_pass);
+               }
+
                if (!$contents) {
                        if (preg_match("/cloudflare\.com/", $fetch_last_error_content)) {
                                $fetch_last_error .= " (feed behind Cloudflare)";
@@ -1521,10 +1461,6 @@ class Feeds extends Handler_Protected {
                        return array("code" => 5, "message" => $fetch_last_error);
                }
 
-               foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_SUBSCRIBE_FEED) as $plugin) {
-                       $contents = $plugin->hook_subscribe_feed($contents, $url, $auth_login, $auth_pass);
-               }
-
                if (is_html($contents)) {
                        $feedUrls = get_feeds_from_html($url, $contents);
 
@@ -1551,7 +1487,7 @@ class Feeds extends Handler_Protected {
                                        (owner_uid,feed_url,title,cat_id, auth_login,auth_pass,update_method,auth_pass_encrypted)
                                VALUES (?, ?, ?, ?, ?, ?, 0, false)");
 
-                       $sth->execute([$_SESSION['uid'], $url, "[Unknown]", $cat_id, $auth_login, $auth_pass]);
+                       $sth->execute([$_SESSION['uid'], $url, "[Unknown]", $cat_id, (string)$auth_login, (string)$auth_pass]);
 
                        $sth = $pdo->prepare("SELECT id FROM ttrss_feeds WHERE feed_url = ?
                                        AND owner_uid = ?");
@@ -1677,7 +1613,7 @@ class Feeds extends Handler_Protected {
 
                        $cat_feeds = array();
                        while ($line = $sth->fetch()) {
-                               array_push($cat_feeds, "feed_id = " . $line["id"]);
+                               array_push($cat_feeds, "feed_id = " . (int)$line["id"]);
                        }
 
                        if (count($cat_feeds) == 0) return 0;
@@ -1892,8 +1828,9 @@ class Feeds extends Handler_Protected {
                                        if ($include_children) {
                                                # sub-cats
                                                $subcats = Feeds::getChildCategories($feed, $owner_uid);
-
                                                array_push($subcats, $feed);
+                                               $subcats = array_map("intval", $subcats);
+
                                                $query_strategy_part = "cat_id IN (".
                                                        implode(",", $subcats).")";
 
@@ -2101,9 +2038,9 @@ class Feeds extends Handler_Protected {
                                                $sanity_interval_qpart
                                                $first_id_query_strategy_part ORDER BY $order_by LIMIT 1";
 
-                               if ($_REQUEST["debug"]) {
+                               /*if ($_REQUEST["debug"]) {
                                        print $query;
-                               }
+                               }*/
 
                                $res = $pdo->query($query);
 
@@ -2149,7 +2086,7 @@ class Feeds extends Handler_Protected {
                                        $query_strategy_part ORDER BY $order_by
                                        $limit_query_part $offset_query_part";
 
-                       if ($_REQUEST["debug"]) print $query;
+                       //if ($_REQUEST["debug"]) print $query;
 
                        $res = $pdo->query($query);