From 41245888f1c538f15d7ffa3a0ddc9310b60c98d7 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 26 Jan 2016 11:45:47 +0300 Subject: [PATCH] only stop inline feed updates with open_basedir enabled if there are any plugins that require CURL enabled add plugin->flags() returning array with additional plugin information, currently only CURL requirement (optional) --- classes/feeds.php | 29 ++++++++++++++++++++++++----- classes/plugin.php | 7 +++++++ plugins/af_readability/init.php | 4 ++++ plugins/af_redditimgur/init.php | 4 ++++ plugins/af_tumblr_1280/init.php | 4 ++++ plugins/af_unburn/init.php | 4 ++++ plugins/af_zz_imgsetsizes/init.php | 4 ++++ 7 files changed, 51 insertions(+), 5 deletions(-) diff --git a/classes/feeds.php b/classes/feeds.php index cb1b032d1..df0fd440b 100755 --- a/classes/feeds.php +++ b/classes/feeds.php @@ -166,12 +166,30 @@ class Feeds extends Handler_Protected { $method_split = explode(":", $method); - if ($method == "ForceUpdate" && $feed > 0 && is_numeric($feed) && !ini_get("open_basedir")) { + 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 ""; + + 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,10 @@ 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'"); } } + } } if ($method_split[0] == "MarkAllReadGR") { diff --git a/classes/plugin.php b/classes/plugin.php index 8fbacf363..01ac46bae 100644 --- a/classes/plugin.php +++ b/classes/plugin.php @@ -15,6 +15,13 @@ class Plugin { return array(1.0, "plugin", "No description", "No author", false); } + function flags() { + /* associative array, possible keys: + needs_curl = boolean + */ + return array(); + } + function get_js() { return ""; } diff --git a/plugins/af_readability/init.php b/plugins/af_readability/init.php index 1d7c638a6..a52b745b8 100755 --- a/plugins/af_readability/init.php +++ b/plugins/af_readability/init.php @@ -9,6 +9,10 @@ class Af_Readability extends Plugin { "fox"); } + function flags() { + return array("needs_curl" => true); + } + function save() { // } diff --git a/plugins/af_redditimgur/init.php b/plugins/af_redditimgur/init.php index 1ab696ce3..67ee0c989 100755 --- a/plugins/af_redditimgur/init.php +++ b/plugins/af_redditimgur/init.php @@ -8,6 +8,10 @@ class Af_RedditImgur extends Plugin { "fox"); } + function flags() { + return array("needs_curl" => true); + } + function init($host) { $this->host = $host; diff --git a/plugins/af_tumblr_1280/init.php b/plugins/af_tumblr_1280/init.php index 985d8c5f8..dbdc78e93 100755 --- a/plugins/af_tumblr_1280/init.php +++ b/plugins/af_tumblr_1280/init.php @@ -8,6 +8,10 @@ class Af_Tumblr_1280 extends Plugin { "fox"); } + function flags() { + return array("needs_curl" => true); + } + function init($host) { $this->host = $host; diff --git a/plugins/af_unburn/init.php b/plugins/af_unburn/init.php index 72f8a2606..e5f43e40a 100755 --- a/plugins/af_unburn/init.php +++ b/plugins/af_unburn/init.php @@ -8,6 +8,10 @@ class Af_Unburn extends Plugin { "fox"); } + function flags() { + return array("needs_curl" => true); + } + function init($host) { $this->host = $host; diff --git a/plugins/af_zz_imgsetsizes/init.php b/plugins/af_zz_imgsetsizes/init.php index 96afbbfe0..cdfd06338 100644 --- a/plugins/af_zz_imgsetsizes/init.php +++ b/plugins/af_zz_imgsetsizes/init.php @@ -8,6 +8,10 @@ class Af_Zz_ImgSetSizes extends Plugin { "fox"); } + function flags() { + return array("needs_curl" => true); + } + function init($host) { $this->host = $host;