allow NO_CURL to disable several CURL-related checks in plugins
af_readability: skip http content-type checking when open_basedir is enabled
This commit is contained in:
parent
4c46702672
commit
aa03bac424
5 changed files with 12 additions and 5 deletions
|
@ -325,6 +325,10 @@
|
||||||
array_push($notices, "It is highly recommended to enable support for CURL in PHP.");
|
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) {
|
if (count($notices) > 0) {
|
||||||
print_notice("Configuration check succeeded with minor problems:");
|
print_notice("Configuration check succeeded with minor problems:");
|
||||||
|
|
||||||
|
|
|
@ -100,13 +100,15 @@ class Af_Readability extends Plugin {
|
||||||
|
|
||||||
if (!class_exists("Readability")) require_once(dirname(dirname(__DIR__)). "/lib/readability/Readability.php");
|
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"]);
|
$ch = curl_init($article["link"]);
|
||||||
|
|
||||||
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
|
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||||
curl_setopt($ch, CURLOPT_HEADER, true);
|
curl_setopt($ch, CURLOPT_HEADER, true);
|
||||||
curl_setopt($ch, CURLOPT_NOBODY, 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);
|
curl_setopt($ch, CURLOPT_USERAGENT, SELF_USER_AGENT);
|
||||||
|
|
||||||
@$result = curl_exec($ch);
|
@$result = curl_exec($ch);
|
||||||
|
|
|
@ -244,7 +244,7 @@ class Af_RedditImgur extends Plugin {
|
||||||
|
|
||||||
$found = $this->inline_stuff($article, $doc, $xpath);
|
$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) {
|
mb_strlen(strip_tags($article["content"])) <= 150) {
|
||||||
|
|
||||||
if (!class_exists("Readability")) require_once(dirname(dirname(__DIR__)). "/lib/readability/Readability.php");
|
if (!class_exists("Readability")) require_once(dirname(dirname(__DIR__)). "/lib/readability/Readability.php");
|
||||||
|
|
|
@ -17,7 +17,7 @@ class Af_Unburn extends Plugin {
|
||||||
function hook_article_filter($article) {
|
function hook_article_filter($article) {
|
||||||
$owner_uid = $article["owner_uid"];
|
$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;
|
return $article;
|
||||||
|
|
||||||
if ((strpos($article["link"], "feedproxy.google.com") !== FALSE ||
|
if ((strpos($article["link"], "feedproxy.google.com") !== FALSE ||
|
||||||
|
|
|
@ -18,7 +18,8 @@ class Af_Zz_ImgSetSizes extends Plugin {
|
||||||
|
|
||||||
function hook_article_filter($article) {
|
function hook_article_filter($article) {
|
||||||
|
|
||||||
$owner_uid = $article["owner_uid"];
|
if (defined('NO_CURL') || !function_exists("curl_init"))
|
||||||
|
return $article;
|
||||||
|
|
||||||
$charset_hack = '<head>
|
$charset_hack = '<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
||||||
|
|
Loading…
Reference in a new issue