Subversion Repositories Applications.projet

Rev

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

Rev 208 Rev 312
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.4 2008-08-25 15:22:48 alexandre_tb 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&eacute;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
		$parser = new ezmlm_parser();
53
		$parser = new ezmlm_parser();
54
        $parser->listdir = $this->listdir ;
54
        $parser->listdir = $this->listdir ;
55
        print '<table class="table_cadre">'."\n";
55
        print '<table class="table_cadre">'."\n";
56
        print '<tr><th class="col1">Num</th><th>De</th><th>Sujet</th><th>Date</th></tr>'."\n";
56
        print '<tr><th class="col1">Num</th><th>De</th><th>Sujet</th><th>Date</th></tr>'."\n";
57
        $ctc = 0;
57
        $ctc = 0;
58
        $recent = $parser->recent_msgs();
58
        $recent = $parser->recent_msgs();
59
        
59
        
60
        // le tableau recent est de la forme
60
        // le tableau recent est de la forme
61
        // $recent[numero_message][1] sujet
61
        // $recent[numero_message][1] sujet
62
        // $recent[numero_message][2] date en anglais => (22 May 2006)
62
        // $recent[numero_message][2] date en anglais => (22 May 2006)
63
        // $recent[numero_message][3] le hash de l auteur
63
        // $recent[numero_message][3] le hash de l auteur
64
        // $recent[numero_message][4] auteur
64
        // $recent[numero_message][4] auteur
65
        
65
        
66
        $class = array ('ligne_paire', 'ligne_impaire') ;
66
        $class = array ('ligne_paire', 'ligne_impaire') ;
-
 
67
        
-
 
68
        include_once 'ezmlm-parser.php';
67
        
69
        
68
        while (list($key,$val) = each($recent)) {
70
        while (list($key,$val) = each($recent)) {
69
            print '<tr class="'.$class[$ctc].'">'."\n";
71
            print '<tr class="'.$class[$ctc].'">'."\n";
70
            //print '<td>'.$val->nummessage.'</td>' ;
72
            //print '<td>'.$val->nummessage.'</td>' ;
71
            
73
            
72
            // $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
73
            // on retrouve le nom du repertoire et le nom du fichier
75
            // on retrouve le nom du repertoire et le nom du fichier
74
            $decimal = (string) $key;
76
            $decimal = (string) $key;
75
            if ($key >= 100) {
77
            if ($key >= 100) {
76
					$fichier_message = substr($decimal, -2) ;
78
					$fichier_message = substr($decimal, -2) ;
77
					$repertoire_message = substr ($decimal, 0,count ($decimal) -2) ;
79
					$repertoire_message = substr ($decimal, 0,count ($decimal) -3) ;
78
				} else {
80
				} else {
79
					if ($key < 10) {
81
					if ($key < 10) {
80
						$fichier_message = '0'.$key;
82
						$fichier_message = '0'.$key;
81
					} else {
83
					} else {
82
						$fichier_message = $decimal;
84
						$fichier_message = $decimal;
83
					}
85
					}
84
					$repertoire_message = '0';
86
					$repertoire_message = '0';
85
			}
87
			}
86
            
88
            
87
            print '<td>'.$key.'</td>' ;
89
            print '<td>'.$key.'</td>' ;
88
            print '<td>';
90
            print '<td>';
89
 
91
 
90
            $from = $val[4];
92
            $from = $val[4];
91
 
93
 
92
            print $this->makelink("action=show_author_msgs&actionargs[]=".$val[3],$this->decode_iso($this->protect_email($from,false)));
94
            print $this->makelink("action=show_author_msgs&amp;actionargs[]=".$val[3],$this->decode_iso($this->protect_email($from,false)));
93
            print "</td>\n";
95
            print "</td>\n";
94
            print '<td><b>';
96
            print '<td><b>';
95
            $actionargs = preg_split("/\//", $val->msgfile);
97
            $actionargs = preg_split("/\//", $val->msgfile);
96
            
-
 
-
 
98
            $parser = new ezmlm_parser();
-
 
99
            $mailDecode = $parser->parse_file_headers($this->listdir.'/archive/'.$repertoire_message.'/'.$fichier_message);
-
 
100
            if (preg_match('/multipart/', $mailDecode->headers['content-type'])) 
-
 
101
            print '<img src="client/projet/images/piece_jointe.png" alt="Pi&egrave;ce jointe" />';
97
            print $this->makelink("action=show_msg&actionargs[]=" .  $repertoire_message . 
102
            print $this->makelink("action=show_msg&amp;actionargs[]=" .  $repertoire_message . 
98
                                "&actionargs[]=" .  $fichier_message ,$this->decode_iso($val[1]));
103
                                "&amp;actionargs[]=" .  $fichier_message , $this->decode_iso($mailDecode->headers['subject']) /* $this->decode_iso($val[1]) */);
99
 
104
 
100
            print "</b></td>\n";
105
            print "</b></td>\n";
101
            
106
            
102
            //print '<td>'.$this->date_francaise($val[2]).'</td>'."\n";
107
            //print '<td>'.$this->date_francaise($val[2]).'</td>'."\n";
103
            print '<td>'.$val[2].'</td>'."\n";
108
            print '<td>'.$val[2].'</td>'."\n";
104
            print "</tr>\n";
109
            print "</tr>\n";
105
 
110
 
106
            $ctc++;
111
            $ctc++;
107
            if ($ctc == 2) { $ctc = 0; }
112
            if ($ctc == 2) { $ctc = 0; }
108
        }
113
        }
