|
|
|
@ -77,7 +77,6 @@ class Download { |
|
|
|
['_id' => $this->_id], |
|
|
|
['$push' => ['event' => $event]] |
|
|
|
); |
|
|
|
file_put_contents('toto', print_r($dbRet, true)); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
@ -86,9 +85,15 @@ file_put_contents('toto', print_r($dbRet, true)); |
|
|
|
* @return array Informations sur le transfert |
|
|
|
*/ |
|
|
|
public function get() { |
|
|
|
// TODO : utiliser un nom de fichier temporaire
|
|
|
|
set_time_limit(0); |
|
|
|
$fp = fopen(DOWNLOADDIR.DIRECTORY_SEPARATOR.$this->filename, 'w+'); |
|
|
|
// TODO : tester si fichier existant (temp et definitif)
|
|
|
|
set_time_limit(0); |
|
|
|
|
|
|
|
if (file_exists(DOWNLOADINGDIR.DIRECTORY_SEPARATOR.$this->filename) || file_exists(DOWNLOADEDDIR.DIRECTORY_SEPARATOR.$this->filename)) { |
|
|
|
echo 'le fichier existe deja, exit'; |
|
|
|
exit(); |
|
|
|
} |
|
|
|
|
|
|
|
$fp = fopen(DOWNLOADINGDIR.DIRECTORY_SEPARATOR.$this->filename, 'w+'); |
|
|
|
$ch = curl_init($this->premURL); |
|
|
|
curl_setopt($ch, CURLOPT_FILE, $fp); |
|
|
|
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
|
|
|
@ -96,7 +101,9 @@ file_put_contents('toto', print_r($dbRet, true)); |
|
|
|
curl_exec($ch); |
|
|
|
$retour = curl_getinfo($ch); |
|
|
|
curl_close($ch); |
|
|
|
fclose($fp); |
|
|
|
fclose($fp); |
|
|
|
|
|
|
|
rename(DOWNLOADINGDIR.DIRECTORY_SEPARATOR.$this->filename, DOWNLOADEDDIR.DIRECTORY_SEPARATOR.$this->filename); |
|
|
|
|
|
|
|
// TODO : verifier le retour ?
|
|
|
|
$this->addEvent([ |
|
|
|
|