Subversion Repositories Applications.projet

Rev

Rev 235 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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