Rev 1372 | Rev 1447 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | General Public License for more details. |
// | |
// | You should have received a copy of the GNU General Public |
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: telechargement.php,v 1.1.2.1 2007-05-11 13:58:45 alexandre_tb Exp $
/**
* Application projet
*
* Service de telechargement recoie un id de document et renvoie le document
*
*@package projet
//Auteur original :
*@author Alexandre Granier <alexandre@tela-botanica.org>
//Autres auteurs :
*@author Aucun
*@copyright Tela-Botanica 2000-2004
*@version $Revision: 1.1.2.1 $
// +------------------------------------------------------------------------------------------------------+
*/
// +------------------------------------------------------------------------------------------------------+
// | ENTETE du PROGRAMME |
// +------------------------------------------------------------------------------------------------------+
if ($this->_id_document == '') {
return 'aucun fichier demandé';
}
include_once PROJET_CHEMIN_CLASSES.'projet.class.php';
include_once PROJET_CHEMIN_CLASSES.'document.class.php';
$projet = new projet ($this->_id_projet);
$document = new document ($this->_id_document, $this->_db, PROJET_CHEMIN_FICHIER, PROJET_CHEMIN_ICONES) ;
// Soit le document est public et on le renvoie, soit il est prive
// et on teste les droits
if ($document->getVisibilite() == 'prive') {
// On teste le login
if ($this->_auth->getAuth()) {
include_once PROJET_CHEMIN_CLASSES.'participe.class.php' ;
$id_utilisateur = $this->_auth->getAuthData(PROJET_CHAMPS_ID);
$participant = new participe($this->_db) ;
if ($participant->isAdministrateur($id_utilisateur) || $participant->isCoordinateur($id_utilisateur)
|| $participant->isContributeur($id_utilisateur)) {
$ok = true ;
} else {
$ok = false ;
return 'Vous devez participer à ce projet pour accéder à ce document';
}
}
} else {
$ok = true ;
}
// Recherche de l extension
$nom_de_fichier = pathinfo ($projet->getNomRepertoire().'/'.$document->getChemin()) ;
$extension = $nom_de_fichier['extension'];
header('Expires: Wen, 01 Dec 1999 01:00:00 GMT');// Date du passé
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');// toujours modifié
header('Cache-Control: Public');// HTTP/1.1
header ('Content-Type: '.$document->getTypeMime()."\r\n") ;
header('Content-Length: '.$document->getTaille().";\r\n");
header ('Content-Disposition: attachment; filename="'.$document->getNomLong().'.'.$extension.'"'."\r\n");
readfile (PROJET_CHEMIN_FICHIER.$document->getChemin());
exit();
?>