1328 |
alexandre_ |
1 |
<?php
|
|
|
2 |
/*vim: set expandtab tabstop=4 shiftwidth=4: */
|
|
|
3 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
4 |
// | PHP version 4.1 |
|
|
|
5 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
6 |
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
|
|
|
7 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
8 |
// | This library is free software; you can redistribute it and/or |
|
|
|
9 |
// | modify it under the terms of the GNU General Public |
|
|
|
10 |
// | License as published by the Free Software Foundation; either |
|
|
|
11 |
// | version 2.1 of the License, or (at your option) any later version. |
|
|
|
12 |
// | |
|
|
|
13 |
// | This library is distributed in the hope that it will be useful, |
|
|
|
14 |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
|
|
15 |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
|
|
16 |
// | General Public License for more details. |
|
|
|
17 |
// | |
|
|
|
18 |
// | You should have received a copy of the GNU General Public |
|
|
|
19 |
// | License along with this library; if not, write to the Free Software |
|
|
|
20 |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
|
|
21 |
// +------------------------------------------------------------------------------------------------------+
|
1646 |
alexandre_ |
22 |
// CVS : $Id: telechargement.php,v 1.3 2007-10-10 13:58:04 alexandre_tb Exp $
|
1328 |
alexandre_ |
23 |
/**
|
|
|
24 |
* Application projet
|
|
|
25 |
*
|
|
|
26 |
* Service de telechargement recoie un id de document et renvoie le document
|
|
|
27 |
*
|
|
|
28 |
*@package projet
|
|
|
29 |
//Auteur original :
|
|
|
30 |
*@author Alexandre Granier <alexandre@tela-botanica.org>
|
|
|
31 |
//Autres auteurs :
|
|
|
32 |
*@author Aucun
|
|
|
33 |
*@copyright Tela-Botanica 2000-2004
|
1646 |
alexandre_ |
34 |
*@version $Revision: 1.3 $
|
1328 |
alexandre_ |
35 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
36 |
*/
|
|
|
37 |
|
|
|
38 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
39 |
// | ENTETE du PROGRAMME |
|
|
|
40 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
41 |
|
|
|
42 |
|
1471 |
alexandre_ |
43 |
if (is_object ($this) && $this->_id_document == '') {
|
|
|
44 |
return 'aucun fichier demandé';
|
|
|
45 |
} else {
|
|
|
46 |
if (!is_object($this) && isset ($_GET['id_document'])) {
|
|
|
47 |
$id_document = $_GET['id_document'];
|
|
|
48 |
}
|
|
|
49 |
}
|
1328 |
alexandre_ |
50 |
|
1471 |
alexandre_ |
51 |
if (is_object ($this)) {
|
|
|
52 |
$id_document = $this->_id_document;
|
|
|
53 |
}
|
1328 |
alexandre_ |
54 |
|
1471 |
alexandre_ |
55 |
include_once PROJET_CHEMIN_CLASSES.'projet.class.php';
|
|
|
56 |
include_once PROJET_CHEMIN_CLASSES.'document.class.php';
|
|
|
57 |
|
|
|
58 |
|
|
|
59 |
$document = new document ($id_document, $GLOBALS['projet_db'], PROJET_CHEMIN_FICHIER, PROJET_CHEMIN_ICONES) ;
|
|
|
60 |
$projet = new projet ($document->_id_projet);
|
|
|
61 |
// Soit le document est public et on le renvoie, soit il est prive
|
|
|
62 |
// et on teste les droits
|
|
|
63 |
|
|
|
64 |
if ($document->getVisibilite() == 'prive') {
|
|
|
65 |
// On teste le login
|
|
|
66 |
if ($GLOBALS['projet_auth']->getAuth()) {
|
|
|
67 |
include_once PROJET_CHEMIN_CLASSES.'participe.class.php' ;
|
|
|
68 |
$id_utilisateur = $GLOBALS['projet_auth']->getAuthData(PROJET_CHAMPS_ID);
|
|
|
69 |
$participant = new participe($GLOBALS['projet_db']) ;
|
1646 |
alexandre_ |
70 |
if ($participant->isAdministrateur($id_utilisateur) || $participant->isCoordinateur($id_utilisateur, $document->_id_projet)
|
|
|
71 |
|| $participant->isContributeur($id_utilisateur, $document->_id_projet)) {
|
1471 |
alexandre_ |
72 |
$ok = true ;
|
|
|
73 |
} else {
|
|
|
74 |
$ok = false ;
|
1646 |
alexandre_ |
75 |
return '<h1>'.$projet->getTitre($document->_id_projet).'</h1>'.
|
|
|
76 |
'<p class="information">Vous devez participer à ce projet pour accéder à ce document</p>';
|
1471 |
alexandre_ |
77 |
}
|
1646 |
alexandre_ |
78 |
} else {
|
|
|
79 |
return '<h1>'.$projet->getTitre($document->_id_projet).'</h1>'.
|
|
|
80 |
'<p class="information">Vous devez participer à ce projet pour accéder à ce document</p>';
|
|
|
81 |
}
|
1471 |
alexandre_ |
82 |
} else {
|
|
|
83 |
$ok = true ;
|
|
|
84 |
}
|
|
|
85 |
|
|
|
86 |
// Recherche de l extension
|
|
|
87 |
$nom_de_fichier = pathinfo ($projet->getNomRepertoire().'/'.$document->getChemin()) ;
|
|
|
88 |
$extension = $nom_de_fichier['extension'];
|
|
|
89 |
|
|
|
90 |
header('Expires: Wen, 01 Dec 1999 01:00:00 GMT');// Date du passé
|
|
|
91 |
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');// toujours modifié
|
|
|
92 |
header('Cache-Control: Public, must-revalidate');// HTTP/1.1
|
|
|
93 |
header('Pragma: hack');
|
|
|
94 |
header ('Content-Type: '.$document->getTypeMime()) ;
|
|
|
95 |
header('Content-Length: '.(string) $document->getTaille());
|
|
|
96 |
header ('Content-Disposition: attachment; filename="'.$document->getNomLong().'.'.$extension.'"');
|
|
|
97 |
header("Content-Transfer-Encoding: binary\n");
|
|
|
98 |
|
|
|
99 |
readfile (PROJET_CHEMIN_FICHIER.$document->getChemin());
|
|
|
100 |
|
|
|
101 |
exit();
|
|
|
102 |
|
|
|
103 |
|
1328 |
alexandre_ |
104 |
?>
|