Subversion Repositories Applications.papyrus

Rev

Rev 1397 | Blame | 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.2 2007-06-04 15:42:49 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.2 $
// +------------------------------------------------------------------------------------------------------+
*/

// +------------------------------------------------------------------------------------------------------+
// |                                            ENTETE du PROGRAMME                                       |
// +------------------------------------------------------------------------------------------------------+


if (is_object ($this) && $this->_id_document == '') {
        return 'aucun fichier demand&eacute;';
} else {
        if (!is_object($this) && isset ($_GET['id_document'])) {
                $id_document = $_GET['id_document'];
        }
}

if (is_object ($this)) {
        $id_document = $this->_id_document;
}

include_once PROJET_CHEMIN_CLASSES.'projet.class.php';
include_once PROJET_CHEMIN_CLASSES.'document.class.php';


$document = new document ($id_document, $GLOBALS['projet_db'], PROJET_CHEMIN_FICHIER, PROJET_CHEMIN_ICONES) ;
$projet = new projet ($document->_id_projet);
// 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 ($GLOBALS['projet_auth']->getAuth()) {
                include_once PROJET_CHEMIN_CLASSES.'participe.class.php' ;
                $id_utilisateur = $GLOBALS['projet_auth']->getAuthData(PROJET_CHAMPS_ID);
                $participant = new participe($GLOBALS['projet_db']) ;
                if ($participant->isAdministrateur($id_utilisateur) || $participant->isCoordinateur($id_utilisateur) 
                                                                || $participant->isContributeur($id_utilisateur)) {
                    $ok = true ;
                } else {
                    $ok = false ;
                    return 'Vous devez participer &agrave; ce projet pour acc&eacuteder &agrave; 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, must-revalidate');// HTTP/1.1
header('Pragma: hack');
header ('Content-Type: '.$document->getTypeMime()) ;
header('Content-Length: '.(string) $document->getTaille());
header ('Content-Disposition: attachment; filename="'.$document->getNomLong().'.'.$extension.'"');
header("Content-Transfer-Encoding: binary\n");

readfile (PROJET_CHEMIN_FICHIER.$document->getChemin());

exit();


?>