sleep(1); // prevent flood (FIXME make this an option?)
}
+ require_once "digest.php";
+
// Send feed digests by email if needed.
send_headlines_digests($link, $debug);
if (!$rss->error()) {
+ // We use local pluginhost here because we need to load different per-user feed plugins
+ $user_plugins = get_pref($link, "_ENABLED_PLUGINS", $owner_uid);
+
+ $pluginhost = new PluginHost($link);
+
+ $pluginhost->load(PLUGINS, $pluginhost::KIND_ALL);
+ $pluginhost->load($user_plugins, $pluginhost::KIND_USER, $owner_uid);
+ $pluginhost->load_data();
+
+ $pluginhost->run_hooks($pluginhost::HOOK_FEED_PARSED, "hook_feed_parsed", $rss);
+
if ($debug_enabled) {
_debug("update_rss_feed: processing feed data...");
}
$owner_uid = db_fetch_result($result, 0, "owner_uid");
- $site_url = db_escape_string(mb_substr(rewrite_relative_url($fetch_url, $rss->get_link()), 0, 250));
+ $site_url = db_escape_string(mb_substr(rewrite_relative_url($fetch_url, $rss->get_link()), 0, 245));
if ($debug_enabled) {
_debug("update_rss_feed: checking favicon...");
}
$icon_url = db_escape_string(mb_substr(
- rewrite_relative_url($fetch_url, $rss->get_image_url()), 0, 250));
+ rewrite_relative_url($fetch_url, $rss->get_image_url()), 0, 245));
if ($icon_url && $orig_icon_url != $icon_url) {
db_query($link, "UPDATE ttrss_feeds SET icon_url = '$icon_url' WHERE id = '$feed'");
}
$entry_title = $item->get_title();
- $entry_link = rewrite_relative_url($site_url, $item->get_link());
+
+ $entry_link = rewrite_relative_url($site_url, htmlspecialchars_decode($item->get_link()));
if ($debug_enabled) {
_debug("update_rss_feed: title $entry_title");
$entry_author = db_escape_string($entry_author);
}
- $entry_guid = db_escape_string(mb_substr($entry_guid, 0, 250));
+ $entry_guid = db_escape_string(mb_substr($entry_guid, 0, 245));
$result = db_query($link, "SELECT id FROM ttrss_entries
WHERE guid = '$entry_guid'");
- $entry_comments = db_escape_string(mb_substr($entry_comments, 0, 250));
- $entry_author = db_escape_string(mb_substr($entry_author, 0, 250));
+ $entry_comments = db_escape_string(mb_substr($entry_comments, 0, 245));
+ $entry_author = db_escape_string(mb_substr($entry_author, 0, 245));
$num_comments = $item->get_item_tags('http://purl.org/rss/1.0/modules/slash/', 'comments');
_debug("update_rss_feed: looking for tags [2]...");
}
- /* taaaags */
- // <a href="..." rel="tag">Xorg</a>, //
-
- $entry_tags = null;
-
- preg_match_all("/<a.*?rel=['\"]tag['\"].*?\>([^<]+)<\/a>/i",
- $entry_content, $entry_tags);
-
- $entry_tags = $entry_tags[1];
-
- $entry_tags = array_merge($entry_tags, $additional_tags);
- $entry_tags = array_unique($entry_tags);
+ $entry_tags = array_unique($additional_tags);
for ($i = 0; $i < count($entry_tags); $i++)
$entry_tags[$i] = mb_strtolower($entry_tags[$i], 'utf-8');
}
// TODO: less memory-hungry implementation
- global $pluginhost;
if ($debug_enabled) {
_debug("update_rss_feed: applying plugin filters..");
}
- $article = array("owner_uid" => $owner_uid,
+ $article = array("owner_uid" => $owner_uid, // read only
+ "guid" => $entry_guid, // read only
"title" => $entry_title,
"content" => $entry_content,
"link" => $entry_link,
"author" => $entry_author);
foreach ($pluginhost->get_hooks($pluginhost::HOOK_ARTICLE_FILTER) as $plugin) {
+
$article = $plugin->hook_article_filter($article);
}
- $entry_title = $article["title"];
- $entry_content = $article["content"];
$entry_tags = $article["tags"];
- $entry_author = $article["author"];
-
- $entry_content = db_escape_string($entry_content, false);
- $entry_title = db_escape_string($entry_title);
- $entry_author = db_escape_string($entry_author);
- $entry_link = db_escape_string($entry_link);
+ $entry_content = db_escape_string($article["content"], false);
+ $entry_title = db_escape_string($article["title"]);
+ $entry_author = db_escape_string($article["author"]);
+ $entry_link = db_escape_string($article["link"]);
$content_hash = "SHA1:" . sha1(strip_tags($entry_content));
} else {
- $error_msg = mb_substr($rss->error(), 0, 250);
+ $error_msg = db_escape_string(mb_substr($rss->error(), 0, 245));
if ($debug_enabled) {
_debug("update_rss_feed: error fetching feed: $error_msg");
}
- $error_msg = db_escape_string($error_msg);
-
db_query($link,
"UPDATE ttrss_feeds SET last_error = '$error_msg',
last_updated = NOW() WHERE id = '$feed'");