Subversion Repositories Applications.papyrus

Rev

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

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