From 2d5bd901f4ef47b34795dce6fafb08a7c821bd27 Mon Sep 17 00:00:00 2001 From: gRoussac Date: Mon, 16 Sep 2013 18:51:06 +0200 Subject: [PATCH] [*] CORE : Refactoring Tools::copy() as copy with context > PHP 5.3 --- classes/Tools.php | 28 +++------------------------- 1 file changed, 3 insertions(+), 25 deletions(-) diff --git a/classes/Tools.php b/classes/Tools.php index 6e2a4030a..38aee11b6 100644 --- a/classes/Tools.php +++ b/classes/Tools.php @@ -1408,31 +1408,9 @@ class ToolsCore 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)) - { - if (!is_null($stream_context)) - return @copy($source, $destination, $stream_context); - else - return @copy($source, $destination); - } - 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($destination, $content); - } - else - return false; + if (is_null($stream_context) && !preg_match('/^https?:\/\//', $source)) + return @copy($source, $destination); + return @file_put_contents($destination, Tools::file_get_contents($source, false, $stream_context)); } /**