| Line 1... |
Line 1... |
| 1 |
<?php
|
1 |
<?php
|
| 2 |
// $Id: ezmlm-threads.php,v 1.5 2007-04-19 15:34:35 neiluj Exp $
|
2 |
// $Id: ezmlm-threads.php,v 1.5.4.1 2008-11-05 09:45:04 aperonnet 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 35... |
Line 35... |
| 35 |
if ($md5 != $this->md5_of_file($this->listdir . "/archive/threads/" . $month)) {
|
35 |
if ($md5 != $this->md5_of_file($this->listdir . "/archive/threads/" . $month)) {
|
| 36 |
print "<!-- $md5 ne " . $this->md5_of_file($this->listdir . "/archive/threads/" . $month) . " -->\n";
|
36 |
print "<!-- $md5 ne " . $this->md5_of_file($this->listdir . "/archive/threads/" . $month) . " -->\n";
|
| 37 |
$this->build($month);
|
37 |
$this->build($month);
|
| 38 |
}
|
38 |
}
|
| 39 |
}
|
39 |
}
|
| 40 |
$this->display($month);
|
40 |
return $this->display($month);
|
| 41 |
}
|
41 |
}
|
| Line 42... |
Line 42... |
| 42 |
|
42 |
|
| 43 |
// display: this loads each cache file sequentially and displays the messages in them
|
43 |
// display: this loads each cache file sequentially and displays the messages in them
|
| 44 |
// there is no checking of checksum's done here so load() is the preferred method to
|
44 |
// there is no checking of checksum's done here so load() is the preferred method to
|
| Line 49... |
Line 49... |
| 49 |
$cache = $this->tempdir . "/ezmlm-php-" . $this->listname . "-" . $month;
|
49 |
$cache = $this->tempdir . "/ezmlm-php-" . $this->listname . "-" . $month;
|
| 50 |
} else {
|
50 |
} else {
|
| 51 |
$cache = $this->tempdir . "/ezmlm-php-" . $this->listname . "/" . $month;
|
51 |
$cache = $this->tempdir . "/ezmlm-php-" . $this->listname . "/" . $month;
|
| 52 |
}
|
52 |
}
|
| 53 |
// Le lien par date et par thread
|
53 |
// Le lien par date et par thread
|
| 54 |
echo '[ '.$this->makelink('action=show_month&actionargs[]='.$month, 'par date').' ]' ;
|
54 |
$html = '[ '.$this->makelink('action=show_month&actionargs[]='.$month, 'par date').' ]' ;
|
| 55 |
$months = array(1 => 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
|
55 |
$months = array(1 => 'January', 2 => 'February', 3 => 'March', 4 => 'April', 5 => 'May', 6 => 'June', 7 => 'July', 8 => 'August',
|
| - |
|
56 |
9 => 'September', 10 => 'October', 11 => 'November', 12 => 'December');
|
| 56 |
// remplacé par le tableau globals $mois dans ezmlm.php
|
57 |
// remplacé par le tableau globals $mois dans ezmlm.php
|
| 57 |
print '<h2>'.FIL_DE_DISCUSSION.' pour '.$GLOBALS['mois'][((int)substr($month,4,2) / 1)] .', ' . substr($month,0,4) . '</h2>'."\n";
|
58 |
$html = '<h2>'.FIL_DE_DISCUSSION.' pour '.$GLOBALS['mois'][((int)substr($month,4,2) / 1)] .', ' . substr($month,0,4) . '</h2>'."\n";
|
| Line 58... |
Line 59... |
| 58 |
|
59 |
|
| 59 |
print '<table class="table_cadre">'."\n";
|
60 |
$html = '<table class="table_cadre">'."\n";
|
| 60 |
print '<tr><th>Num</th><th>De</th><th>Sujet</th><th>Date</th></tr>'."\n";
|
61 |
$html = '<tr><th>Num</th><th>De</th><th>Sujet</th><th>Date</th></tr>'."\n";
|
| 61 |
print '<tr><td colspan="3"><hr /></td></tr>'."\n";
|
62 |
$html = '<tr><td colspan="3"><hr /></td></tr>'."\n";
|
| Line 62... |
Line 63... |
| 62 |
$ctc = 0;
|
63 |
$ctc = 0;
|
| 63 |
|
64 |
|
| 64 |
if (is_file($cache)) {
|
65 |
if (is_file($cache)) {
|
| 65 |
include($cache);
|
66 |
include($cache);
|
| 66 |
}
|
67 |
}
|
| 67 |
print '<tr><td colspan="3"></td></tr>'."\n";
|
68 |
$html = '<tr><td colspan="3"></td></tr>'."\n";
|
| Line 68... |
Line 69... |
| 68 |
print '</table>'."\n";
|
69 |
$html = '</table>'."\n";
|
| 69 |
}
|
70 |
}
|
| Line 250... |
Line 251... |
| 250 |
return TRUE;
|
251 |
return TRUE;
|
| 251 |
}
|
252 |
}
|
| Line 252... |
Line 253... |
| 252 |
|
253 |
|
| 253 |
// listmessages: prints out a nice little calendar and displays the message
|
254 |
// listmessages: prints out a nice little calendar and displays the message
|
| 254 |
// totals for each month. The link jumps to the thread listing.
|
255 |
// totals for each month. The link jumps to the thread listing.
|
| 255 |
// On lit le répertoire archive/threads/ qui contient un fichier par moi avec tous les thread, par sujet
|
256 |
// On lit le repetoire archive/threads/ qui contient un fichier par moi avec tous les thread, par sujet
|
| 256 |
// Présentés comme suit
|
257 |
// Presentes comme suit
|
| 257 |
// num_thread:hash [taille_du_thread] Sujet du thread (le dernier)
|
258 |
// num_thread:hash [taille_du_thread] Sujet du thread (le dernier)
|
| 258 |
// les messages sont rangés par leur numéro
|
259 |
// les messages sont ranges par leur numero
|
| 259 |
function listmessages() {
|
260 |
function listmessages() {
|
| 260 |
if (!is_dir($this->listdir . "/archive/threads/")) {
|
261 |
if (!is_dir($this->listdir . "/archive/threads/")) {
|
| 261 |
return false ;
|
262 |
return false ;
|
| - |
|
263 |
}
|
| - |
|
264 |
|
| - |
|
265 |
$res = '<table id="petit_calendrier">'."\n";
|
| - |
|
266 |
$res .= " <tr>\n";
|
| - |
|
267 |
$res .= " <td></td>" ;
|
| - |
|
268 |
foreach ($GLOBALS['mois'] as $valeur) $res .= '<th>'.$valeur.'</th>' ;
|
| - |
|
269 |
$res .=" </tr>\n";
|
| - |
|
270 |
$res .= $this->calendrierMessage();
|
| - |
|
271 |
$res .= "</table>\n";
|
| - |
|
272 |
return $res;
|
| 262 |
}
|
273 |
/*
|
| Line 263... |
Line 274... |
| 263 |
$threadcount = array();
|
274 |
$threadcount = array();
|
| 264 |
|
- |
|
| - |
|
275 |
|
| 265 |
$repertoire_archive = opendir($this->listdir . "/archive/");
|
276 |
$repertoire_archive = opendir($this->listdir . "/archive/");
|
| 266 |
|
277 |
$tableau_annee = array();
|
| 267 |
while (false !== ($item = readdir($repertoire_archive))) {
|
278 |
while (false !== ($item = readdir($repertoire_archive))) {
|
| Line 268... |
Line 279... |
| 268 |
// $item contient les noms des repertoires
|
279 |
// $item contient les noms des repertoires
|
| Line 278... |
Line 289... |
| 278 |
$temp = fgets($fichier_index, 4096);
|
289 |
$temp = fgets($fichier_index, 4096);
|
| 279 |
// dans la seconde on recupere la date
|
290 |
// dans la seconde on recupere la date
|
| 280 |
$temp = fgets($fichier_index, 4096);
|
291 |
$temp = fgets($fichier_index, 4096);
|
| 281 |
preg_match('/\t([0-9]+) ([a-zA-Z][a-zA-Z][a-zA-Z]) ([0-9][0-9][0-9][0-9])/', $temp, $match) ;
|
292 |
preg_match('/\t([0-9]+) ([a-zA-Z][a-zA-Z][a-zA-Z]) ([0-9][0-9][0-9][0-9])/', $temp, $match) ;
|
| 282 |
if ($match[0] != '') {
|
293 |
if ($match[0] != '') {
|
| - |
|
294 |
|
| 283 |
$threadmonth = date('n', strtotime($match[0])) ;
|
295 |
$threadmonth = date('n', strtotime($match[0])) ;
|
| 284 |
$threadyear = date('Y', strtotime($match[0])) ;
|
296 |
$threadyear = date('Y', strtotime($match[0])) ;
|
| 285 |
$threadcount[$threadyear][$threadmonth]++;
|
297 |
$threadcount[$threadyear][$threadmonth]++;
|
| - |
|
298 |
if (!in_array($threadyear, $tableau_annee)) array_push ($tableau_annee, $threadyear);
|
| 286 |
}
|
299 |
}
|
| 287 |
}
|
300 |
}
|
| 288 |
fclose ($fichier_index);
|
301 |
fclose ($fichier_index);
|
| 289 |
}
|
302 |
}
|
| 290 |
}
|
303 |
}
|
| 291 |
|
- |
|
| - |
|
304 |
if (count($threadcount) == 0) return 'Il n\y a pas de messages dans les archives';
|
| 292 |
// La partie qui suit, simple, crée la table avec le nombre de message échangé chaque mois
|
305 |
// La partie qui suit, simple, cree la table avec le nombre de message echange chaque mois
|
| 293 |
$res = '<table id="petit_calendrier">'."\n";
|
306 |
$res = '<table id="petit_calendrier">'."\n";
|
| 294 |
$res .= " <tr>\n";
|
307 |
$res .= " <tr>\n";
|
| 295 |
$res .= " <td></td>" ;
|
308 |
$res .= " <td></td>" ;
|
| 296 |
foreach ($GLOBALS['mois'] as $valeur) $res .= '<td>'.$valeur.'</td>' ;
|
309 |
foreach ($GLOBALS['mois'] as $valeur) $res .= '<th>'.$valeur.'</th>' ;
|
| 297 |
$res .=" </tr>\n";
|
310 |
$res .=" </tr>\n";
|
| 298 |
|
- |
|
| - |
|
311 |
arsort($tableau_annee);
|
| 299 |
while (list($key,$val) = each($threadcount)) {
|
312 |
foreach ($tableau_annee as $annee) {
|
| 300 |
$res .= " <tr>\n";
|
313 |
$res .= " <tr>\n";
|
| 301 |
$res .= " <td>$key</td>";
|
314 |
$res .= ' <td class="col_annee">'.$annee.'</td>';
|
| 302 |
for ($i = 1; $i <= 12; $i++) {
|
315 |
for ($i = 1; $i <= 12; $i++) {
|
| - |
|
316 |
$res .= '<td class="mois">';
|
| 303 |
if (isset($threadcount[$key][$i]) && $threadcount[$key][$i] > 0) {
|
317 |
if (isset($threadcount[$annee][$i]) && $threadcount[$annee][$i] > 0) {
|
| 304 |
$res .= "<td bgcolor=\"" . $this->tablecolours[0] . "\" valign=\"middle\">";
|
- |
|
| 305 |
$res .= $this->makelink('action=show_month&actionargs[]='.$key.($i < 10 ? '0'.$i:$i),$threadcount[$key][$i]);
|
318 |
$res .= $this->makelink('action=show_month&actionargs[]='.$annee.($i < 10 ? '0'.$i:$i),$threadcount[$annee][$i]);
|
| 306 |
$res .= "</td>";
|
- |
|
| 307 |
} else {
|
- |
|
| 308 |
$res .= "<td bgcolor=\"" . $this->tablecolours[0] . "\"></td>";
|
- |
|
| 309 |
}
|
319 |
}
|
| - |
|
320 |
$res .= '</td>';
|
| 310 |
}
|
321 |
}
|
| 311 |
$res .= "</tr>\n";
|
322 |
$res .= '</tr>'."\n";
|
| 312 |
}
|
323 |
}
|
| 313 |
$res .= "</table>\n";
|
324 |
$res .= "</table>\n";
|
| 314 |
echo $res ;
|
325 |
return $res ;
|
| - |
|
326 |
*/
|
| - |
|
327 |
}
|
| - |
|
328 |
/*
|
| - |
|
329 |
* Cree un fichier liste.calendrierPermanent qui contient
|
| - |
|
330 |
* le nombre de message par mois pour toutes les annees
|
| - |
|
331 |
* depuis le debut de la liste sauf la derniere
|
| - |
|
332 |
*
|
| - |
|
333 |
*/
|
| - |
|
334 |
function calculeCalendrierPermanent($Annnee = '') {
|
| - |
|
335 |
$numArchive = $this->getNumArchive();
|
| - |
|
336 |
$dernierRepertoire = floor($numArchive / 100);
|
| - |
|
337 |
|
| - |
|
338 |
$threadcount = array();
|
| - |
|
339 |
$tableau_annee = array();
|
| - |
|
340 |
|
| - |
|
341 |
|
| - |
|
342 |
for ($rep_courant = $dernierRepertoire; $rep_courant >= 0; $rep_courant--) {
|
| - |
|
343 |
$fichier_index = file ($this->listdir.'/archive/'.$rep_courant.'/index', FILE_IGNORE_NEW_LINES);
|
| - |
|
344 |
|
| - |
|
345 |
// On parcours le fichier a l envers
|
| - |
|
346 |
for ($j = count($fichier_index)-1; $j >= 0; $j-=2) {
|
| - |
|
347 |
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) ;
|
| - |
|
348 |
if ($match[0] != '') {
|
| - |
|
349 |
$threadmonth = date('n', strtotime($match[0])) ;
|
| - |
|
350 |
$threadyear = date('Y', strtotime($match[0])) ;
|
| - |
|
351 |
if ($Annnee != '') {
|
| - |
|
352 |
if ($threadyear < date('Y')) {
|
| - |
|
353 |
$sortir = true;
|
| - |
|
354 |
break;
|
| - |
|
355 |
}
|
| - |
|
356 |
} else {
|
| - |
|
357 |
if ($threadyear == date('Y')) continue;
|
| - |
|
358 |
}
|
| - |
|
359 |
$threadcount[$threadyear][$threadmonth]++;
|
| - |
|
360 |
if (!in_array($threadyear, $tableau_annee)) array_push ($tableau_annee, $threadyear);
|
| - |
|
361 |
}
|
| - |
|
362 |
}
|
| - |
|
363 |
if ($sortir) break;
|
| - |
|
364 |
}
|
| - |
|
365 |
$res = '';
|
| - |
|
366 |
arsort($tableau_annee);
|
| - |
|
367 |
foreach ($tableau_annee as $annee) {
|
| - |
|
368 |
$res .= " <tr>\n";
|
| - |
|
369 |
$res .= ' <td class="col_annee">'.$annee.'</td>';
|
| - |
|
370 |
for ($i = 1; $i <= 12; $i++) {
|
| - |
|
371 |
$res .= '<td class="mois">';
|
| - |
|
372 |
if (isset($threadcount[$annee][$i]) && $threadcount[$annee][$i] > 0) {
|
| - |
|
373 |
$res .= $this->makelink('action=show_month&actionargs[]='.$annee.($i < 10 ? '0'.$i:$i),$threadcount[$annee][$i]);
|
| - |
|
374 |
}
|
| - |
|
375 |
$res .= '</td>';
|
| - |
|
376 |
}
|
| - |
|
377 |
$res .= '</tr>'."\n";
|
| - |
|
378 |
}
|
| - |
|
379 |
return $res;
|
| - |
|
380 |
}
|
| - |
|
381 |
function ecrireFichierCalendrier() {
|
| - |
|
382 |
$html = $this->calculeCalendrierPermanent();
|
| - |
|
383 |
$f = fopen ('tmp/'.$this->listname.'.calendrier', 'w') ;
|
| - |
|
384 |
fwrite ($f, $html);
|
| - |
|
385 |
fclose($f);
|
| - |
|
386 |
return $html;
|
| - |
|
387 |
}
|
| - |
|
388 |
|
| - |
|
389 |
function calendrierMessage() {
|
| - |
|
390 |
$html = '';
|
| - |
|
391 |
// On ajoute la derniere annee
|
| - |
|
392 |
$html .= $this->calculeCalendrierPermanent(date ('Y'));
|
| - |
|
393 |
|
| - |
|
394 |
if ($this->isFichierCalendrierExiste()) {
|
| - |
|
395 |
// S il existe mais qu il est trop vieux, il faut le recalculer
|
| - |
|
396 |
if ($this->isDoitRecalculerCalendrier()) {
|
| - |
|
397 |
$annees = $this->getAnneesARecalculer();
|
| - |
|
398 |
$html .= $this->calculeCalendrierPermanent($annees);
|
| - |
|
399 |
}
|
| - |
|
400 |
$html .= file_get_contents('tmp/'.$this->listname.'.calendrier');
|
| - |
|
401 |
} else {
|
| - |
|
402 |
$html .= $this->ecrireFichierCalendrier();
|
| - |
|
403 |
}
|
| - |
|
404 |
return $html;
|
| - |
|
405 |
}
|
| - |
|
406 |
|
| - |
|
407 |
function isFichierCalendrierExiste() {
|
| - |
|
408 |
if (file_exists('tmp/'.$this->listname.'.calendrier')) {
|
| - |
|
409 |
return true;
|
| - |
|
410 |
}
|
| - |
|
411 |
return false;
|
| - |
|
412 |
}
|
| - |
|
413 |
function isDoitRecalculerCalendrier() {
|
| - |
|
414 |
|
| - |
|
415 |
if (date ('Y', fileatime('tmp/'.$this->listname.'.calendrier')) != date('Y')) return true;
|
| - |
|
416 |
return false;
|
| - |
|
417 |
}
|
| - |
|
418 |
|
| - |
|
419 |
function getAnneesARecalculer() {
|
| - |
|
420 |
// On suppose que l index de ezmlm est correct
|
| - |
|
421 |
$anneeFichierCalendrier = date ('Y', fileatime('tmp/'.$this->listname.'.calendrier'));
|
| - |
|
422 |
return $anneeFichierCalendrier + 1;
|
| 315 |
}
|
423 |
}
|
| - |
|
424 |
|
| 316 |
}
|
425 |
}
|
| Line 317... |
Line 426... |
| 317 |
|
426 |
|
| 318 |
// CLASS: ezmlm-thread is a quick little class to allow us to define
|
427 |
// CLASS: ezmlm-thread is a quick little class to allow us to define
|
| 319 |
// a structure of the current thread in a single-linked list.
|
428 |
// a structure of the current thread in a single-linked list.
|