[-] BO : fixed image import with allow_url_fopen deactivated #PSCFV-8181
This commit is contained in:
+23
-2
@@ -1313,9 +1313,30 @@ class ToolsCore
|
|||||||
{
|
{
|
||||||
return @simplexml_load_string(Tools::file_get_contents($url), $class_name);
|
return @simplexml_load_string(Tools::file_get_contents($url), $class_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function copy($source, $destination, $stream_context = null)
|
||||||
|
{
|
||||||
|
if ($stream_context == null && preg_match('/^https?:\/\//', $source))
|
||||||
|
$stream_context = @stream_context_create(array('http' => array('timeout' => 10)));
|
||||||
|
|
||||||
|
if (in_array(@ini_get('allow_url_fopen'), array('On', 'on', '1')) || !preg_match('/^https?:\/\//', $source))
|
||||||
public static $a = 0;
|
return @copy($source, $destination, $stream_context);
|
||||||
|
elseif (function_exists('curl_init'))
|
||||||
|
{
|
||||||
|
$curl = curl_init();
|
||||||
|
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
||||||
|
curl_setopt($curl, CURLOPT_URL, $source);
|
||||||
|
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 5);
|
||||||
|
curl_setopt($curl, CURLOPT_TIMEOUT, 10);
|
||||||
|
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
|
||||||
|
$opts = stream_context_get_options($stream_context);
|
||||||
|
$content = curl_exec($curl);
|
||||||
|
curl_close($curl);
|
||||||
|
return file_put_contents($content, $destination);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated as of 1.5 use Media::minifyHTML()
|
* @deprecated as of 1.5 use Media::minifyHTML()
|
||||||
|
|||||||
@@ -819,7 +819,7 @@ class AdminImportControllerCore extends AdminController
|
|||||||
|
|
||||||
// 'file_exists' doesn't work on distant file, and getimagesize make the import slower.
|
// 'file_exists' doesn't work on distant file, and getimagesize make the import slower.
|
||||||
// Just hide the warning, the traitment will be the same.
|
// Just hide the warning, the traitment will be the same.
|
||||||
if (@copy($url, $tmpfile))
|
if (Tools::copy($url, $tmpfile))
|
||||||
{
|
{
|
||||||
ImageManager::resize($tmpfile, $path.'.jpg');
|
ImageManager::resize($tmpfile, $path.'.jpg');
|
||||||
$images_types = ImageType::getImagesTypes($entity);
|
$images_types = ImageType::getImagesTypes($entity);
|
||||||
|
|||||||
Reference in New Issue
Block a user