2 |
ddelon |
1 |
<?php
|
391 |
aurelien |
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 () {
|
391 |
aurelien |
14 |
//return is_dir($this->listdir.'/archive/0') ;
|
2 |
ddelon |
15 |
}
|
|
|
16 |
function display() {
|
391 |
aurelien |
17 |
|
|
|
18 |
if (!is_dir($this->listdir.'/archive/0')) { // On teste si il y a au moins un message, cad le r�pertoire 0
|
2 |
ddelon |
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 |
|
391 |
aurelien |
49 |
function show_recentmsgs($title = "Messages r�cents") {
|
2 |
ddelon |
50 |
|
|
|
51 |
if (!is_dir($this->listdir.'/archive/0')) return false;
|
|
|
52 |
|
356 |
aperonnet |
53 |
|
|
|
54 |
$html = '' ;
|
2 |
ddelon |
55 |
$parser = new ezmlm_parser();
|
|
|
56 |
$parser->listdir = $this->listdir ;
|
356 |
aperonnet |
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";
|
2 |
ddelon |
59 |
$ctc = 0;
|
|
|
60 |
$recent = $parser->recent_msgs();
|
208 |
neiluj |
61 |
|
|
|
62 |
// le tableau recent est de la forme
|
|
|
63 |
// $recent[numero_message][1] sujet
|
|
|
64 |
// $recent[numero_message][2] date en anglais => (22 May 2006)
|
|
|
65 |
// $recent[numero_message][3] le hash de l auteur
|
|
|
66 |
// $recent[numero_message][4] auteur
|
|
|
67 |
|
2 |
ddelon |
68 |
$class = array ('ligne_paire', 'ligne_impaire') ;
|
|
|
69 |
|
|
|
70 |
while (list($key,$val) = each($recent)) {
|
356 |
aperonnet |
71 |
$html .= '<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) ;
|
356 |
aperonnet |
79 |
$repertoire_message = substr ($decimal, 0, -2) ;
|
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 |
|
356 |
aperonnet |
89 |
$html .= '<td>'.$key.'</td>' ;
|
|
|
90 |
$html .= '<td>';
|
208 |
neiluj |
91 |
|
|
|
92 |
$from = $val[4];
|
|
|
93 |
|
356 |
aperonnet |
94 |
$html .= $this->makelink("action=show_author_msgs&actionargs[]=".$val[3],$this->decode_iso($this->protect_email($from,false)));
|
|
|
95 |
$html .= "</td>\n";
|
|
|
96 |
$html .= '<td><b>';
|
2 |
ddelon |
97 |
$actionargs = preg_split("/\//", $val->msgfile);
|
356 |
aperonnet |
98 |
|
|
|
99 |
$html .= $this->makelink("action=show_msg&actionargs[]=".$repertoire_message.
|
|
|
100 |
"&actionargs[]=".$fichier_message ,$this->decode_iso($val[1]));
|
208 |
neiluj |
101 |
|
356 |
aperonnet |
102 |
$html .= "</b></td>\n";
|
2 |
ddelon |
103 |
|
208 |
neiluj |
104 |
//print '<td>'.$this->date_francaise($val[2]).'</td>'."\n";
|
356 |
aperonnet |
105 |
$html .= '<td>'.$val[2].'</td>'."\n";
|
|
|
106 |
$html .= "</tr>\n";
|
2 |
ddelon |
107 |
|
|
|
108 |
$ctc++;
|
|
|
109 |
if ($ctc == 2) { $ctc = 0; }
|
|
|
110 |
}
|
356 |
aperonnet |
111 |
$html .= '</table>'."\n";
|
|
|
112 |
return $html;
|
2 |
ddelon |
113 |
}
|
|
|
114 |
|
391 |
aurelien |
115 |
// month = yyyymm
|
|
|
116 |
function show_month ($month) {
|
356 |
aperonnet |
117 |
$html = '' ;
|
|
|
118 |
|
2 |
ddelon |
119 |
// on ouvre chaque fichier en lecture
|
356 |
aperonnet |
120 |
if(!file_exists($this->listdir . '/archive/threads/' . $month)) {
|
|
|
121 |
return false ;
|
|
|
122 |
}
|
2 |
ddelon |
123 |
|
391 |
aurelien |
124 |
$numeros_mails_mois = $this->calculerNumMessagesDansMois($month);
|
|
|
125 |
|
356 |
aperonnet |
126 |
$html .= '<table class="table_cadre">'."\n";
|
|
|
127 |
$html .= '<tr><th class="col1">Num</th><th>De</th><th>Sujet</th><th>Date</th></tr>'."\n";
|
2 |
ddelon |
128 |
$ctc = 0;
|
|
|
129 |
|
|
|
130 |
$class = array ('ligne_paire', 'ligne_impaire') ;
|
391 |
aurelien |
131 |
|
|
|
132 |
if(count($numeros_mails_mois) > 0) {
|
|
|
133 |
$repertoire_premier_mail = (int) ($numeros_mails_mois[0] / 100) ;
|
|
|
134 |
}
|
2 |
ddelon |
135 |
|
391 |
aurelien |
136 |
foreach ($numeros_mails_mois as $num_message) {
|
|
|
137 |
|
|
|
138 |
$i = $num_message;
|
|
|
139 |
|
2 |
ddelon |
140 |
if ($i > 99) {
|
|
|
141 |
$multiplicateur = (int) ($i / 100) ;
|
391 |
aurelien |
142 |
// pour les mails > 99, on retranche n fois 100, ex 256 => 56 cad 256 - 2 * 100
|
2 |
ddelon |
143 |
$i = $i - $multiplicateur * 100 ;
|
|
|
144 |
}
|
391 |
aurelien |
145 |
|
2 |
ddelon |
146 |
if ($i < 10) $num_message = '0'.$i ; else $num_message = $i ;
|
208 |
neiluj |
147 |
if (file_exists($this->listdir.'/archive/'.$repertoire_premier_mail.'/'.$num_message)) {
|
|
|
148 |
$mimeDecode = new Mail_mimeDecode(file_get_contents ($this->listdir.'/archive/'.$repertoire_premier_mail.'/'.$num_message)) ;
|
|
|
149 |
$mailDecode = $mimeDecode->decode() ;
|
391 |
aurelien |
150 |
|
208 |
neiluj |
151 |
if ($i == 99) {
|
|
|
152 |
$repertoire_premier_mail++;
|
|
|
153 |
$i = -1;
|
|
|
154 |
}
|
2 |
ddelon |
155 |
|
391 |
aurelien |
156 |
$html .= '<tr class="'.$class[$ctc].'">'."\n";
|
356 |
aperonnet |
157 |
$html .= '<td>'.($repertoire_premier_mail != 0 ? $repertoire_premier_mail : '').$num_message.'</td><td>';
|
208 |
neiluj |
158 |
$hash = $this->makehash($mailDecode->headers['from']);
|
2 |
ddelon |
159 |
|
356 |
aperonnet |
160 |
$html .= $this->makelink("action=show_author_msgs&actionargs[]=".
|
208 |
neiluj |
161 |
$hash,$this->decode_iso($this->protect_email($mailDecode->headers['from'],TRUE)));
|
356 |
aperonnet |
162 |
$html .= "</td>\n";
|
|
|
163 |
$html .= '<td><b>';
|
208 |
neiluj |
164 |
$actionargs[0] = $repertoire_premier_mail ;
|
|
|
165 |
$actionargs[1] = $num_message ;
|
2 |
ddelon |
166 |
|
208 |
neiluj |
167 |
if (count ($actionargs) > 1) {
|
356 |
aperonnet |
168 |
$html .= $this->makelink("action=show_msg&actionargs[]=".
|
208 |
neiluj |
169 |
$actionargs[(count($actionargs) - 2)] .
|
|
|
170 |
"&actionargs[]=".
|
|
|
171 |
$actionargs[(count($actionargs) - 1)] ,$this->decode_iso($mailDecode->headers['subject']));
|
|
|
172 |
}
|
356 |
aperonnet |
173 |
$html .= "</b></td>\n";
|
|
|
174 |
$html .= '<td>'.$this->date_francaise($mailDecode->headers['date']).'</td>'."\n";
|
|
|
175 |
$html .= "</tr>\n";
|
208 |
neiluj |
176 |
$ctc++;
|
|
|
177 |
if ($ctc == 2) { $ctc = 0; }
|
|
|
178 |
}
|
2 |
ddelon |
179 |
}
|
356 |
aperonnet |
180 |
$html .= '</table>'."\n";
|
391 |
aurelien |
181 |
|
356 |
aperonnet |
182 |
return $html;
|
2 |
ddelon |
183 |
}
|
391 |
aurelien |
184 |
|
|
|
185 |
private function calculerNumMessagesDansMois($mois) {
|
|
|
186 |
|
|
|
187 |
/* Pour le calcul du nombre de message par mois
|
|
|
188 |
* 1 => ouvrir fichier /archive/threads/yyyymm qui contient les sujets abordés dans le mois
|
|
|
189 |
* 2 => pour chaque ligne:
|
|
|
190 |
* a => extraire l'id du du premier message (1er nombre de la ligne)
|
|
|
191 |
* b => extraire l'id du sujet et ouvrir le fichier concerné dans /archive/subjects/
|
|
|
192 |
* b1 => pour chaque ligne du fichier des sujets extraire les id des messages concernés
|
|
|
193 |
* s'ils sont dans le mois demandé
|
|
|
194 |
*/
|
|
|
195 |
|
|
|
196 |
// étape 1
|
|
|
197 |
$fd = file_get_contents($this->listdir . '/archive/threads/'.$mois, 'r');
|
|
|
198 |
$fichier = explode ("\n", $fd) ;
|
|
|
199 |
|
|
|
200 |
$premiere_ligne = $fichier[0] ;
|
|
|
201 |
|
|
|
202 |
$nb_lignes_fichier = count($fichier);
|
|
|
203 |
|
|
|
204 |
$lignes_messages = array();
|
|
|
205 |
|
|
|
206 |
preg_match ('/[0-9]+/', $premiere_ligne, $match) ;
|
|
|
207 |
$numero_premier_mail = $match[0] ;
|
|
|
208 |
|
|
|
209 |
$lignes_messages[$numero_premier_mail] = $numero_premier_mail;
|
|
|
210 |
|
|
|
211 |
// étape 2
|
|
|
212 |
foreach($fichier as $ligne) {
|
|
|
213 |
|
|
|
214 |
if(trim($ligne == '')) { continue ;}
|
|
|
215 |
|
|
|
216 |
// étape 2 a
|
|
|
217 |
$ligne_tableau = explode(' ', $ligne);
|
|
|
218 |
$num_mail_sujet = explode(':',$ligne_tableau[0]);
|
|
|
219 |
$num_sujet = $num_mail_sujet[1];
|
|
|
220 |
|
|
|
221 |
// étape 2 b
|
|
|
222 |
$fd_sujet = file_get_contents($this->listdir.'/archive/subjects/'.substr($num_sujet,0,2).'/'.substr($num_sujet,2,strlen($num_sujet) - 1), 'r');
|
|
|
223 |
$premiere_ligne = true;
|
|
|
224 |
|
|
|
225 |
$fichier_sujet = explode ("\n", $fd_sujet) ;
|
|
|
226 |
foreach($fichier_sujet as $ligne_sujet) {
|
|
|
227 |
if($premiere_ligne || trim($ligne_sujet) == '') {$premiere_ligne = false; continue; }
|
|
|
228 |
|
|
|
229 |
// étape 2 b b1
|
|
|
230 |
$ligne_tableau_sujet = explode(':', $ligne_sujet);
|
|
|
231 |
$num_mail = $ligne_tableau_sujet[0];
|
|
|
232 |
$mois_ligne = $ligne_tableau_sujet[1];
|
|
|
233 |
if($mois_ligne == $mois) {
|
|
|
234 |
$lignes_messages[$num_mail] = $num_mail;
|
|
|
235 |
}
|
|
|
236 |
}
|
|
|
237 |
}
|
|
|
238 |
|
|
|
239 |
// Tri sur les id de message pour les avoir par ordre d'arrivée
|
|
|
240 |
asort($lignes_messages);
|
|
|
241 |
return $lignes_messages;
|
|
|
242 |
}
|
2 |
ddelon |
243 |
}
|
356 |
aperonnet |
244 |
?>
|