Subversion Repositories Applications.projet

Rev

Rev 393 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 393 Rev 431
Line 1... Line 1...
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.5 2008-11-04 17:11:10 aperonnet 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') ;
Line 15... Line 15...
15
    }
15
    }
16
	function display() {
16
	function display() {
Line 17... Line 17...
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
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 114... Line -...
114
    
-
 
115
    // month = yyyymm
114
    
-
 
115
    function show_month ($month) {
-
 
116
        // Le nom du fichier est ann�emoi ex 200501 pour janvier 2005
-
 
117
        
116
    function show_month ($month) {        
118
        // le html est vide au début
Line 117... Line 119...
117
        $html = '' ;
119
        $html = '' ;
118
        
120
        
119
        // on ouvre chaque fichier en lecture
121
        // on ouvre chaque fichier en lecture
120
        if(!file_exists($this->listdir . '/archive/threads/' . $month)) {
122
        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
Line 121... Line -...
121
        	return false ;
-
 
Line -... Line 128...
-
 
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
-
 
139
        
-
 
140
        $repertoire_premier_mail = (int) ($numero_premier_mail / 100) ;
-
 
141
        
-
 
142
        // petite verification de coherence
-
 
143
        if ($numero_premier_mail > $numero_dernier_mail) {
122
        }
144
        	$temp = $numero_premier_mail;
123
        
145
        	$numero_premier_mail = $numero_dernier_mail ;
124
	$numeros_mails_mois = $this->calculerNumMessagesDansMois($month);
146
        	$numero_dernier_mail = $temp;
Line 125... Line 147...
125
 
147
        }
Line 126... Line -...
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";
148
        $html .= '<table class="table_cadre">'."\n";
128
        $ctc = 0;
-
 
129
        
-
 
130
        $class = array ('ligne_paire', 'ligne_impaire') ;
-
 
131
 
-
 
132
	if(count($numeros_mails_mois) > 0) {
-
 
133
	    $repertoire_premier_mail = (int) (reset($numeros_mails_mois) / 100) ;
-
 
134
	}
149
        $html .= '<tr><th class="col1">Num</th><th>De</th><th>Sujet</th><th>Date</th></tr>'."\n";
135
        
150
        $ctc = 0;
136
        foreach ($numeros_mails_mois as $num_message) {
151
        
137
 
152
        $class = array ('ligne_paire', 'ligne_impaire') ;
138
	    $i = $num_message;
153
        
139
 
-
 
140
            if ($i > 99) {
154
        for ($i = $numero_premier_mail, $compteur = $numero_premier_mail ; $compteur <= $numero_dernier_mail; $i++, $compteur++) {
141
                $multiplicateur = (int) ($i / 100) ;
155
            if ($i > 99) {
142
                // pour les mails > 99, on retranche n fois 100, ex 256 => 56 cad 256 - 2 * 100 
156
                $multiplicateur = (int) ($i / 100) ;
143
                $i = $i - $multiplicateur * 100 ;
157
                // pour les nails > 99, on retranche n fois 100, ex 256 => 56 cad 256 - 2 * 100 
144
            }
-
 
145
 
158
                $i = $i - $multiplicateur * 100 ;
146
            if ($i < 10) $num_message = '0'.$i ; else $num_message = $i ;
159
            }
147
            if (file_exists($this->listdir.'/archive/'.$repertoire_premier_mail.'/'.$num_message)) { 
160
            if ($i < 10) $num_message = '0'.$i ; else $num_message = $i ;
148
	            $mimeDecode = new Mail_mimeDecode(file_get_contents ($this->listdir.'/archive/'.$repertoire_premier_mail.'/'.$num_message)) ;
161
            if (file_exists($this->listdir.'/archive/'.$repertoire_premier_mail.'/'.$num_message)) { 
Line 175... Line 188...
175
            	$html .= "</tr>\n";
188
            	$html .= "</tr>\n";
176
            	$ctc++;
189
            	$ctc++;
177
            	if ($ctc == 2) { $ctc = 0; }
190
            	if ($ctc == 2) { $ctc = 0; }
178
	    }
191
			}
179
        }
192
        }
180
 
-
 
181
        $html .= '</table>'."\n";
193
        $html .= '</table>'."\n";
182
 
-
 
183
        return $html;
194
        return $html;
184
    }
195
    }
185
 
-
 
186
    private function calculerNumMessagesDansMois($mois) {
-
 
187
 
-
 
188
	$fd = file_get_contents($this->listdir . '/archive/threads/'.$mois, 'r');
-
 
189
        $fichier = explode ("\n", $fd) ;
-
 
190
 
-
 
191
        $premiere_ligne = $fichier[0] ;
-
 
192
 
-
 
193
	$nb_lignes_fichier = count($fichier);
-
 
194
 
-
 
195
	$lignes_messages = array();
-
 
196
	        
-
 
197
        preg_match ('/[0-9]+/', $premiere_ligne, $match) ;
-
 
198
        $numero_premier_mail  = $match[0] ;
-
 
199
 
-
 
200
	$lignes_messages[$numero_premier_mail] = $numero_premier_mail;
-
 
201
 
-
 
202
	foreach($fichier as $ligne) {
-
 
203
 
-
 
204
	      if(trim($ligne == '')) { continue ;}
-
 
205
 
-
 
206
	      $ligne_tableau = explode(' ', $ligne);
-
 
207
	      $num_mail_sujet = explode(':',$ligne_tableau[0]);
-
 
208
	      $num_sujet =  $num_mail_sujet[1];
-
 
209
 
-
 
210
	      $fd_sujet = file_get_contents($this->listdir.'/archive/subjects/'.substr($num_sujet,0,2).'/'.substr($num_sujet,2,strlen($num_sujet) - 1), 'r');
-
 
211
	      $premiere_ligne = true;
-
 
212
 
-
 
213
	      $fichier_sujet = explode ("\n", $fd_sujet) ;
-
 
214
	      foreach($fichier_sujet as $ligne_sujet) {
-
 
215
 
-
 
216
		if($premiere_ligne || trim($ligne_sujet) == '') {$premiere_ligne = false; continue; }
-
 
217
		  $ligne_tableau_sujet = explode(':', $ligne_sujet);
-
 
218
		  $num_mail =  $ligne_tableau_sujet[0];
-
 
219
		  $mois_ligne =  $ligne_tableau_sujet[1];
-
 
220
		  if($mois_ligne == $mois) {
-
 
221
			if(is_numeric($num_mail)) {
-
 
222
			    $lignes_messages[$num_mail] = $num_mail;
-
 
223
			} else {
-
 
224
			    $num_mail = preg_replace('/[^0-9]+/','', $num_mail) ;
-
 
225
			    $lignes_messages[$num_mail] = $num_mail;
-
 
226
			}
-
 
227
		  }
-
 
228
	      }
-
 
229
	}
-
 
230
 
-
 
231
	asort($lignes_messages);
-
 
232
	return $lignes_messages;
-
 
233
    }
-
 
234
}
196
}
235
?>
197
?>
236
198