Subversion Repositories Applications.projet

Rev

Rev 208 | Rev 356 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 ddelon 1
<?php
312 alexandre_ 2
// $Id: ezmlm-listinfo.php,v 1.4 2008-08-25 15:22:48 alexandre_tb Exp $
2 ddelon 3
//
4
// ezmlm-listinfo.php - ezmlm-php v2.0
5
// --------------------------------------------------------------
6
// Displays general list info in the format of a welcome page.
7
// --------------------------------------------------------------
8
 
9
require_once("ezmlm.php");
10
 
11
class ezmlm_listinfo extends ezmlm_php {
12
 
13
    function ezmlm_listinfo () {
14
        return is_dir($this->listdir.'/archive/0') ;
15
    }
16
	function display() {
17
 
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' ;
20
 
21
            return false ;
22
        }
23
 
24
		$parser = new ezmlm_parser();
25
        $parser->listdir = $this->listdir ;
26
 
27
		//$this->show_info_file();
28
 
29
 
30
		$threads = new ezmlm_threads();
31
        $threads->listdir = $this->listdir ;
32
        $threads->listname = $this->listname ;
33
        $threads->forcehref = $this->forcehref ;        /// ajout alex
34
        $threads->listmessages() ;
35
		$this->show_recentmsgs();
36
        return true ;
37
	}
38
 
39
	function show_info_file() {
40
		if (@is_file($this->listdir . "/text/info")) {
41
			$infofile = @file($this->listdir . "/text/info");
42
			while (list($line_num, $line) = each($infofile)) {
43
				print nl2br($line);
44
			}
45
		}
46
	}
47
 
48
 
312 alexandre_ 49
	function show_recentmsgs($title = "Messages r&eacute;cents") {
2 ddelon 50
 
51
        if (!is_dir($this->listdir.'/archive/0')) return false;
52
 
53
		$parser = new ezmlm_parser();
54
        $parser->listdir = $this->listdir ;
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";
57
        $ctc = 0;
58
        $recent = $parser->recent_msgs();
208 neiluj 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
 
2 ddelon 66
        $class = array ('ligne_paire', 'ligne_impaire') ;
67
 
312 alexandre_ 68
        include_once 'ezmlm-parser.php';
69
 
2 ddelon 70
        while (list($key,$val) = each($recent)) {
71
            print '<tr class="'.$class[$ctc].'">'."\n";
208 neiluj 72
            //print '<td>'.$val->nummessage.'</td>' ;
73
 
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
76
            $decimal = (string) $key;
77
            if ($key >= 100) {
78
					$fichier_message = substr($decimal, -2) ;
312 alexandre_ 79
					$repertoire_message = substr ($decimal, 0,count ($decimal) -3) ;
208 neiluj 80
				} else {
81
					if ($key < 10) {
82
						$fichier_message = '0'.$key;
83
					} else {
84
						$fichier_message = $decimal;
85
					}
86
					$repertoire_message = '0';
87
			}
88
 
89
            print '<td>'.$key.'</td>' ;
2 ddelon 90
            print '<td>';
208 neiluj 91
 
92
            $from = $val[4];
93
 
312 alexandre_ 94
            print $this->makelink("action=show_author_msgs&amp;actionargs[]=".$val[3],$this->decode_iso($this->protect_email($from,false)));
2 ddelon 95
            print "</td>\n";
96
            print '<td><b>';
97
            $actionargs = preg_split("/\//", $val->msgfile);
312 alexandre_ 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" />';
102
            print $this->makelink("action=show_msg&amp;actionargs[]=" .  $repertoire_message .
103
                                "&amp;actionargs[]=" .  $fichier_message , $this->decode_iso($mailDecode->headers['subject']) /* $this->decode_iso($val[1]) */);
208 neiluj 104
 
2 ddelon 105
            print "</b></td>\n";
106
 
208 neiluj 107
            //print '<td>'.$this->date_francaise($val[2]).'</td>'."\n";
108
            print '<td>'.$val[2].'</td>'."\n";
2 ddelon 109
            print "</tr>\n";
110
 
111
            $ctc++;
112
            if ($ctc == 2) { $ctc = 0; }
113
        }
114
        print '</table>'."\n";
115
        return true;
116
	}
