Subversion Repositories Applications.projet

Rev

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

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