Subversion Repositories Applications.projet

Rev

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

Rev 356 Rev 359
1
<?php
1
<?php
2
// $Id: ezmlm-listinfo.php,v 1.5 2008-11-04 17:11:10 aperonnet Exp $
2
// $Id: ezmlm-listinfo.php,v 1.6 2008-11-19 09:28:46 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
// --------------------------------------------------------------
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
    function show_month ($month) {
115
    function show_month ($month) {
116
        // Le nom du fichier est annéemois ex 200501 pour janvier 2005
116
        // Le nom du fichier est annéemois ex 200501 pour janvier 2005
117
        
117
        
118
        // le html est vide au début
118
        // le html est vide au début
119
        $html = '' ;
119
        $html = '' ;
120
        
120
        
121
        // on ouvre chaque fichier en lecture
121
        // on ouvre chaque fichier en lecture
122
        if(!file_exists($this->listdir . '/archive/threads/' . $month)) {
122
        if(!file_exists($this->listdir . '/archive/threads/' . $month)) {
123
        	return false ;
123
        	return false ;
124
        }
124
        }
125
        $fd = file_get_contents($this->listdir . '/archive/threads/' . $month, 'r');
125
        $fd = file_get_contents($this->listdir . '/archive/threads/' . $month, 'r');
126
        $fichier = explode ("\n", $fd) ;
126
        $fichier = explode ("\n", $fd) ;
127
        // on récupère la première ligne
127
        // on récupère la première ligne
128
        $premiere_ligne = $fichier[0] ;
128
        $premiere_ligne = $fichier[0] ;
129
        $derniere_ligne = $fichier[count($fichier)-2];
129
        $derniere_ligne = $fichier[count($fichier)-2];
130
        
130
        
131
        
131
        
132
        preg_match ('/[0-9]+/', $premiere_ligne, $match) ;
132
        preg_match ('/[0-9]+/', $premiere_ligne, $match) ;
133
        $numero_premier_mail  = $match[0] ;
133
        $numero_premier_mail  = $match[0] ;
134
        
134
        
135
        preg_match ('/[0-9]+/', $derniere_ligne, $match1) ;
135
        preg_match ('/[0-9]+/', $derniere_ligne, $match1) ;
136
        $numero_dernier_mail  = $match1[0] ;
136
        $numero_dernier_mail  = $match1[0] ;
137
		
137
		
138
		// On cherche le répertoire du premier mail
138
		// On cherche le répertoire du premier mail
139
        
139
        
140
        $repertoire_premier_mail = (int) ($numero_premier_mail / 100) ;
140
        $repertoire_premier_mail = (int) ($numero_premier_mail / 100) ;
141
        
141
        
142
        // petite verification de coherence
142
        // petite verification de coherence
143
        if ($numero_premier_mail > $numero_dernier_mail) {
143
        if ($numero_premier_mail > $numero_dernier_mail) {
144
        	$temp = $numero_premier_mail;
144
        	$temp = $numero_premier_mail;
145
        	$numero_premier_mail = $numero_dernier_mail ;
145
        	$numero_premier_mail = $numero_dernier_mail ;
146
        	$numero_dernier_mail = $temp;
146
        	$numero_dernier_mail = $temp;
147
        }
147
        }
148
        $html .= '<table class="table_cadre">'."\n";
148
        $html .= '<table class="table_cadre">'."\n";
149
        $html .= '<tr><th class="col1">Num</th><th>De</th><th>Sujet</th><th>Date</th></tr>'."\n";
149
        $html .= '<tr><th class="col1">Num</th><th>De</th><th>Sujet</th><th>Date</th></tr>'."\n";
150
        $ctc = 0;
150
        $ctc = 0;
151
        
151
        
152
        $class = array ('ligne_paire', 'ligne_impaire') ;
152
        $class = array ('ligne_paire', 'ligne_impaire') ;
153
        
153
        
154
        for ($i = $numero_premier_mail, $compteur = $numero_premier_mail ; $compteur <= $numero_dernier_mail; $i++, $compteur++) {
154
        for ($i = $numero_premier_mail, $compteur = $numero_premier_mail ; $compteur <= $numero_dernier_mail; $i++, $compteur++) {
155
            if ($i > 99) {
155
            if ($i > 99) {
156
                $multiplicateur = (int) ($i / 100) ;
156
                $multiplicateur = (int) ($i / 100) ;
157
                // pour les nails > 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 
158
                $i = $i - $multiplicateur * 100 ;
158
                $i = $i - $multiplicateur * 100 ;
159
            }
159
            }
160
            if ($i < 10) $num_message = '0'.$i ; else $num_message = $i ;
160
            if ($i < 10) $num_message = '0'.$i ; else $num_message = $i ;
161
            if (file_exists($this->listdir.'/archive/'.$repertoire_premier_mail.'/'.$num_message)) { 
161
            if (file_exists($this->listdir.'/archive/'.$repertoire_premier_mail.'/'.$num_message)) { 
162
	            $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)) ;
163
        	    $mailDecode = $mimeDecode->decode() ;
163
        	    $mailDecode = $mimeDecode->decode() ;
164
            	if ($i == 99) {
164
            	if ($i == 99) {
165
                	$repertoire_premier_mail++;
165
                	$repertoire_premier_mail++;
166
               	 $i = -1;
166
               	 $i = -1;
167
            	}
167
            	}
168
            
168
            
169
           	 	$html .= '<tr class="'.$class[$ctc].'">'."\n";
169
           	 	$html .= '<tr class="'.$class[$ctc].'">'."\n";
170
            	$html .= '<td>'.($repertoire_premier_mail != 0 ? $repertoire_premier_mail : '').$num_message.'</td><td>';
170
            	$html .= '<td>'.($repertoire_premier_mail != 0 ? $repertoire_premier_mail : '').$num_message.'</td><td>';
171
            	$hash = $this->makehash($mailDecode->headers['from']);
171
            	$hash = $this->makehash($mailDecode->headers['from']);
172
            
172
            
173
            	$html .= $this->makelink("action=show_author_msgs&actionargs[]=".
173
            	$html .= $this->makelink("action=show_author_msgs&actionargs[]=".
174
            			$hash,$this->decode_iso($this->protect_email($mailDecode->headers['from'],TRUE)));
174
            			$hash,$this->decode_iso($this->protect_email($mailDecode->headers['from'],TRUE)));
175
            	$html .= "</td>\n";
175
            	$html .= "</td>\n";
176
            	$html .= '<td><b>';
176
            	$html .= '<td><b>';
177
            	$actionargs[0] = $repertoire_premier_mail ;
177
            	$actionargs[0] = $repertoire_premier_mail ;
178
            	$actionargs[1] = $num_message ;
178
            	$actionargs[1] = $num_message ;
179
            
179
            
180
           	 	if (count ($actionargs) > 1) {
180
           	 	if (count ($actionargs) > 1) {
181
                	$html .= $this->makelink("action=show_msg&actionargs[]=".
181
                	$html .= $this->makelink("action=show_msg&actionargs[]=".
182
                			$actionargs[(count($actionargs) - 2)] . 
182
                			$actionargs[(count($actionargs) - 2)] . 
183
                            "&actionargs[]=".
183
                            "&actionargs[]=".
184
                            $actionargs[(count($actionargs) - 1)] ,$this->decode_iso($mailDecode->headers['subject']));
184
                            $actionargs[(count($actionargs) - 1)] ,$this->decode_iso($mailDecode->headers['subject']));
185
            	}
185
            	}
186
            	$html .= "</b></td>\n";
186
            	$html .= "</b></td>\n";
187
           	 	$html .= '<td>'.$this->date_francaise($mailDecode->headers['date']).'</td>'."\n";
187
           	 	$html .= '<td>'.$this->date_francaise($mailDecode->headers['date']).'</td>'."\n";
188
            	$html .= "</tr>\n";
188
            	$html .= "</tr>\n";
189
            	$ctc++;
189
            	$ctc++;
190
            	if ($ctc == 2) { $ctc = 0; }
190
            	if ($ctc == 2) { $ctc = 0; }
191
			}
191
			}
192
        }
192
        }
193
        $html .= '</table>'."\n";
193
        $html .= '</table>'."\n";
194
        return $html;
194
        return $html;
195
    }
195
    }
196
}
196
}
197
?>
197
?>