// Tools::simplexml_load_file now use curl if allow_url_fopen is disabled

This commit is contained in:
Rémi Gaillard committed 2013-01-29 10:13:34 +01:00
1 parent d920c050b4
commit 734b227a7f
1 file changed
+4 -7
+4 -7
View File
@@ -1277,9 +1277,9 @@ class ToolsCore
public static function file_get_contents($url, $use_include_path = false, $stream_context = null, $curl_timeout = 5) public static function file_get_contents($url, $use_include_path = false, $stream_context = null, $curl_timeout = 5)
{ {
if ($stream_context == null && !strstr($url, 'http')) if ($stream_context == null && !preg_match('/^https?:\/\//', $url))
$stream_context = @stream_context_create(array('http' => array('timeout' => 5))); $stream_context = @stream_context_create(array('http' => array('timeout' => $curl_timeout)));
if (in_array(ini_get('allow_url_fopen'), array('On', 'on', '1')) || !strstr($url, 'http')) if (in_array(ini_get('allow_url_fopen'), array('On', 'on', '1')) || !preg_match('/^https?:\/\//', $url))
return @file_get_contents($url, $use_include_path, $stream_context); return @file_get_contents($url, $use_include_path, $stream_context);
elseif (function_exists('curl_init')) elseif (function_exists('curl_init'))
{ {
@@ -1308,10 +1308,7 @@ class ToolsCore
public static function simplexml_load_file($url, $class_name = null) public static function simplexml_load_file($url, $class_name = null)
{ {
if (in_array(ini_get('allow_url_fopen'), array('On', 'on', '1'))) return @simplexml_load_string(Tools::file_get_contents($url), $class_name);
return @simplexml_load_string(Tools::file_get_contents($url), $class_name);
else
return false;
} }