]> git.wh0rd.org - tt-rss.git/blobdiff - include/rssfuncs.php
force refetch feed when clicking update/clicking on same feed in the tree
[tt-rss.git] / include / rssfuncs.php
index 241896f8bcb737ed749cea292e265efea9656441..14fa5f34838640c5de79e435fadd53f923eb3987 100644 (file)
@@ -1,7 +1,7 @@
 <?php
        define('DAEMON_UPDATE_LOGIN_LIMIT', 30);
        define('DAEMON_FEED_LIMIT', 100);
-       define('DAEMON_SLEEP_INTERVAL', 120);
+       define('DAEMON_SLEEP_INTERVAL', 60);
 
        function update_feedbrowser_cache($link) {
 
 
        } // function update_daemon_common
 
-       function fetch_twitter_rss($link, $url, $owner_uid) {
-
-               require_once 'lib/tmhoauth/tmhOAuth.php';
-               require_once "lib/magpierss/rss_fetch.inc";
-               require_once 'lib/magpierss/rss_utils.inc';
-
-               $result = db_query($link, "SELECT twitter_oauth FROM ttrss_users
-                       WHERE id = $owner_uid");
-
-               $access_token = json_decode(db_fetch_result($result, 0, 'twitter_oauth'), true);
-               $url_escaped = db_escape_string($url);
-
-               if ($access_token) {
-
-                       $tmhOAuth = new tmhOAuth(array(
-                               'consumer_key'    => CONSUMER_KEY,
-                               'consumer_secret' => CONSUMER_SECRET,
-                               'user_token' => $access_token['oauth_token'],
-                               'user_secret' => $access_token['oauth_token_secret'],
-                       ));
-
-                       $code = $tmhOAuth->request('GET', $url,
-                               convertUrlQuery(parse_url($url, PHP_URL_QUERY)));
-
-                       if ($code == 200) {
-
-                               $content = $tmhOAuth->response['response'];
-
-                               define('MAGPIE_CACHE_ON', false);
-
-                               $rss = new MagpieRSS($content, MAGPIE_OUTPUT_ENCODING,
-                                       MAGPIE_INPUT_ENCODING, MAGPIE_DETECT_ENCODING );
-
-                               return $rss;
-
-                       } else {
-
-                               db_query($link, "UPDATE ttrss_feeds
-                                       SET last_error = 'OAuth authorization failed ($code).'
-                                       WHERE feed_url = '$url_escaped' AND owner_uid = $owner_uid");
-                       }
-
-               } else {
-
-                       db_query($link, "UPDATE ttrss_feeds
-                               SET last_error = 'OAuth information not found.'
-                               WHERE feed_url = '$url_escaped' AND owner_uid = $owner_uid");
-
-                       return false;
-               }
-       }
-
        function update_rss_feed($link, $feed, $ignore_daemon = false, $no_cache = false,
                $override_url = false) {
 
                $cache_age = (is_null($last_updated) || $last_updated == '1970-01-01 00:00:00') ?
                        -1 : get_feed_update_interval($link, $feed) * 60;
 
-               if ($update_method == 3) {
-                       $rss = fetch_twitter_rss($link, $fetch_url, $owner_uid);
-               } else if ($update_method == 1) {
+               if ($update_method == 1) {
 
                        define('MAGPIE_CACHE_AGE', $cache_age);
                        define('MAGPIE_CACHE_ON', !$no_cache);
-                       define('MAGPIE_FETCH_TIME_OUT', 60);
+                       define('MAGPIE_FETCH_TIME_OUT', $no_cache ? 15 : 60);
                        define('MAGPIE_CACHE_DIR', CACHE_DIR . "/magpie");
 
                        $rss = @fetch_rss($fetch_url);
 
                        $rss = new SimplePie();
                        $rss->set_useragent(SELF_USER_AGENT);
-#                      $rss->set_timeout(10);
+                       $rss->set_timeout($no_cache ? 15 : 60);
                        $rss->set_feed_url($fetch_url);
                        $rss->set_output_encoding('UTF-8');
                        //$rss->force_feed(true);
 
                        $filters = load_filters($link, $feed, $owner_uid);
 
-//                     if ($debug_enabled) {
-//                             print_r($filters);
-//                     }
+                       if ($debug_enabled) {
+                               //print_r($filters);
+                               _debug("update_rss_feed: " . count($filters) . " filters loaded.");
+                       }
 
                        if ($use_simplepie) {
                                $iterator = $rss->get_items();
                                        $entry_tags[$i] = mb_strtolower($entry_tags[$i], 'utf-8');
 
                                if ($debug_enabled) {
-                                       _debug("update_rss_feed: unfiltered tags found:");
-                                       print_r($entry_tags);
+                                       //_debug("update_rss_feed: unfiltered tags found:");
+                                       //print_r($entry_tags);
                                }
 
                                # sanitize content
                                // check for manual tags (we have to do it here since they're loaded from filters)
 
                                foreach ($article_filters as $f) {
-                                       if ($f[0] == "tag") {
+                                       if ($f["type"] == "tag") {
 
-                                               $manual_tags = trim_array(explode(",", $f[1]));
+                                               $manual_tags = trim_array(explode(",", $f["param"]));
 
                                                foreach ($manual_tags as $tag) {
                                                        if (tag_is_valid($tag)) {