X-Git-Url: https://git.wh0rd.org/?a=blobdiff_plain;f=classes%2Ffeeds.php;h=7da3f6f4d36b45d4a67c10d6ed07379992376faf;hb=8359ca6dad9051702d2635f5c2ce6b20ad0d4c2b;hp=7b5531464db1d38c05dfcb7d847da39e5321e7ed;hpb=8f92a67e6f1831d9cf1e746ddf8a06cc065d94ce;p=tt-rss.git diff --git a/classes/feeds.php b/classes/feeds.php index 7b553146..7da3f6f4 100755 --- a/classes/feeds.php +++ b/classes/feeds.php @@ -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 ""; - - 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") { @@ -316,7 +277,6 @@ 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'); if (is_object($result)) { @@ -385,7 +345,7 @@ class Feeds extends Handler_Protected { $score_pic = "images/" . get_score_pic($score); - $score_pic = ""; if ($score > 500) { @@ -402,9 +362,7 @@ class Feeds extends Handler_Protected { $entry_author = " — $entry_author"; } - $has_feed_icon = feeds::feedHasIcon($feed_id); - - if ($has_feed_icon) { + if (feeds::feedHasIcon($feed_id)) { $feed_icon_img = "\"\""; } else { $feed_icon_img = "\"\""; @@ -432,7 +390,7 @@ class Feeds extends Handler_Protected { $vf_catchup_link = "".__('mark feed as read').""; - $reply['content'] .= "
". + $reply['content'] .= "
". "
$feed_icon_img
". "". $line["feed_title"]." @@ -456,8 +414,8 @@ class Feeds extends Handler_Protected { $reply['content'] .= "
"; $reply['content'] .= "
"; - $reply['content'] .= ""; + $reply['content'] .= "" . truncate_string($line["title"], 200); @@ -476,7 +434,7 @@ class Feeds extends Handler_Protected { if (@$line["feed_title"]) { $rgba = @$rgba_cache[$feed_id]; - $reply['content'] .= "". + $reply['content'] .= "". truncate_string($line["feed_title"],30).""; } } @@ -516,6 +474,8 @@ class Feeds extends Handler_Protected { $line = $p->hook_render_article_cdm($line); } + $line['content'] = rewrite_cached_urls($line['content']); + if ($vfeed_group_enabled && $line["feed_title"]) { if ($feed_id != $vgroup_last_feed) { @@ -526,7 +486,7 @@ class Feeds extends Handler_Protected { $feed_icon_src = Feeds::getFeedIcon($feed_id); $feed_icon_img = ""; - $reply['content'] .= "
". + $reply['content'] .= "
". "
$feed_icon_img
". "". $line["feed_title"]." $vf_catchup_link
"; @@ -534,12 +494,12 @@ class Feeds extends Handler_Protected { } } - $expanded_class = $expand_cdm ? "expanded" : "expandable"; + $content_encoded = htmlspecialchars($line["content"]); - $tmp_content = "
"; + $tmp_content = "
"; - $tmp_content .= "
"; + $tmp_content .= "
"; $tmp_content .= "
"; $tmp_content .= " 0) { foreach ($highlight_words as $word) { - $line["title"] = preg_replace("/(\Q$word\E)/i", + $word = preg_quote($word, "/"); + + $line["title"] = preg_replace("/($word)/i", "$1", $line["title"]); } } // data-article-id included for context menu - $tmp_content .= " + class=\"titleWrap hlMenuAttach $hlc_suffix\"> "; - - if (!$expand_cdm) - $content_hidden = "style=\"display : none\""; - else - $excerpt_hidden = "style=\"display : none\""; - - $tmp_content .= "" . $content_preview . ""; - $tmp_content .= ""; if (!$vfeed_group_enabled) { if (@$line["feed_title"]) { $rgba = @$rgba_cache[$feed_id]; - $tmp_content .= "
+ $tmp_content .= "
". truncate_string($line["feed_title"],30)." @@ -599,7 +550,7 @@ class Feeds extends Handler_Protected { $tmp_content .= "$updated_fmt"; - $tmp_content .= "
"; + $tmp_content .= "
"; $tmp_content .= "$score_pic"; if (!get_pref("VFEED_GROUP_BY_FEED") && $line["feed_title"]) { @@ -607,13 +558,11 @@ class Feeds extends Handler_Protected { title=\"".htmlspecialchars($line["feed_title"])."\" onclick=\"viewfeed({feed:$feed_id})\">$feed_icon_img"; } - $tmp_content .= "
"; //scoreWrap + $tmp_content .= "
"; //score wrapper2 - $tmp_content .= "
"; //cdmHeader + $tmp_content .= "
"; //header - $tmp_content .= "
"; + $tmp_content .= "
"; $tmp_content .= "
"; if ($line['note']) { @@ -623,7 +572,8 @@ class Feeds extends Handler_Protected { if (!$line['lang']) $line['lang'] = 'en'; - $tmp_content .= "
"; + // this is filled from RROW data-content + $tmp_content .= "
"; if ($line["orig_feed_id"]) { @@ -651,15 +601,8 @@ class Feeds extends Handler_Protected { } } - $tmp_content .= ""; - $tmp_content .= ""; - $tmp_content .= htmlspecialchars($line["content"]); - $tmp_content .= ""; - $tmp_content .= ""; - - $tmp_content .= "
"; //cdmContentInner - - $tmp_content .= "
"; + $tmp_content .= "
"; //content-inner + $tmp_content .= "
"; $always_display_enclosures = $line["always_display_enclosures"]; $tmp_content .= Article::format_article_enclosures($id, $always_display_enclosures, @@ -667,7 +610,7 @@ class Feeds extends Handler_Protected { $tmp_content .= "
"; // cdmIntermediate - $tmp_content .= "
"; + $tmp_content .= "
"; foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_LEFT_BUTTON) as $p) { $tmp_content .= $p->hook_article_left_button($line); @@ -712,7 +655,7 @@ class Feeds extends Handler_Protected { $tmp_content .= "
"; // buttons - $tmp_content .= "
"; // cdmFooter + $tmp_content .= "
"; // cdm footer $tmp_content .= "
"; // cdmContent $tmp_content .= "
"; // RROW.cdm @@ -996,6 +939,8 @@ class Feeds extends Handler_Protected { } function quickAddFeed() { + print "
"; + print_hidden("op", "rpc"); print_hidden("method", "addfeed"); @@ -1060,10 +1005,8 @@ class Feeds extends Handler_Protected {
"; - print ""; - print "
- "; + "; if (!(defined('_DISABLE_FEED_BROWSER') && _DISABLE_FEED_BROWSER)) { print ""; @@ -1072,6 +1015,8 @@ class Feeds extends Handler_Protected { print "
"; + print ""; + //return; } @@ -1129,6 +1074,8 @@ class Feeds extends Handler_Protected { $active_feed_id = sprintf("%d", $this->params[0]); $is_cat = $this->params[1] != "false"; + print "
"; + print "
".__('Look for')."
"; print "
"; @@ -1155,14 +1102,19 @@ class Feeds extends Handler_Protected {
"; } - print " + print "
"; + + print ""; } 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"]; @@ -1259,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); @@ -1425,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"; } @@ -1496,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)"; @@ -1504,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); @@ -1534,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 = ?"); @@ -1660,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; @@ -1875,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).")"; @@ -2084,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); @@ -2132,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);