Subversion Repositories Applications.projet

Rev

Rev 106 | Rev 308 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 106 Rev 208
Line 1... Line 1...
1
<?php
1
<?php
2
// $Id: ezmlm-threads.php,v 1.4 2006-04-19 13:50:13 alexandre_tb Exp $
2
// $Id: ezmlm-threads.php,v 1.5 2007-04-19 15:34:35 neiluj 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");
Line 12... Line 13...
12
require_once("ezmlm-parser.php");
13
require_once ('ezmlm-langue-fr.php');
13
 
14
 
Line 14... Line 15...
14
// 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 51... Line 52...
51
		}
52
		}
52
        // Le lien par date et par thread
53
        // Le lien par date et par thread
53
        echo '[ '.$this->makelink('action=show_month&amp;actionargs[]='.$month, 'par date').' ]' ;
54
        echo '[ '.$this->makelink('action=show_month&amp;actionargs[]='.$month, 'par date').' ]' ;
54
		$months = array(1 => 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
55
		$months = array(1 => 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
55
        // remplacé par le tableau globals $mois dans ezmlm.php
56
        // remplacé par le tableau globals $mois dans ezmlm.php
56
		print '<h2>'.PROJET_FILE_DE_DISCUSSION.' pour '.$GLOBALS['mois'][((int)substr($month,4,2) / 1)] .', ' . substr($month,0,4) . '</h2>'."\n";
57
		print '<h2>'.FIL_DE_DISCUSSION.' pour '.$GLOBALS['mois'][((int)substr($month,4,2) / 1)] .', ' . substr($month,0,4) . '</h2>'."\n";
Line 57... Line 58...
57
		
58
		
58
		print '<table class="table_cadre">'."\n";
59
		print '<table class="table_cadre">'."\n";
59
		print '<tr><th>Num</th><th>De</th><th>Sujet</th><th>Date</th></tr>'."\n";
60
		print '<tr><th>Num</th><th>De</th><th>Sujet</th><th>Date</th></tr>'."\n";
60
		print '<tr><td colspan="3"><hr /></td></tr>'."\n";
61
		print '<tr><td colspan="3"><hr /></td></tr>'."\n";
Line 172... Line 173...
172
                        $mimeDecode = new Mail_mimeDecode($message) ;
173
                        $mimeDecode = new Mail_mimeDecode($message) ;
173
                        $mailDecode = $mimeDecode->decode() ;
174
                        $mailDecode = $mimeDecode->decode() ;
Line 174... Line 175...
174
                        
175
                        
175
                        
176
                        
176
                        
177
                        
177
                        // On stocke le fichier analysée pour réutilisation ultérieure
178
                        // On stocke le fichier analysée pour réutilisation ultàrieure
178
                        $GLOBALS['fichiers_analyses'][$msgdir][$msgfile] =  $mailDecode ;
179
                        $GLOBALS['fichiers_analyses'][$msgdir][$msgfile] =  $mailDecode ;
179
						$msgid = (isset ($mailDecode->headers['message-id']) ? $mailDecode->headers['message-id'] : '');
180
						$msgid = (isset ($mailDecode->headers['message-id']) ? $mailDecode->headers['message-id'] : '');
Line 249... Line 250...
249
		return TRUE;
250
		return TRUE;
250
	}
251
	}
Line 251... Line 252...
251
 
252
 
252
	// listmessages: prints out a nice little calendar and displays the message
253
	// listmessages: prints out a nice little calendar and displays the message
253
	// totals for each month. The link jumps to the thread listing.
254
	// totals for each month. The link jumps to the thread listing.
254
    // On lit le répetoire archive/threads/ qui contient un fichier par moi avec tous les thread, par sujet 
255
    // On lit le répertoire archive/threads/ qui contient un fichier par moi avec tous les thread, par sujet 
255
    // Présentés comme suit 
256
    // Présentés comme suit 
256
    // num_thread:hash [taille_du_thread] Sujet du thread (le dernier)
257
    // num_thread:hash [taille_du_thread] Sujet du thread (le dernier)
257
    // les messages sont rangés par leur numéro
258
    // les messages sont rangés par leur numéro
