Subversion Repositories Applications.projet

Rev

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

Rev 106 Rev 208
1
<?php
1
<?php
2
// $Id: ezmlm-msgdisplay.php,v 1.3 2006-04-19 13:50:04 alexandre_tb Exp $
2
// $Id: ezmlm-msgdisplay.php,v 1.4 2007-04-19 15:34:35 neiluj Exp $
3
//
3
//
4
// ezmlm-msgdisplay.php - ezmlm-php v2.0
4
// ezmlm-msgdisplay.php - ezmlm-php v2.0
5
// --------------------------------------------------------------
5
// --------------------------------------------------------------
6
// Will parse a template (if specified) and display a message.
6
// Will parse a template (if specified) and display a message.
7
// Includes a default template.
7
// Includes a default template.
8
// --------------------------------------------------------------
8
// --------------------------------------------------------------
9
 
9
 
10
require_once("ezmlm.php");
10
require_once("ezmlm.php");
11
require_once("Mail/mimeDecode.php") ;
11
require_once("Mail/mimeDecode.php") ;
12
 
12
 
13
class ezmlm_msgdisplay extends ezmlm_php {
13
class ezmlm_msgdisplay extends ezmlm_php {
14
	// our template
14
	// our template
15
	var $msgtmpl;
15
	var $msgtmpl;
16
    var $message_rendu ;
16
    var $message_rendu ;
17
    var $_auth ;
17
    var $_auth ;
18
	// display: parses a message (using ezmlm_parser) and displays it
18
	// display: parses a message (using ezmlm_parser) and displays it
19
	// using a template
19
	// using a template
-
 
20
    var $msgfile;
20
    
21
    
21
	function display($msgfile) {
22
    function display($msgfile) {
22
        if (!is_file($msgfile)) {
23
        if (!is_file($msgfile)) {
23
			if (is_file($this->listdir . "/" . $msgfile)) { $msgfile = $this->listdir . "/" . $msgfile; }
24
            if (is_file($this->listdir . "/" . $msgfile)) { $msgfile = $this->listdir . "/" . $msgfile; }
24
			else if (is_file($this->listdir . "/archive/" . $msgfile)) { $msgfile = $this->listdir . "/archive/" . $msgfile; }
25
		else if (is_file($this->listdir . "/archive/" . $msgfile)) { $msgfile = $this->listdir . "/archive/" . $msgfile; }
25
			else { return FALSE; }
26
		else { return FALSE; }
-
 
27
	    }
26
		}
28
	$this->msgfile = $msgfile ;
-
 
29
        $message = file_get_contents($msgfile) ;
-
 
30
	// En cours de codage
-
 
31
	// La fonction display retourne tout simplement le source du mail
-
 
32
	// Il n'y a plus d'analyse à ce niveau
-
 
33
	
27
        $message = file_get_contents($msgfile) ;
34
	return $message;
28
        $mimeDecode = new Mail_mimeDecode($message) ;
35
        $mimeDecode = new Mail_mimeDecode($message) ;
29
        $mailDecode = $mimeDecode->decode(array('decode_bodies' => 'true', 'include_bodies' => 'true')) ;
36
        $mailDecode = $mimeDecode->decode(array('decode_bodies' => 'true', 'include_bodies' => 'true')) ;
30
        
37
        
31
        // $msg->msgfile contient le chemin du fichier du mail en partant de la racine
38
        // $msg->msgfile contient le chemin du fichier du mail en partant de la racine
32
        // Le point d'exclamation est le délimiteur de l'expression régulière
39
        // Le point d'exclamation est le délimiteur de l'expression régulière
33
		$relfile = preg_replace('!' . $this->listdir . '!', '', $msgfile);
40
		$relfile = preg_replace('!' . $this->listdir . '!', '', $msgfile);
34
        
41
        
35
		$a1 = preg_replace('!/archive/(.*)/.*$!', '\1', $relfile);  // $a1 contient le nom du répertoire
42
		$a1 = preg_replace('!/archive/(.*)/.*$!', '\1', $relfile);  // $a1 contient le nom du répertoire
36
		$a2 = preg_replace('!/archive/.*/(.*)$!', '\1', $relfile);  // $a2 contient le nom du fichier
43
		$a2 = preg_replace('!/archive/.*/(.*)$!', '\1', $relfile);  // $a2 contient le nom du fichier
37
		if (isset($mailDecode->headers['date'])) $msgtime = strtotime(preg_replace ('/CEST/', '', $mailDecode->headers['date']));
44
		if (isset($mailDecode->headers['date'])) $msgtime = strtotime(preg_replace ('/CEST/', '', $mailDecode->headers['date']));
38
        $threadidx = date("Ym", $msgtime);
45
        $threadidx = date("Ym", $msgtime);
39
        if ($a2 <= 10) $numero_precedent = '0'.($a2 - 1) ; else $numero_precedent = ($a2 - 1) ;
46
        if ($a2 <= 10) $numero_precedent = '0'.($a2 - 1) ; else $numero_precedent = ($a2 - 1) ;
40
        if ($a2 < 9) $numero_suivant = '0'.($a2 + 1) ; else $numero_suivant =  ($a2 + 1);
47
        if ($a2 < 9) $numero_suivant = '0'.($a2 + 1) ; else $numero_suivant =  ($a2 + 1);
41
        // On teste si le message suivant existe
48
        // On teste si le message suivant existe
42
        $decoupe = explode ('/', $msgfile) ;
49
        $decoupe = explode ('/', $msgfile) ;
43
        
50
        
44
        // Les nom de fichiers sont du format :
51
        // Les nom de fichiers sont du format :
45
        // archive/0/01
52
        // archive/0/01
46
        // archive/0/02 ... 0/99 archive/1/01 ...
53
        // archive/0/02 ... 0/99 archive/1/01 ...
47
        
54
        
48
        $nom_fichier = $decoupe[count($decoupe)-1] ;
55
        $nom_fichier = $decoupe[count($decoupe)-1] ;
49
        $nom_repertoire = $decoupe[count($decoupe)-2] ;
56
        $nom_repertoire = $decoupe[count($decoupe)-2] ;
50
        $repertoire_suivant = $nom_repertoire ; $repertoire_precedent = $nom_repertoire ;
57
        $repertoire_suivant = $nom_repertoire ; $repertoire_precedent = $nom_repertoire ;
51
        if ($nom_fichier > 8) {
58
        if ($nom_fichier > 8) {
52
            $fichier_suivant = $nom_fichier + 1 ;
59
            $fichier_suivant = $nom_fichier + 1 ;
53
            if ($nom_fichier == 99) {
60
            if ($nom_fichier == 99) {
54
                $fichier_suivant = '01' ;
61
                $fichier_suivant = '01' ;
55
                $repertoire_suivant = $nom_repertoire + 1 ;
62
                $repertoire_suivant = $nom_repertoire + 1 ;
56
            }
63
            }
57
        } else {
64
        } else {
58
            $fichier_suivant = '0'.($nom_fichier + 1) ;
65
            $fichier_suivant = '0'.($nom_fichier + 1) ;
59
        }
66
        }
60
        if ($nom_fichier > 10) {
67
        if ($nom_fichier > 10) {
61
            $fichier_precedent = $nom_fichier - 1 ;
68
            $fichier_precedent = $nom_fichier - 1 ;
62
        } else {
69
        } else {
63
            if ($nom_fichier == '01') {
70
            if ($nom_fichier == '01') {
64
                $fichier_precedent = '99' ;
71
                $fichier_precedent = '99' ;
65
                $repertoire_precedent = $nom_repertoire - 1 ;
72
                $repertoire_precedent = $nom_repertoire - 1 ;
66
            } else {
73
            } else {
67
                $fichier_precedent = '0'.($nom_fichier - 1) ;
74
                $fichier_precedent = '0'.($nom_fichier - 1) ;
68
            }
75
            }
69
        }
76
        }
70
        
-
 
71
        if (is_file($this->listdir.'/archive/'.$repertoire_precedent.'/'.$fichier_precedent)) {
-
 
72
            print "[" . $this->makelink("action=show_msg&actionargs[]=$a1&actionargs[]=" . $numero_precedent, ' '.PROJET_PRECEDENT.' ') . "] ";
-
 
73
        } else {
-
 
74
            print '['.PROJET_PRECEDENT.']' ;
-
 
75
        }
-
 
76
        if (is_file($this->listdir.'/archive/'.$repertoire_suivant.'/'.$fichier_suivant)) {
-
 
77
            print "[" . $this->makelink("action=show_msg&actionargs[]=$a1&actionargs[]=" . $numero_suivant, ' '.PROJET_SUIVANT.' ') . "] ";
-
 
78
        } else {
-
 
79
            print '['.PROJET_SUIVANT.']' ;
-
 
80
        }
-
 
81
        // on crée un lien vers la thread avec une ancre vers le message
-
 
82
        $parser = new ezmlm_parser();
-
 
83
        $parser->listdir = $this->listdir ;
-
 
84
        $recent = $parser->recent_msgs(1);
-
 
85
        $actionargs = preg_split("/\//", $recent[0]->msgfile);
-
 
86
		print "[" . $this->makelink('action=show_msg&actionargs[]=' . $actionargs[(count($actionargs) - 2)] . 
-
 
87
                                '&actionargs[]=' .  $actionargs[(count($actionargs) - 1)] , ' '.PROJET_DERNIER_MESSAGE.' ') . '] ';
-
 
88
        if ($this->_auth->getAuth()) {
-
 
89
            print '['.$this->makelink('action=repondre&actionargs[]='.$a1.'&actionargs[]='.$a2, PROJET_REPONDRE).'] ';
-
 
90
        }
-
 
91
		print '<br />'."\n";
-
 
92
        print '<div class="message">' ;
-
 
93
        print $this->parse_entete_mail($mailDecode) ;
77
        print $this->parse_entete_mail($mailDecode) ;
94
		$this->parse_template($mailDecode, $a2, $a1);
78
		$this->parse_template($mailDecode, $a2, $a1);
95
        print $this->message_rendu;
79
        print $this->message_rendu;
96
        print '</div>' ;
80
        //print '</div>' ;
97
	}
81
	}
98
    
82
    
99
    /**
83
    /**
-
 
84
     * Renvoie les infos des messages suivants
-
 
85
     * 
-
 
86
     *
-
 
87
    */
-
 
88
    function getInfoSuivant() {
-
 
89
		$relfile = preg_replace('!' . $this->listdir . '!', '', $this->msgfile);
-
 
90
	 	$nom_repertoire = preg_replace('!/archive/(.*)/.*$!', '\1', $relfile);
-
 
91
		$nom_fichier = preg_replace('!/archive/.*/(.*)$!', '\1', $relfile);
-
 
92
	       
-
 
93
		$repertoire_suivant = $nom_repertoire;
-
 
94
		
-
 
95
		// a partir du nom du fichier
-
 
96
		// et du nom du repertoire, on reconstitue
-
 
97
		// le numero du message stocke dans le fichier d index
-
 
98
		// le message 12 du repertoire 2 a le numero 112
-
 
99
		
-
 
100
		if ($nom_repertoire == '0') {
-
 
101
			$numero_message = $nom_fichier;
-
 
102
		} else {
-
 
103
			$numero_message = $nom_repertoire.$nom_fichier ;
-
 
104
		}
-
 
105
		
-
 
106
		// On ouvre le fichier d index
-
 
107
		$fichier_index = fopen ($this->listdir.'/archive/'.$nom_repertoire.'/index', 'r');
-
 
108
		
-
 
109
		
-
 
110
		$compteur_ligne = 1;
-
 
111
		if (preg_match ('/0([1-9][0-9]*)/', $nom_fichier, $match)) {
-
 
112
			$nom_fichier = $match[1];
-
 
113
			$prefixe = '0' ;
-
 
114
		} else {
-
 
115
			$prefixe = '' ;
-
 
116
		}
-
 
117
		$prefixe = $this->prefixe_nom_message($nom_fichier);
-
 
118
		//echo $numero_message;
-
 
119
		// on cherche la ligne avec le numero du message
-
 
120
		while (!feof($fichier_index)) {
-
 
121
				
-
 
122
				$temp = fgets($fichier_index,4096);
-
 
123
				list($num, $hash, $sujet) = split (':', $temp) ;
-
 
124
				
-
 
125
				if ($num == $numero_message) {
-
 
126
					
-
 
127
					$ligne_message_precedent = $compteur_ligne -2;
-
 
128
					$temp = fgets($fichier_index, 4096);
-
 
129
					$temp = fgets($fichier_index, 4096);
-
 
130
					list ($fichier_suivant,$hash, $sujet) = split(':', $temp);
-
 
131
					
-
 
132
					// Au cas ou est au dernier message du fichier d index
-
 
133
					// il faut ouvrir le suivant
-
 
134
					if (feof($fichier_index)) {
-
 
135
						$repertoire_suivant++;
-
 
136
						if (file_exists($this->listdir.'/archive/'.$repertoire_suivant.'/index')) {
-
 
137
							$fichier_index_suivant = fopen($this->listdir.'/archive/'.$repertoire_suivant.'/index', 'r');
-
 
138
							// on recupere le numero du premier message
-
 
139
							list($fichier_suivant, $hash, $sujet) = split (':', fgets($fichier_index_suivant), 4096);
-
 
140
							fclose ($fichier_index_suivant);
-
 
141
						}
-
 
142
					}
-
 
143
					
-
 
144
					// Si le numero est > 100, il faut decouper et ne retenir
-
 
145
					// que les dizaines et unites
-
 
146
					if ($fichier_suivant >= 100) {
-
 
147
						$decimal = (string) $fichier_suivant;
-
 
148
						$numero = substr($decimal, -2) ;
-
 
149
						$fichier_suivant = $numero ;
-
 
150
					} else {
-
 
151
						if ($fichier_suivant < 9)$fichier_suivant = '0'.$fichier_suivant;
-
 
152
					}
-
 
153
					
-
 
154
					break;
-
 
155
				}
-
 
156
				
-
 
157
				// On avance d une ligne, la 2e ligne contient date hash auteur
-
 
158
				$temp2 = fgets($fichier_index, 4096);
-
 
159
				$compteur_ligne += 2;
-
 
160
		}
-
 
161
		
-
 
162
		// On utilise $ligne_message_precedent pour recupere le num du message precedent
-
 
163
		// Si $ligne_precedent est negatif soit c le premier message de la liste
-
 
164
		// soit il faut ouvrir le repertoire precedent 
-
 
165
		
-
 
166
		if ($ligne_message_precedent > 0) {
-
 
167
			$compteur = 1;
-
 
168
			rewind($fichier_index);
-
 
169
			while (!feof($fichier_index)) {
-
 
170
				$temp = fgets($fichier_index, 4096);
-
 
171
				if ($ligne_message_precedent == $compteur) {
-
 
172
					list ($fichier_precedent, $hash, $sujet) = split (':', $temp) ; 	
-
 
173
				}
-
 
174
				$compteur++;
-
 
175
			}
-
 
176
			// Le nom du repertoire precedent est le meme que le repertoire courant
-
 
177
			$repertoire_precedent = $nom_repertoire ;
-
 
178
		// Si $ligne_message_precedent est negatif, alors il faut ouvrir
-
 
179
		// le fichier index du repertoire precedent
-
 
180
		// si le nom du repertoire est 0, alors il n y a pas de repertoire precedent
-
 
181
		// et donc pas de message precedent
-
 
182
		} else {
-
 
183
			
-
 
184
			if ($nom_repertoire != '0') {
-
 
185
				$repertoire_precedent = $nom_repertoire -1 ;
-
 
186
				// on ouvre le fichier d index et on extraie le numero
-
 
187
				// du dernier message
-
 
188
				
-
 
189
				$fichier_index_precedent = fopen ($this->listdir.'/archive/'.$repertoire_precedent.'/index', 'r') ;
-
 
190
				while (!feof($fichier_index_precedent)) {
-
 
191
					$temp = fgets($fichier_index_precedent,4096);
-
 
192
					$ligne = split (':', $temp) ;
-
 
193
					if ($ligne[0] != '') $fichier_precedent = $ligne[0];
-
 
194
					$temp = fgets($fichier_index_precedent,4096);
-
 
195
				}
-
 
196
				
-
 
197
				fclose ($fichier_index_precedent);
-
 
198
			// on se situe dans le repertoire 0 donc pas de message precedent
-
 
199
			} else {
-
 
200
				$fichier_precedent = null;
-
 
201
				$repertoire_precedent = null;
-
 
202
			}
-
 
203
		}
-
 
204
		if ($fichier_precedent > 100) {
-
 
205
			$decimal = (string) $fichier_precedent;
-
 
206
			$numero = substr($decimal, -2) ;
-
 
207
			$fichier_precedent = $numero ;
-
 
208
		} else {
-
 
209
			if ($fichier_precedent < 10 )$fichier_precedent = '0'.$fichier_precedent;
-
 
210
		}
-
 
211
		fclose ($fichier_index);
-
 
212
		//if ($fichier_precedent != null && $fichier_precedent < 10) $fichier_precedent = '0'.$fichier_precedent;
-
 
213
	
-
 
214
		return array ('fichier_suivant' => $fichier_suivant,
-
 
215
			      'repertoire_suivant' => $repertoire_suivant,
-
 
216
			      'fichier_precedent' => $fichier_precedent,
-
 
217
			      'repertoire_precedent' => $repertoire_precedent);
-
 
218
	}
-
 
219
	
-
 
220
    /**
100
    *   analyse l'entete d'un mail pour en extraire les entêtes
221
    *   analyse l'entete d'un mail pour en extraire les entête
101
    *   to, from, subject, date
222
    *   to, from, subject, date
102
    *   met à jour la variable $this->msgtmpl
223
    *   met à jour la variable $this->msgtmpl
103
    *
224
    *
104
    */
225
    */
105
    
226
    
106
    function parse_entete_mail (&$mailDecode) {
227
    function parse_entete_mail (&$mailDecode) {
107
        $startpos = strpos(strtolower($this->msgtmpl_entete), '<ezmlm-headers>');
228
        $startpos = strpos(strtolower($this->msgtmpl_entete), '<ezmlm-headers>');
108
		$endpos = strpos(strtolower($this->msgtmpl_entete), '</ezmlm-headers>');
229
        $endpos = strpos(strtolower($this->msgtmpl_entete), '</ezmlm-headers>');
109
		$headers = substr($this->msgtmpl_entete,$startpos + 15,($endpos - $startpos - 15));
230
		$headers = substr($this->msgtmpl_entete,$startpos + 15,($endpos - $startpos - 15));
110
        $headers_replace = '' ;
231
        $headers_replace = '' ;
111
		for ($i = 0; $i < count($this->showheaders); $i++) {
232
		for ($i = 0; $i < count($this->showheaders); $i++) {
112
			$val = $this->showheaders[$i];
233
		    $val = $this->showheaders[$i];
113
			$headers_replace .= $headers;
234
		    $headers_replace .= $headers;
114
			$hnpos = strpos(strtolower($headers_replace), '<ezmlm-header-name>');
235
		    $hnpos = strpos(strtolower($headers_replace), '<ezmlm-header-name>');
115
			$headers_replace = substr_replace($headers_replace, $this->header_en_francais[$val], $hnpos, 19);
236
		    $headers_replace = substr_replace($headers_replace, $this->header_en_francais[$val], $hnpos, 19);
116
			$hvpos = strpos(strtolower($headers_replace), '<ezmlm-header-value');
237
		    $hvpos = strpos(strtolower($headers_replace), '<ezmlm-header-value');
117
            if ($val == 'date') {
-
 
118
                $headers_replace = substr_replace($headers_replace, $this->date_francaise($mailDecode->headers[strtolower($val)]), $hvpos, 20);
-
 
119
            } else {
-
 
120
                $headers_replace = substr_replace($headers_replace, $this->protect_email($mailDecode->headers[strtolower($val)]), $hvpos, 20);
-
 
121
            }
-
 
122
            $headers_replace = $this->decode_iso ($headers_replace) ;
238
            $headers_replace = $this->decode_iso ($headers_replace) ;
-
 
239
            switch ($val) {
-
 
240
            	case 'date':
-
 
241
            	$headers_replace = substr_replace($headers_replace, $this->date_francaise($mailDecode->headers[strtolower($val)]), $hvpos, 20);
-
 
242
            	break;
-
 
243
            	case 'from':
-
 
244
            	if ($mailDecode->headers[strtolower($val)] == '') $from = $mailDecode->headers['return-path'] ;
-
 
245
            		else $from = $mailDecode->headers['from'];
-
 
246
            	$headers_replace = substr_replace($headers_replace, $this->protect_email($this->decode_iso($from)), $hvpos, 20);
-
 
247
            	//$headers_replace = htmlspecialchars($headers_replace);
-
 
248
            	break;
-
 
249
            	default:
-
 
250
            	$headers_replace = substr_replace($headers_replace, $this->protect_email($this->decode_iso($mailDecode->headers[strtolower($val)])), $hvpos, 20);
-
 
251
            }
123
		}
252
		}
124
        
-
 
125
		return substr_replace($this->msgtmpl_entete, $headers_replace, $startpos, (($endpos + 16) - $startpos));
253
        return substr_replace($this->msgtmpl_entete, $headers_replace, $startpos, (($endpos + 16) - $startpos));
126
    }
254
    }
127
    
255
    
128
    
256
    
129
	function parse_template(&$mailDecode, $numero_mail, $numero_mois, $num_part = '') {
257
	function parse_template(&$mailDecode, $numero_mail, $numero_mois, $num_part = '') {
130
        static $profondeur = array();
258
        static $profondeur = array();
131
        array_push ($profondeur, $num_part) ;
259
        array_push ($profondeur, $num_part) ;
132
        $corps = '' ;
260
        $corps = '' ;
133
        
261
        
134
		if ($mailDecode->ctype_primary == 'multipart') {
262
		if ($mailDecode->ctype_primary == 'multipart') {
135
            include_once PROJET_CHEMIN_CLASSES.'type_fichier_mime.class.php' ;
263
            include_once PROJET_CHEMIN_CLASSES.'type_fichier_mime.class.php' ;
136
			for ($i = 0; $i < count($mailDecode->parts); $i++) {
264
			for ($i = 0; $i < count($mailDecode->parts); $i++) {
137
                switch ($mailDecode->parts[$i]->ctype_secondary) {
265
                switch ($mailDecode->parts[$i]->ctype_secondary) {
138
                    case 'plain' : 
266
                    case 'plain' : 
-
 
267
                    if ($mailDecode->parts[$i]->headers['content-transfer-encoding'] == '8bit') {
-
 
268
                    	$corps .= $this->_cte_8bit($mailDecode->parts[$i]->body);
-
 
269
                    }
-
 
270
                    break;
139
                    case 'html' : $corps .= $mailDecode->parts[$i]->body ;
271
                    case 'html' : $corps .= $mailDecode->parts[$i]->body ;
140
                    break ;
272
                    break ;
141
                    case 'mixed' : 
273
                    case 'mixed' : 
142
                    case 'rfc822' :
274
                    case 'rfc822' :
143
                    case 'alternative' :
275
                    case 'alternative' :
144
                    case 'appledouble' :
276
                    case 'appledouble' :
145
                        $this->parse_template($mailDecode->parts[$i], $numero_mail, $numero_mois, $i) ;
277
                        $this->parse_template($mailDecode->parts[$i], $numero_mail, $numero_mois, $i) ;
146
                    break ;
278
                    break ;
147
                    case 'applefile' : continue ;
279
                    case 'applefile' : continue ;
148
                    break ;
280
                    break ;
149
                    default : 
281
                    default : 
150
                    
282
                    
151
                    if ($mailDecode->parts[$i]->ctype_secondary == 'octet-stream') {
283
                    if ($mailDecode->parts[$i]->ctype_secondary == 'octet-stream') {
152
                        $nom_piece_jointe = $mailDecode->parts[$i]->ctype_parameters['name'] ;
284
                        $nom_piece_jointe = $mailDecode->parts[$i]->ctype_parameters['name'] ;
153
                        $tab = explode ('.', $nom_piece_jointe) ;
285
                        $tab = explode ('.', $nom_piece_jointe) ;
154
                        $extension = $tab[count ($tab) - 1] ;
286
                        $extension = $tab[count ($tab) - 1] ;
155
                        $mimeType = type_fichier_mime::factory($extension, $GLOBALS['projet_db']);
287
                        $mimeType = type_fichier_mime::factory($extension, $GLOBALS['projet_db']);
156
                        $mimeType->setCheminIcone(PROJET_CHEMIN_ICONES) ;
288
                        $mimeType->setCheminIcone(PROJET_CHEMIN_ICONES) ;
157
                    } else {
289
                    } else {
158
                        $nom_piece_jointe = isset ($mailDecode->parts[$i]->d_parameters['filename']) ? 
290
                        $nom_piece_jointe = isset ($mailDecode->parts[$i]->d_parameters['filename']) ? 
159
                                            $mailDecode->parts[$i]->d_parameters['filename'] : $mailDecode->parts[$i]->ctype_parameters['name'] ;
291
                                            $mailDecode->parts[$i]->d_parameters['filename'] : $mailDecode->parts[$i]->ctype_parameters['name'] ;
160
                        $mimeType = new type_fichier_mime($GLOBALS['projet_db'], $mailDecode->parts[$i]->ctype_primary.'/'.
292
                        $mimeType = new type_fichier_mime($GLOBALS['projet_db'], $mailDecode->parts[$i]->ctype_primary.'/'.
161
                                            $mailDecode->parts[$i]->ctype_secondary, PROJET_CHEMIN_ICONES) ;
293
                                            $mailDecode->parts[$i]->ctype_secondary, PROJET_CHEMIN_ICONES) ;
162
                    }
294
                    }
163
                    
295
                    
164
                    $corps .= '<a href="'.PROJET_CHEMIN_APPLI.'fichier_attache.php?nom_liste='.$this->listname.
296
                    $corps .= '<a href="'.PROJET_CHEMIN_APPLI.'synchroliste/fichier_attache.php?nom_liste='.$this->listname.
165
                                    '&actionargs[]='.$numero_mois.
297
                                    '&actionargs[]='.$numero_mois.
166
                                    '&actionargs[]='.$numero_mail;
298
                                    '&actionargs[]='.$numero_mail;
167
                                    
299
                                    
168
                    if (count ($profondeur) > 0) {
300
                    if (count ($profondeur) > 0) {
169
                        array_shift($profondeur) ;
301
                        array_shift($profondeur) ;
170
                        for ($j= 0; $j < count ($profondeur); $j++) $corps .= '&actionargs[]='.$profondeur[$j];
302
                        for ($j= 0; $j < count ($profondeur); $j++) $corps .= '&actionargs[]='.$profondeur[$j];
171
                    }
303
                    }
172
                    $corps .= '&actionargs[]='.$i ;
304
                    $corps .= '&actionargs[]='.$i ;
173
                    $corps .= '">'.'<img src="'.$mimeType->getCheminIcone().'" alt="'.$nom_piece_jointe.'" />&nbsp;' ;
305
                    $corps .= '">'.'<img src="'.$mimeType->getCheminIcone().'" alt="'.$nom_piece_jointe.'" />&nbsp;' ;
174
                    $corps .= $nom_piece_jointe;
306
                    $corps .= $nom_piece_jointe;
175
                    $corps .= '</a><br />' ;
307
                    $corps .= '</a><br />' ;
176
                    break ;
308
                    break ;
177
                }
309
                }
178
            }
310
            }
179
            $this->message_rendu .= preg_replace('/<ezmlm-body>/i', $this->cleanup_body($corps,TRUE), $this->msgtmpl);
311
            $this->message_rendu .= preg_replace('/<ezmlm-body>/i', $this->cleanup_body($corps,TRUE), $this->msgtmpl);
180
            
312
            
181
		} else if ($mailDecode->ctype_primary == 'message') {
313
		} else if ($mailDecode->ctype_primary == 'message') {
182
            
314
            
183
            $this->message_rendu .= "\n".'<div class="message">'.$this->parse_entete_mail($mailDecode->parts[0]);
315
            $this->message_rendu .= "\n".'<div class="message">'.$this->parse_entete_mail($mailDecode->parts[0]);
184
            $corps .= $this->parse_template($mailDecode->parts[0], $numero_mail, $numero_mois, 0) ;
316
            $corps .= $this->parse_template($mailDecode->parts[0], $numero_mail, $numero_mois, 0) ;
185
            $this->message_rendu .= preg_replace('/<ezmlm-body>/i', $this->cleanup_body($corps,true), $this->msgtmpl).'</div>';
317
            $this->message_rendu .= preg_replace('/<ezmlm-body>/i', $this->cleanup_body($corps,true), $this->msgtmpl).'</div>';
186
            
318
            
187
        } else if ($mailDecode->ctype_primary == 'application' || $mailDecode->ctype_primary == 'image'){
319
        } else if ($mailDecode->ctype_primary == 'application' || $mailDecode->ctype_primary == 'image'){
188
            if ($mailDecode->ctype_secondary == 'applefile') return ;
320
            if ($mailDecode->ctype_secondary == 'applefile') return ;
189
            $mimeType = new type_fichier_mime($GLOBALS['projet_db'], $mailDecode->ctype_primary.'/'.$mailDecode->ctype_secondary,PROJET_CHEMIN_ICONES) ;
321
            $mimeType = new type_fichier_mime($GLOBALS['projet_db'], $mailDecode->ctype_primary.'/'.$mailDecode->ctype_secondary,PROJET_CHEMIN_ICONES) ;
190
            
322
            
191
            if ($mimeType->getIdType() != 12) {
323
            if ($mimeType->getIdType() != 12) {
192
                $corps .= '<a href="'.PROJET_CHEMIN_APPLI.'fichier_attache.php?nom_liste='.$this->listname.'&actionargs[]='.
324
                $corps .= '<a href="'.PROJET_CHEMIN_APPLI.'synchroliste/fichier_attache.php?nom_liste='.$this->listname.'&actionargs[]='.
193
                                    $numero_mois.'&actionargs[]='.
325
                                    $numero_mois.'&actionargs[]='.
194
                                    $numero_mail.'&actionargs[]='.$i.'">'.
326
                                    $numero_mail.'&actionargs[]='.$i.'">'.
195
                                    '<img src="'.$mimeType->getCheminIcone().'" alt="'.$mailDecode->ctype_parameters['name'].'" />&nbsp;' ;
327
                                    '<img src="'.$mimeType->getCheminIcone().'" alt="'.$mailDecode->ctype_parameters['name'].'" />&nbsp;' ;
196
                $corps .= $mailDecode->ctype_parameters['name'].'</a><br />' ;
328
                $corps .= $mailDecode->ctype_parameters['name'].'</a><br />' ;
197
                
329
                
198
                $this->message_rendu .= preg_replace('/<ezmlm-body>/i', $this->cleanup_body($corps,true), $this->msgtmpl);
330
                $this->message_rendu .= preg_replace('/<ezmlm-body>/i', $this->cleanup_body($corps,true), $this->msgtmpl);
199
            }
331
            }
200
        } else {
332
        } else {
201
			if (preg_match('/html/i', $mailDecode->ctype_secondary)) {
333
			if (preg_match('/html/i', $mailDecode->ctype_secondary)) {
202
                $this->message_rendu .= preg_replace('/<ezmlm-body>/i', $this->cleanup_body($mailDecode->body,TRUE), $this->msgtmpl);
334
                $this->message_rendu .= preg_replace('/<ezmlm-body>/i', $this->cleanup_body($mailDecode->body,TRUE), $this->msgtmpl);
203
            } else {
335
            } else {
204
                if (isset ($mailDecode->ctype_parameters['charset']) && $mailDecode->ctype_parameters['charset'] == 'UTF-8') {
336
                if (isset ($mailDecode->ctype_parameters['charset']) && $mailDecode->ctype_parameters['charset'] == 'UTF-8') {
205
                    $this->message_rendu .= preg_replace('/<ezmlm-body>/i', '<pre>' . utf8_decode($this->cleanup_body($mailDecode->body,TRUE)) . '</pre>', $this->msgtmpl);
337
                    $this->message_rendu .= preg_replace('/<ezmlm-body>/i', '<pre>' . utf8_decode($this->cleanup_body($mailDecode->body,TRUE)) . '</pre>', $this->msgtmpl);
206
                } else {
338
                } else {
207
                    $this->message_rendu .= preg_replace('/<ezmlm-body>/i', '<pre>' . $this->cleanup_body($mailDecode->body,TRUE) . '</pre>', $this->msgtmpl);
339
                    $this->message_rendu .= preg_replace('/<ezmlm-body>/i', '<pre>' . $this->cleanup_body($mailDecode->body,TRUE) . '</pre>', $this->msgtmpl);
208
                }
340
                }
209
            }
341
            }
210
		}
342
		}
211
	}	
343
	}	
212
 
344
 
213
	function ezmlm_msgdisplay() {
345
	function ezmlm_msgdisplay() {
214
		$this->ezmlm_php();
346
		$this->ezmlm_php();
215
		if (($this->msgtemplate != "") and (is_file($this->msgtemplate))) {
347
		if (($this->msgtemplate != "") and (is_file($this->msgtemplate))) {
216
			$fd = fopen($this->msgtemplate, "r");
348
			$fd = fopen($this->msgtemplate, "r");
217
			while (!feof($fd)) { $this->msgtmpl .= fgets($fd,4096); }
349
			while (!feof($fd)) { $this->msgtmpl .= fgets($fd,4096); }
218
			fclose($fd);
350
			fclose($fd);
219
		} else {
351
		} else {
220
			$this->msgtmpl = '<pre>
352
			$this->msgtmpl = '<pre>
221
<ezmlm-body>
353
<ezmlm-body>
222
</pre>
354
</pre>
223
        ';
355
        ';
224
		}
356
		}
225
        $this->msgtmpl_entete = '<dl><ezmlm-headers>
357
        $this->msgtmpl_entete = '<dl><ezmlm-headers>
226
<dt><ezmlm-header-name> :</dt>
358
<dt><ezmlm-header-name> :</dt>
227
<dd><ezmlm-header-value></dd>
359
<dd><ezmlm-header-value></dd>
228
</ezmlm-headers>
360
</ezmlm-headers>
229
</dl>' ;
361
</dl>' ;
230
	}
362
	}
231
 
363
 
232
}
364
}