Subversion Repositories Applications.projet

Rev

Rev 264 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
109 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
// +------------------------------------------------------------------------------------------------------+
22
// CVS : $Id: fichier_attache.php,v 1.1 2006-04-19 13:51:57 alexandre_tb Exp $
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
34
*@version       $Revision: 1.1 $
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 ('classes/ezmlmAccessObject.class.php') ;
47
include_once 'Mail/mimeDecode.php' ;
48
 
49
 
50
$num_rep = array_shift ($actionargs) ;
51
$num_message = array_shift($actionargs) ;
52
 
53
$xml_parser = &new ezmlmAccessObject('message', PROJET_DOMAINE_LISTE,
54
            									$nom_liste, $GLOBALS['lang']) ;
55
$xml_parser->setIdMessage($num_rep, $num_message) ;
56
$xml_parser->load();
57
ob_start ();
58
$xml_parser->parse() ;
59
$mail = ob_get_contents() ;
60
ob_end_clean();
61
/*
62
$mail = file_get_contents (PROJET_CHEMIN_LISTES.PROJET_DOMAINE_LISTE.'/'.$nom_liste.'/'.'archive/'.$num_rep.'/'.$num_message) ;
63
*/
64
 
65
$decodeur = new Mail_mimeDecode($mail) ;
66
$mailDecode = $decodeur->decode(array ('decode_bodies' => 'true', 'include_bodies' => 'true')) ;
67
 
68
//var_dump ($mailDecode) ;
69
function getParts(&$part, $num_part) {
70
    $part =  $part->parts[$num_part] ;
71
    return $part ;
72
}
73
 
74
for ($i = 0; $i < count ($actionargs); $i++) {
75
    $part = getParts($mailDecode, $actionargs[$i]) ;
76
}
77
 
78
$content_type = $part->ctype_primary.'/'.$part->ctype_secondary ;
79
 
80
// Certain fichiers attaché n'ont pas de ctype_primary et ctype_secondary
81
if ($content_type == '/') {
82
    $content_type = $part->content_type;
83
}
84
 
85
$nom_du_fichier = isset($part->d_parameters['filename']) ? $part->d_parameters['filename'] : $part->ctype_parameters['name'] ;
86
//echo $content_type ;
87
 
88
header('Expires: Wen, 01 Dec 1999 01:00:00 GMT');// Date du passé
89
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');// toujours modifié
90
header('Cache-Control: Public');// HTTP/1.1
91
header ('Content-Type: '.$content_type."\r\n") ;
92
header("Content-Length: ".strlen($part->body).";\r\n");
93
header ('Content-Disposition: attachment; filename="'.$nom_du_fichier.'"'."\r\n");
94
header('Content-Transfer-Encoding: '.$part->content-transfer-encoding);
95
echo $part->body ;
96
exit(0) ;
97
 
98
?>