Subversion Repositories Applications.projet

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 ddelon 1
<?php
175 alexandre_ 2
// $Id: ezmlm-author.php,v 1.2.4.2 2007-03-12 11:24:25 alexandre_tb Exp $
2 ddelon 3
//
4
// ezmlm-author.php - ezmlm-php v2.0
5
// --------------------------------------------------------------
6
// Displays all messages by a given author
7
// --------------------------------------------------------------
8
 
9
require_once("ezmlm.php");
10
 
11
class ezmlm_author extends ezmlm_php {
12
	function display($authorhash) {
13
		$file = "/archive/authors/" . substr($authorhash,0,2) . "/" . substr($authorhash,2,18);
14
        //echo $file ;
15
		if (!is_file($this->listdir . $file)) { $this->error(EZMLM_INVALID_AUTHOR); return; }
16
        // Le fichier author comprend
17
        // Première ligne hash_auteur nom_auteur
18
        // num_mess:annéemois:hash_sujet sujet
19
		$fd = @fopen($this->listdir . $file, "r");
20
        $i = 0 ;
21
        $class = array ('ligne_impaire', 'ligne_paire') ;
22
		while (!feof($fd)) {
23
			$buf = fgets($fd,4096);
24
			if (preg_match('/^' . $authorhash . '/', $buf)) {
25
				// this should ALWAYS be the first line in the file
26
				$author = preg_replace('/^' . $authorhash . ' /', '', $buf);
166 alexandre_ 27
                print '<h3>'.$author.'</h3>' ;
2 ddelon 28
				print '<table class="table_cadre">'."\n";
29
                print '<tr><th class="col1">De</th><th>Sujet</th><th>Date</th></tr>'."\n";
30
				$tableopened = TRUE;
31
			} else if (preg_match('/^[0-9]*:[0-9]/',$buf)) {
175 alexandre_ 32
				// si la ligne est valide
2 ddelon 33
                // on récupère le numéro du message pour en extraire le nom du fichier
34
				$msgfile = preg_replace('/^([0-9]*):.*/', '\1', $buf);
35
				$msgdir  = (int)((int)$msgfile / 100);
36
				$msgfile = (int)$msgfile % 100;
37
 
38
				if ($msgfile < 10) { $msgfile = "0" . $msgfile; }
39
 
40
				if (!is_file($this->listdir . "/archive/" . $msgdir . "/" . $msgfile)) {
41
					print "<!-- " . $this->listdir . "/archive/" . $msgdir . "/" . $msgfile . " -->\n";
42
					$this->error(EZMLM_INCONSISTANCY);
43
					fclose($fd);
44
					return;
45
				}
46
 
47
				//$msg = new ezmlm_parser();
48
				//$msg->parse_file_headers($this->listdir . "/archive/" . $msgdir . "/" . $msgfile);
49
 
50
                $message = file_get_contents($this->listdir . "/archive/" . $msgdir . "/" . $msgfile) ;
51
                $mimeDecode = new Mail_mimeDecode($message) ;
52
                $mailDecode = $mimeDecode->decode() ;
53
 
54
				$subject = $mailDecode->headers['subject'];
55
				$subject = preg_replace("/\[" . $this->listname . "\]/", "", $subject);
56
                $date = preg_replace ('/CEST/', '', $mailDecode->headers['date']);
57
				print '<tr class="'.$class[$i].'">'."\n";
175 alexandre_ 58
                if ($mailDecode->headers['from'] == '') $from = $mailDecode->headers['return-path'] ; else $from = $mailDecode->headers['from'];
59
                $hash = $this->makehash($from);
60
                print '<td>'.$this->makelink("action=show_author_msgs&actionargs[]=" . $hash,$this->decode_iso($this->protect_email($from,false)));
2 ddelon 61
                print '</td>';
62
                print "<td><b>" . $this->makelink("action=show_msg&actionargs[]=" . $msgdir . "&actionargs[]=" . $msgfile, $this->decode_iso($subject)) . "</b></td>";
63
				print "<td>" . $this->date_francaise($mailDecode->headers['date']) . "</td>\n";
64
				print "</tr>\n";
65
                $i++;
66
                if ($i == 2) $i = 0 ;
67
                unset ($mailDecode) ;
68
			}
69
		}
70
		if ($tableopened) { print "</table>\n"; }
71
	}
72
}