Rev 2 | Rev 312 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
<?php
// $Id: ezmlm-listinfo.php,v 1.2 2005-09-27 16:43:08 alexandre_tb Exp $
//
// ezmlm-listinfo.php - ezmlm-php v2.0
// --------------------------------------------------------------
// Displays general list info in the format of a welcome page.
// --------------------------------------------------------------
require_once("ezmlm.php");
class ezmlm_listinfo extends ezmlm_php {
function ezmlm_listinfo () {
return is_dir($this->listdir.'/archive/0') ;
}
function display() {
if (!is_dir($this->listdir.'/archive/0')) { // On teste si il y a au moins un message, cad le répertoire 0
echo $this->listdir.'/archive/0' ;
return false ;
}
$parser = new ezmlm_parser();
$parser->listdir = $this->listdir ;
//$this->show_info_file();
$threads = new ezmlm_threads();
$threads->listdir = $this->listdir ;
$threads->listname = $this->listname ;
$threads->forcehref = $this->forcehref ; /// ajout alex
$threads->listmessages() ;
$this->show_recentmsgs();
return true ;
}
function show_info_file() {
if (@is_file($this->listdir . "/text/info")) {
$infofile = @file($this->listdir . "/text/info");
while (list($line_num, $line) = each($infofile)) {
print nl2br($line);
}
}
}
function show_recentmsgs($title = "Messages récents") {
if (!is_dir($this->listdir.'/archive/0')) return false;
$parser = new ezmlm_parser();
$parser->listdir = $this->listdir ;
print '<table class="table_cadre">'."\n";
print '<tr><th class="col1">Num</th><th>De</th><th>Sujet</th><th>Date</th></tr>'."\n";
$ctc = 0;
$recent = $parser->recent_msgs();
$class = array ('ligne_paire', 'ligne_impaire') ;
while (list($key,$val) = each($recent)) {
print '<tr class="'.$class[$ctc].'">'."\n";
print '<td>'.$val->nummessage.'</td>' ;
print '<td>';
$hash = $this->makehash($val->headers['from']);
print $this->makelink("action=show_author_msgs&actionargs[]=" . $hash,$this->decode_iso($this->protect_email($val->headers['from'],TRUE)));
print "</td>\n";
print '<td><b>';
$actionargs = preg_split("/\//", $val->msgfile);
if (count ($actionargs) > 2) {
print $this->makelink("action=show_msg&actionargs[]=" . $actionargs[(count($actionargs) - 2)] .
"&actionargs[]=" . $actionargs[(count($actionargs) - 1)] ,$this->decode_iso($val->headers['subject']));
}
print "</b></td>\n";
print '<td>'.$this->date_francaise($val->headers['date']).'</td>'."\n";
print "</tr>\n";
$ctc++;
if ($ctc == 2) { $ctc = 0; }
}
print '</table>'."\n";
return true;
}
function show_month ($month) {
// Le nom du fichier est annéemoi ex 200501 pour janvier 2005
// on ouvre chaque fichier en lecture
$fd = file_get_contents($this->listdir . '/archive/threads/' . $month, 'r');
$fichier = explode ("\n", $fd) ;
// on récupère la première ligne
$premiere_ligne = $fichier[0] ;
$derniere_ligne = $fichier[count($fichier)-2];
preg_match ('/[0-9]+/', $premiere_ligne, $match) ;
$numero_premier_mail = $match[0] ;
preg_match ('/[0-9]+/', $derniere_ligne, $match1) ;
$numero_dernier_mail = $match1[0] ;
// On cherche le répertoire du premier mail
$repertoire_premier_mail = (int) ($numero_premier_mail / 100) ;
print '<table class="table_cadre">'."\n";
print '<tr><th class="col1">Num</th><th>De</th><th>Sujet</th><th>Date</th></tr>'."\n";
$ctc = 0;
$class = array ('ligne_paire', 'ligne_impaire') ;
for ($i = $numero_premier_mail, $compteur = $numero_premier_mail ; $compteur <= $numero_dernier_mail; $i++, $compteur++) {
if ($i > 99) {
$multiplicateur = (int) ($i / 100) ;
// pour les nails > 99, on retranche n fois 100, ex 256 => 56 cad 256 - 2 * 100
$i = $i - $multiplicateur * 100 ;
}
if ($i < 10) $num_message = '0'.$i ; else $num_message = $i ;
$mimeDecode = new Mail_mimeDecode(file_get_contents ($this->listdir.'/archive/'.$repertoire_premier_mail.'/'.$num_message)) ;
$mailDecode = $mimeDecode->decode() ;
if ($i == 99) {
$repertoire_premier_mail++;
$i = -1;
}
print '<tr class="'.$class[$ctc].'">'."\n";
print '<td>'.$repertoire_premier_mail.$num_message.'</td><td>';
$hash = $this->makehash($mailDecode->headers['from']);
print $this->makelink("action=show_author_msgs&actionargs[]=" . $hash,$this->decode_iso($this->protect_email($mailDecode->headers['from'],TRUE)));
print "</td>\n";
print '<td><b>';
$actionargs[0] = $repertoire_premier_mail ;
$actionargs[1] = $num_message ;
if (count ($actionargs) > 1) {
print $this->makelink("action=show_msg&actionargs[]=" . $actionargs[(count($actionargs) - 2)] .
"&actionargs[]=" . $actionargs[(count($actionargs) - 1)] ,$this->decode_iso($mailDecode->headers['subject']));
}
print "</b></td>\n";
print '<td>'.$this->date_francaise($mailDecode->headers['date']).'</td>'."\n";
print "</tr>\n";
$ctc++;
if ($ctc == 2) { $ctc = 0; }
}
print '</table>'."\n";
return true;
}
}