Subversion Repositories Applications.projet

Rev

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

Rev 320 Rev 431
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: fichier_attache.php,v 1.2 2008-08-25 15:27:32 alexandre_tb Exp $
22
// CVS : $Id: fichier_attache.php,v 1.1 2006/04/19 13:51:57 alexandre_tb Exp $
23
/**
23
/**
24
* Application projet
24
* Application projet
25
*
25
*
26
* Fichier pour afficher les pièces jointes
26
* Fichier pour afficher les pièces jointes
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.2 $
34
*@version       $Revision: 1.1 $
35
// +------------------------------------------------------------------------------------------------------+
35
// +------------------------------------------------------------------------------------------------------+
36
*/
36
*/
37
 
37
 
38
 
38
 
39
// +------------------------------------------------------------------------------------------------------+
39
// +------------------------------------------------------------------------------------------------------+
40
// |                                            ENTETE du PROGRAMME                                       |
40
// |                                            ENTETE du PROGRAMME                                       |
41
// +------------------------------------------------------------------------------------------------------+
41
// +------------------------------------------------------------------------------------------------------+
42
 
42
 
43
// A faire
43
// A faire
44
set_include_path(get_include_path().':../../api/pear/');
44
set_include_path(get_include_path().':../../api/pear/');
45
include_once 'configuration/projet.config.inc.php' ;
45
include_once 'configuration/projet.config.inc.php' ;
46
include_once ('classes/ezmlmAccessObject.class.php') ;
46
include_once ('classes/ezmlmAccessObject.class.php') ;
47
include_once 'Mail/mimeDecode.php' ;
47
include_once 'Mail/mimeDecode.php' ;
48
include_once 'Net/URL.php' ;
48
include_once 'Net/URL.php' ;
49
 
49
 
50
$num_rep = array_shift ($actionargs) ;
50
$num_rep = array_shift ($actionargs) ;
51
$num_message = array_shift($actionargs) ;
51
$num_message = array_shift($actionargs) ;
52
 
52
 
53
$xml_parser = &new ezmlmAccessObject('message', PROJET_DOMAINE_LISTE,
53
$xml_parser = &new ezmlmAccessObject('message', PROJET_DOMAINE_LISTE,
54
            									$nom_liste, $GLOBALS['lang']) ;
54
            									$nom_liste, $GLOBALS['lang']) ;
55
$xml_parser->setIdMessage($num_rep, $num_message) ;
55
$xml_parser->setIdMessage($num_rep, $num_message) ;
56
$xml_parser->load();
56
$xml_parser->load();
57
ob_start ();
57
ob_start ();
58
$xml_parser->parse() ;
58
$xml_parser->parse() ;
59
$mail = ob_get_contents() ;
59
$mail = ob_get_contents() ;
60
ob_end_clean();
60
ob_end_clean();
61
/*
61
/*
62
$mail = file_get_contents (PROJET_CHEMIN_LISTES.PROJET_DOMAINE_LISTE.'/'.$nom_liste.'/'.'archive/'.$num_rep.'/'.$num_message) ;
62
$mail = file_get_contents (PROJET_CHEMIN_LISTES.PROJET_DOMAINE_LISTE.'/'.$nom_liste.'/'.'archive/'.$num_rep.'/'.$num_message) ;
63
*/
63
*/
64
 
64
 
65
$decodeur = new Mail_mimeDecode($mail) ;
65
$decodeur = new Mail_mimeDecode($mail) ;
66
$mailDecode = $decodeur->decode(array ('decode_bodies' => 'true', 'include_bodies' => 'true')) ;
66
$mailDecode = $decodeur->decode(array ('decode_bodies' => 'true', 'include_bodies' => 'true')) ;
67
 
67
 
68
//var_dump ($mailDecode) ;
68
//var_dump ($mailDecode) ;
69
function getParts(&$part, $num_part) {
69
function getParts(&$part, $num_part) {
70
    $part =  $part->parts[$num_part] ;
70
    $part =  $part->parts[$num_part] ;
71
    return $part ;
71
    return $part ;
72
}
72
}
73
 
73
 
74
for ($i = 0; $i < count ($actionargs); $i++) {
74
for ($i = 0; $i < count ($actionargs); $i++) {
75
    $part = getParts($mailDecode, $actionargs[$i]) ;
75
    $part = getParts($mailDecode, $actionargs[$i]) ;
76
}
76
}
77
$content_type = $part->ctype_primary.'/'.$part->ctype_secondary ;
77
$content_type = $part->ctype_primary.'/'.$part->ctype_secondary ;
78
 
78
 
79
// Certain fichiers attaché n'ont pas de ctype_primary et ctype_secondary
79
// Certain fichiers attaché n'ont pas de ctype_primary et ctype_secondary
80
if ($content_type == '/') {
80
if ($content_type == '/') {
81
    $content_type = $part->content_type;
81
    $content_type = $part->content_type;
82
}
82
}
83
 
83
 
84
$tableau_type_image = array ('jpg', 'jpeg', 'pjpeg');
84
$tableau_type_image = array ('jpg', 'jpeg', 'pjpeg');
85
 
85
 
