Subversion Repositories Applications.projet

Rev

Rev 359 | Rev 392 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 359 Rev 391
Line 1... Line 1...
1
<?php
1
<?php
2
// $Id: ezmlm-listinfo.php,v 1.6 2008-11-19 09:28:46 aperonnet 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
// --------------------------------------------------------------
Line 9... Line 9...
9
require_once("ezmlm.php");
9
require_once("ezmlm.php");
Line 10... Line 10...
10
 
10
 
Line 11... Line 11...
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
	        
Line 18... Line 18...
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' ;
Line 44... Line 44...
44
			}
44
			}
45
		}
45
		}
46
	}
46
	}
Line 47... Line 47...
47
 
47
 
Line 48... Line 48...
48
 
48
 
Line 49... Line 49...
49
	function show_recentmsgs($title = "Messages récents") {
49
	function show_recentmsgs($title = "Messages r�cents") {
Line 110... Line 110...
110
        }
110
        }
111
        $html .= '</table>'."\n";
111
        $html .= '</table>'."\n";
112
        return $html;
112
        return $html;
113
	}
113
	}
Line -... Line 114...
-
 
114
    
114
    
115
    // month = yyyymm
115
    function show_month ($month) {
-
 
116
        // Le nom du fichier est annéemois ex 200501 pour janvier 2005
-
 
117
        
-
 
118
        // le html est vide au début
116
    function show_month ($month) {        
Line 119... Line 117...
119
        $html = '' ;
117
        $html = '' ;
120
        
118
        
121
        // on ouvre chaque fichier en lecture
119
        // on ouvre chaque fichier en lecture
122
        if(!file_exists($this->listdir . '/archive/threads/' . $month)) {
120
        if(!file_exists($this->listdir . '/archive/threads/' . $month)) {
123
        	return false ;
-
 
124
        }
-
 
125
        $fd = file_get_contents($this->listdir . '/archive/threads/' . $month, 'r');
-
 
126
        $fichier = explode ("\n", $fd) ;
-
 
127
        // on récupère la première ligne
-
 
128
        $premiere_ligne = $fichier[0] ;
-
 
129
        $derniere_ligne = $fichier[count($fichier)-2];
-
 
130
        
-
 
131
        
-
 
132
        preg_match ('/[0-9]+/', $premiere_ligne, $match) ;
-
 
133
        $numero_premier_mail  = $match[0] ;
-
 
134
        
-
 
135
        preg_match ('/[0-9]+/', $derniere_ligne, $match1) ;
-
 
136
        $numero_dernier_mail  = $match1[0] ;
-
 
137
		
-
 
138
		// On cherche le répertoire du premier mail
-
 
Line 139... Line -...
139
        
-
 
140
        $repertoire_premier_mail = (int) ($numero_premier_mail / 100) ;
-
 
141
        
-
 
142
        // petite verification de coherence
121
        	return false ;
143
        if ($numero_premier_mail > $numero_dernier_mail) {
-
 
144
        	$temp = $numero_premier_mail;
122
        }
145
        	$numero_premier_mail = $numero_dernier_mail ;
123
        
146
        	$numero_dernier_mail = $temp;
124
	$numeros_mails_mois = $this->calculerNumMessagesDansMois($month);
147
        }
125
 
Line 148... Line 126...
148
        $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";
-
 
128
        $ctc = 0;
-
 
129
        
-
 
130
        $class = array ('ligne_paire', 'ligne_impaire') ;
Line 149... Line 131...
149
        $html .= '<tr><th class="col1">Num</th><th>De</th><th>Sujet</th><th>Date</th></tr>'."\n";
131
 
-
 
132
	if(count($numeros_mails_mois) > 0) {
-
 
133
	    $repertoire_premier_mail = (int) ($numeros_mails_mois[0] / 100) ;
-
 
134
	}
150
        $ctc = 0;
135
        
151
        
136
        foreach ($numeros_mails_mois as $num_message) {
152
        $class = array ('ligne_paire', 'ligne_impaire') ;
137
 
153
        
138
	    $i = $num_message;
154
        for ($i = $numero_premier_mail, $compteur = $numero_premier_mail ; $compteur <= $numero_dernier_mail; $i++, $compteur++) {
139
 
-
 
140
            if ($i > 99) {
155
            if ($i > 99) {
141
                $multiplicateur = (int) ($i / 100) ;
156
                $multiplicateur = (int) ($i / 100) ;
142
                // pour les mails > 99, on retranche n fois 100, ex 256 => 56 cad 256 - 2 * 100 
157
                // pour les nails > 99, on retranche n fois 100, ex 256 => 56 cad 256 - 2 * 100 
143
                $i = $i - $multiplicateur * 100 ;
158
                $i = $i - $multiplicateur * 100 ;
144
            }
-
 
145
 
159
            }
146
            if ($i < 10) $num_message = '0'.$i ; else $num_message = $i ;
160
            if ($i < 10) $num_message = '0'.$i ; else $num_message = $i ;
147
            if (file_exists($this->listdir.'/archive/'.$repertoire_premier_mail.'/'.$num_message)) { 
161
            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)) ;
162
	            $mimeDecode = new Mail_mimeDecode(file_get_contents ($this->listdir.'/archive/'.$repertoire_premier_mail.'/'.$num_message)) ;
149
        	    $mailDecode = $mimeDecode->decode() ;
Line 163... Line 150...
163
        	    $mailDecode = $mimeDecode->decode() ;
150
 
164
            	if ($i == 99) {
151
            	if ($i == 99) {
165
                	$repertoire_premier_mail++;
152
                	$repertoire_premier_mail++;
Line 166... Line 153...
166
               	 $i = -1;
153
               	 $i = -1;
167
            	}
154
            	}
Line 189... Line 176...
189
            	$ctc++;
176
            	$ctc++;
190
            	if ($ctc == 2) { $ctc = 0; }
177
            	if ($ctc == 2) { $ctc = 0; }
191
			}
178
			}
192
        }
