diff options
author | Andrew Dolgov <[email protected]> | 2013-02-23 18:38:50 +0400 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2013-02-23 18:38:50 +0400 |
commit | 017401ddce4ee4bafabf74996b9ca1f2d3c51f91 (patch) | |
tree | d5809fc6b6db12900ee41d5a590890e3283762a0 /include/rssfuncs.php | |
parent | fb850eecda80035e9c3db5bc749e9f8f17a0fab4 (diff) |
implement HOOK_FEED_FETCHED
Diffstat (limited to 'include/rssfuncs.php')
-rw-r--r-- | include/rssfuncs.php | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/include/rssfuncs.php b/include/rssfuncs.php index 4ad637342..af9a8b65c 100644 --- a/include/rssfuncs.php +++ b/include/rssfuncs.php @@ -204,15 +204,14 @@ $feed = db_escape_string($feed); - if ($auth_login && $auth_pass ){ + /* if ($auth_login && $auth_pass ){ $url_parts = array(); preg_match("/(^[^:]*):\/\/(.*)/", $fetch_url, $url_parts); if ($url_parts[1] && $url_parts[2]) { $fetch_url = $url_parts[1] . "://$auth_login:$auth_pass@" . $url_parts[2]; } - - } + } */ if ($override_url) $fetch_url = $override_url; @@ -231,12 +230,32 @@ mkdir($simplepie_cache_dir); } + $feed_data = fetch_file_contents($fetch_url, false, + $auth_login, $auth_pass, false, $no_cache ? 15 : 45); + + if (!$feed_data) { + global $fetch_last_error; + + if ($debug_enabled) { + _debug("update_rss_feed: unable to fetch: $fetch_last_error"); + } + + db_query($link, + "UPDATE ttrss_feeds SET last_error = '$fetch_last_error', + last_updated = NOW() WHERE id = '$feed'"); + + return; + } + + $pluginhost = new PluginHost($link); + + foreach ($pluginhost->get_hooks($pluginhost::HOOK_FEED_FETCHED) as $plugin) { + $feed_data = $plugin->hook_feed_fetched($feed_data); + } + $rss = new SimplePie(); - $rss->set_useragent(SELF_USER_AGENT); - $rss->set_timeout($no_cache ? 15 : 60); - $rss->set_feed_url($fetch_url); $rss->set_output_encoding('UTF-8'); - $rss->force_feed(true); + $rss->set_raw_data($feed_data); if ($debug_enabled) { _debug("feed update interval (sec): " . @@ -265,8 +284,6 @@ // 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(); |