]> git.wh0rd.org - tt-rss.git/blobdiff - classes/feeds.php
inline feed update: set feed as needing update if open_basedir is set + plugins need...
[tt-rss.git] / classes / feeds.php
index 07a18741dc692e8166006b267de08897d79efbce..e0390ecc17cf212352f5bcb20d9540c50fe47297 100755 (executable)
@@ -169,9 +169,27 @@ class Feeds extends Handler_Protected {
                if ($method == "ForceUpdate" && $feed > 0 && is_numeric($feed)) {
                        // Update the feed if required with some basic flood control
 
-                       $result = $this->dbh->query(
-                               "SELECT cache_images,".SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated
-                                       FROM ttrss_feeds WHERE id = '$feed'");
+                       $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 "<!-- any_needs_curl: $any_needs_curl -->";
+
+                       if (!$any_needs_curl) {
+
+                               $result = $this->dbh->query(
+                                               "SELECT cache_images," . SUBSTRING_FOR_DATE . "(last_updated,1,19) AS last_updated
+                                               FROM ttrss_feeds WHERE id = '$feed'");
 
                                if ($this->dbh->num_rows($result) != 0) {
                                        $last_updated = strtotime($this->dbh->fetch_result($result, 0, "last_updated"));
@@ -182,9 +200,13 @@ class Feeds extends Handler_Protected {
                                                update_rss_feed($feed, true, true);
                                        } else {
                                                $this->dbh->query("UPDATE ttrss_feeds SET last_updated = '1970-01-01', last_update_started = '1970-01-01'
-                                                       WHERE id = '$feed'");
+                                                               WHERE id = '$feed'");
                                        }
                                }
+                       } else {
+                               $this->dbh->query("UPDATE ttrss_feeds SET last_updated = '1970-01-01', last_update_started = '1970-01-01'
+                                                               WHERE id = '$feed'");
+                       }
                }
 
                if ($method_split[0] == "MarkAllReadGR")  {
@@ -280,19 +302,7 @@ class Feeds extends Handler_Protected {
                        $feed, $cat_view, $search, $view_mode,
                        $last_error, $last_updated);
 
-               $headlines_count = $this->dbh->num_rows($result);
-
-               /* if (get_pref('COMBINED_DISPLAY_MODE')) {
-                       $button_plugins = array();
-                       foreach (explode(",", ARTICLE_BUTTON_PLUGINS) as $p) {
-                               $pclass = "button_" . trim($p);
-
-                               if (class_exists($pclass)) {
-                                       $plugin = new $pclass();
-                                       array_push($button_plugins, $plugin);
-                               }
-                       }
-               } */
+               $headlines_count = is_numeric($result) ? 0 : $this->dbh->num_rows($result);
 
                if ($offset == 0) {
                        foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_HEADLINES_BEFORE) as $p) {
@@ -302,7 +312,7 @@ class Feeds extends Handler_Protected {
 
                $reply['content'] = '';
 
-               if (!is_numeric($result) && $this->dbh->num_rows($result) > 0) {
+               if ($headlines_count > 0) {
 
                        $lnum = $offset;
 
@@ -664,7 +674,7 @@ class Feeds extends Handler_Protected {
                        if ($line["orig_feed_id"]) {
 
                                $tmp_result = $this->dbh->query("SELECT * FROM ttrss_archived_feeds
-                                       WHERE id = ".$line["orig_feed_id"]);
+                                       WHERE id = ".$line["orig_feed_id"] . " AND owner_uid = " . $_SESSION["uid"]);
 
                                                if ($this->dbh->num_rows($tmp_result) != 0) {
 
@@ -935,7 +945,7 @@ class Feeds extends Handler_Protected {
                //$reply['headlines']['content'] =& $ret[5]['content'];
                //$reply['headlines']['toolbar'] =& $ret[5]['toolbar'];
 
-               $reply['headlines'] =& $ret[5];
+               $reply['headlines'] = $ret[5];
 
                if (!$next_unread_feed)
                        $reply['headlines']['id'] = $feed;