Subversion Repositories Applications.papyrus

Rev

Rev 448 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
448 ddelon 1
<?php
474 alexandre_ 2
// $Id: ezmlm-listinfo.php,v 1.2 2005-09-27 16:43:08 alexandre_tb Exp $
448 ddelon 3
//
4
// ezmlm-listinfo.php - ezmlm-php v2.0
5
// --------------------------------------------------------------
6
// Displays general list info in the format of a welcome page.
7
// --------------------------------------------------------------
8
 
9
require_once("ezmlm.php");
10
 
11
class ezmlm_listinfo extends ezmlm_php {
12
 
13
    function ezmlm_listinfo () {
14
        return is_dir($this->listdir.'/archive/0') ;
15
    }
16
	function display() {
17
 
18
        if (!is_dir($this->listdir.'/archive/0')) {  // On teste si il y a au moins un message, cad le répertoire 0
19
            echo $this->listdir.'/archive/0' ;
20
 
21
            return false ;
22
        }
23
 
24
		$parser = new ezmlm_parser();
25
        $parser->listdir = $this->listdir ;
26
 
27
		//$this->show_info_file();
28
 
29
 
30
		$threads = new ezmlm_threads();
31
        $threads->listdir = $this->listdir ;
32
        $threads->listname = $this->listname ;
33
        $threads->forcehref = $this->forcehref ;        /// ajout alex
34
        $threads->listmessages() ;
35
		$this->show_recentmsgs();
36
        return true ;
37
	}
38
 
39
	function show_info_file() {
40
		if (@is_file($this->listdir . "/text/info")) {
41
			$infofile = @file($this->listdir . "/text/info");
42
			while (list($line_num, $line) = each($infofile)) {
43
				print nl2br($line);
44
			}
45
		}
46
	}
47
 
48
 
49
	function show_recentmsgs($title = "Messages récents") {
50
 
51
        if (!is_dir($this->listdir.'/archive/0')) return false;
52
 
53
		$parser = new ezmlm_parser();
54
        $parser->listdir = $this->listdir ;
55
        print '<table class="table_cadre">'."\n";
56
        print '<tr><th class="col1">Num</th><th>De</th><th>Sujet</th><th>Date</th></tr>'."\n";
57
        $ctc = 0;
58
        $recent = $parser->recent_msgs();
59
        $class = array ('ligne_paire', 'ligne_impaire') ;
60
 
61
        while (list($key,$val) = each($recent)) {
62
            print '<tr class="'.$class[$ctc].'">'."\n";
63
            print '<td>'.$val->nummessage.'</td>' ;
64
            print '<td>';
65
            $hash = $this->makehash($val->headers['from']);
66
 
67
            print $this->makelink("action=show_author_msgs&actionargs[]=" . $hash,$this->decode_iso($this->protect_email($val->headers['from'],TRUE)));
68
            print "</td>\n";
69
            print '<td><b>';
70
            $actionargs = preg_split("/\//", $val->msgfile);
71
            if (count ($actionargs) > 2) {
72
                print $this->makelink("action=show_msg&actionargs[]=" .  $actionargs[(count($actionargs) - 2)] .
73
                                "&actionargs[]=" .  $actionargs[(count($actionargs) - 1)] ,$this->decode_iso($val->headers['subject']));
74
            }
75
            print "</b></td>\n";
76
 
77
            print '<td>'.$this->date_francaise($val->headers['date']).'</td>'."\n";
78
            print "</tr>\n";
79
 
80
            $ctc++;
81
            if ($ctc == 2) { $ctc = 0; }
82
        }
83
        print '</table>'."\n";
84
        return true;
85
	}
86
 
87
    function show_month ($month) {
88
        // Le nom du fichier est annéemoi ex 200501 pour janvier 2005
89
 
90
        // on ouvre chaque fichier en lecture
91
        $fd = file_get_contents($this->listdir . '/archive/threads/' . $month, 'r');
92
        $fichier = explode ("\n", $fd) ;
93
        // on récupère la première ligne
94
        $premiere_ligne = $fichier[0] ;
95
        $derniere_ligne = $fichier[count($fichier)-2];
96
 
97
 
98
        preg_match ('/[0-9]+/', $premiere_ligne, $match) ;
99
        $numero_premier_mail  = $match[0] ;
100
 
101
        preg_match ('/[0-9]+/', $derniere_ligne, $match1) ;
102
        $numero_dernier_mail  = $match1[0] ;
103
 
104
		// On cherche le répertoire du premier mail
105
 
106
        $repertoire_premier_mail = (int) ($numero_premier_mail / 100) ;
107
 
108
        print '<table class="table_cadre">'."\n";
109
        print '<tr><th class="col1">Num</th><th>De</th><th>Sujet</th><th>Date</th></tr>'."\n";
110
        $ctc = 0;
111
 
112
        $class = array ('ligne_paire', 'ligne_impaire') ;
113
 
114
        for ($i = $numero_premier_mail, $compteur = $numero_premier_mail ; $compteur <= $numero_dernier_mail; $i++, $compteur++) {
115
            if ($i > 99) {
116
                $multiplicateur = (int) ($i / 100) ;
117
                // pour les nails > 99, on retranche n fois 100, ex 256 => 56 cad 256 - 2 * 100
118
                $i = $i - $multiplicateur * 100 ;
119
            }
120
            if ($i < 10) $num_message = '0'.$i ; else $num_message = $i ;
121
 
122
            $mimeDecode = new Mail_mimeDecode(file_get_contents ($this->listdir.'/archive/'.$repertoire_premier_mail.'/'.$num_message)) ;
123
            $mailDecode = $mimeDecode->decode() ;
124
            if ($i == 99) {
125
                $repertoire_premier_mail++;
126
                $i = -1;
127
            }
128
 
129
            print '<tr class="'.$class[$ctc].'">'."\n";
130
            print '<td>'.$repertoire_premier_mail.$num_message.'</td><td>';
131
            $hash = $this->makehash($mailDecode->headers['from']);
132
 
133
            print $this->makelink("action=show_author_msgs&actionargs[]=" . $hash,$this->decode_iso($this->protect_email($mailDecode->headers['from'],TRUE)));
134
            print "</td>\n";
135
            print '<td><b>';
136
            $actionargs[0] = $repertoire_premier_mail ;
137
            $actionargs[1] = $num_message ;
138
 
139
            if (count ($actionargs) > 1) {
140
                print $this->makelink("action=show_msg&actionargs[]=" .  $actionargs[(count($actionargs) - 2)] .
141
                                "&actionargs[]=" .  $actionargs[(count($actionargs) - 1)] ,$this->decode_iso($mailDecode->headers['subject']));
142
            }
143
            print "</b></td>\n";
144
            print '<td>'.$this->date_francaise($mailDecode->headers['date']).'</td>'."\n";
145
            print "</tr>\n";
146
            $ctc++;
147
            if ($ctc == 2) { $ctc = 0; }
148
        }
149
        print '</table>'."\n";
150
        return true;
151
    }
152
}
153