|
|
|
@ -5,18 +5,30 @@ class Stream { |
|
|
|
* Telecharge depuis $url vers $out. |
|
|
|
* |
|
|
|
* @param string $url URL a telecharger |
|
|
|
* @param string $out Fichier de destination |
|
|
|
* |
|
|
|
* @return array Informations sur le transfert |
|
|
|
*/ |
|
|
|
static function get($url, $out) { |
|
|
|
static function get($url, $filename) { |
|
|
|
set_time_limit(0); |
|
|
|
$ch = curl_init($url);//Here is the file we are downloading, replace spaces with %20
|
|
|
|
curl_exec($ch); // get curl response
|
|
|
|
|
|
|
|
$ch = curl_init($url); |
|
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
|
|
|
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'HEAD'); |
|
|
|
curl_setopt($ch, CURLOPT_HEADER, true); |
|
|
|
curl_setopt($ch, CURLOPT_NOBODY, true); |
|
|
|
curl_setopt ($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); |
|
|
|
$res = curl_exec($ch); |
|
|
|
curl_close($ch); |
|
|
|
|
|
|
|
foreach(explode("\n", $res) as $headerLine) { |
|
|
|
header($headerLine); |
|
|
|
} |
|
|
|
|
|
|
|
$ch = curl_init($url); |
|
|
|
curl_setopt ($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); |
|
|
|
curl_exec($ch); |
|
|
|
$retour = curl_getinfo($ch); |
|
|
|
curl_close($ch); |
|
|
|
return $retour; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//$result = Stream::get('https://dl.sdv.fr/files/0/6/7/rubygem-csscss-1.0.0-1.fc18.src.rpm', 'Archive.zip');
|
|
|
|
} |