X-Git-Url: https://git.wh0rd.org/?a=blobdiff_plain;f=classes%2Ffeeds.php;h=48e3337e02ebe4eb17fdcf8e3b372f9281e40735;hb=9563e3bcd662b87ea6779714b51afb61571dd32d;hp=98507d361a7e076db3e47f06dd8ab2b4f4ce2862;hpb=bed2d6e05499c574b64d1dfdf6be3f43d704abb6;p=tt-rss.git diff --git a/classes/feeds.php b/classes/feeds.php index 98507d36..48e3337e 100755 --- a/classes/feeds.php +++ b/classes/feeds.php @@ -173,53 +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) { - try { - RSSUtils::update_rss_feed($feed, true); - } catch (PDOException $e) { - user_error("PDO Exception while doing on-demand feed update for $feed: " . $e->getMessage(), E_USER_NOTICE); - } - } 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") { @@ -320,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)) { @@ -520,6 +476,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) { @@ -538,10 +496,10 @@ class Feeds extends Handler_Protected { } } - $expanded_class = $expand_cdm ? "expanded" : "expandable"; + $content_encoded = htmlspecialchars(json_encode($line["content"])); - $tmp_content = "
"; + $tmp_content = "
"; $tmp_content .= "
"; $tmp_content .= "
"; @@ -568,7 +526,7 @@ class Feeds extends Handler_Protected { $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) { @@ -617,9 +568,7 @@ class Feeds extends Handler_Protected { $tmp_content .= "
"; //cdmHeader - $tmp_content .= "
"; + $tmp_content .= "
"; $tmp_content .= "
"; if ($line['note']) { @@ -629,6 +578,7 @@ class Feeds extends Handler_Protected { if (!$line['lang']) $line['lang'] = 'en'; + // this is filled from RROW data-content $tmp_content .= "
"; if ($line["orig_feed_id"]) { @@ -657,14 +607,7 @@ class Feeds extends Handler_Protected { } } - $tmp_content .= ""; - $tmp_content .= ""; - $tmp_content .= htmlspecialchars($line["content"]); - $tmp_content .= ""; - $tmp_content .= ""; - $tmp_content .= "
"; //cdmContentInner - $tmp_content .= "
"; $always_display_enclosures = $line["always_display_enclosures"]; @@ -673,7 +616,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); @@ -1175,6 +1118,9 @@ class Feeds extends Handler_Protected { 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"]; @@ -1509,6 +1455,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)"; @@ -1517,10 +1467,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); @@ -1547,7 +1493,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 = ?");