Subversion Repositories Applications.projet

Rev

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

Rev 391 Rev 392
1
<?php
1
<?php
2
// $Id: ezmlm-listinfo.php,v 1.3 2007/04/19 15:34:35 neiluj Exp $
2
// $Id: ezmlm-listinfo.php,v 1.3 2007/04/19 15:34:35 neiluj Exp $
3
//
3
//
4
// ezmlm-listinfo.php - ezmlm-php v2.0
4
// ezmlm-listinfo.php - ezmlm-php v2.0
5
// --------------------------------------------------------------
5
// --------------------------------------------------------------
6
// Displays general list info in the format of a welcome page.
6
// Displays general list info in the format of a welcome page.
7
// --------------------------------------------------------------
7
// --------------------------------------------------------------
8
 
8
 
9
require_once("ezmlm.php");
9
require_once("ezmlm.php");
10
 
10
 
11
class ezmlm_listinfo extends ezmlm_php {
11
class ezmlm_listinfo extends ezmlm_php {
12
 
12
 
13
    function ezmlm_listinfo () {
13
    function ezmlm_listinfo () {
14
        //return is_dir($this->listdir.'/archive/0') ;
14
        //return is_dir($this->listdir.'/archive/0') ;
15
    }
15
    }
16
	function display() {
16
	function display() {
17
	        
17
	        
18
        if (!is_dir($this->listdir.'/archive/0')) {  // On teste si il y a au moins un message, cad le r�pertoire 0
18
        if (!is_dir($this->listdir.'/archive/0')) {  // On teste si il y a au moins un message, cad le r�pertoire 0
19
            echo $this->listdir.'/archive/0' ;
19
            echo $this->listdir.'/archive/0' ;
20
            
20
            
21
            return false ;
21
            return false ;
22
        }
22
        }
23
        
23
        
24
		$parser = new ezmlm_parser();
24
		$parser = new ezmlm_parser();
25
        $parser->listdir = $this->listdir ;
25
        $parser->listdir = $this->listdir ;
26
		
26
		
27
		//$this->show_info_file();
27
		//$this->show_info_file();
28
		
28
		
29
        
29
        
30
		$threads = new ezmlm_threads();
30
		$threads = new ezmlm_threads();
31
        $threads->listdir = $this->listdir ;
31
        $threads->listdir = $this->listdir ;
32
        $threads->listname = $this->listname ;
32
        $threads->listname = $this->listname ;
33
        $threads->forcehref = $this->forcehref ;        /// ajout alex
33
        $threads->forcehref = $this->forcehref ;        /// ajout alex
34
        $threads->listmessages() ;
34
        $threads->listmessages() ;
35
		$this->show_recentmsgs();
35
		$this->show_recentmsgs();
36
        return true ;
36
        return true ;
37
	}
37
	}
38
 
38
 
39
	function show_info_file() {
39
	function show_info_file() {
40
		if (@is_file($this->listdir . "/text/info")) {
40
		if (@is_file($this->listdir . "/text/info")) {
41
			$infofile = @file($this->listdir . "/text/info");
41
			$infofile = @file($this->listdir . "/text/info");
42
			while (list($line_num, $line) = each($infofile)) {
42
			while (list($line_num, $line) = each($infofile)) {
43
				print nl2br($line);
43
				print nl2br($line);
44
			}
44
			}
45
		}
45
		}
46
	}
46
	}
47
 
47
 
48
 
48
 
49
	function show_recentmsgs($title = "Messages r�cents") {
49
	function show_recentmsgs($title = "Messages r�cents") {
50
        
50
        
51
        if (!is_dir($this->listdir.'/archive/0')) return false;
51
        if (!is_dir($this->listdir.'/archive/0')) return false;
52
        
52
        
53
        
53
        
54
        $html = '' ;
54
        $html = '' ;
55
		$parser = new ezmlm_parser();
55
		$parser = new ezmlm_parser();
56
        $parser->listdir = $this->listdir ;
56
        $parser->listdir = $this->listdir ;
57
        $html .= '<table class="table_cadre">'."\n";
57
        $html .= '<table class="table_cadre">'."\n";
58
        $html .= '<tr><th class="col1">Num</th><th>De</th><th>Sujet</th><th>Date</th></tr>'."\n";
58
        $html .= '<tr><th class="col1">Num</th><th>De</th><th>Sujet</th><th>Date</th></tr>'."\n";
59
        $ctc = 0;
59
        $ctc = 0;
60
        $recent = $parser->recent_msgs();
60
        $recent = $parser->recent_msgs();
61
        
61
        
62
        // le tableau recent est de la forme
62
        // le tableau recent est de la forme
63
        // $recent[numero_message][1] sujet
63
        // $recent[numero_message][1] sujet
64
        // $recent[numero_message][2] date en anglais => (22 May 2006)
64
        // $recent[numero_message][2] date en anglais => (22 May 2006)
65
        // $recent[numero_message][3] le hash de l auteur
65
        // $recent[numero_message][3] le hash de l auteur
66
        // $recent[numero_message][4] auteur
66
        // $recent[numero_message][4] auteur
67
        
67
        
68
        $class = array ('ligne_paire', 'ligne_impaire') ;
68
        $class = array ('ligne_paire', 'ligne_impaire') ;
69
        
69
        
70
        while (list($key,$val) = each($recent)) {
70
        while (list($key,$val) = each($recent)) {
71
            $html .= '<tr class="'.$class[$ctc].'">'."\n";
71
            $html .= '<tr class="'.$class[$ctc].'">'."\n";
72
            //print '<td>'.$val->nummessage.'</td>' ;
72
            //print '<td>'.$val->nummessage.'</td>' ;
73
            
73
            
74
            // $key contient le numero du message tel que dans les fichiers d index par ex 216
74
            // $key contient le numero du message tel que dans les fichiers d index par ex 216
75
            // on retrouve le nom du repertoire et le nom du fichier
75
            // on retrouve le nom du repertoire et le nom du fichier
76
            $decimal = (string) $key;
76
            $decimal = (string) $key;
77
            if ($key >= 100) {
77
            if ($key >= 100) {
78
					$fichier_message = substr($decimal, -2) ;
78
					$fichier_message = substr($decimal, -2) ;
79
					$repertoire_message = substr ($decimal, 0, -2) ;
79
					$repertoire_message = substr ($decimal, 0, -2) ;
80
				} else {
80
				} else {
81
					if ($key < 10) {
81
					if ($key < 10) {
82
						$fichier_message = '0'.$key;
82
						$fichier_message = '0'.$key;
83
					} else {
83
					} else {
84
						$fichier_message = $decimal;
84
						$fichier_message = $decimal;
85
					}
85
					}
86
					$repertoire_message = '0';
86
					$repertoire_message = '0';
87
			}
87
			}
88
            
88
            
89
            $html .= '<td>'.$key.'</td>' ;
89
            $html .= '<td>'.$key.'</td>' ;
90
            $html .= '<td>';
90
            $html .= '<td>';
91
 
91
 
92
            $from = $val[4];
92
            $from = $val[4];
93
 
93
 
94
            $html .= $this->makelink("action=show_author_msgs&actionargs[]=".$val[3],$this->decode_iso($this->protect_email($from,false)));
94
            $html .= $this->makelink("action=show_author_msgs&actionargs[]=".$val[3],$this->decode_iso($this->protect_email($from,false)));
95
            $html .= "</td>\n";
95
            $html .= "</td>\n";
96
            $html .= '<td><b>';
96
            $html .= '<td><b>';
97
            $actionargs = preg_split("/\//", $val->msgfile);
97
            $actionargs = preg_split("/\//", $val->msgfile);
98
            
98
            
99
            $html .= $this->makelink("action=show_msg&actionargs[]=".$repertoire_message.
99
            $html .= $this->makelink("action=show_msg&actionargs[]=".$repertoire_message.
100
                                "&actionargs[]=".$fichier_message ,$this->decode_iso($val[1]));
100
                                "&actionargs[]=".$fichier_message ,$this->decode_iso($val[1]));
101
 
101
 
102
            $html .= "</b></td>\n";
102
            $html .= "</b></td>\n";
103
            
103
            
104
            //print '<td>'.$this->date_francaise($val[2]).'</td>'."\n";
104
            //print '<td>'.$this->date_francaise($val[2]).'</td>'."\n";
105
            $html .= '<td>'.$val[2].'</td>'."\n";
105
            $html .= '<td>'.$val[2].'</td>'."\n";
106
            $html .= "</tr>\n";
106
            $html .= "</tr>\n";
107
 
107
 
108
            $ctc++;
108
            $ctc++;
109
            if ($ctc == 2) { $ctc = 0; }
109
            if ($ctc == 2) { $ctc = 0; }
110
        }
110
        }
111
        $html .= '</table>'."\n";
111
        $html .= '</table>'."\n";
112
        return $html;
112
        return $html;
113
	}
113
	}
114
    
114
    
115
    // month = yyyymm
115
    // month = yyyymm
116
    function show_month ($month) {        
116
    function show_month ($month) {        
117
        $html = '' ;
117
        $html = '' ;
118
        
118
        
119
        // on ouvre chaque fichier en lecture
119
        // on ouvre chaque fichier en lecture
120
        if(!file_exists($this->listdir . '/archive/threads/' . $month)) {
120
        if(!file_exists($this->listdir . '/archive/threads/' . $month)) {
121
        	return false ;
121
        	return false ;
122
        }
122
        }
123
        
123
        
124
	$numeros_mails_mois = $this->calculerNumMessagesDansMois($month);
124
	$numeros_mails_mois = $this->calculerNumMessagesDansMois($month);
125
 
125
 
126
        $html .= '<table class="table_cadre">'."\n";
126
        $html .= '<table class="table_cadre">'."\n";
127
        $html .= '<tr><th class="col1">Num</th><th>De</th><th>Sujet</th><th>Date</th></tr>'."\n";
127
        $html .= '<tr><th class="col1">Num</th><th>De</th><th>Sujet</th><th>Date</th></tr>'."\n";
128
        $ctc = 0;
128
        $ctc = 0;
129
        
129
        
130
        $class = array ('ligne_paire', 'ligne_impaire') ;
130
        $class = array ('ligne_paire', 'ligne_impaire') ;
131
 
131
 
132
	if(count($numeros_mails_mois) > 0) {
132
	if(count($numeros_mails_mois) > 0) {
133
	    $repertoire_premier_mail = (int) ($numeros_mails_mois[0] / 100) ;
133
	    $repertoire_premier_mail = (int) ($numeros_mails_mois[0] / 100) ;
134
	}
134
	}
135
        
135
        
136
        foreach ($numeros_mails_mois as $num_message) {
136
        foreach ($numeros_mails_mois as $num_message) {
137
 
137
 
138
	    $i = $num_message;
138
	    $i = $num_message;
139
 
139
 
140
            if ($i > 99) {
140
            if ($i > 99) {
141
                $multiplicateur = (int) ($i / 100) ;
141
                $multiplicateur = (int) ($i / 100) ;
142
                // pour les mails > 99, on retranche n fois 100, ex 256 => 56 cad 256 - 2 * 100 
142
                // pour les mails > 99, on retranche n fois 100, ex 256 => 56 cad 256 - 2 * 100 
143
                $i = $i - $multiplicateur * 100 ;
143
                $i = $i - $multiplicateur * 100 ;
144
            }
144
            }
145
 
145
 
146
            if ($i < 10) $num_message = '0'.$i ; else $num_message = $i ;
146
            if ($i < 10) $num_message = '0'.$i ; else $num_message = $i ;
147
            if (file_exists($this->listdir.'/archive/'.$repertoire_premier_mail.'/'.$num_message)) { 
147
            if (file_exists($this->listdir.'/archive/'.$repertoire_premier_mail.'/'.$num_message)) { 
148
	            $mimeDecode = new Mail_mimeDecode(file_get_contents ($this->listdir.'/archive/'.$repertoire_premier_mail.'/'.$num_message)) ;
148
	            $mimeDecode = new Mail_mimeDecode(file_get_contents ($this->listdir.'/archive/'.$repertoire_premier_mail.'/'.$num_message)) ;
149
        	    $mailDecode = $mimeDecode->decode() ;
149
        	    $mailDecode = $mimeDecode->decode() ;
150
 
150
 
151
            	if ($i == 99) {
151
            	if ($i == 99) {
152
                	$repertoire_premier_mail++;
152
                	$repertoire_premier_mail++;
153
               	 $i = -1;
153
               	 $i = -1;
154
            	}
154
            	}
155
            
155
            
156
           	$html .= '<tr class="'.$class[$ctc].'">'."\n";
156
           	$html .= '<tr class="'.$class[$ctc].'">'."\n";
157
            	$html .= '<td>'.($repertoire_premier_mail != 0 ? $repertoire_premier_mail : '').$num_message.'</td><td>';
157
            	$html .= '<td>'.($repertoire_premier_mail != 0 ? $repertoire_premier_mail : '').$num_message.'</td><td>';
158
            	$hash = $this->makehash($mailDecode->headers['from']);
158
            	$hash = $this->makehash($mailDecode->headers['from']);
159
            
159
            
160
            	$html .= $this->makelink("action=show_author_msgs&actionargs[]=".
160
            	$html .= $this->makelink("action=show_author_msgs&actionargs[]=".
161
            			$hash,$this->decode_iso($this->protect_email($mailDecode->headers['from'],TRUE)));
161
            			$hash,$this->decode_iso($this->protect_email($mailDecode->headers['from'],TRUE)));
162
            	$html .= "</td>\n";
162
            	$html .= "</td>\n";
163
            	$html .= '<td><b>';
163
            	$html .= '<td><b>';
164
            	$actionargs[0] = $repertoire_premier_mail ;
164
            	$actionargs[0] = $repertoire_premier_mail ;
165
            	$actionargs[1] = $num_message ;
165
            	$actionargs[1] = $num_message ;
166
            
166
            
167
           	 	if (count ($actionargs) > 1) {
167
           	 	if (count ($actionargs) > 1) {
168
                	$html .= $this->makelink("action=show_msg&actionargs[]=".
168
                	$html .= $this->makelink("action=show_msg&actionargs[]=".
169
                			$actionargs[(count($actionargs) - 2)] . 
169
                			$actionargs[(count($actionargs) - 2)] . 
170
                            "&actionargs[]=".
170
                            "&actionargs[]=".
171
                            $actionargs[(count($actionargs) - 1)] ,$this->decode_iso($mailDecode->headers['subject']));
171
                            $actionargs[(count($actionargs) - 1)] ,$this->decode_iso($mailDecode->headers['subject']));
172
            	}
172
            	}
173
            	$html .= "</b></td>\n";
173
            	$html .= "</b></td>\n";
174
           	 	$html .= '<td>'.$this->date_francaise($mailDecode->headers['date']).'</td>'."\n";
174
           	 	$html .= '<td>'.$this->date_francaise($mailDecode->headers['date']).'</td>'."\n";
175
            	$html .= "</tr>\n";
175
            	$html .= "</tr>\n";
176
            	$ctc++;
176
            	$ctc++;
177
            	if ($ctc == 2) { $ctc = 0; }
177
            	if ($ctc == 2) { $ctc = 0; }
178
			}
178
			}
179
        }
179
        }
180
        $html .= '</table>'."\n";
180
        $html .= '</table>'."\n";
181
 
181
 
182
        return $html;
182
        return $html;
183
    }
183
    }
184
 
184
 
185
    private function calculerNumMessagesDansMois($mois) {
185
    private function calculerNumMessagesDansMois($mois) {
186
 
186
 
187
		/* Pour le calcul du nombre de message par mois 
187
		/* Pour le calcul du nombre de message par mois 
188
		* 1 => ouvrir fichier /archive/threads/yyyymm qui contient les sujets abordés dans le mois
188
		* 1 => ouvrir fichier /archive/threads/yyyymm qui contient les sujets abordés dans le mois
189
		* 2 => pour chaque ligne: 
189
		* 2 => pour chaque ligne: 
190
		* 	a =>  extraire l'id du du premier message (1er nombre de la ligne)
190
		* 	a =>  extraire l'id du du premier message (1er nombre de la ligne)
191
		* 	b =>  extraire l'id du sujet et ouvrir le fichier concerné dans /archive/subjects/
191
		* 	b =>  extraire l'id du sujet et ouvrir le fichier concerné dans /archive/subjects/
192
		*     b1 => pour chaque ligne du fichier des sujets extraire les id des messages concernés 
192
		*     b1 => pour chaque ligne du fichier des sujets extraire les id des messages concernés 
193
		*     s'ils sont dans le mois demandé
193
		*     s'ils sont dans le mois demandé
194
		*/		
194
		*/		
195
 
195
 
196
		// étape 1
196
		// étape 1
197
		$fd = file_get_contents($this->listdir . '/archive/threads/'.$mois, 'r');
197
		$fd = file_get_contents($this->listdir . '/archive/threads/'.$mois, 'r');
198
        $fichier = explode ("\n", $fd) ;
198
        $fichier = explode ("\n", $fd) ;
199
 
199
 
200
        $premiere_ligne = $fichier[0] ;
200
        $premiere_ligne = $fichier[0] ;
201
 
201
 
202
		$nb_lignes_fichier = count($fichier);
202
		$nb_lignes_fichier = count($fichier);
203
 
203
 
204
		$lignes_messages = array();
204
		$lignes_messages = array();
205
	        
205
	        
206
        preg_match ('/[0-9]+/', $premiere_ligne, $match) ;
206
        preg_match ('/[0-9]+/', $premiere_ligne, $match) ;
207
        $numero_premier_mail  = $match[0] ;
207
        $numero_premier_mail  = $match[0] ;
208
 
208
 
209
		$lignes_messages[$numero_premier_mail] = $numero_premier_mail;
209
		$lignes_messages[$numero_premier_mail] = $numero_premier_mail;
210
 
210
 
211
		// étape 2
211
		// étape 2
212
		foreach($fichier as $ligne) {
212
		foreach($fichier as $ligne) {
213
	
213
	
214
		      if(trim($ligne == '')) { continue ;}
214
		      if(trim($ligne == '')) { continue ;}
-
 
215
		      // Une ligne du fichier mois se présente comme ceci
-
 
216
			  //numero_premier_message_sujet:md5_sujet [nb_messages_sujet] titre_sujet
215
	
217
	
216
			  // étape 2 a 
218
			  // étape 2 a 
217
		      $ligne_tableau = explode(' ', $ligne);
219
		      $ligne_tableau = explode(' ', $ligne);
218
		      $num_mail_sujet = explode(':',$ligne_tableau[0]);
220
		      $num_mail_sujet = explode(':',$ligne_tableau[0]);
219
		      $num_sujet =  $num_mail_sujet[1];
221
		      $num_sujet =  $num_mail_sujet[1];
220
	
222
	
221
			  // étape 2 b
223
			  // étape 2 b
222
		      $fd_sujet = file_get_contents($this->listdir.'/archive/subjects/'.substr($num_sujet,0,2).'/'.substr($num_sujet,2,strlen($num_sujet) - 1), 'r');
224
		      $fd_sujet = file_get_contents($this->listdir.'/archive/subjects/'.substr($num_sujet,0,2).'/'.substr($num_sujet,2,strlen($num_sujet) - 1), 'r');
223
		      $premiere_ligne = true;
225
		      $premiere_ligne = true;
224
	
226
	
225
		      $fichier_sujet = explode ("\n", $fd_sujet) ;
227
		      $fichier_sujet = explode ("\n", $fd_sujet) ;
-
 
228
		      // La première ligne d'un fichier de sujet se présente ainsi 
-
 
229
		      // md5_sujet titre_sujet
-
 
230
		      // Les lignes suivante sont de la forme :
-
 
231
			  // id_message:yyyymm:id_message_fichier_index nom_expediteur
226
		      foreach($fichier_sujet as $ligne_sujet) {
232
		      foreach($fichier_sujet as $ligne_sujet) {
227
				if($premiere_ligne || trim($ligne_sujet) == '') {$premiere_ligne = false; continue; }
233
				if($premiere_ligne || trim($ligne_sujet) == '') {$premiere_ligne = false; continue; }
228
	
234
	
229
			      // étape 2 b b1
235
			      // étape 2 b b1
230
				  $ligne_tableau_sujet = explode(':', $ligne_sujet);
236
				  $ligne_tableau_sujet = explode(':', $ligne_sujet);
231
				  $num_mail =  $ligne_tableau_sujet[0];
237
				  $num_mail =  $ligne_tableau_sujet[0];
232
				  $mois_ligne =  $ligne_tableau_sujet[1];
238
				  $mois_ligne =  $ligne_tableau_sujet[1];
233
				  if($mois_ligne == $mois) {
239
				  if($mois_ligne == $mois) {
234
				    	$lignes_messages[$num_mail] = $num_mail;
240
				    	$lignes_messages[$num_mail] = $num_mail;
235
			  	  }
241
			  	  }
236
		      }
242
		      }
237
		}
243
		}
238
 
244
 
239
        // Tri sur les id de message pour les avoir par ordre d'arrivée
245
        // Tri sur les id de message pour les avoir par ordre d'arrivée
240
		asort($lignes_messages);
246
		asort($lignes_messages);
241
		return $lignes_messages;
247
		return $lignes_messages;
242
    }
248
    }
243
}
249
}
244
?>
250
?>