258
	function listmessages() {
259
	function listmessages() {
259
        if (!is_dir($this->listdir . "/archive/threads/")) {
260
        if (!is_dir($this->listdir . "/archive/threads/")) {
260
            return false ;
261
            return false ;
-
 
262
        }
-
 
263
        $threadcount = array();
261
        }
264
 
-
 
265
		$repertoire_archive = opendir($this->listdir . "/archive/");
262
		$dir = opendir($this->listdir . "/archive/threads/");
266
 
263
		while ($item = readdir($dir)) {
267
		while (false !== ($item = readdir($repertoire_archive))) {
264
			if (($item == ".") or ($item == "..")) { continue; }
268
			// $item contient les noms des repertoires
265
            // Le nom du fichier est annéemoi ex 200501 pour janvier 2005
269
			// on ne garde que ceux qui sont des chiffres
266
            
270
 
267
			if (preg_match("/^[0-9][0-9][0-9][0-9][0-9][0-9]/",$item)) {
271
			if (preg_match('/[0-9]+/', $item)) {
268
                // on ouvre chaque fichier en lecture
272
				// on ouvre le fichier d index de chaque repertoire
269
				$fd = fopen($this->listdir . "/archive/threads/" . $item, "r");
273
				$fichier_index = fopen($this->listdir.'/archive/'.$item.'/index', 'r');
-
 
274
				$compteur = 0 ;
270
				$count = 0; // on initialise un compteur
275
				
-
 
276
				while (!feof($fichier_index)) {
-
 
277
					// On ignore la premiere ligne
-
 
278
					$temp = fgets($fichier_index, 4096);
271
				while(!feof($fd)) {
279
					// dans la seconde on recupere la date
272
					$curthread = fgets($fd,4096);
280
					$temp = fgets($fichier_index, 4096);
273
					$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) ;
-
 
282
					if ($match[0] != '') {
-
 
283
						$threadmonth = date('n', strtotime($match[0]))  ;
-
 
284
						$threadyear = date('Y', strtotime($match[0])) ;
-
 
285
						$threadcount[$threadyear][$threadmonth]++;
274
					$count = $count + $num;
286
					}
275
				}
287
				}
276
				$threadyear = substr($item,0,4);
-
 
277
				$threadmonth = substr($item,4,2);
-
 
278
                // on construit un tableau à 2 entrée [année][mois] = nbre_message
-
 
279
				$threadcount[$threadyear][$threadmonth] = $count;
288
				fclose ($fichier_index);
280
			}
289
			}
281
		}
-
 
282
		closedir($dir);
290
		}
283
 
-
 
284
		arsort($threadcount);       // modifié par alex, car remplace l'année par 0 
-
 
285
        
291
		
286
        // 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
287
		$res = '<table id="petit_calendrier">'."\n";
293
		$res = '<table id="petit_calendrier">'."\n";
288
		$res .= " <tr>\n";
294
		$res .= " <tr>\n";
289
		$res .= "  <td></td>" ;
295
		$res .= "  <td></td>" ;
Line 292... Line 298...
292
 
298
 
293
		while (list($key,$val) = each($threadcount)) {
299
		while (list($key,$val) = each($threadcount)) {
294
			$res .= " <tr>\n";
300
			$res .= " <tr>\n";
295
			$res .= "  <td>$key</td>";
301
			$res .= "  <td>$key</td>";
296
			for ($i = 1; $i <= 12; $i++) {
-
 
297
				if ($i < 10) { $key2 = "0" . $i; }
-
 
298
				else { $key2 = $i; }
302
			for ($i = 1; $i <= 12; $i++) {
299
				if (isset($threadcount[$key][$key2]) && $threadcount[$key][$key2] > 0) {
303
				if (isset($threadcount[$key][$i]) && $threadcount[$key][$i] > 0) {
300
					$res .= "<td bgcolor=\"" . $this->tablecolours[0] . "\" valign=\"middle\">";
304
					$res .= "<td bgcolor=\"" . $this->tablecolours[0] . "\" valign=\"middle\">";
301
                    $res .= $this->makelink("action=show_month&amp;actionargs[]=$key$key2",$threadcount[$key][$key2]);
305
                    $res .= $this->makelink('action=show_month&amp;actionargs[]='.$key.($i < 10 ? '0'.$i:$i),$threadcount[$key][$i]);
302
					$res .= "</td>";
306
					$res .= "</td>";
303
				} else {
307
				} else {
304
					$res .= "<td bgcolor=\"" . $this->tablecolours[0] . "\"></td>";
308
					$res .= "<td bgcolor=\"" . $this->tablecolours[0] . "\"></td>";
305
				}
309
				}