//// Merge -> revision 8290

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@8295 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
tDidierjean
2011-09-01 09:53:43 +00:00
parent d27c0b3b7d
commit c2258ae8e9
50 changed files with 431 additions and 256 deletions
+7 -7
View File
@@ -1162,15 +1162,19 @@ class ToolsCore
return self::$file_exists_cache[$filename];
}
public static function file_get_contents($url, $useIncludePath = false, $streamContext = NULL)
public static function file_get_contents($url, $useIncludePath = false, $streamContext = NULL, $curlTimeOut = 5)
{
if ($streamContext == NULL)
$streamContext = stream_context_create(array('http' => array('timeout' => 5)));
if (in_array(ini_get('allow_url_fopen'), array('On', 'on', '1')))
return file_get_contents($url, $useIncludePath, $streamContext);
else if (function_exists('curl_init'))
return @file_get_contents($url, $useIncludePath, $streamContext);
elseif (function_exists('curl_init') && in_array(ini_get('allow_url_fopen'), array('On', 'on', '1')))
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, $curlTimeOut);
$content = curl_exec($curl);
curl_close($curl);
return $content;
@@ -1182,11 +1186,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_file($url, $class_name);
elseif (function_exists('curl_init'))
{
return simplexml_load_string(Tools::file_get_contents($url), $class_name);
}
else
return false;
}