86
if (isset($_GET['min']) && (in_array ($part->ctype_secondary, $tableau_type_image))) {
86
if (isset($_GET['min']) && (in_array ($part->ctype_secondary, $tableau_type_image))) {
87
	
87
	
88
	$chemin = $PHP_SELF.'?'.$_SERVER["QUERY_STRING"]; // le chemin en absolu
88
	$chemin = $PHP_SELF.'?'.$_SERVER["QUERY_STRING"]; // le chemin en absolu
89
	$url = new Net_URL($chemin);
89
	$url = new Net_URL($chemin);
90
	$url->removeQueryString('min');
90
	$url->removeQueryString('min');
91
	$chemin = $url->getURL();
91
	$chemin = $url->getURL();
92
 
92
 
93
	// vous pouvez travailler en url relative aussi: img.jpg
93
	// vous pouvez travailler en url relative aussi: img.jpg
94
	$x = 500; # largeur a redimensionner
94
	$x = 500; # largeur a redimensionner
95
	$y = 150; # hauteur a redimensionner
95
	$y = 150; # hauteur a redimensionner
96
	//echo $chemin;
96
	//echo $chemin;
97
	
97
	
98
	$im = imagecreatefromjpeg($chemin);
98
	$im = imagecreatefromjpeg($chemin);
99
	
99
	
100
	$ow = imagesx($im);
100
	$ow = imagesx($im);
101
	$oh = imagesy($im);
101
	$oh = imagesy($im);
102
	
102
	
103
	$mw = 200; // max width
103
	$mw = 200; // max width
104
    $mh = 200; // max height
104
    $mh = 200; // max height
105
	 if( $ow > $mw || $oh > $mh ) {
105
	 if( $ow > $mw || $oh > $mh ) {
106
        if( $ow > $oh ) {
106
        if( $ow > $oh ) {
107
            $tnw = $mw;
107
            $tnw = $mw;
108
            $tnh = $tnw * $oh / $ow;
108
            $tnh = $tnw * $oh / $ow;
109
        } else {
109
        } else {
110
            $tnh = $mh;
110
            $tnh = $mh;
111
            $tnw = $tnh * $ow / $oh;
111
            $tnw = $tnh * $ow / $oh;
112
        }
112
        }
113
     } else {
113
     } else {
114
	 	$tnw = $ow;
114
	 	$tnw = $ow;
115
        $tnh = $oh;
115
        $tnh = $oh;
116
	 }
116
	 }
117
	  $imtn = imagecreatetruecolor($tnw, $tnh);
117
	  $imtn = imagecreatetruecolor($tnw, $tnh);
118
      if (!imagecopyresized($imtn, $im, 0, 0, 0, 0, $tnw, $tnh, $ow, $oh)) {
118
      if (!imagecopyresized($imtn, $im, 0, 0, 0, 0, $tnw, $tnh, $ow, $oh)) {
119
           $erreur = 'Photo %s. Redimensionnement impossible : %s.'."\n";           
119
           $erreur = 'Photo %s. Redimensionnement impossible : %s.'."\n";           
120
      }
120
      }
121
      Header("Content-type: image/jpeg");
121
      Header("Content-type: image/jpeg");
122
     if (!imagejpeg($imtn)) {
122
     if (!imagejpeg($imtn)) {
123
        $erreur = 'Photo %s. Création de l\'image redimenssionnée impossible : %s.'."\n";
123
        $erreur = 'Photo %s. Création de l\'image redimenssionnée impossible : %s.'."\n";
124
     }
124
     }
125
      imagedestroy($im);
125
      imagedestroy($im);
126
      imagedestroy($imtn);
126
      imagedestroy($imtn);
127
	exit();
127
	exit();
128
}
128
}
129
 
129
 
130
 
130
 
131
$nom_du_fichier = isset($part->d_parameters['filename']) ? $part->d_parameters['filename'] : $part->ctype_parameters['name'] ;
131
$nom_du_fichier = isset($part->d_parameters['filename']) ? $part->d_parameters['filename'] : $part->ctype_parameters['name'] ;
132
//var_dump ($part); 
132
//var_dump ($part); 
133
 
133
 
134
header('Expires: Wen, 01 Dec 1999 01:00:00 GMT');// Date du passé
134
header('Expires: Wen, 01 Dec 1999 01:00:00 GMT');// Date du passé
135
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');// toujours modifié
135
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');// toujours modifié
136
header('Cache-Control: Public');// HTTP/1.1
136
header('Cache-Control: Public');// HTTP/1.1
137
header('Content-Type: '.$content_type) ;
137
header('Content-Type: '.$content_type) ;
138
header('Content-Length: '.strlen($part->body).";");
138
header('Content-Length: '.strlen($part->body).";");
139
header('Content-Disposition: attachment; filename="'.$nom_du_fichier.'"');
139
header('Content-Disposition: attachment; filename="'.$nom_du_fichier.'"');
140
//header('Content-Transfer-Encoding: '.$part->content-transfer-encoding);
140
//header('Content-Transfer-Encoding: '.$part->content-transfer-encoding);
141
echo $part->body ;
141
echo $part->body ;
142
exit(0) ;
142
exit(0) ;
143
 
143
 
144
?>
144
?>