Subversion Repositories Applications.projet

Rev

Rev 359 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 ddelon 1
<?php
431 mathias 2
// $Id: ezmlm-author.php,v 1.3 2007/04/19 15:34:35 neiluj 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
431 mathias 17
        // Premi�re ligne hash_auteur nom_auteur
18
        // num_mess:ann�emois:hash_sujet sujet
2 ddelon 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);
208 neiluj 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)) {
208 neiluj 32
				// si la ligne est valide
431 mathias 33
                // on r�cup�re le num�ro du message pour en extraire le nom du fichier
2 ddelon 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";
208 neiluj 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
}