From ce1f6fb7d7d0507a5764389ba523321fa8ec1df6 Mon Sep 17 00:00:00 2001 From: Michael RICOIS Date: Tue, 5 Jun 2012 16:25:46 +0000 Subject: [PATCH] Add a better name for the file --- .../controllers/TelechargementController.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/application/controllers/TelechargementController.php b/application/controllers/TelechargementController.php index 194675d33..80f698cc2 100644 --- a/application/controllers/TelechargementController.php +++ b/application/controllers/TelechargementController.php @@ -16,16 +16,21 @@ class TelechargementController extends Zend_Controller_Action /** * Vérifie ou télécharge le fichier sur une url * @param string $url + * @param mixed $filename */ - protected function getFile($url) + protected function getFile($url, $filename=null) { if (!is_dir($this->path)) mkdir($this->path); require_once 'common/curl.php'; // Recuperation du nom du fichier - $tableau = explode('/', $url); - $file = $tableau[sizeof($tableau) - 1]; + if ($filename===null) { + $tableau = explode('/', $url); + $file = $tableau[sizeof($tableau) - 1]; + } else { + $file = $filename; + } // Suppression du fichier si le temps de cache est depasse if (file_exists($this->path.'/'.$file)){ @@ -232,9 +237,7 @@ class TelechargementController extends Zend_Controller_Action $authinfo = '/login/'.$identity->username.'/hach/'.$identity->password; $url = $url.$authinfo.'/'.$q; - Zend_Registry::get('firebug')->info($url); - - $file = $this->getFile($url); + $file = $this->getFile($url, uniqid().'.pdf'); // Le fichier existe sur l'extranet if ($file && file_exists($this->path.'/'.$file)) {