Line 1... |
Line 1... |
1 |
<?php
|
1 |
<?php
|
2 |
// $Id: ezmlm-threads.php,v 1.7 2008-11-19 09:28:46 aperonnet Exp $
|
2 |
// $Id: ezmlm-threads.php,v 1.6 2008-08-25 15:19:15 alexandre_tb Exp $
|
3 |
//
|
3 |
//
|
4 |
// ezmlm-threads.php - ezmlm-php v2.0
|
4 |
// ezmlm-threads.php - ezmlm-php v2.0
|
5 |
// --------------------------------------------------------------
|
5 |
// --------------------------------------------------------------
|
6 |
// Builds, maintains & displays thread caches
|
6 |
// Builds, maintains & displays thread caches
|
7 |
// These cache files live in $ezmlm->tmpdir and are serialized
|
7 |
// These cache files live in $ezmlm->tmpdir and are serialized
|
Line 54... |
Line 54... |
54 |
}
|
54 |
}
|
55 |
// Le lien par date et par thread
|
55 |
// Le lien par date et par thread
|
56 |
$html .= '[ '.$this->makelink('action=show_month&actionargs[]='.$month, 'par date').' ]' ;
|
56 |
$html .= '[ '.$this->makelink('action=show_month&actionargs[]='.$month, 'par date').' ]' ;
|
57 |
$months = array(1 => 'January', 2 => 'February', 3 => 'March', 4 => 'April', 5 => 'May', 6 => 'June', 7 => 'July', 8 => 'August',
|
57 |
$months = array(1 => 'January', 2 => 'February', 3 => 'March', 4 => 'April', 5 => 'May', 6 => 'June', 7 => 'July', 8 => 'August',
|
58 |
9 => 'September', 10 => 'October', 11 => 'November', 12 => 'December');
|
58 |
9 => 'September', 10 => 'October', 11 => 'November', 12 => 'December');
|
59 |
// remplacé par le tableau globals $mois dans ezmlm.php
|
59 |
// remplac� par le tableau globals $mois dans ezmlm.php
|
60 |
$html .= '<h2>'.FIL_DE_DISCUSSION.' pour '.$GLOBALS['mois'][((int)substr($month,4,2) / 1) -1] .', ' . substr($month,0,4) . '</h2>'."\n";
|
60 |
$html .= '<h2>'.FIL_DE_DISCUSSION.' pour '.$GLOBALS['mois'][((int)substr($month,4,2) / 1) -1] .', ' . substr($month,0,4) . '</h2>'."\n";
|
Line 61... |
Line 61... |
61 |
|
61 |
|
62 |
$html .= '<table class="table_cadre">'."\n";
|
62 |
$html .= '<table class="table_cadre">'."\n";
|
63 |
$html .= '<tr><th>Num</th><th>De</th><th>Sujet</th><th>Date</th></tr>'."\n";
|
63 |
$html .= '<tr><th>Num</th><th>De</th><th>Sujet</th><th>Date</th></tr>'."\n";
|
64 |
$html .= '<tr><td colspan="3"><hr /></td></tr>'."\n";
|
64 |
$html .= '<tr><td colspan="3"><hr /></td></tr>'."\n";
|
Line 65... |
Line 65... |
65 |
$ctc .= 0;
|
65 |
$ctc .= 0;
|
66 |
|
66 |
|
67 |
if (is_file($cache)) {
|
67 |
if (is_file($cache)) {
|
68 |
$html .= file_get_contents($cache);
|
68 |
include($cache);
|
69 |
}
|
69 |
}
|
Line 70... |
Line 70... |
70 |
$html .= '<tr><td colspan="3"></td></tr>'."\n";
|
70 |
$html .= '<tr><td colspan="3"></td></tr>'."\n";
|
Line 97... |
Line 97... |
97 |
$html .= '<td>'.$actionargs[2].$actionargs[3].'</td><td>';
|
97 |
$html .= '<td>'.$actionargs[2].$actionargs[3].'</td><td>';
|
98 |
$html .= $this->makelink('action=show_author_msgs&actionargs[]='.
|
98 |
$html .= $this->makelink('action=show_author_msgs&actionargs[]='.
|
99 |
$this->makehash($this->decode_iso($mailDecode->headers['from'])),$this->decode_iso($this->protect_email($mailDecode->headers['from'],TRUE)));
|
99 |
$this->makehash($this->decode_iso($mailDecode->headers['from'])),$this->decode_iso($this->protect_email($mailDecode->headers['from'],TRUE)));
|
100 |
$html .= '</td>'."\n";
|
100 |
$html .= '</td>'."\n";
|
101 |
$html .= '<td><b>';
|
101 |
$html .= '<td><b>';
|
102 |
//$html .= " <a name=\"" . urlencode($thread_curr->file) . "\">"; A quoi ça sert ?
|
102 |
//$html .= " <a name=\"" . urlencode($thread_curr->file) . "\">"; A quoi �a sert ?
|
103 |
for ($i = 0; $i < $thread_curr->depth; $i++) {
|
103 |
for ($i = 0; $i < $thread_curr->depth; $i++) {
|
104 |
$html .= " ";
|
104 |
$html .= " ";
|
105 |
}
|
105 |
}
|
106 |
if (($this->thread_subjlen > 0) and (strlen($this->decode_iso($mailDecode->headers['subject'])) > $this->thread_subjlen)) {
|
106 |
if (($this->thread_subjlen > 0) and (strlen($this->decode_iso($mailDecode->headers['subject'])) > $this->thread_subjlen)) {
|
107 |
$subject = substr($this->decode_iso($mailDecode->headers['subject']), 0, ($this->thread_subjlen - 3 - ($thread_curr->depth * 2)));
|
107 |
$subject = substr($this->decode_iso($mailDecode->headers['subject']), 0, ($this->thread_subjlen - 3 - ($thread_curr->depth * 2)));
|
Line 126... |
Line 126... |
126 |
|
126 |
|
127 |
$html .= '<tr><td colspan="3"><hr noshade size="1" /></td></tr>'."\n";
|
127 |
$html .= '<tr><td colspan="3"><hr noshade size="1" /></td></tr>'."\n";
|
128 |
return $html;
|
128 |
return $html;
|
Line 129... |
Line -... |
129 |
}
|
- |
|
130 |
|
- |
|
131 |
// TODO: Fonction à tester et compléter
|
- |
|
132 |
// Construit un index de tous les messages envoyés dans une liste donnée pour un mois
|
- |
|
133 |
// au format YYYYMM
|
- |
|
134 |
/* // commenté sur le serveur
|
- |
|
135 |
function build_month_list($date)
|
- |
|
136 |
{
|
- |
|
137 |
$months = array(1 => 'Jan', 2 => 'Feb', 3 => 'Mar', 4 => 'Apr', 5 => 'May', 6 => 'Jun', 7 => 'Jul', 8 => 'Aug',
|
- |
|
138 |
9 => 'Sep', 10 => 'Oct', 11 => 'Nov', 12 => 'Dec');
|
- |
|
139 |
|
- |
|
140 |
$month = $months[((int)substr($month,4,2) / 1) -1] ;
|
- |
|
141 |
$year = substr($month,0,4) ;
|
- |
|
142 |
$numArchive = $this->getNumArchive();
|
- |
|
143 |
$dernierRepertoire = floor($numArchive / 100);
|
- |
|
144 |
|
- |
|
145 |
$threads = array();
|
- |
|
146 |
|
- |
|
147 |
for ($rep_courant = $dernierRepertoire; $rep_courant >= 0; $rep_courant--) {
|
- |
|
148 |
$fichier_index = file ($this->listdir.'/archive/'.$rep_courant.'/index', FILE_IGNORE_NEW_LINES);
|
- |
|
149 |
|
- |
|
150 |
// On parcourt le fichier a l envers
|
- |
|
151 |
for ($j = count($fichier_index)-1; $j >= 0; $j-=2) {
|
- |
|
152 |
$match = strpos($fichier_index[$j],$month.' '.$year) ;
|
- |
|
153 |
if ($match) {
|
- |
|
154 |
|
- |
|
155 |
$threads[] = $fichier_index[$j-1] ;
|
- |
|
156 |
|
- |
|
157 |
}
|
- |
|
158 |
}
|
- |
|
159 |
}
|
- |
|
160 |
}
|
- |
|
161 |
*/
|
129 |
}
|
162 |
|
130 |
|
163 |
// build: takes one argument in the format YYYYMM and builds the thread cache file
|
131 |
// build: takes one argument in the format YYYYMM and builds the thread cache file
|
164 |
// for that month if the ezmlm thread file exists. The resulting cache file is then
|
132 |
// for that month if the ezmlm thread file exists. The resulting cache file is then
|
165 |
// stored in $this->tmpdir;
|
133 |
// stored in $this->tmpdir;
|
Line 172... |
Line 140... |
172 |
$fd2 = fopen($this->tempdir . "/ezmlm-php-" . $this->listname . "/" . $month,"w+");
|
140 |
$fd2 = fopen($this->tempdir . "/ezmlm-php-" . $this->listname . "/" . $month,"w+");
|
173 |
}
|
141 |
}
|
174 |
fclose($fd2);
|
142 |
fclose($fd2);
|
175 |
$i=0;
|
143 |
$i=0;
|
176 |
// ouverture du fichier thread de ezmlm
|
144 |
// ouverture du fichier thread de ezmlm
|
177 |
// Ils sont classés mois par mois
|
145 |
// Ils sont class�s mois par mois
|
178 |
$fd1 = fopen($this->listdir . "/archive/threads/" . $month, "r");
|
146 |
$fd1 = fopen($this->listdir . "/archive/threads/" . $month, "r");
|
179 |
while (!feof($fd1)) {
|
147 |
while (!feof($fd1)) {
|
180 |
$line = fgets($fd1,4096);
|
148 |
$line = fgets($fd1,4096);
|
181 |
if (preg_match('/^[0-9]*\:[a-z]* \[.*/', $line)) {
|
149 |
if (preg_match('/^[0-9]*\:[a-z]* \[.*/', $line)) {
|
182 |
// valid ezmlm thread file entry
|
150 |
// valid ezmlm thread file entry
|
Line 190... |
Line 158... |
190 |
$thread_temp = NULL;
|
158 |
$thread_temp = NULL;
|
191 |
$thread_depth = 1;
|
159 |
$thread_depth = 1;
|
Line 192... |
Line 160... |
192 |
|
160 |
|
193 |
if (!is_file($this->listdir . "/archive/subjects/" . $subjectfile)) { continue; }
|
161 |
if (!is_file($this->listdir . "/archive/subjects/" . $subjectfile)) { continue; }
|
194 |
// on ouvre le fichier sujet
|
162 |
// on ouvre le fichier sujet
|
195 |
// Celui-ci contient sur la première ligne le hash du sujet puis le sujet
|
163 |
// Celui-ci contient sur la premi�re ligne le hash du sujet puis le sujet
|
196 |
// sur les autres lignes :
|
164 |
// sur les autres lignes :
|
197 |
// num_message:annéemois:hash_auteur nom_auteur
|
165 |
// num_message:ann�emois:hash_auteur nom_auteur
|
198 |
$fd2 = fopen($this->listdir . "/archive/subjects/" . $subjectfile, "r");
|
166 |
$fd2 = fopen($this->listdir . "/archive/subjects/" . $subjectfile, "r");
|
199 |
while (!feof($fd2)) {
|
167 |
while (!feof($fd2)) {
|
200 |
$line2 = fgets($fd2,4096);
|
168 |
$line2 = fgets($fd2,4096);
|
201 |
if (preg_match('/^[0-9]/',$line2)) {
|
169 |
if (preg_match('/^[0-9]/',$line2)) {
|
Line 210... |
Line 178... |
210 |
$mimeDecode = new Mail_mimeDecode($message) ;
|
178 |
$mimeDecode = new Mail_mimeDecode($message) ;
|
211 |
$mailDecode = $mimeDecode->decode() ;
|
179 |
$mailDecode = $mimeDecode->decode() ;
|
Line 212... |
Line 180... |
212 |
|
180 |
|
213 |
|
181 |
|
214 |
|
182 |
|
215 |
// On stocke le fichier analysée pour réutilisation ultàrieure
|
183 |
// On stocke le fichier analys�e pour r�utilisation ult�rieure
|
216 |
$GLOBALS['fichiers_analyses'][$msgdir][$msgfile] = $mailDecode ;
|
184 |
$GLOBALS['fichiers_analyses'][$msgdir][$msgfile] = $mailDecode ;
|
217 |
$msgid = (isset ($mailDecode->headers['message-id']) ? $mailDecode->headers['message-id'] : '');
|
185 |
$msgid = (isset ($mailDecode->headers['message-id']) ? $mailDecode->headers['message-id'] : '');
|
Line 287... |
Line 255... |
287 |
return TRUE;
|
255 |
return TRUE;
|
288 |
}
|
256 |
}
|
Line 289... |
Line 257... |
289 |
|
257 |
|
290 |
// listmessages: prints out a nice little calendar and displays the message
|
258 |
// listmessages: prints out a nice little calendar and displays the message
|
291 |
// totals for each month. The link jumps to the thread listing.
|
259 |
// totals for each month. The link jumps to the thread listing.
|
292 |
// On lit le repertoire archive/threads/ qui contient un fichier par mois avec tous les thread, par sujet
|
260 |
// On lit le repetoire archive/threads/ qui contient un fichier par moi avec tous les thread, par sujet
|
293 |
// Presentes comme suit
|
261 |
// Presentes comme suit
|
294 |
// num_thread:hash [taille_du_thread] Sujet du thread (le dernier)
|
262 |
// num_thread:hash [taille_du_thread] Sujet du thread (le dernier)
|
295 |
// les messages sont ranges par leur numero
|
263 |
// les messages sont ranges par leur numero
|
296 |
function listmessages() {
|
264 |
function listmessages() {
|
Line 303... |
Line 271... |
303 |
$res .= " <td></td>" ;
|
271 |
$res .= " <td></td>" ;
|
304 |
foreach ($GLOBALS['mois'] as $valeur) $res .= '<th>'.$valeur.'</th>' ;
|
272 |
foreach ($GLOBALS['mois'] as $valeur) $res .= '<th>'.$valeur.'</th>' ;
|
305 |
$res .=" </tr>\n";
|
273 |
$res .=" </tr>\n";
|
306 |
$res .= $this->calendrierMessage();
|
274 |
$res .= $this->calendrierMessage();
|
307 |
$res .= "</table>\n";
|
275 |
$res .= "</table>\n";
|
308 |
|
- |
|
309 |
return $res;
|
276 |
return $res;
|
310 |
/*
|
277 |
/*
|
311 |
$threadcount = array();
|
278 |
$threadcount = array();
|
Line 312... |
Line 279... |
312 |
|
279 |
|
Line 373... |
Line 340... |
373 |
$dernierRepertoire = floor($numArchive / 100);
|
340 |
$dernierRepertoire = floor($numArchive / 100);
|
Line 374... |
Line 341... |
374 |
|
341 |
|
375 |
$threadcount = array();
|
342 |
$threadcount = array();
|
Line -... |
Line 343... |
- |
|
343 |
$tableau_annee = array();
|
376 |
$tableau_annee = array();
|
344 |
|
377 |
|
345 |
|
Line 378... |
Line 346... |
378 |
for ($rep_courant = $dernierRepertoire; $rep_courant >= 0; $rep_courant--) {
|
346 |
for ($rep_courant = $dernierRepertoire; $rep_courant >= 0; $rep_courant--) {
|
379 |
$fichier_index = file ($this->listdir.'/archive/'.$rep_courant.'/index', FILE_IGNORE_NEW_LINES);
|
347 |
$fichier_index = file ($this->listdir.'/archive/'.$rep_courant.'/index', FILE_IGNORE_NEW_LINES);
|
380 |
|
348 |
|
381 |
// On parcours le fichier a l envers
|
349 |
// On parcours le fichier a l envers
|
382 |
for ($j = count($fichier_index)-1; $j >= 0; $j-=2) {
|
350 |
for ($j = count($fichier_index)-1; $j >= 0; $j-=2) {
|
383 |
preg_match('/\t([0-9]+) ([a-zA-Z]{3}) ([0-9]{4})/', $fichier_index[$j], $match) ;
|
351 |
preg_match('/\t([0-9]+) ([a-zA-Z][a-zA-Z][a-zA-Z]) ([0-9][0-9][0-9][0-9])/', $fichier_index[$j], $match) ;
|
384 |
if ($match[0] != '') {
|
352 |
if ($match[0] != '') {
|
385 |
$threadmonth = date('n', strtotime($match[0]));
|
353 |
$threadmonth = date('n', strtotime($match[0])) ;
|
Line 425... |
Line 393... |
425 |
function calendrierMessage() {
|
393 |
function calendrierMessage() {
|
426 |
$html = '';
|
394 |
$html = '';
|
427 |
// On ajoute la derniere annee
|
395 |
// On ajoute la derniere annee
|
428 |
$html .= $this->calculeCalendrierPermanent(date ('Y'));
|
396 |
$html .= $this->calculeCalendrierPermanent(date ('Y'));
|
Line 429... |
Line 397... |
429 |
|
397 |
|
430 |
if (! $this->isFichierCalendrierExiste()) return $html . $this->ecrireFichierCalendrier();
|
398 |
if ($this->isFichierCalendrierExiste()) {
|
431 |
// S'il existe mais qu il est trop vieux, il faut le recalculer et le réécrire
|
399 |
// S il existe mais qu il est trop vieux, il faut le recalculer
|
432 |
if ($this->isDoitRecalculerCalendrier()) return $html . $this->ecrireFichierCalendrier();
|
- |
|
433 |
// précédemment, dans ce cas ci-dessus
|
- |
|
434 |
// était effectuée un recalcul partiel, mais sans réécriture du fichier:
|
400 |
if ($this->isDoitRecalculerCalendrier()) {
|
435 |
/* $annees = $this->getAnneesARecalculer();
|
401 |
$annees = $this->getAnneesARecalculer();
|
436 |
$html .= $this->calculeCalendrierPermanent($annees); */
|
402 |
$html .= $this->calculeCalendrierPermanent($annees);
|
437 |
|
403 |
}
|
- |
|
404 |
$html .= file_get_contents('tmp/'.$this->listname.'.calendrier');
|
- |
|
405 |
} else {
|
- |
|
406 |
$html .= $this->ecrireFichierCalendrier();
|
- |
|
407 |
}
|
438 |
return $html . file_get_contents('tmp/'.$this->listname.'.calendrier');
|
408 |
return $html;
|
Line 439... |
Line 409... |
439 |
}
|
409 |
}
|
440 |
|
410 |
|
441 |
function isFichierCalendrierExiste() {
|
411 |
function isFichierCalendrierExiste() {
|
442 |
if (file_exists('tmp/'.$this->listname.'.calendrier')) {
|
412 |
if (file_exists('tmp/'.$this->listname.'.calendrier')) {
|
443 |
return true;
|
413 |
return true;
|
444 |
}
|
414 |
}
|
445 |
return false;
|
415 |
return false;
|
- |
|
416 |
}
|
446 |
}
|
417 |
function isDoitRecalculerCalendrier() {
|
- |
|
418 |
|
447 |
function isDoitRecalculerCalendrier() {
|
419 |
if (date ('Y', fileatime('tmp/'.$this->listname.'.calendrier')) != date('Y')) return true;
|
Line 448... |
Line 420... |
448 |
return (date ('Y', filemtime('tmp/'.$this->listname.'.calendrier')) <= date('Y') - 1);
|
420 |
return false;
|
449 |
}
|
421 |
}
|
450 |
|
422 |
|
451 |
function getAnneesARecalculer() {
|
423 |
function getAnneesARecalculer() {
|
452 |
// On suppose que l index de ezmlm est correct
|
424 |
// On suppose que l index de ezmlm est correct
|
Line 453... |
Line 425... |
453 |
$anneeFichierCalendrier = date ('Y', filemtime('tmp/'.$this->listname.'.calendrier'));
|
425 |
$anneeFichierCalendrier = date ('Y', fileatime('tmp/'.$this->listname.'.calendrier'));
|