Subversion Repositories Applications.projet

Rev

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

Rev Author Line No. Line
2 ddelon 1
<?php
208 neiluj 2
// $Id: ezmlm-listinfo.php,v 1.3 2007-04-19 15:34:35 neiluj 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
 
208 neiluj 49
	function show_recentmsgs($title = "Messages rà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
 
68
        while (list($key,$val) = each($recent)) {
69
            print '<tr class="'.$class[$ctc].'">'."\n";
208 neiluj 70
            //print '<td>'.$val->nummessage.'</td>' ;
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>' ;
2 ddelon 88
            print '<td>';
208 neiluj 89
 
90
            $from = $val[4];
91
 
92
            print $this->makelink("action=show_author_msgs&actionargs[]=".$val[3],$this->decode_iso($this->protect_email($from,false)));
2 ddelon 93
            print "</td>\n";
94
            print '<td><b>';
95
            $actionargs = preg_split("/\//", $val->msgfile);
208 neiluj 96
 
97
            print $this->makelink("action=show_msg&actionargs[]=" .  $repertoire_message .
98
                                "&actionargs[]=" .  $fichier_message ,$this->decode_iso($val[1]));
99
 
2 ddelon 100
            print "</b></td>\n";
101
 
208 neiluj 102
            //print '<td>'.$this->date_francaise($val[2]).'</td>'."\n";
103
            print '<td>'.$val[2].'</td>'."\n";
2 ddelon 104
            print "</tr>\n";
105
 
106
            $ctc++;
107
            if ($ctc == 2) { $ctc = 0; }
108
        }
109
        print '</table>'."\n";
110
        return true;
111
	}
112
 
113
    function show_month ($month) {
208 neiluj 114
        // Le nom du fichier est annéemois ex 200501 pour janvier 2005
2 ddelon 115
 
116
        // on ouvre chaque fichier en lecture
117
        $fd = file_get_contents($this->listdir . '/archive/threads/' . $month, 'r');
118
        $fichier = explode ("\n", $fd) ;
119
        // on récupère la première ligne
120
        $premiere_ligne = $fichier[0] ;
121
        $derniere_ligne = $fichier[count($fichier)-2];
122
 
123
 
124
        preg_match ('/[0-9]+/', $premiere_ligne, $match) ;
125
        $numero_premier_mail  = $match[0] ;
126
 
127
        preg_match ('/[0-9]+/', $derniere_ligne, $match1) ;
128
        $numero_dernier_mail  = $match1[0] ;
129
 
130
		// On cherche le répertoire du premier mail
131
 
132
        $repertoire_premier_mail = (int) ($numero_premier_mail / 100) ;
133
 
208 neiluj 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;
139
        }
2 ddelon 140
        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";
142
        $ctc = 0;
143
 
144
        $class = array ('ligne_paire', 'ligne_impaire') ;
145
 
146
        for ($i = $numero_premier_mail, $compteur = $numero_premier_mail ; $compteur <= $numero_dernier_mail; $i++, $compteur++) {
147
            if ($i > 99) {
148
                $multiplicateur = (int) ($i / 100) ;
149
                // pour les nails > 99, on retranche n fois 100, ex 256 => 56 cad 256 - 2 * 100
150
                $i = $i - $multiplicateur * 100 ;
151
            }
152
            if ($i < 10) $num_message = '0'.$i ; else $num_message = $i ;
208 neiluj 153
            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)) ;
155
        	    $mailDecode = $mimeDecode->decode() ;
156
            	if ($i == 99) {
157
                	$repertoire_premier_mail++;
158
               	 $i = -1;
159
            	}
2 ddelon 160
 
208 neiluj 161
           	 	print '<tr class="'.$class[$ctc].'">'."\n";
162
            	print '<td>'.($repertoire_premier_mail != 0 ? $repertoire_premier_mail : '').$num_message.'</td><td>';
163
            	$hash = $this->makehash($mailDecode->headers['from']);
2 ddelon 164
 
208 neiluj 165
            	print $this->makelink("action=show_author_msgs&actionargs[]=".
166
            			$hash,$this->decode_iso($this->protect_email($mailDecode->headers['from'],TRUE)));
167
            	print "</td>\n";
168
            	print '<td><b>';
169
            	$actionargs[0] = $repertoire_premier_mail ;
170
            	$actionargs[1] = $num_message ;
2 ddelon 171
 
208 neiluj 172
           	 	if (count ($actionargs) > 1) {
173
                	print $this->makelink("action=show_msg&actionargs[]=".
174
                			$actionargs[(count($actionargs) - 2)] .
175
                            "&actionargs[]=".
176
                            $actionargs[(count($actionargs) - 1)] ,$this->decode_iso($mailDecode->headers['subject']));
177
            	}
178
            	print "</b></td>\n";
179
           	 	print '<td>'.$this->date_francaise($mailDecode->headers['date']).'</td>'."\n";
180
            	print "</tr>\n";
181
            	$ctc++;
182
            	if ($ctc == 2) { $ctc = 0; }
183
			}
2 ddelon 184
        }
185
        print '</table>'."\n";
186
        return true;
187
    }
188
}
189