109
        print '</table>'."\n";
114
        print '</table>'."\n";
110
        return true;
115
        return true;
111
	}
116
	}
112
    
117
    
113
    function show_month ($month) {
118
    function show_month ($month) {
114
        // Le nom du fichier est annéemois ex 200501 pour janvier 2005
119
        // Le nom du fichier est annéemois ex 200501 pour janvier 2005
115
        
120
        
116
        // on ouvre chaque fichier en lecture
121
        // on ouvre chaque fichier en lecture
117
        $fd = file_get_contents($this->listdir . '/archive/threads/' . $month, 'r');
122
        $fd = file_get_contents($this->listdir . '/archive/threads/' . $month, 'r');
118
        $fichier = explode ("\n", $fd) ;
123
        $fichier = explode ("\n", $fd) ;
119
        // on récupère la première ligne
124
        // on récupère la première ligne
120
        $premiere_ligne = $fichier[0] ;
125
        $premiere_ligne = $fichier[0] ;
121
        $derniere_ligne = $fichier[count($fichier)-2];
126
        $derniere_ligne = $fichier[count($fichier)-2];
122
        
127
        
123
        
128
        
124
        preg_match ('/[0-9]+/', $premiere_ligne, $match) ;
129
        preg_match ('/[0-9]+/', $premiere_ligne, $match) ;
125
        $numero_premier_mail  = $match[0] ;
130
        $numero_premier_mail  = $match[0] ;
126
        
131
        
127
        preg_match ('/[0-9]+/', $derniere_ligne, $match1) ;
132
        preg_match ('/[0-9]+/', $derniere_ligne, $match1) ;
128
        $numero_dernier_mail  = $match1[0] ;
133
        $numero_dernier_mail  = $match1[0] ;
129
		
134
		
130
		// On cherche le répertoire du premier mail
135
		// On cherche le répertoire du premier mail
131
        
136
        
132
        $repertoire_premier_mail = (int) ($numero_premier_mail / 100) ;
137
        $repertoire_premier_mail = (int) ($numero_premier_mail / 100) ;
133
        
138
        
134
        // petite verification de coherence
139
        // petite verification de coherence
135
        if ($numero_premier_mail > $numero_dernier_mail) {
140
        if ($numero_premier_mail > $numero_dernier_mail) {
136
        	$temp = $numero_premier_mail;
141
        	$temp = $numero_premier_mail;
137
        	$numero_premier_mail = $numero_dernier_mail ;
142
        	$numero_premier_mail = $numero_dernier_mail ;
138
        	$numero_dernier_mail = $temp;
143
        	$numero_dernier_mail = $temp;
139
        }
144
        }
140
        print '<table class="table_cadre">'."\n";
145
        print '<table class="table_cadre">'."\n";
141
        print '<tr><th class="col1">Num</th><th>De</th><th>Sujet</th><th>Date</th></tr>'."\n";
146
        print '<tr><th class="col1">Num</th><th>De</th><th>Sujet</th><th>Date</th></tr>'."\n";
142
        $ctc = 0;
147
        $ctc = 0;
143
        
148
        
144
        $class = array ('ligne_paire', 'ligne_impaire') ;
149
        $class = array ('ligne_paire', 'ligne_impaire') ;
145
        
150
        
146
        for ($i = $numero_premier_mail, $compteur = $numero_premier_mail ; $compteur <= $numero_dernier_mail; $i++, $compteur++) {
151
        for ($i = $numero_premier_mail, $compteur = $numero_premier_mail ; $compteur <= $numero_dernier_mail; $i++, $compteur++) {
147
            if ($i > 99) {
152
            if ($i > 99) {
148
                $multiplicateur = (int) ($i / 100) ;
153
                $multiplicateur = (int) ($i / 100) ;
149
                // pour les nails > 99, on retranche n fois 100, ex 256 => 56 cad 256 - 2 * 100 
154
                // pour les nails > 99, on retranche n fois 100, ex 256 => 56 cad 256 - 2 * 100 
150
                $i = $i - $multiplicateur * 100 ;
155
                $i = $i - $multiplicateur * 100 ;
151
            }
156
            }
152
            if ($i < 10) $num_message = '0'.$i ; else $num_message = $i ;
157
            if ($i < 10) $num_message = '0'.$i ; else $num_message = $i ;
153
            if (file_exists($this->listdir.'/archive/'.$repertoire_premier_mail.'/'.$num_message)) { 
158
            if (file_exists($this->listdir.'/archive/'.$repertoire_premier_mail.'/'.$num_message)) { 
154
	            $mimeDecode = new Mail_mimeDecode(file_get_contents ($this->listdir.'/archive/'.$repertoire_premier_mail.'/'.$num_message)) ;
159
	            $mimeDecode = new Mail_mimeDecode(file_get_contents ($this->listdir.'/archive/'.$repertoire_premier_mail.'/'.$num_message)) ;
155
        	    $mailDecode = $mimeDecode->decode() ;
160
        	    $mailDecode = $mimeDecode->decode() ;
156
            	if ($i == 99) {
161
            	if ($i == 99) {
157
                	$repertoire_premier_mail++;
162
                	$repertoire_premier_mail++;
158
               	 $i = -1;
163
               	 $i = -1;
159
            	}
164
            	}
160
            
165
            
161
           	 	print '<tr class="'.$class[$ctc].'">'."\n";
166
           	 	print '<tr class="'.$class[$ctc].'">'."\n";
162
            	print '<td>'.($repertoire_premier_mail != 0 ? $repertoire_premier_mail : '').$num_message.'</td><td>';
167
            	print '<td>'.($repertoire_premier_mail != 0 ? $repertoire_premier_mail : '').$num_message.'</td><td>';
163
            	$hash = $this->makehash($mailDecode->headers['from']);
168
            	$hash = $this->makehash($mailDecode->headers['from']);
164
            
169
            
165
            	print $this->makelink("action=show_author_msgs&actionargs[]=".
170
            	print $this->makelink("action=show_author_msgs&actionargs[]=".
166
            			$hash,$this->decode_iso($this->protect_email($mailDecode->headers['from'],TRUE)));
171
            			$hash,$this->decode_iso($this->protect_email($mailDecode->headers['from'],TRUE)));
167
            	print "</td>\n";
172
            	print "</td>\n";
168
            	print '<td><b>';
173
            	print '<td><b>';
169
            	$actionargs[0] = $repertoire_premier_mail ;
174
            	$actionargs[0] = $repertoire_premier_mail ;
170
            	$actionargs[1] = $num_message ;
175
            	$actionargs[1] = $num_message ;
171
            
176
            
172
           	 	if (count ($actionargs) > 1) {
177
           	 	if (count ($actionargs) > 1) {
173
                	print $this->makelink("action=show_msg&actionargs[]=".
178
                	print $this->makelink("action=show_msg&actionargs[]=".
174
                			$actionargs[(count($actionargs) - 2)] . 
179
                			$actionargs[(count($actionargs) - 2)] . 
175
                            "&actionargs[]=".
180
                            "&actionargs[]=".
176
                            $actionargs[(count($actionargs) - 1)] ,$this->decode_iso($mailDecode->headers['subject']));
181
                            $actionargs[(count($actionargs) - 1)] ,$this->decode_iso($mailDecode->headers['subject']));
177
            	}
182
            	}
178
            	print "</b></td>\n";
183
            	print "</b></td>\n";
179
           	 	print '<td>'.$this->date_francaise($mailDecode->headers['date']).'</td>'."\n";
184
           	 	print '<td>'.$this->date_francaise($mailDecode->headers['date']).'</td>'."\n";
180
            	print "</tr>\n";
185
            	print "</tr>\n";
181
            	$ctc++;
186
            	$ctc++;
182
            	if ($ctc == 2) { $ctc = 0; }
187
            	if ($ctc == 2) { $ctc = 0; }
183
			}
188
			}
184
        }
189
        }
185
        print '</table>'."\n";
190
        print '</table>'."\n";
186
        return true;
191
        return true;
187
    }
192
    }
188
}
193
}
189
 
194