117
 
118
    function show_month ($month) {
208 neiluj 119
        // Le nom du fichier est annéemois ex 200501 pour janvier 2005
2 ddelon 120
 
121
        // on ouvre chaque fichier en lecture
122
        $fd = file_get_contents($this->listdir . '/archive/threads/' . $month, 'r');
123
        $fichier = explode ("\n", $fd) ;
124
        // on récupère la première ligne
125
        $premiere_ligne = $fichier[0] ;
126
        $derniere_ligne = $fichier[count($fichier)-2];
127
 
128
 
129
        preg_match ('/[0-9]+/', $premiere_ligne, $match) ;
130
        $numero_premier_mail  = $match[0] ;
131
 
132
        preg_match ('/[0-9]+/', $derniere_ligne, $match1) ;
133
        $numero_dernier_mail  = $match1[0] ;
134
 
135
		// On cherche le répertoire du premier mail
136
 
137
        $repertoire_premier_mail = (int) ($numero_premier_mail / 100) ;
138
 
208 neiluj 139
        // petite verification de coherence
140
        if ($numero_premier_mail > $numero_dernier_mail) {
141
        	$temp = $numero_premier_mail;
142
        	$numero_premier_mail = $numero_dernier_mail ;
143
        	$numero_dernier_mail = $temp;
144
        }
2 ddelon 145
        print '<table class="table_cadre">'."\n";
146
        print '<tr><th class="col1">Num</th><th>De</th><th>Sujet</th><th>Date</th></tr>'."\n";
147
        $ctc = 0;
148
 
149
        $class = array ('ligne_paire', 'ligne_impaire') ;
150
 
151
        for ($i = $numero_premier_mail, $compteur = $numero_premier_mail ; $compteur <= $numero_dernier_mail; $i++, $compteur++) {
152
            if ($i > 99) {
153
                $multiplicateur = (int) ($i / 100) ;
154
                // pour les nails > 99, on retranche n fois 100, ex 256 => 56 cad 256 - 2 * 100
155
                $i = $i - $multiplicateur * 100 ;
156
            }
157
            if ($i < 10) $num_message = '0'.$i ; else $num_message = $i ;
208 neiluj 158
            if (file_exists($this->listdir.'/archive/'.$repertoire_premier_mail.'/'.$num_message)) {
159
	            $mimeDecode = new Mail_mimeDecode(file_get_contents ($this->listdir.'/archive/'.$repertoire_premier_mail.'/'.$num_message)) ;
160
        	    $mailDecode = $mimeDecode->decode() ;
161
            	if ($i == 99) {
162
                	$repertoire_premier_mail++;
163
               	 $i = -1;
164
            	}
2 ddelon 165
 
208 neiluj 166
           	 	print '<tr class="'.$class[$ctc].'">'."\n";
167
            	print '<td>'.($repertoire_premier_mail != 0 ? $repertoire_premier_mail : '').$num_message.'</td><td>';
168
            	$hash = $this->makehash($mailDecode->headers['from']);
2 ddelon 169
 
208 neiluj 170
            	print $this->makelink("action=show_author_msgs&actionargs[]=".
171
            			$hash,$this->decode_iso($this->protect_email($mailDecode->headers['from'],TRUE)));
172
            	print "</td>\n";
173
            	print '<td><b>';
174
            	$actionargs[0] = $repertoire_premier_mail ;
175
            	$actionargs[1] = $num_message ;
2 ddelon 176
 
208 neiluj 177
           	 	if (count ($actionargs) > 1) {
178
                	print $this->makelink("action=show_msg&actionargs[]=".
179
                			$actionargs[(count($actionargs) - 2)] .
180
                            "&actionargs[]=".
181
                            $actionargs[(count($actionargs) - 1)] ,$this->decode_iso($mailDecode->headers['subject']));
182
            	}
183
            	print "</b></td>\n";
184
           	 	print '<td>'.$this->date_francaise($mailDecode->headers['date']).'</td>'."\n";
185
            	print "</tr>\n";
186
            	$ctc++;
187
            	if ($ctc == 2) { $ctc = 0; }
188
			}
2 ddelon 189
        }
190
        print '</table>'."\n";
191
        return true;
192
    }
193
}
194