From 734b227a7fdaf8b4709559240f3df42ef2a3b1a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Gaillard?= Date: Tue, 29 Jan 2013 10:13:34 +0100 Subject: [PATCH] // Tools::simplexml_load_file now use curl if allow_url_fopen is disabled --- classes/Tools.php | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/classes/Tools.php b/classes/Tools.php index e2217c6e5..feb1bdb34 100644 --- a/classes/Tools.php +++ b/classes/Tools.php @@ -1277,9 +1277,9 @@ class ToolsCore public static function file_get_contents($url, $use_include_path = false, $stream_context = null, $curl_timeout = 5) { - if ($stream_context == null && !strstr($url, 'http')) - $stream_context = @stream_context_create(array('http' => array('timeout' => 5))); - if (in_array(ini_get('allow_url_fopen'), array('On', 'on', '1')) || !strstr($url, 'http')) + if ($stream_context == null && !preg_match('/^https?:\/\//', $url)) + $stream_context = @stream_context_create(array('http' => array('timeout' => $curl_timeout))); + 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); elseif (function_exists('curl_init')) { @@ -1308,10 +1308,7 @@ class ToolsCore 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); - else - return false; + return @simplexml_load_string(Tools::file_get_contents($url), $class_name); }