$search_q = "";
}
- $reply .= "<span class=\"holder\">";
+ $reply = "<span class=\"holder\">";
$rss_link = htmlspecialchars(get_self_url_prefix() .
"/public.php?op=rss&id=$feed_id$cat_q$search_q");
$target = "target=\"_blank\"";
$reply .= "<a title=\"$last_updated\" $target href=\"$feed_site_url\">".
- truncate_string($feed_title, 30)."</a>";
+ truncate_string(strip_tags($feed_title), 30)."</a>";
if ($error) {
$error = htmlspecialchars($error);
}
} else {
- $reply .= $feed_title;
+ $reply .= strip_tags($feed_title);
}
$reply .= "</span>";
$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 = sql_bool_to_bool($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") {
}
}
- @$search = db_escape_string($_REQUEST["query"]);
- @$search_language = db_escape_string($_REQUEST["search_language"]); // PGSQL only
+ @$search = $_REQUEST["query"];
+ @$search_language = $_REQUEST["search_language"]; // PGSQL only
if ($search) {
$disable_cache = true;
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];
$feed, $cat_view, $search,
$last_error, $last_updated);
- $headlines_count = is_numeric($result) ? 0 : db_num_rows($result);
-
if ($offset == 0) {
foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_HEADLINES_BEFORE) as $p) {
$reply['content'] .= $p->hook_headlines_before($feed, $cat_view, $qfh_ret);
$reply['content'] = '';
- if ($headlines_count > 0) {
-
- $lnum = $offset;
+ $headlines_count = 0;
- $num_unread = 0;
+ $lnum = $offset;
+ $num_unread = 0;
+ if ($_REQUEST["debug"]) $timing_info = print_checkpoint("PS", $timing_info);
+ $expand_cdm = get_pref('CDM_EXPANDED');
- if ($_REQUEST["debug"]) $timing_info = print_checkpoint("PS", $timing_info);
+ if (is_object($result)) {
- $expand_cdm = get_pref('CDM_EXPANDED');
+ while ($line = $result->fetch()) {
- while ($line = db_fetch_assoc($result)) {
+ ++$headlines_count;
$line["content_preview"] = "— " . truncate_string(strip_tags($line["content"]), 250);
$label_cache = $line["label_cache"];
$labels = false;
+ $mouseover_attrs = "onmouseover='postMouseIn(event, $id)' onmouseout='postMouseOut($id)'";
+
if ($label_cache) {
$label_cache = json_decode($label_cache, true);
$class = "";
- if (sql_bool_to_bool($line["unread"])) {
+ if ($line["unread"]) {
$class .= " Unread";
++$num_unread;
}
- if (sql_bool_to_bool($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 (sql_bool_to_bool($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)'>";
- }
-
-# $content_link = "<a target=\"_blank\" rel=\"noopener noreferrer\" href=\"".$line["link"]."\">" .
-# $line["title"] . "</a>";
-
-# $content_link = "<a
-# href=\"" . htmlspecialchars($line["link"]) . "\"
-# onclick=\"view($id,$feed_id);\">" .
-# $line["title"] . "</a>";
+ $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)'>";
-# $content_link = "<a href=\"javascript:viewContentUrl('".$line["link"]."');\">" .
-# $line["title"] . "</a>";
+ $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",
$score_pic = "images/" . get_score_pic($score);
-/* $score_title = __("(Click to change)");
- $score_pic = "<img class='hlScorePic' src=\"images/$score_pic\"
- onclick=\"adjustArticleScore($id, $score)\" title=\"$score $score_title\">"; */
-
$score_pic = "<img class='hlScorePic' score='$score' onclick='changeScore($id, this)' src=\"$score_pic\"
- title=\"$score\">";
+ title=\"$score\">";
if ($score > 500) {
$hlc_suffix = "high";
$entry_author = " — $entry_author";
}
- $has_feed_icon = feed_has_icon($feed_id);
+ $has_feed_icon = feeds::feedHasIcon($feed_id);
if ($has_feed_icon) {
$feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"".ICONS_URL."/$feed_id.ico\" alt=\"\">";
if ($vfeed_group_enabled) {
if ($feed_id != $vgroup_last_feed && $line["feed_title"]) {
- $cur_feed_title = $line["feed_title"];
$vgroup_last_feed = $feed_id;
- $cur_feed_title = htmlspecialchars($cur_feed_title);
-
$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 class='title' href=\"#\" onclick=\"viewfeed({feed:$feed_id})\">".
$line["feed_title"]."</a>
- $vf_catchup_link</div>";
+ $vf_catchup_link</div>";
}
}
- $mouseover_attrs = "onmouseover='postMouseIn(event, $id)'
- onmouseout='postMouseOut($id)'";
-
$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'] .= "<input dojoType=\"dijit.form.CheckBox\"
- type=\"checkbox\" onclick=\"toggleSelectRow2(this)\"
- class='rchk'>";
+ type=\"checkbox\" onclick=\"toggleSelectRow2(this)\"
+ class='rchk'>";
$reply['content'] .= "$marked_pic";
$reply['content'] .= "$published_pic";
$reply['content'] .= "</div>";
$reply['content'] .= "<div onclick='return hlClicked(event, $id)'
- class=\"hlTitle\"><span class='hlContent $hlc_suffix'>";
+ class=\"hlTitle\"><span class='hlContent $hlc_suffix'>";
$reply['content'] .= "<a id=\"RTITLE-$id\" class=\"title $hlc_suffix\"
- href=\"" . htmlspecialchars($line["link"]) . "\"
- onclick=\"\">" .
+ href=\"" . htmlspecialchars($line["link"]) . "\"
+ onclick=\"\">" .
truncate_string($line["title"], 200);
if (get_pref('SHOW_CONTENT_PREVIEW')) {
- $reply['content'] .= "<span class=\"contentPreview\">" . $line["content_preview"] . "</span>";
+ $reply['content'] .= "<span class=\"contentPreview\">" . $line["content_preview"] . "</span>";
}
$reply['content'] .= "</a></span>";
$reply['content'] .= "<span class=\"hlUpdated\">";
$reply['content'] .= "<div title='$date_entered_fmt'>$updated_fmt</div>
- </span>";
+ </span>";
$reply['content'] .= "<div class=\"hlRight\">";
if ($line["feed_title"] && !$vfeed_group_enabled) {
$reply['content'] .= "<span onclick=\"viewfeed({feed:$feed_id})\"
- style=\"cursor : pointer\"
- title=\"".htmlspecialchars($line['feed_title'])."\">
- $feed_icon_img</span>";
+ style=\"cursor : pointer\"
+ title=\"".htmlspecialchars($line['feed_title'])."\">
+ $feed_icon_img</span>";
}
$reply['content'] .= "</div>";
$tags = false;
$line["content"] = sanitize($line["content"],
- sql_bool_to_bool($line['hide_images']), false, $entry_site_url, $highlight_words, $line["id"]);
+ $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);
if ($vfeed_group_enabled && $line["feed_title"]) {
if ($feed_id != $vgroup_last_feed) {
- $cur_feed_title = $line["feed_title"];
$vgroup_last_feed = $feed_id;
- $cur_feed_title = htmlspecialchars($cur_feed_title);
-
$vf_catchup_link = "<a class='catchup' onclick='catchupFeedInGroup($feed_id);' href='#'>".__('mark feed as read')."</a>";
- $has_feed_icon = feed_has_icon($feed_id);
-
- 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/blank_icon.gif\" alt=\"\">";
- }
+ $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' id='FTITLE-$feed_id' class='cdmFeedTitle'>".
"<div style=\"float : right\">$feed_icon_img</div>".
}
}
- $mouseover_attrs = "onmouseover='postMouseIn(event, $id)'
- onmouseout='postMouseOut($id)'";
-
$expanded_class = $expand_cdm ? "expanded" : "expandable";
-
+
$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>";
+ id=\"RROW-$id\" 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 .= "<input dojoType=\"dijit.form.CheckBox\"
- type=\"checkbox\" onclick=\"toggleSelectRow2(this, false, true)\"
- class='rchk'>";
+ type=\"checkbox\" onclick=\"toggleSelectRow2(this, false, true)\"
+ class='rchk'>";
$tmp_content .= "$marked_pic";
$tmp_content .= "$published_pic";
$tmp_content .= "</div>";
- if ($highlight_words && count($highlight_words > 0)) {
+ if ($highlight_words && count($highlight_words) > 0) {
foreach ($highlight_words as $word) {
- $line["title"] = preg_replace("/(\Q$word\E)/i",
+ $word = preg_quote($word, "/");
+
+ $line["title"] = preg_replace("/($word)/i",
"<span class=\"highlight\">$1</span>", $line["title"]);
}
}
// data-article-id included for context menu
$tmp_content .= "<span id=\"RTITLE-$id\"
- onclick=\"return cdmClicked(event, $id);\"
- data-article-id=\"$id\"
- class=\"titleWrap hlMenuAttach $hlc_suffix\">
- <a class=\"title $hlc_suffix\"
- title=\"".htmlspecialchars($line["title"])."\"
- target=\"_blank\" rel=\"noopener noreferrer\" href=\"".
+ onclick=\"return cdmClicked(event, $id);\"
+ data-article-id=\"$id\"
+ 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>";
+ <img src=\"images/collapse.png\" onclick=\"cdmCollapseArticle(event, $id)\"
+ title=\"".__("Collapse article")."\"/></span>";
if (!$expand_cdm)
$content_hidden = "style=\"display : none\"";
$rgba = @$rgba_cache[$feed_id];
$tmp_content .= "<div class=\"hlFeed\">
- <a href=\"#\" style=\"background-color: rgba($rgba,0.3)\"
- onclick=\"viewfeed({feed:$feed_id})\">".
+ <a href=\"#\" style=\"background-color: rgba($rgba,0.3)\"
+ onclick=\"viewfeed({feed:$feed_id})\">".
truncate_string($line["feed_title"],30)."</a>
- </div>";
+ </div>";
}
}
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>";
+ title=\"".htmlspecialchars($line["feed_title"])."\"
+ onclick=\"viewfeed({feed:$feed_id})\">$feed_icon_img</span>";
}
$tmp_content .= "</div>"; //scoreWrap
$tmp_content .= "</div>"; //cdmHeader
$tmp_content .= "<div class=\"cdmContent\" $content_hidden
- onclick=\"return cdmClicked(event, $id, true);\"
- id=\"CICD-$id\">";
+ onclick=\"return cdmClicked(event, $id, true);\"
+ id=\"CICD-$id\">";
$tmp_content .= "<div id=\"POSTNOTE-$id\">";
if ($line['note']) {
if ($line["orig_feed_id"]) {
$ofgh = $this->pdo->prepare("SELECT * FROM ttrss_archived_feeds
- WHERE id = ? AND owner_uid = ?");
+ WHERE id = ? AND owner_uid = ?");
$ofgh->execute([$line["orig_feed_id"], $_SESSION['uid']]);
if ($tmp_line = $ofgh->fetch()) {
$tmp_content .= " ";
$tmp_content .= "<a target='_blank' rel='noopener noreferrer'
- href=' " . htmlspecialchars($tmp_line['site_url']) . "'>" .
+ href=' " . htmlspecialchars($tmp_line['site_url']) . "'>" .
$tmp_line['title'] . "</a>";
$tmp_content .= " ";
$tmp_content .= "<div class=\"cdmIntermediate\">";
- $always_display_enclosures = sql_bool_to_bool($line["always_display_enclosures"]);
- $tmp_content .= Article::format_article_enclosures($id, $always_display_enclosures, $line["content"], sql_bool_to_bool($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 .= "<span class='left'>";
$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>";
+ <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 = "";
$comments_url = htmlspecialchars($line["link"]);
}
$entry_comments = "<a class=\"postComments\"
- target='_blank' rel='noopener noreferrer' href=\"$comments_url\">$num_comments ".
+ target='_blank' rel='noopener noreferrer' href=\"$comments_url\">$num_comments ".
_ngettext("comment", "comments", $num_comments)."</a>";
} else {
$tmp_content .= "</span>";
$tmp_content .= "<div>";
-// $tmp_content .= "$marked_pic";
-// $tmp_content .= "$published_pic";
-
foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_BUTTON) as $p) {
$tmp_content .= $p->hook_article_button($line);
}
++$lnum;
}
+ }
- if ($_REQUEST["debug"]) $timing_info = print_checkpoint("PE", $timing_info);
-
- } else if (!is_numeric($result)) {
- $message = "";
-
- switch ($view_mode) {
- case "unread":
- $message = __("No unread articles found to display.");
- break;
- case "updated":
- $message = __("No updated articles found to display.");
- break;
- case "marked":
- $message = __("No starred articles found to display.");
- break;
- default:
- if ($feed < LABEL_BASE_INDEX) {
- $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.");
- } else {
- $message = __("No articles found to display.");
- }
- }
+ if ($_REQUEST["debug"]) $timing_info = print_checkpoint("PE", $timing_info);
+
+ if (!$headlines_count) {
+
+ if (!is_numeric($result)) {
+
+ switch ($view_mode) {
+ case "unread":
+ $message = __("No unread articles found to display.");
+ break;
+ case "updated":
+ $message = __("No updated articles found to display.");
+ break;
+ case "marked":
+ $message = __("No starred articles found to display.");
+ break;
+ default:
+ if ($feed < LABEL_BASE_INDEX) {
+ $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.");
+ } else {
+ $message = __("No articles found to display.");
+ }
+ }
- if (!$offset && $message) {
- $reply['content'] = "<div class='whiteBox'>$message";
+ if (!$offset && $message) {
+ $reply['content'] = "<div class='whiteBox'>$message";
- $reply['content'] .= "<p><span class=\"insensitive\">";
+ $reply['content'] .= "<p><span class=\"insensitive\">";
- $sth = $this->pdo->prepare("SELECT ".SUBSTRING_FOR_DATE."(MAX(last_updated), 1, 19) AS last_updated FROM ttrss_feeds
- WHERE owner_uid = ?");
- $sth->execute([$_SESSION['uid']]);
- $row = $sth->fetch();
+ $sth = $this->pdo->prepare("SELECT " . SUBSTRING_FOR_DATE . "(MAX(last_updated), 1, 19) AS last_updated FROM ttrss_feeds
+ WHERE owner_uid = ?");
+ $sth->execute([$_SESSION['uid']]);
+ $row = $sth->fetch();
- $last_updated = make_local_datetime($row["last_updated"], false);
+ $last_updated = make_local_datetime($row["last_updated"], false);
- $reply['content'] .= sprintf(__("Feeds last updated at %s"), $last_updated);
+ $reply['content'] .= sprintf(__("Feeds last updated at %s"), $last_updated);
- $sth = $this->pdo->prepare("SELECT COUNT(id) AS num_errors
- FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ?");
- $sth->execute([$_SESSION['uid']]);
- $row = $sth->fetch();
+ $sth = $this->pdo->prepare("SELECT COUNT(id) AS num_errors
+ FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ?");
+ $sth->execute([$_SESSION['uid']]);
+ $row = $sth->fetch();
- $num_errors = $row["num_errors"];
+ $num_errors = $row["num_errors"];
- if ($num_errors > 0) {
- $reply['content'] .= "<br/>";
- $reply['content'] .= "<a class=\"insensitive\" href=\"#\" onclick=\"showFeedsWithErrors()\">".
- __('Some feeds have update errors (click for details)')."</a>";
- }
- $reply['content'] .= "</span></p></div>";
+ if ($num_errors > 0) {
+ $reply['content'] .= "<br/>";
+ $reply['content'] .= "<a class=\"insensitive\" href=\"#\" onclick=\"showFeedsWithErrors()\">" .
+ __('Some feeds have update errors (click for details)') . "</a>";
+ }
+ $reply['content'] .= "</span></p></div>";
+ }
+ } else if (is_numeric($result) && $result == -1) {
+ $reply['first_id_changed'] = true;
}
- } else if (is_numeric($result) && $result == -1) {
- $reply['first_id_changed'] = true;
}
if ($_REQUEST["debug"]) $timing_info = print_checkpoint("H2", $timing_info);
if ($_REQUEST["debug"]) $timing_info = print_checkpoint("0", $timing_info);
- $feed = db_escape_string($_REQUEST["feed"]);
- $method = db_escape_string($_REQUEST["m"]);
- $view_mode = db_escape_string($_REQUEST["view_mode"]);
+ $feed = $_REQUEST["feed"];
+ $method = $_REQUEST["m"];
+ $view_mode = $_REQUEST["view_mode"];
$limit = 30;
@$cat_view = $_REQUEST["cat"] == "true";
- @$next_unread_feed = db_escape_string($_REQUEST["nuf"]);
- @$offset = db_escape_string($_REQUEST["skip"]);
- @$vgroup_last_feed = db_escape_string($_REQUEST["vgrlf"]);
- $order_by = db_escape_string($_REQUEST["order_by"]);
- $check_first_id = db_escape_string($_REQUEST["fid"]);
+ @$next_unread_feed = $_REQUEST["nuf"];
+ @$offset = $_REQUEST["skip"];
+ @$vgroup_last_feed = $_REQUEST["vgrlf"];
+ $order_by = $_REQUEST["order_by"];
+ $check_first_id = $_REQUEST["fid"];
if (is_numeric($feed)) $feed = (int) $feed;
}
function quickAddFeed() {
+ print "<form onsubmit='return false'>";
+
print_hidden("op", "rpc");
print_hidden("method", "addfeed");
<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>";
print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('feedAddDlg').hide()\">".__('Cancel')."</button>
</div>";
+ print "</form>";
+
//return;
}
function feedBrowser() {
if (defined('_DISABLE_FEED_BROWSER') && _DISABLE_FEED_BROWSER) return;
- $browser_search = db_escape_string($_REQUEST["search"]);
+ $browser_search = $_REQUEST["search"];
print_hidden("op", "rpc");
print_hidden("method", "updateFeedBrowser");
}
function search() {
- $this->params = explode(":", db_escape_string($_REQUEST["param"]), 2);
+ $this->params = explode(":", $_REQUEST["param"], 2);
$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\">";
</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() {
@$do_update = $_REQUEST["action"] == "do_update";
$csrf_token = $_REQUEST["csrf_token"];
+ $sth = $this->pdo->prepare("SELECT id FROM ttrss_feeds WHERE id = ? AND owner_uid = ?");
+ $sth->execute([$feed_id, $_SESSION['uid']]);
+
+ if (!$sth->fetch()) {
+ print "Access denied.";
+ return;
+ }
+
$refetch_checked = isset($_REQUEST["force_refetch"]) ? "checked" : "";
$rehash_checked = isset($_REQUEST["force_rehash"]) ? "checked" : "";
?>
<html>
<head>
- <link rel="stylesheet" type="text/css" href="css/utility.css">
+ <?php echo stylesheet_tag("css/default.css") ?>
<title>Feed Debugger</title>
</head>
- <body class="small_margins">
+ <body class="small_margins ttrss_utility claro">
<h1>Feed Debugger: <?php echo "$feed_id: " . $this->getFeedTitle($feed_id) ?></h1>
<form method="GET" action="">
<input type="hidden" name="op" value="feeds">
if ($feed > 0) {
$children = Feeds::getChildCategories($feed, $owner_uid);
array_push($children, $feed);
+ $children = array_map("intval", $children);
$children = join(",", $children);
} 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";
}
$url = key($feedUrls);
}
- if ($cat_id == "0" || !$cat_id) {
- $cat_qpart = "NULL";
- } else {
- $cat_qpart = "'$cat_id'";
- }
-
- if (!(int)$cat_id) $cat_id = null;
+ if (!$cat_id) $cat_id = null;
$sth = $pdo->prepare("SELECT id FROM ttrss_feeds
WHERE feed_url = ? AND owner_uid = ?");
(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 = ?");
}
}
+ static function getIconFile($feed_id) {
+ return ICONS_DIR . "/$feed_id.ico";
+ }
+
+ static function feedHasIcon($id) {
+ return is_file(ICONS_DIR . "/$id.ico") && filesize(ICONS_DIR . "/$id.ico") > 0;
+ }
+
static function getFeedIcon($id) {
switch ($id) {
case 0:
if ($id < LABEL_BASE_INDEX) {
return "images/label.png";
} else {
- if (file_exists(ICONS_DIR . "/$id.ico"))
- return ICONS_URL . "/$id.ico";
+ $icon = self::getIconFile($id);
+
+ if ($icon && file_exists($icon)) {
+ return ICONS_URL . "/" . basename($icon) . "?" . filemtime($icon);
+ }
}
break;
}
$sth = $pdo->prepare("SELECT id FROM ttrss_feeds
WHERE (cat_id = :cat OR (:cat IS NULL AND cat_id IS NULL))
- AND owner_uid = ?");
+ AND owner_uid = :uid");
$sth->execute([":cat" => $cat, ":uid" => $owner_uid]);
$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;
}
if ($since_id) {
- $since_id_part = "ttrss_entries.id > $since_id AND ";
+ $since_id_part = "ttrss_entries.id > ".$pdo->quote($since_id)." AND ";
} else {
$since_id_part = "";
}
}
if ($limit > 0) {
- $limit_query_part = "LIMIT " . $limit;
+ $limit_query_part = "LIMIT " . (int)$limit;
}
$allow_archived = false;
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).")";
} else {
- $query_strategy_part = "cat_id = '$feed'";
+ $query_strategy_part = "cat_id = " . $pdo->quote($feed);
}
} else {
$vfeed_query_part = "ttrss_feeds.title AS feed_title,";
} else {
- $query_strategy_part = "feed_id = '$feed'";
+ $query_strategy_part = "feed_id = " . $pdo->quote($feed);
}
} else if ($feed == 0 && !$cat_view) { // archive virtual feed
$query_strategy_part = "feed_id IS NULL";
} else if ($feed == -3) { // fresh virtual feed
$query_strategy_part = "unread = true AND score >= 0";
- $intl = get_pref("FRESH_ARTICLE_MAX_AGE", $owner_uid);
+ $intl = (int) get_pref("FRESH_ARTICLE_MAX_AGE", $owner_uid);
if (DB_TYPE == "pgsql") {
$query_strategy_part .= " AND date_entered > NOW() - INTERVAL '$intl hour' ";
} else if ($feed <= LABEL_BASE_INDEX) { // labels
$label_id = Labels::feed_to_label_id($feed);
- $query_strategy_part = "label_id = '$label_id' AND
+ $query_strategy_part = "label_id = ".$pdo->quote($label_id)." AND
ttrss_labels2.id = ttrss_user_labels2.label_id AND
ttrss_user_labels2.article_id = ref_id";
$content_query_part = "content, ";
if ($limit_query_part) {
- $offset_query_part = "OFFSET $offset";
+ $offset_query_part = "OFFSET " . (int)$offset;
} else {
$offset_query_part = "";
}
// proper override_order applied above
if ($vfeed_query_part && !$ignore_vfeed_group && get_pref('VFEED_GROUP_BY_FEED', $owner_uid)) {
if (!$override_order) {
- $order_by = "ttrss_feeds.title, $order_by";
+ $order_by = "ttrss_feeds.title, ".$order_by;
} else {
- $order_by = "ttrss_feeds.title, $override_order";
+ $order_by = "ttrss_feeds.title, ".$override_order;
}
}
$from_qpart
WHERE
$feed_check_qpart
- ttrss_user_entries.owner_uid = '$owner_uid' AND
+ ttrss_user_entries.owner_uid = ".$pdo->quote($owner_uid)." AND
$search_query_part
$start_ts_query_part
$since_id_part
$sanity_interval_qpart
$first_id_query_strategy_part ORDER BY $order_by LIMIT 1";
- if ($_REQUEST["debug"]) {
+ /*if ($_REQUEST["debug"]) {
print $query;
- }
+ }*/
- $result = db_query($query);
+ $res = $pdo->query($query);
- if ($result && db_num_rows($result) > 0) {
- $first_id = (int)db_fetch_result($result, 0, "id");
+ if ($row = $res->fetch()) {
+ $first_id = (int)$row["id"];
if ($offset > 0 && $first_id && $check_first_id && $first_id != $check_first_id) {
return array(-1, $feed_title, $feed_site_url, $last_error, $last_updated, $search_words, $first_id);
$from_qpart
WHERE
$feed_check_qpart
- ttrss_user_entries.owner_uid = '$owner_uid' AND
+ ttrss_user_entries.owner_uid = ".$pdo->quote($owner_uid)." AND
$search_query_part
$start_ts_query_part
$view_query_part
$query_strategy_part ORDER BY $order_by
$limit_query_part $offset_query_part";
- if ($_REQUEST["debug"]) print $query;
+ //if ($_REQUEST["debug"]) print $query;
- $result = db_query($query);
+ $res = $pdo->query($query);
} else {
// browsing by tag
FROM ttrss_entries, ttrss_user_entries, ttrss_tags
WHERE
ref_id = ttrss_entries.id AND
- ttrss_user_entries.owner_uid = $owner_uid AND
+ ttrss_user_entries.owner_uid = ".$pdo->quote($owner_uid)." AND
post_int_id = int_id AND
- tag_name = '$feed' AND
+ tag_name = ".$pdo->quote($feed)." AND
$view_query_part
$search_query_part
$query_strategy_part ORDER BY $order_by
if ($_REQUEST["debug"]) print $query;
- $result = db_query($query);
+ $res = $pdo->query($query);
}
- return array($result, $feed_title, $feed_site_url, $last_error, $last_updated, $search_words, $first_id);
+ return array($res, $feed_title, $feed_site_url, $last_error, $last_updated, $search_words, $first_id);
}
static function getParentCategories($cat, $owner_uid) {
$rv = array();
- $result = db_query("SELECT parent_cat FROM ttrss_feed_categories
- WHERE id = '$cat' AND parent_cat IS NOT NULL AND owner_uid = $owner_uid");
+ $pdo = Db::pdo();
+
+ $sth = $pdo->prepare("SELECT parent_cat FROM ttrss_feed_categories
+ WHERE id = ? AND parent_cat IS NOT NULL AND owner_uid = ?");
+ $sth->execute([$cat, $owner_uid]);
- while ($line = db_fetch_assoc($result)) {
+ while ($line = $sth->fetch()) {
array_push($rv, $line["parent_cat"]);
$rv = array_merge($rv, Feeds::getParentCategories($line["parent_cat"], $owner_uid));
}
static function getChildCategories($cat, $owner_uid) {
$rv = array();
- $result = db_query("SELECT id FROM ttrss_feed_categories
- WHERE parent_cat = '$cat' AND owner_uid = $owner_uid");
+ $pdo = Db::pdo();
- while ($line = db_fetch_assoc($result)) {
+ $sth = $pdo->prepare("SELECT id FROM ttrss_feed_categories
+ WHERE parent_cat = ? AND owner_uid = ?");
+ $sth->execute([$cat, $owner_uid]);
+
+ while ($line = $sth->fetch()) {
array_push($rv, $line["id"]);
$rv = array_merge($rv, Feeds::getChildCategories($line["id"], $owner_uid));
}
}
static function getFeedCategory($feed) {
- $result = db_query("SELECT cat_id FROM ttrss_feeds
- WHERE id = '$feed'");
+ $pdo = Db::pdo();
- if (db_num_rows($result) > 0) {
- return db_fetch_result($result, 0, "cat_id");
+ $sth = $pdo->prepare("SELECT cat_id FROM ttrss_feeds
+ WHERE id = ?");
+ $sth->execute([$feed]);
+
+ if ($row = $sth->fetch()) {
+ return $row["cat_id"];
} else {
return false;
}