]> git.wh0rd.org Git - tt-rss.git/commitdiff
allow NO_CURL to disable several CURL-related checks in plugins
authorAndrew Dolgov <noreply@madoka.volgo-balt.ru>
Fri, 20 Nov 2015 10:34:52 +0000 (13:34 +0300)
committerAndrew Dolgov <noreply@madoka.volgo-balt.ru>
Fri, 20 Nov 2015 10:34:52 +0000 (13:34 +0300)
af_readability: skip http content-type checking when open_basedir is enabled

install/index.php
plugins/af_readability/init.php
plugins/af_redditimgur/init.php
plugins/af_unburn/init.php
plugins/af_zz_imgsetsizes/init.php

index 959dc6c0eeb87cd9cff498b75a2b0f54d3fc0202..74ea65652549a97771639df869485b6b10a4e4fe 100755 (executable)
                        array_push($notices, "It is highly recommended to enable support for CURL in PHP.");
                }
 
+               if (function_exists("curl_init") && ini_get("open_basedir")) {
+                       array_push($notices, "CURL and open_basedir combination breaks support for HTTP redirects. See the FAQ for more information.");
+               }
+
                if (count($notices) > 0) {
                        print_notice("Configuration check succeeded with minor problems:");
 
index 6216d510a58cd59abe609a88012a7c3107808d90..675e5c5d5214ea309bb289f8b59ff8f60f6385df 100755 (executable)
@@ -100,13 +100,15 @@ class Af_Readability extends Plugin {
 
                if (!class_exists("Readability")) require_once(dirname(dirname(__DIR__)). "/lib/readability/Readability.php");
 
-               if (function_exists("curl_init")) {
+               if (!defined('NO_CURL') && function_exists('curl_init') && !ini_get("open_basedir")) {
+
                        $ch = curl_init($article["link"]);
+
                        curl_setopt($ch, CURLOPT_TIMEOUT, 5);
                        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                        curl_setopt($ch, CURLOPT_HEADER, true);
                        curl_setopt($ch, CURLOPT_NOBODY, true);
-                       curl_setopt($ch, CURLOPT_FOLLOWLOCATION, !ini_get("open_basedir"));
+                       curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
                        curl_setopt($ch, CURLOPT_USERAGENT, SELF_USER_AGENT);
 
                        @$result = curl_exec($ch);
index f99941477484733fbae91caca6e76cca4e1ae8a9..3ff9607293a2a6b863a048f67fa00dcc02fdbbdf 100755 (executable)
@@ -244,7 +244,7 @@ class Af_RedditImgur extends Plugin {
 
                        $found = $this->inline_stuff($article, $doc, $xpath);
 
-                       if (function_exists("curl_init") && !$found && $this->host->get($this, "enable_readability") &&
+                       if (!defined('NO_CURL') && function_exists("curl_init") && !$found && $this->host->get($this, "enable_readability") &&
                                mb_strlen(strip_tags($article["content"])) <= 150) {
 
                                if (!class_exists("Readability")) require_once(dirname(dirname(__DIR__)). "/lib/readability/Readability.php");
index 5930388711fdf66ad778290b721e6495074bd984..263997dbf330a70c17c3758093a836f6f8efe2db 100755 (executable)
@@ -17,7 +17,7 @@ class Af_Unburn extends Plugin {
        function hook_article_filter($article) {
                $owner_uid = $article["owner_uid"];
 
-               if (!function_exists("curl_init") || ini_get("open_basedir"))
+               if (defined('NO_CURL') || !function_exists("curl_init") || ini_get("open_basedir"))
                        return $article;
 
                if ((strpos($article["link"], "feedproxy.google.com") !== FALSE ||
index d71ec096e23eb722bd4d879cab1c655a905a990c..96afbbfe0c47edbbace30082139965d66bbf0ed7 100644 (file)
@@ -18,7 +18,8 @@ class Af_Zz_ImgSetSizes extends Plugin {
 
        function hook_article_filter($article) {
 
-               $owner_uid = $article["owner_uid"];
+               if (defined('NO_CURL') || !function_exists("curl_init"))
+                       return $article;
 
                $charset_hack = '<head>
                        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>