Line 1... |
Line 1... |
1 |
<?php
|
1 |
<?php
|
2 |
// $Id: ezmlm-threads.php,v 1.4.2.1 2007-02-16 13:40:21 alexandre_tb Exp $
|
2 |
// $Id: ezmlm-threads.php,v 1.4.2.2 2007-03-12 11:23:46 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
|
8 |
// php objects that can be unserialized and displayed easily
|
8 |
// php objects that can be unserialized and displayed easily
|
9 |
// --------------------------------------------------------------
|
9 |
// --------------------------------------------------------------
|
Line 10... |
Line 10... |
10 |
|
10 |
|
11 |
require_once("ezmlm.php");
|
11 |
require_once("ezmlm.php");
|
12 |
require_once("ezmlm-parser.php");
|
12 |
require_once("ezmlm-parser.php");
|
Line 13... |
Line 13... |
13 |
require_once ('ezmlm-langue-fr.php');
|
13 |
//require_once ('ezmlm-langue-fr.php');
|
14 |
|
14 |
|
Line 15... |
Line 15... |
15 |
// CLASS: ezmlm_threads will build, maintain & display thread files (even if a thread is only 1 msg)
|
15 |
// CLASS: ezmlm_threads will build, maintain & display thread files (even if a thread is only 1 msg)
|
Line 258... |
Line 258... |
258 |
// les messages sont rangés par leur numéro
|
258 |
// les messages sont rangés par leur numéro
|
259 |
function listmessages() {
|
259 |
function listmessages() {
|
260 |
if (!is_dir($this->listdir . "/archive/threads/")) {
|
260 |
if (!is_dir($this->listdir . "/archive/threads/")) {
|
261 |
return false ;
|
261 |
return false ;
|
262 |
}
|
262 |
}
|
- |
|
263 |
$threadcount = array();
|
- |
|
264 |
|
263 |
$dir = opendir($this->listdir . "/archive/threads/");
|
265 |
$repertoire_archive = opendir($this->listdir . "/archive/");
|
- |
|
266 |
|
264 |
while ($item = readdir($dir)) {
|
267 |
while (false !== ($item = readdir($repertoire_archive))) {
|
265 |
if (($item == ".") or ($item == "..")) { continue; }
|
268 |
// $item contient les noms des repertoires
|
266 |
// Le nom du fichier est annéemoi ex 200501 pour janvier 2005
|
269 |
// on ne garde que ceux qui sont des chiffres
|
267 |
|
270 |
|
268 |
if (preg_match("/^[0-9][0-9][0-9][0-9][0-9][0-9]/",$item)) {
|
271 |
if (preg_match('/[0-9]+/', $item)) {
|
269 |
// on ouvre chaque fichier en lecture
|
272 |
// on ouvre le fichier d index de chaque repertoire
|
270 |
$fd = fopen($this->listdir . "/archive/threads/" . $item, "r");
|
273 |
$fichier_index = fopen($this->listdir.'/archive/'.$item.'/index', 'r');
|
271 |
$count = 0; // on initialise un compteur
|
274 |
$compteur = 0 ;
|
- |
|
275 |
|
272 |
while(!feof($fd)) {
|
276 |
while (!feof($fichier_index)) {
|
- |
|
277 |
// On ignore la premiere ligne
|
- |
|
278 |
$temp = fgets($fichier_index, 4096);
|
- |
|
279 |
// dans la seconde on recupere la date
|
273 |
$curthread = fgets($fd,4096);
|
280 |
$temp = fgets($fichier_index, 4096);
|
274 |
$num = preg_replace("/.*\[([0-9].*)\].*/", "\\1", $curthread); // $num contient le nbre de message du thread
|
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) ;
|
275 |
$count = $count + $num;
|
282 |
if ($match[0] != '') {
|
- |
|
283 |
$threadmonth = date('n', strtotime($match[0])) ;
|
- |
|
284 |
$threadyear = date('Y', strtotime($match[0])) ;
|
- |
|
285 |
$threadcount[$threadyear][$threadmonth]++;
|
- |
|
286 |
}
|
276 |
}
|
287 |
}
|
277 |
$threadyear = substr($item,0,4);
|
288 |
fclose ($fichier_index);
|
278 |
$threadmonth = substr($item,4,2);
|
- |
|
279 |
// on construit un tableau à 2 entrée [année][mois] = nbre_message
|
- |
|
280 |
$threadcount[$threadyear][$threadmonth] = $count;
|
- |
|
281 |
}
|
289 |
}
|
282 |
}
|
290 |
}
|
283 |
closedir($dir);
|
- |
|
284 |
|
291 |
|
285 |
# arsort($threadcount); // modifié par alex, car remplace l'année par 0
|
- |
|
286 |
|
- |
|
287 |
// La partie qui suit, simple, crée la table avec le nombre de message échangé chaque mois
|
292 |
// La partie qui suit, simple, crée la table avec le nombre de message échangé chaque mois
|
288 |
$res = '<table id="petit_calendrier">'."\n";
|
293 |
$res = '<table id="petit_calendrier">'."\n";
|
289 |
$res .= " <tr>\n";
|
294 |
$res .= " <tr>\n";
|
290 |
$res .= " <td></td>" ;
|
295 |
$res .= " <td></td>" ;
|
291 |
foreach ($GLOBALS['mois'] as $valeur) $res .= '<td>'.$valeur.'</td>' ;
|
296 |
foreach ($GLOBALS['mois'] as $valeur) $res .= '<td>'.$valeur.'</td>' ;
|
Line 293... |
Line 298... |
293 |
|
298 |
|
294 |
while (list($key,$val) = each($threadcount)) {
|
299 |
while (list($key,$val) = each($threadcount)) {
|
295 |
$res .= " <tr>\n";
|
300 |
$res .= " <tr>\n";
|
296 |
$res .= " <td>$key</td>";
|
301 |
$res .= " <td>$key</td>";
|
297 |
for ($i = 1; $i <= 12; $i++) {
|
- |
|
298 |
if ($i < 10) { $key2 = "0" . $i; }
|
- |
|
299 |
else { $key2 = $i; }
|
302 |
for ($i = 1; $i <= 12; $i++) {
|
300 |
if (isset($threadcount[$key][$key2]) && $threadcount[$key][$key2] > 0) {
|
303 |
if (isset($threadcount[$key][$i]) && $threadcount[$key][$i] > 0) {
|
301 |
$res .= "<td bgcolor=\"" . $this->tablecolours[0] . "\" valign=\"middle\">";
|
304 |
$res .= "<td bgcolor=\"" . $this->tablecolours[0] . "\" valign=\"middle\">";
|
302 |
$res .= $this->makelink("action=show_month&actionargs[]=$key$key2",$threadcount[$key][$key2]);
|
305 |
$res .= $this->makelink('action=show_month&actionargs[]='.$key.($i < 10 ? '0'.$i:$i),$threadcount[$key][$i]);
|
303 |
$res .= "</td>";
|
306 |
$res .= "</td>";
|
304 |
} else {
|
307 |
} else {
|
305 |
$res .= "<td bgcolor=\"" . $this->tablecolours[0] . "\"></td>";
|
308 |
$res .= "<td bgcolor=\"" . $this->tablecolours[0] . "\"></td>";
|
306 |
}
|
309 |
}
|