| 320 | 
           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.2 2008-08-25 15:27:32 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.2 $
  | 
        
        
            | 
            | 
           35 | 
           // +------------------------------------------------------------------------------------------------------+
  | 
        
        
            | 
            | 
           36 | 
           */
  | 
        
        
            | 
            | 
           37 | 
              | 
        
        
            | 
            | 
           38 | 
              | 
        
        
            | 
            | 
           39 | 
           // +------------------------------------------------------------------------------------------------------+
  | 
        
        
            | 
            | 
           40 | 
           // |                                            ENTETE du PROGRAMME                                       |
  | 
        
        
            | 
            | 
           41 | 
           // +------------------------------------------------------------------------------------------------------+
  | 
        
        
            | 
            | 
           42 | 
              | 
        
        
            | 
            | 
           43 | 
           // A faire
  | 
        
        
            | 
            | 
           44 | 
           set_include_path(get_include_path().':../../api/pear/');
  | 
        
        
            | 
            | 
           45 | 
           include_once 'configuration/projet.config.inc.php' ;
  | 
        
        
            | 
            | 
           46 | 
           include_once ('classes/ezmlmAccessObject.class.php') ;
  | 
        
        
            | 
            | 
           47 | 
           include_once 'Mail/mimeDecode.php' ;
  | 
        
        
            | 
            | 
           48 | 
           include_once 'Net/URL.php' ;
  | 
        
        
            | 
            | 
           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 | 
           $content_type = $part->ctype_primary.'/'.$part->ctype_secondary ;
  | 
        
        
            | 
            | 
           78 | 
              | 
        
        
            | 
            | 
           79 | 
           // Certain fichiers attaché n'ont pas de ctype_primary et ctype_secondary
  | 
        
        
            | 
            | 
           80 | 
           if ($content_type == '/') {
  | 
        
        
            | 
            | 
           81 | 
               $content_type = $part->content_type;
  | 
        
        
            | 
            | 
           82 | 
           }
  | 
        
        
            | 
            | 
           83 | 
              | 
        
        
            | 
            | 
           84 | 
           $tableau_type_image = array ('jpg', 'jpeg', 'pjpeg');
  | 
        
        
            | 
            | 
           85 | 
              | 
        
        
            | 
            | 
           86 | 
           if (isset($_GET['min']) && (in_array ($part->ctype_secondary, $tableau_type_image))) {
  | 
        
        
            | 
            | 
           87 | 
              | 
        
        
            | 
            | 
           88 | 
           	$chemin = $PHP_SELF.'?'.$_SERVER["QUERY_STRING"]; // le chemin en absolu
  | 
        
        
            | 
            | 
           89 | 
           	$url = new Net_URL($chemin);
  | 
        
        
            | 
            | 
           90 | 
           	$url->removeQueryString('min');
  | 
        
        
            | 
            | 
           91 | 
           	$chemin = $url->getURL();
  | 
        
        
            | 
            | 
           92 | 
              | 
        
        
            | 
            | 
           93 | 
           	// vous pouvez travailler en url relative aussi: img.jpg
  | 
        
        
            | 
            | 
           94 | 
           	$x = 500; # largeur a redimensionner
  | 
        
        
            | 
            | 
           95 | 
           	$y = 150; # hauteur a redimensionner
  | 
        
        
            | 
            | 
           96 | 
           	//echo $chemin;
  | 
        
        
            | 
            | 
           97 | 
              | 
        
        
            | 
            | 
           98 | 
           	$im = imagecreatefromjpeg($chemin);
  | 
        
        
            | 
            | 
           99 | 
              | 
        
        
            | 
            | 
           100 | 
           	$ow = imagesx($im);
  | 
        
        
            | 
            | 
           101 | 
           	$oh = imagesy($im);
  | 
        
        
            | 
            | 
           102 | 
              | 
        
        
            | 
            | 
           103 | 
           	$mw = 200; // max width
  | 
        
        
            | 
            | 
           104 | 
               $mh = 200; // max height
  | 
        
        
            | 
            | 
           105 | 
           	 if( $ow > $mw || $oh > $mh ) {
  | 
        
        
            | 
            | 
           106 | 
                   if( $ow > $oh ) {
  | 
        
        
            | 
            | 
           107 | 
                       $tnw = $mw;
  | 
        
        
            | 
            | 
           108 | 
                       $tnh = $tnw * $oh / $ow;
  | 
        
        
            | 
            | 
           109 | 
                   } else {
  | 
        
        
            | 
            | 
           110 | 
                       $tnh = $mh;
  | 
        
        
            | 
            | 
           111 | 
                       $tnw = $tnh * $ow / $oh;
  | 
        
        
            | 
            | 
           112 | 
                   }
  | 
        
        
            | 
            | 
           113 | 
                } else {
  | 
        
        
            | 
            | 
           114 | 
           	 	$tnw = $ow;
  | 
        
        
            | 
            | 
           115 | 
                   $tnh = $oh;
  | 
        
        
            | 
            | 
           116 | 
           	 }
  | 
        
        
            | 
            | 
           117 | 
           	  $imtn = imagecreatetruecolor($tnw, $tnh);
  | 
        
        
            | 
            | 
           118 | 
                 if (!imagecopyresized($imtn, $im, 0, 0, 0, 0, $tnw, $tnh, $ow, $oh)) {
  | 
        
        
            | 
            | 
           119 | 
                      $erreur = 'Photo %s. Redimensionnement impossible : %s.'."\n";
  | 
        
        
            | 
            | 
           120 | 
                 }
  | 
        
        
            | 
            | 
           121 | 
                 Header("Content-type: image/jpeg");
  | 
        
        
            | 
            | 
           122 | 
                if (!imagejpeg($imtn)) {
  | 
        
        
            | 
            | 
           123 | 
                   $erreur = 'Photo %s. Création de l\'image redimenssionnée impossible : %s.'."\n";
  | 
        
        
            | 
            | 
           124 | 
                }
  | 
        
        
            | 
            | 
           125 | 
                 imagedestroy($im);
  | 
        
        
            | 
            | 
           126 | 
                 imagedestroy($imtn);
  | 
        
        
            | 
            | 
           127 | 
           	exit();
  | 
        
        
            | 
            | 
           128 | 
           }
  | 
        
        
            | 
            | 
           129 | 
              | 
        
        
            | 
            | 
           130 | 
              | 
        
        
            | 
            | 
           131 | 
           $nom_du_fichier = isset($part->d_parameters['filename']) ? $part->d_parameters['filename'] : $part->ctype_parameters['name'] ;
  | 
        
        
            | 
            | 
           132 | 
           //var_dump ($part);
  | 
        
        
            | 
            | 
           133 | 
              | 
        
        
            | 
            | 
           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é
  | 
        
        
            | 
            | 
           136 | 
           header('Cache-Control: Public');// HTTP/1.1
  | 
        
        
            | 
            | 
           137 | 
           header('Content-Type: '.$content_type) ;
  | 
        
        
            | 
            | 
           138 | 
           header('Content-Length: '.strlen($part->body).";");
  | 
        
        
            | 
            | 
           139 | 
           header('Content-Disposition: attachment; filename="'.$nom_du_fichier.'"');
  | 
        
        
            | 
            | 
           140 | 
           //header('Content-Transfer-Encoding: '.$part->content-transfer-encoding);
  | 
        
        
            | 
            | 
           141 | 
           echo $part->body ;
  | 
        
        
            | 
            | 
           142 | 
           exit(0) ;
  | 
        
        
            | 
            | 
           143 | 
              | 
        
        
            | 
            | 
           144 | 
           ?>
  |