179
        }
193
        $html .= '</table>'."\n";
180
        $html .= '</table>'."\n";
-
 
181
 
194
        return $html;
182
        return $html;
195
    }
183
    }
-
 
184
 
-
 
185
    private function calculerNumMessagesDansMois($mois) {
-
 
186
 
-
 
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
-
 
189
		* 2 => pour chaque 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/
-
 
192
		*     b1 => pour chaque ligne du fichier des sujets extraire les id des messages concernés 
-
 
193
		*     s'ils sont dans le mois demandé
-
 
194
		*/		
-
 
195
 
-
 
196
		// étape 1
-
 
197
		$fd = file_get_contents($this->listdir . '/archive/threads/'.$mois, 'r');
-
 
198
        $fichier = explode ("\n", $fd) ;
-
 
199
 
-
 
200
        $premiere_ligne = $fichier[0] ;
-
 
201
 
-
 
202
		$nb_lignes_fichier = count($fichier);
-
 
203
 
-
 
204
		$lignes_messages = array();
-
 
205
	        
-
 
206
        preg_match ('/[0-9]+/', $premiere_ligne, $match) ;
-
 
207
        $numero_premier_mail  = $match[0] ;
-
 
208
 
-
 
209
		$lignes_messages[$numero_premier_mail] = $numero_premier_mail;
-
 
210
 
-
 
211
		// étape 2
-
 
212
		foreach($fichier as $ligne) {
-
 
213
	
-
 
214
		      if(trim($ligne == '')) { continue ;}
-
 
215
	
-
 
216
			  // étape 2 a 
-
 
217
		      $ligne_tableau = explode(' ', $ligne);
-
 
218
		      $num_mail_sujet = explode(':',$ligne_tableau[0]);
-
 
219
		      $num_sujet =  $num_mail_sujet[1];
-
 
220
	
-
 
221
			  // é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');
-
 
223
		      $premiere_ligne = true;
-
 
224
	
-
 
225
		      $fichier_sujet = explode ("\n", $fd_sujet) ;
-
 
226
		      foreach($fichier_sujet as $ligne_sujet) {
-
 
227
				if($premiere_ligne || trim($ligne_sujet) == '') {$premiere_ligne = false; continue; }
-
 
228
	
-
 
229
			      // étape 2 b b1
-
 
230
				  $ligne_tableau_sujet = explode(':', $ligne_sujet);
-
 
231
				  $num_mail =  $ligne_tableau_sujet[0];
-
 
232
				  $mois_ligne =  $ligne_tableau_sujet[1];
-
 
233
				  if($mois_ligne == $mois) {
-
 
234
				    	$lignes_messages[$num_mail] = $num_mail;
-
 
235
			  	  }
-
 
236
		      }
-
 
237
		}
-
 
238
 
-
 
239
        // Tri sur les id de message pour les avoir par ordre d'arrivée
-
 
240
		asort($lignes_messages);
-
 
241
		return $lignes_messages;
-
 
242
    }
196
}
243
}
197
?>
244
?>
198
245