Subversion Repositories Applications.papyrus

Rev

Rev 448 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
448 ddelon 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
// +------------------------------------------------------------------------------------------------------+
474 alexandre_ 22
// CVS : $Id: fichier_attache.php,v 1.2 2005-09-27 16:46:06 alexandre_tb Exp $
448 ddelon 23
/**
24
* Application projet
25
*
26
* Fichier pour afficher les pièces jointes
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
474 alexandre_ 34
*@version       $Revision: 1.2 $
448 ddelon 35
// +------------------------------------------------------------------------------------------------------+
36
*/
37
 
38
 
39
// +------------------------------------------------------------------------------------------------------+
40
// |                                            ENTETE du PROGRAMME                                       |
41
// +------------------------------------------------------------------------------------------------------+
42
 
43
// A faire
44
 
45
include_once '../configuration/projet.config.inc.php' ;
46
include_once 'Mail/mimeDecode.php' ;
47
 
48
 
49
$num_rep = array_shift ($actionargs) ;
50
$num_message = array_shift($actionargs) ;
51
 
52
$mail = file_get_contents (PROJET_CHEMIN_LISTES.PROJET_DOMAINE_LISTE.'/'.$nom_liste.'/'.'archive/'.$num_rep.'/'.$num_message) ;
53
$decodeur = new Mail_mimeDecode($mail) ;
54
$mailDecode = $decodeur->decode(array ('decode_bodies' => 'true', 'include_bodies' => 'true')) ;
55
 
56
//var_dump ($mailDecode) ;
57
function getParts(&$part, $num_part) {
58
    $part =  $part->parts[$num_part] ;
59
    return $part ;
60
}
61
 
62
for ($i = 0; $i < count ($actionargs); $i++) {
63
    $part = getParts($mailDecode, $actionargs[$i]) ;
64
}
65
 
66
$content_type = $part->ctype_primary.'/'.$part->ctype_secondary ;
67
 
68
// Certain fichiers attaché n'ont pas de ctype_primary et ctype_secondary
69
if ($content_type == '/') {
70
    $content_type = $part->content_type;
71
}
72
 
73
$nom_du_fichier = isset($part->d_parameters['filename']) ? $part->d_parameters['filename'] : $part->ctype_parameters['name'] ;
74
//echo $content_type ;
75
 
76
header('Expires: Wen, 01 Dec 1999 01:00:00 GMT');// Date du passé
77
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');// toujours modifié
78
header('Cache-Control: Public');// HTTP/1.1
79
header ('Content-Type: '.$content_type."\r\n") ;
80
header("Content-Length: ".strlen($part->body).";\r\n");
81
header ('Content-Disposition: attachment; filename="'.$nom_du_fichier.'"'."\r\n");
82
header('Content-Transfer-Encoding: '.$part->content-transfer-encoding);
83
echo $part->body ;
84
exit(0) ;
85
 
86
?>