/tags/2014_06_04/classes/ezmlm-php-2.0/ezmlm-repondre.php |
---|
New file |
0,0 → 1,187 |
<?php |
// $Id: ezmlm-repondre.php,v 1.2 2005/09/27 16:43:08 alexandre_tb Exp $ |
// |
// ezmlm-msgdisplay.php - ezmlm-php v2.0 |
// -------------------------------------------------------------- |
// Will parse a template (if specified) and display a message. |
// Includes a default template. |
// -------------------------------------------------------------- |
require_once("ezmlm.php"); |
require_once("Mail/mimeDecode.php") ; |
class ezmlm_repondre extends ezmlm_php { |
// our template |
var $msgtmpl; |
var $message_rendu ; |
// display: parses a message (using ezmlm_parser) and displays it |
// using a template |
function repondre($msgfile) { |
if (!is_file($msgfile)) { |
if (is_file($this->listdir . "/" . $msgfile)) { $msgfile = $this->listdir . "/" . $msgfile; } |
else if (is_file($this->listdir . "/archive/" . $msgfile)) { $msgfile = $this->listdir . "/archive/" . $msgfile; } |
else { return FALSE; } |
} |
$message = file_get_contents($msgfile) ; |
$mimeDecode = new Mail_mimeDecode($message) ; |
$mailDecode = $mimeDecode->decode(array('decode_bodies' => 'true', 'include_bodies' => 'true')) ; |
// $msg->msgfile contient le chemin du fichier du mail en partant de la racine |
// Le point d'exclamation est le délimiteur de l'expression régulière |
$relfile = preg_replace('!' . $this->listdir . '!', '', $msgfile); |
$a1 = preg_replace('!/archive/(.*)/.*$!', '\1', $relfile); // $a1 contient le nom du répertoire |
$a2 = preg_replace('!/archive/.*/(.*)$!', '\1', $relfile); // $a2 contient le nom du fichier |
if (isset($mailDecode->headers['date'])) $msgtime = strtotime(preg_replace ('/CEST/', '', $mailDecode->headers['date'])); |
$threadidx = date("Ym", $msgtime); |
if ($a2 <= 10) $numero_precedent = '0'.($a2 - 1) ; else $numero_precedent = ($a2 - 1) ; |
if ($a2 < 9) $numero_suivant = '0'.($a2 + 1) ; else $numero_suivant = ($a2 + 1); |
// On teste si le message suivant existe |
$decoupe = explode ('/', $msgfile) ; |
// Les nom de fichiers sont du format : |
// archive/0/01 |
// archive/0/02 ... 0/99 archive/1/01 ... |
$nom_fichier = $decoupe[count($decoupe)-1] ; |
$nom_repertoire = $decoupe[count($decoupe)-2] ; |
$repertoire_suivant = $nom_repertoire ; $repertoire_precedent = $nom_repertoire ; |
if ($nom_fichier > 8) { |
$fichier_suivant = $nom_fichier + 1 ; |
if ($nom_fichier == 99) { |
$fichier_suivant = '01' ; |
$repertoire_suivant = $nom_repertoire + 1 ; |
} |
} else { |
$fichier_suivant = '0'.($nom_fichier + 1) ; |
} |
if ($nom_fichier > 10) { |
$fichier_precedent = $nom_fichier - 1 ; |
} else { |
if ($nom_fichier == '01') { |
$fichier_precedent = '99' ; |
$repertoire_precedent = $nom_repertoire - 1 ; |
} else { |
$fichier_precedent = '0'.($nom_fichier - 1) ; |
} |
} |
print '<br />'."\n"; |
$this->parse_template($mailDecode, $a2, $a1); |
$formulaireReponse = new HTML_formulaireMail('formulaire_reponse', 'post', str_replace('&', '&', $this->forcehref).'&action=repondre&'. |
'actionargs[]='.$a1.'&actionargs[]='.$a2.'&'.PROJET_VARIABLE_ACTION.'='.PROJET_ENVOYER_UN_MAIL_V) ; |
$formulaireReponse->construitFormulaire() ; |
$formulaireReponse->addElement ('hidden', 'messageid', $mailDecode->headers['message-id']) ; |
// Ajout de > au début de chaque ligne du message |
$tableau = explode ("\n", $this->message_rendu) ; |
$this->message_rendu = "> ".implode ("\n> ", $tableau) ; |
$formulaireReponse->setDefaults(array('mail_corps' => $this->message_rendu, |
'mail_titre' => 'Re : '.$this->decode_iso ($mailDecode->headers['subject']))) ; |
print $formulaireReponse->toHTML() ; |
} |
function parse_template(&$mailDecode, $numero_mail, $numero_mois, $num_part = '') { |
static $profondeur = array(); |
array_push ($profondeur, $num_part) ; |
$corps = '' ; |
if ($mailDecode->ctype_primary == 'multipart') { |
include_once PROJET_CHEMIN_CLASSES.'type_fichier_mime.class.php' ; |
for ($i = 0; $i < count($mailDecode->parts); $i++) { |
switch ($mailDecode->parts[$i]->ctype_secondary) { |
case 'plain' : |
case 'html' : $corps .= $mailDecode->parts[$i]->body ; |
break ; |
case 'mixed' : |
case 'rfc822' : |
case 'alternative' : |
case 'appledouble' : |
$this->parse_template($mailDecode->parts[$i], $numero_mail, $numero_mois, $i) ; |
break ; |
case 'applefile' : continue ; |
break ; |
default : |
if ($mailDecode->parts[$i]->ctype_secondary == 'octet-stream') { |
$nom_piece_jointe = $mailDecode->parts[$i]->ctype_parameters['name'] ; |
$tab = explode ('.', $nom_piece_jointe) ; |
$extension = $tab[count ($tab) - 1] ; |
$mimeType = type_fichier_mime::factory($extension, $GLOBALS['projet_db']); |
$mimeType->setCheminIcone(PROJET_CHEMIN_ICONES) ; |
} else { |
$nom_piece_jointe = isset ($mailDecode->parts[$i]->d_parameters['filename']) ? |
$mailDecode->parts[$i]->d_parameters['filename'] : $mailDecode->parts[$i]->ctype_parameters['name'] ; |
$mimeType = new type_fichier_mime($GLOBALS['projet_db'], $mailDecode->parts[$i]->ctype_primary.'/'. |
$mailDecode->parts[$i]->ctype_secondary, PROJET_CHEMIN_ICONES) ; |
} |
$corps .= ''; |
if (count ($profondeur) > 0) { |
array_shift($profondeur) ; |
//for ($j= 0; $j < count ($profondeur); $j++) $corps .= '&actionargs[]='.$profondeur[$j]; |
} |
/*$corps .= '&actionargs[]='.$i ; |
$corps .= '">'.'<img src="'.$mimeType->getCheminIcone().'" alt="'.$nom_piece_jointe.'" /> ' ; |
$corps .= $nom_piece_jointe; |
$corps .= '</a><br />' ;*/ |
break ; |
} |
} |
$this->message_rendu .= preg_replace('/<ezmlm-body>/i', $this->cleanup_body($corps,TRUE), $this->msgtmpl); |
} else if ($mailDecode->ctype_primary == 'message') { |
$this->message_rendu .= "\n".'<div class="message">'.$this->parse_entete_mail($mailDecode->parts[0]); |
$corps .= $this->parse_template($mailDecode->parts[0], $numero_mail, $numero_mois, 0) ; |
$this->message_rendu .= preg_replace('/<ezmlm-body>/i', $this->cleanup_body($corps,true), $this->msgtmpl).'</div>'; |
} else if ($mailDecode->ctype_primary == 'application' || $mailDecode->ctype_primary == 'image'){ |
if ($mailDecode->ctype_secondary == 'applefile') return ; |
$mimeType = new type_fichier_mime($GLOBALS['projet_db'], $mailDecode->ctype_primary.'/'.$mailDecode->ctype_secondary,PROJET_CHEMIN_ICONES) ; |
if ($mimeType->getIdType() != 12) { |
$corps .= '' ; |
$this->message_rendu .= preg_replace('/<ezmlm-body>/i', $this->cleanup_body($corps,true), $this->msgtmpl); |
} |
} else { |
if (preg_match('/html/i', $mailDecode->ctype_secondary)) { |
$this->message_rendu .= preg_replace('/<ezmlm-body>/i', $this->cleanup_body($mailDecode->body), $this->msgtmpl); |
} else { |
if (isset ($mailDecode->ctype_parameters['charset']) && $mailDecode->ctype_parameters['charset'] == 'UTF-8') { |
$this->message_rendu .= preg_replace('/<ezmlm-body>/i', utf8_decode($this->cleanup_body($mailDecode->body)) , $this->msgtmpl); |
} else { |
$this->message_rendu .= preg_replace('/<ezmlm-body>/i', $this->cleanup_body($mailDecode->body), $this->msgtmpl); |
} |
} |
} |
} |
function ezmlm_repondre() { |
$this->ezmlm_php(); |
if (($this->msgtemplate != "") and (is_file($this->msgtemplate))) { |
$fd = fopen($this->msgtemplate, "r"); |
while (!feof($fd)) { $this->msgtmpl .= fgets($fd,4096); } |
fclose($fd); |
} else { |
$this->msgtmpl = '<ezmlm-body>'; |
} |
$this->msgtmpl_entete = '<dl><ezmlm-headers> |
<dt><ezmlm-header-name> :</dt> |
<dd><ezmlm-header-value></dd> |
</ezmlm-headers> |
</dl>' ; |
} |
} |
/tags/2014_06_04/classes/ezmlm-php-2.0/ezmlm-langue-fr.php |
---|
New file |
0,0 → 1,5 |
<?php |
define ('FIL_DE_DISCUSSION', 'Fil de discussion') ; |
?> |
/tags/2014_06_04/classes/ezmlm-php-2.0/ezmlm-author.php |
---|
New file |
0,0 → 1,72 |
<?php |
// $Id: ezmlm-author.php,v 1.4 2008-11-19 09:28:46 aperonnet Exp $ |
// |
// ezmlm-author.php - ezmlm-php v2.0 |
// -------------------------------------------------------------- |
// Displays all messages by a given author |
// -------------------------------------------------------------- |
require_once("ezmlm.php"); |
class ezmlm_author extends ezmlm_php { |
function display($authorhash) { |
$file = "/archive/authors/" . substr($authorhash,0,2) . "/" . substr($authorhash,2,18); |
//echo $file ; |
if (!is_file($this->listdir . $file)) { $this->error(EZMLM_INVALID_AUTHOR); return; } |
// Le fichier author comprend |
// première ligne hash_auteur nom_auteur |
// num_mess:annéemois:hash_sujet sujet |
$fd = @fopen($this->listdir . $file, "r"); |
$i = 0 ; |
$class = array ('ligne_impaire', 'ligne_paire') ; |
while (!feof($fd)) { |
$buf = fgets($fd,4096); |
if (preg_match('/^' . $authorhash . '/', $buf)) { |
// this should ALWAYS be the first line in the file |
$author = preg_replace('/^' . $authorhash . ' /', '', $buf); |
print '<h3>'.$author.'</h3>' ; |
print '<table class="table_cadre">'."\n"; |
print '<tr><th class="col1">De</th><th>Sujet</th><th>Date</th></tr>'."\n"; |
$tableopened = TRUE; |
} else if (preg_match('/^[0-9]*:[0-9]/',$buf)) { |
// si la ligne est valide |
// on récupère le numéro du message pour en extraire le nom du fichier |
$msgfile = preg_replace('/^([0-9]*):.*/', '\1', $buf); |
$msgdir = (int)((int)$msgfile / 100); |
$msgfile = (int)$msgfile % 100; |
if ($msgfile < 10) { $msgfile = "0" . $msgfile; } |
if (!is_file($this->listdir . "/archive/" . $msgdir . "/" . $msgfile)) { |
print "<!-- " . $this->listdir . "/archive/" . $msgdir . "/" . $msgfile . " -->\n"; |
$this->error(EZMLM_INCONSISTANCY); |
fclose($fd); |
return; |
} |
//$msg = new ezmlm_parser(); |
//$msg->parse_file_headers($this->listdir . "/archive/" . $msgdir . "/" . $msgfile); |
$message = file_get_contents($this->listdir . "/archive/" . $msgdir . "/" . $msgfile) ; |
$mimeDecode = new Mail_mimeDecode($message) ; |
$mailDecode = $mimeDecode->decode() ; |
$subject = $mailDecode->headers['subject']; |
$subject = preg_replace("/\[" . $this->listname . "\]/", "", $subject); |
$date = preg_replace ('/CEST/', '', $mailDecode->headers['date']); |
print '<tr class="'.$class[$i].'">'."\n"; |
if ($mailDecode->headers['from'] == '') $from = $mailDecode->headers['return-path'] ; else $from = $mailDecode->headers['from']; |
$hash = $this->makehash($from); |
print '<td>'.$this->makelink("action=show_author_msgs&actionargs[]=" . $hash,$this->decode_iso($this->protect_email($from,false))); |
print '</td>'; |
print "<td><b>" . $this->makelink("action=show_msg&actionargs[]=" . $msgdir . "&actionargs[]=" . $msgfile, $this->decode_iso($subject)) . "</b></td>"; |
print "<td>" . $this->date_francaise($mailDecode->headers['date']) . "</td>\n"; |
print "</tr>\n"; |
$i++; |
if ($i == 2) $i = 0 ; |
unset ($mailDecode) ; |
} |
} |
if ($tableopened) { print "</table>\n"; } |
} |
} |
/tags/2014_06_04/classes/ezmlm-php-2.0/ezmlm.php |
---|
New file |
0,0 → 1,346 |
<?php |
// $Id: ezmlm.php,v 1.3.2.2 2007/03/13 11:04:46 alexandre_tb Exp $ |
// |
// ezmlm.php - ezmlm-php v2.0 |
// -------------------------------------------------------------- |
// As the site that ezmlm-php was developed for grew, and grew |
// the old system used had to be bandaid fixed more, and more |
// because the site started moving to an object oriented design |
// for all the backend systems and ezmlm wasn't playing nice |
// with the new design. So, ezmlm was redesigned too, and here |
// it is. |
// |
// It may look a little more confusing if you're not used to |
// working with objects but it actually is much more effiecient |
// and organized in it's new incarnation. |
// Simply edit the variables in the ezmlm-php constructor below |
// just like you would with the old ezmlm-php-config.php file, |
// if you're unsure howto do this check out the file CONFIG, |
// then check the USAGE file for how you should include and use |
// the new classes if you are integrating ezmlm-php into your |
// site. |
// (SEARCH FOR: USER-CONFIG to find where to edit.) |
// -------------------------------------------------------------- |
require_once("ezmlm-errors.def"); |
require_once("ezmlm-parser.php"); |
require_once("ezmlm-threads.php"); |
require_once("ezmlm-listinfo.php"); |
require_once("ezmlm-msgdisplay.php"); |
require_once("ezmlm-repondre.php"); |
require_once("ezmlm-author.php"); |
$GLOBALS['mois'] = array ('Janvier', 'Février', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Août', 'Septembre', 'Octobre', 'Novembre', 'Décembre') ; |
// CLASS: ezmlm_php |
// the base class, contains common functions and the config |
class ezmlm_php { |
var $listdir; // the root directory of the list |
var $listname; // the list address upto the @ |
var $listdomain; // the domain for the list |
var $tempdir; // a directory in which the webserver can write cache files |
var $sendheaders; // send generic page headers |
var $sendbody; // send generic body definitions |
var $sendfooters; // send generic page footers |
var $includebefore; // a file to include before the content |
var $includeafter; // a file to include after the content |
var $href; // what to add before the '?param=value' in links |
var $prefertype; // what mime type do you prefer? |
var $showheaders; // what headers should we show? |
var $msgtemplate; // the template for displaying messages (see the file TEMPLATE) |
var $tablecolours; // what are the colours for the table rows? |
var $thread_subjlen; // the maximum length of subjects in the thread view (0 = no limit) |
var $forcehref; // force the base of makelink(); |
// --------- END USER CONFIGURATION --------- |
// Internal variables |
var $action = ''; |
var $actionargs; |
function ezmlm_php() { |
// USER-CONFIG section |
// these variables act the same way ezmlm-php-config.php did in the first release |
// simply edit these variables to match your setup |
$this->listdir = ""; |
$this->listname = ""; |
$this->listdomain = ""; |
$this->tempdir = ""; |
$this->sendheaders = TRUE; |
$this->sendbody = TRUE; |
$this->sendfooters = TRUE; |
$this->includebefore = ""; |
$this->includeafter = ""; |
$this->href = ""; |
$this->prefertype = "text/html"; |
$this->showheaders = array( |
"to", |
"from", |
"subject", |
"date" |
); |
$this->header_en_francais = array ('to' => 'A', |
'from' => 'De', |
'subject' => 'Sujet', |
'date' => 'Date') ; |
$this->msgtemplate = "<pre><ezmlm-body></pre>"; // if blank it will use the internal one |
$this->tablecolours = array( |
// delete the next line if you don't want alternating colours |
"#eeeeee", |
"#ffffff" |
); |
$this->thread_subjlen = 55; |
// --- STOP EDITING HERE --- |
// some sanity checking |
if ((!is_dir($this->listdir . "/archive")) or |
(!is_dir($this->listdir . "/archive/authors")) or |
(!is_dir($this->listdir . "/archive/threads")) or |
(!is_dir($this->listdir . "/archive/subjects"))) { |
return false ; |
/*$this->error(EZMLM_INVALID_DIR,TRUE);*/ |
} |
} |
/* |
* Renvoi le nombre de message dans une archive |
* Le nombre contenu dans liste/num |
*/ |
function getNumArchive() { |
if ($this->listdir != '') { |
$num = split(':', file_get_contents($this->listdir.'/num')); |
return $num[0]; |
} |
} |
function set_action($action) { |
if (is_array($action)) { $this->error(EZMLM_INVALID_SYNTAX,TRUE); } |
$this->action = $action; |
} |
function set_actionargs($actionargs) { |
if ($this->action == '') { $this->error(EZMLM_INVALID_SYNTAX,TRUE); } |
$this->actionargs = $actionargs; |
} |
function run() { |
if ($this->action == '') { $this->error(EZMLM_INVALID_SYNTAX,TRUE); } |
if ($this->sendheaders) { $this->sendheaders(); } |
if ($this->sendbody) { $this->sendbody(); } |
if ($this->includebefore != '') { @include_once($this->includebefore); } |
switch ($this->action) { |
case "list_info": |
$info = new ezmlm_listinfo(); |
$info->display(); |
break; |
case "show_msg": |
if (count($this->actionargs) < 2) { |
$this->error(EZMLM_INVALID_SYNTAX,TRUE); |
} |
$show_msg = new ezmlm_msgdisplay(); |
$show_msg->display($this->actionargs[0] . "/" . $this->actionargs[1]); |
break; |
case "show_threads": |
$threads = new ezmlm_threads(); |
$threads->load($this->actionargs[0]); |
break; |
case "show_author_msgs": |
$author = new ezmlm_author(); |
$author->display($this->actionargs[0]); |
break; |
} |
if ($this->includeafter != '') { @include_once($this->includeafter); } |
if ($this->sendfooters) { $this->sendfooters(); } |
} |
function sendheaders() { |
print "<html><head>\n"; |
print "<style type=\"text/css\">\n"; |
print "<!--\n"; |
print ".heading { font-family: helvetica; font-size: 16px; line-height: 18px; font-weight: bold; }\n"; |
print "//-->\n"; |
print "</style>\n"; |
print "</head>\n"; |
} |
function sendbody() { |
print "<body>\n"; |
} |
function sendfooters() { |
print "</body>\n"; |
print "</html>\n"; |
} |
// begin common functions |
// makehash - generates an author hash using the included makehash program |
function makehash($str) { |
$str = preg_replace ('/>/', '', $str) ; |
$handle = popen ('/usr/local/lib/safe_mode/makehash \''.$str.'\'', 'r') ; |
$hash = fread ($handle, 256) ; |
pclose ($handle) ; |
return $hash; |
} |
// makelink - writes the <a href=".."> tag |
function makelink($params,$text) { |
if ($this->forcehref != "") { |
$basehref = $this->forcehref; |
} else { |
$basehref = preg_replace('/^(.*)\?.*/', '\\1', $_SERVER['REQUEST_URI']); |
} |
$link = '<a href="'. $basehref . '&' . $params . '">' . $text . '</a>'; |
return $link; |
} |
// md5_of_file - provides wrapper function that emulates md5_file for PHP < 4.2.0 |
function md5_of_file($file) { |
if (function_exists("md5_file")) { // php >= 4.2.0 |
return md5_file($file); |
} else { |
if (is_file($file)) { |
$fd = fopen($file, "rb"); |
$filecontents = fread($fd, filesize($file)); |
fclose ($fd); |
return md5($filecontents); |
} else { |
return FALSE; |
} |
} |
} |
// protect_email - protects email address turns user@domain.com into user@d... |
function protect_email($str,$short = FALSE) { |
if (preg_match("/[a-zA-Z0-9\-\.]\@[a-zA-Z0-9\-\.]*\./", $str)) { |
$outstr = preg_replace("/([a-zA-Z0-9\-\.]*\@)([a-zA-Z0-9\-\.])[a-zA-Z0-9\-\.]*\.[a-zA-Z0-9\-\.]*/","\\1\\2...",$str); |
$outstr = preg_replace("/\</", '<', $outstr); |
$outstr = preg_replace("/\>/", '>', $outstr); |
} else { |
$outstr = $str; |
} |
if ($short) { |
$outstr = preg_replace("/<.*>/", '', $outstr); |
$outstr = preg_replace("/[\"']/", '', $outstr); |
} |
$at_split = explode('@',$outstr); |
$outstr = $at_split[0]; |
$points_sep = explode('.',$outstr); |
if(count($points_sep) > 2) { |
$outstr = implode('.', array_slice($points_sep,0,count($points_sep) - 2)); |
$outstr = rtrim($outstr, '.').'...'; |
} |
return trim($outstr); |
} |
// cleanup_body: sortta like protect_email, just for message bodies |
function cleanup_body($str) { |
$outstr = preg_replace("/([a-zA-Z0-9\-\.]*\@)([a-zA-Z0-9\-\.])[a-zA-Z0-9\-\.]*\.[a-zA-Z0-9\-\.]*/","\\1\\2...",$str); |
return $outstr; |
} |
function error($def, $critical = FALSE) { |
global $ezmlm_error; |
print "\n\n"; |
print "<table width=600 border=1 cellpadding=3 cellspacing=0>\n"; |
print "<tr bgcolor=\"#cccccc\"><td><b>EZMLM-PHP Error: " . $ezmlm_error[$def]['title'] . "</td></tr>\n"; |
print "<tr bgcolor=\"#aaaaaa\"><td>" . $ezmlm_error[$def]['body'] . "</td></tr>\n"; |
print "</table>\n\n"; |
if ($critical) { die; } |
} |
/** |
* Parse une chaine et supprime les probleme d'encodage de type ISO-4 ... |
* |
* @return string |
*/ |
function decode_iso ($chaine) { |
if (preg_match ('/windows-[0-9][0-9][0-9][0-9]/i', $chaine, $nombre)) { |
$reg_exp = $nombre[0] ; |
$chaine = str_replace(' ', '', $chaine); |
} else { |
$reg_exp = 'ISO-8859-15?' ; |
} |
if (preg_match ('/UTF/i', $chaine)) $reg_exp = 'UTF-8' ; |
preg_match_all ("/=\?$reg_exp\?(Q|B)\?(.*?)\?=/i", $chaine, $match, PREG_PATTERN_ORDER) ; |
for ($i = 0; $i < count ($match[0]); $i++ ) { |
if (strtoupper($match[1][$i]) == 'Q') { |
$decode = quoted_printable_decode ($match[2][$i]) ; |
} elseif ($match[1][$i] == 'B') { |
$decode = base64_decode ($match[2][$i]) ; |
} |
$decode = preg_replace ("/_/", " ", $decode) ; |
if ($reg_exp == 'UTF-8') { |
$decode = utf8_decode ($decode) ; |
} |
$chaine = str_replace ($match[0][$i], $decode, $chaine) ; |
} |
return $chaine ; |
} |
/** |
* |
* |
* @return |
*/ |
function date_francaise ($date_mail) { |
$date_mail = preg_replace ('/CEST/', '', $date_mail) ; |
$numero_mois = date('m ', strtotime($date_mail)) - 1 ; |
$date = date ('d ', strtotime($date_mail)).$GLOBALS['mois'][$numero_mois] ; // Le jour et le mois |
$date .= date(' Y ', strtotime($date_mail)) ; // l'annee |
if (date('a', strtotime($date_mail)) == 'pm') { |
$date .= (int) date('g', strtotime($date_mail)) + 12 ; // Les heures |
} else { |
$date .= date('g', strtotime($date_mail)) ; |
} |
$date .= date(':i', strtotime($date_mail)) ; // Les minutes |
return $date ; |
} |
/** |
* Cette fonction renvoie le prefixe, cad 0 ou rien |
* d un nom de message, ex : pour 09, on renvoie 0 |
* pour 12 on renvoie rien |
*/ |
function prefixe_nom_message($nom) { |
if (preg_match ('/0([1-9][0-9]*)/', $nom, $match)) { |
$nom_fichier = $match[1]; |
return '0' ; |
} else { |
return '' ; |
} |
} |
} |
// |
// --- END OF CLASS DEFINITION --- |
// |
// FIN |
/tags/2014_06_04/classes/ezmlm-php-2.0/services_vpopmail/suppression_abonne.php |
---|
New file |
0,0 → 1,7 |
<?php |
$repertoire = '/home/vpopmail/domains/'.$domaine.'/'.$liste ; |
echo exec ('ezmlm-unsub '.$repertoire.' '.$mail, $output, $ret) ; |
echo 'ezmlm-unsub '.$repertoire.' '.$mail; |
?> |
/tags/2014_06_04/classes/ezmlm-php-2.0/services_vpopmail/est_abonne.php |
---|
New file |
0,0 → 1,65 |
<?php |
/*vim: set expandtab tabstop=4 shiftwidth=4: */ |
// +------------------------------------------------------------------------------------------------------+ |
// | PHP version 4.1 | |
// +------------------------------------------------------------------------------------------------------+ |
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) | |
// +------------------------------------------------------------------------------------------------------+ |
// | This library is free software; you can redistribute it and/or | |
// | modify it under the terms of the GNU General Public | |
// | License as published by the Free Software Foundation; either | |
// | version 2.1 of the License, or (at your option) any later version. | |
// | | |
// | This library is distributed in the hope that it will be useful, | |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
// | General Public License for more details. | |
// | | |
// | You should have received a copy of the GNU General Public | |
// | License along with this library; if not, write to the Free Software | |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
// +------------------------------------------------------------------------------------------------------+ |
// CVS : $Id: est_abonne.php,v 1.1 2008-10-27 16:45:25 aperonnet Exp $ |
/** |
* Application projet |
* |
* Renvoie une balise xml contenant 1 si l'utilisateur est abonné à une liste de discussion donnée, 0 sinon |
* |
*@package projet |
//Auteur original : |
*@author Aurelien Peronnet <aurelien@tela-botanica.org> |
*@copyright Tela-Botanica 2000-2008 |
*@version $Revision: 1.1 $ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
include_once 'XML/Util.php' ; |
$xml = XML_Util::getXMLDeclaration('1.0', 'ISO-8859-15', 'no') ; |
// Les 2 parametres doivent etres present |
if (!isset($_GET['domaine']) || !isset($_GET['liste'])) { |
$xml .= XML_Util::createTag('erreur', 'Vous devez spécifier un domaine et une liste'); |
} else { |
$repertoire = '/home/vpopmail/domains/'.$domaine.'/'.$liste ; |
exec ('ezmlm-list '.$repertoire, $output, $ret) ; |
$xml .= XML_Util::createStartElement ('ezmlm_est_abonne') ; |
if(in_array($mail,$output) >= 1) { |
$xml .= '1' ; |
} |
else { |
$xml .= '0' ; |
} |
$xml .= XML_Util::createEndElement('ezmlm_est_abonne') ; |
header ('Content-type: text/xml'); |
echo $xml ; |
} |
/* +--Fin du code ----------------------------------------------------------------------------------------+ |
* |
* |
* +-- Fin du code ----------------------------------------------------------------------------------------+ |
*/ |
?> |
/tags/2014_06_04/classes/ezmlm-php-2.0/services_vpopmail/forumRSS.php |
---|
New file |
0,0 → 1,54 |
<?php |
/*vim: set expandtab tabstop=4 shiftwidth=4: */ |
// +------------------------------------------------------------------------------------------------------+ |
// | PHP version 4.1 | |
// +------------------------------------------------------------------------------------------------------+ |
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) | |
// +------------------------------------------------------------------------------------------------------+ |
// | This library is free software; you can redistribute it and/or | |
// | modify it under the terms of the GNU Lesser General Public | |
// | License as published by the Free Software Foundation; either | |
// | version 2.1 of the License, or (at your option) any later version. | |
// | | |
// | This library is distributed in the hope that it will be useful, | |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
// | Lesser General Public License for more details. | |
// | | |
// | You should have received a copy of the GNU Lesser General Public | |
// | License along with this library; if not, write to the Free Software | |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
// +------------------------------------------------------------------------------------------------------+ |
// CVS : $Id: forumRSS.php,v 1.2 2008-08-26 09:23:33 alexandre_tb Exp $ |
/** |
* Générateur de flux RSS à partir d'une liste |
* |
*@package projet |
//Auteur original : |
*@author Alexandre Granier <alexandre@tela-botanica.org> |
* |
*@copyright Tela-Botanica 2000-2004 |
*@version $$ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
include_once 'ezmlm-php-2.0/ezmlm-xml.php' ; |
// test des variables |
if (!isset($domaine) || !isset($liste)) { |
exit() ; |
} |
$list = new ezmlm_xml() ; |
$list->listdir = '/home/vpopmail/domains/'.$domaine.'/'.$liste ; |
header('Content-type: text/xml') ; |
$list->show_rss() ; |
/* +--Fin du code ----------------------------------------------------------------------------------------+ |
* |
* $Log: not supported by cvs2svn $ |
* |
* |
* +-- Fin du code ----------------------------------------------------------------------------------------+ |
*/ |
?> |
/tags/2014_06_04/classes/ezmlm-php-2.0/services_vpopmail/message.php |
---|
New file |
0,0 → 1,50 |
<?php |
include_once 'ezmlm-php-2.0/ezmlm.php' ; |
// Parametrage de la liste |
$message = new ezmlm_msgdisplay(); |
if (!$message) return 'Les fichiers de la liste ne sont pas visible sur le serveur' ; |
$message->forcehref = $url; |
$message->listdir = '/home/vpopmail/domains/'.$domaine.'/'.$liste ; |
$message->listname = $liste; |
$message->listdomain = $domaine ; |
$id_rep = $actionargs[0] ; |
$num_message = $actionargs[1] ; |
if ($id_rep =='' || $num_message == '') exit(); |
$html = $message->display ($id_rep.'/'.$num_message) ; |
include_once 'XML/Util.php' ; |
$xml = XML_Util::getXMLDeclaration('1.0', 'ISO-8859-15', 'no') ; |
if (!$html) { |
$xml .= XML_Util::createStartElement ('ezmlm_erreur') ; |
$xml .= 'Le message n\'existe pas'; |
$xml .= XML_Util::createEndElement('ezmlm_erreur') ; |
header ('Content-type: text/xml'); |
echo $xml; |
exit(); |
} |
$xml .= XML_Util::createStartElement ('ezmlm_message', array('domaine' => $domaine, 'liste' => $liste, 'langue' => $langue)) ; |
$xml .= "\n".'<![CDATA[ '.$html.']]>'; |
$info_suivant = $message->getInfoSuivant() ; |
$xml .= XML_Util::createStartElement ('message_suivant', array ('numero' => $info_suivant['fichier_suivant'], |
'numero_repertoire' => $info_suivant['repertoire_suivant'])) ; |
$xml .= XML_Util::createEndElement('message_suivant') ; |
$xml .= XML_Util::createStartElement ('message_precedent', array ('numero' => $info_suivant['fichier_precedent'], |
'numero_repertoire' => $info_suivant['repertoire_precedent'])) ; |
$xml .= XML_Util::createEndElement('message_precedent') ; |
$xml .= XML_Util::createEndElement('ezmlm_message') ; |
header ('Content-type: text/xml'); |
echo $xml ; |
?> |
/tags/2014_06_04/classes/ezmlm-php-2.0/services_vpopmail/.htaccess |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/tags/2014_06_04/classes/ezmlm-php-2.0/services_vpopmail/.htaccess |
---|
New file |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/tags/2014_06_04/classes/ezmlm-php-2.0/services_vpopmail/liste_abonnes.php |
---|
New file |
0,0 → 1,17 |
<?php |
$repertoire = '/home/vpopmail/domains/'.$domaine.'/'.$liste ; |
exec ('ezmlm-list '.$repertoire, $output, $ret) ; |
include_once 'XML/Util.php' ; |
$xml = XML_Util::getXMLDeclaration('1.0', 'ISO-8859-15', 'no') ; |
$xml .= XML_Util::createStartElement ('ezmlm_liste_abonnes', array('domaine' => $domaine, 'liste' => $liste)) ; |
foreach ($output as $mail) $xml .= XML_Util::createTag('email', '', $mail) ; |
$xml .= XML_Util::createEndElement('ezmlm_liste_abonnes') ; |
header ('Content-type: text/xml'); |
echo $xml ; |
?> |
/tags/2014_06_04/classes/ezmlm-php-2.0/services_vpopmail/supprimer.php |
---|
New file |
0,0 → 1,15 |
<?php |
/** |
* Supprime un message d'une liste |
* Entrée domaine, liste, numero_repertoire, numero_message |
*/ |
$repertoire_liste = '/home/vpopmail/domains/'.$domaine.'/'.$liste; |
$message_a_supprimer = $repertoire_liste.'/archive/'.$actionargs[0].'/'.$actionargs[1] ; |
if (file_exists ($message_a_supprimer)) { |
echo $message_a_supprimer; |
exec ('rm '.$message_a_supprimer) ; |
exec ('ezmlm-archive -c '.$repertoire_liste); |
exec ('ezmlm-idx '.$repertoire_liste); |
} |
/tags/2014_06_04/classes/ezmlm-php-2.0/services_vpopmail/clical.php |
---|
New file |
0,0 → 1,68 |
<?php |
/** |
* @author Raphaël Droz <raphael@tela-botanica.org> |
* @copyright 2013, Tela-Botanica |
* @license GPL v3 |
* @license CECILL v2 |
*/ |
// eg: php clical.php amorphophallus_et_araceae|html2text |
if (PHP_SAPI !== 'cli') die; |
// for standalone use |
// WARNING: this uses cache ! |
// php-cli user could have != permission than a webserver |
// then cache file created could become inaccessible to webserver |
error_reporting(E_ALL ^ E_STRICT ^ E_NOTICE ^ E_DEPRECATED); |
date_default_timezone_set('Europe/Paris'); |
$path = '/home/vpopmail/domains'; |
$domaine = 'tela-botanica.org'; |
/* |
List (ezmlm_threads::listmessages()), /calendrier_messages.php, |
Recent (ezmlm_listinfo::show_recentmsgs()), /derniers_messages.php?domaine=&liste= |
Month (ezmlm_listinfo::show_month(X)), /messages_mois.php?domaine=&liste=&actionargs[]=201306 |
month/Thread (ezmlm_listinfo::show_month(X)), /messages_thread.php?domaine=&liste=&actionargs[]=201306 |
XXX: Show (ezmlm_msgdisplay::display(X)), /message.php?domaine=&liste=&action=show_msg&actionargs[]=18&actionargs[]=09 |
-p: path |
-d: domaine |
*/ |
$options = getopt("LRMTp:d:"); |
if(isset($options['p'])) $path = $options['p']; |
if(isset($options['d'])) $domaine = $options['d']; |
$liste = array_slice($argv, -1)[0]; |
if(!$liste || !$domaine || !$path) die; |
include_once 'ezmlm-php-2.0/ezmlm.php' ; |
// Parametrage de la liste |
if(array_key_exists('R', $options) || array_key_exists('M', $options)) { |
$info = new ezmlm_listinfo(); |
} else { // cal & show threads |
$info = new ezmlm_threads(); |
} |
if (!$info) die('Les fichiers de la liste ne sont pas visible sur le serveur'); |
$info->forcehref = $url; |
$info->listdir = $path . '/' . $domaine . '/' . $liste ; |
$info->listname = $liste; |
$info->listdomain = $domaine ; |
if(array_key_exists('R', $options)) { |
echo $info->show_recentmsgs(); |
} |
elseif(array_key_exists('M', $options)) { |
echo $info->show_month("201307"); |
} |
elseif(array_key_exists('T', $options)) { |
$info->tempdir = '/tmp' ; echo $info->load("201306"); |
} |
else { |
echo $info->listmessages(); // ezmlm_threads |
} |
/tags/2014_06_04/classes/ezmlm-php-2.0/services_vpopmail/suppression_liste.php |
---|
New file |
0,0 → 1,20 |
<?php |
if (!isset ($domaine) || $domaine == '' || !isset($liste) || $liste == '') { |
die ('manque paramètre domaine ou liste') ; |
} |
$repertoire = '/home/vpopmail/domains/'.$domaine.'/'.$liste ; |
$fichier_qmail = '/home/vpopmail/domains/'.$domaine.'/.qmail-'.$liste ; |
echo exec ('rm '.$fichier_qmail, $output2, $ret2) ; |
echo exec ('rm '.$fichier_qmail.'-default', $output2, $ret2) ; |
echo exec ('rm '.$fichier_qmail.'-digest-owner', $output2, $ret2) ; |
echo exec ('rm '.$fichier_qmail.'-digest-return-default', $output2, $ret2) ; |
echo exec ('rm '.$fichier_qmail.'-owner', $output2, $ret2) ; |
echo exec ('rm '.$fichier_qmail.'-return-default', $output2, $ret2) ; |
echo 'rm '.$fichier_qmail ; |
echo exec ('rm -rf '.$repertoire, $output, $ret) ; |
echo 'rm -rf '.$repertoire ; |
?> |
/tags/2014_06_04/classes/ezmlm-php-2.0/services_vpopmail/messages_auteur.php |
---|
New file |
0,0 → 1,32 |
<?php |
include_once 'ezmlm-php-2.0/ezmlm.php' ; |
// Parametrage de la liste |
$info = new ezmlm_author(); |
if (!$info) return 'Les fichiers de la liste ne sont pas visible sur le serveur' ; |
$info->forcehref = $url; |
$info->listdir = '/home/vpopmail/domains/'.$domaine.'/'.$liste ; |
$info->listname = $liste; |
$info->listdomain = $domaine ; |
ob_start() ; |
if (!$info->display($actionargs[0])) { |
if (!$info) return 'Les fichiers de la liste ne sont pas visible sur le serveur' ; |
} |
$html = ob_get_contents() ; |
ob_end_clean() ; |
include_once 'XML/Util.php' ; |
$xml = XML_Util::getXMLDeclaration('1.0', 'ISO-8859-15', 'no') ; |
$xml .= XML_Util::createStartElement ('ezmlm_messages_auteur', array('domaine' => $domaine, 'liste' => $liste, 'langue' => $langue )) ; |
$xml .= '<![CDATA[ '.$html.']]>'; |
$xml .= XML_Util::createEndElement('ezmlm_messages_auteur') ; |
header ('Content-type: text/xml'); |
echo $xml ; |
?> |
/tags/2014_06_04/classes/ezmlm-php-2.0/services_vpopmail/messages_mois.php |
---|
New file |
0,0 → 1,101 |
<?php |
/*vim: set expandtab tabstop=4 shiftwidth=4: */ |
// +------------------------------------------------------------------------------------------------------+ |
// | PHP version 4.1 | |
// +------------------------------------------------------------------------------------------------------+ |
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) | |
// +------------------------------------------------------------------------------------------------------+ |
// | This library is free software; you can redistribute it and/or | |
// | modify it under the terms of the GNU General Public | |
// | License as published by the Free Software Foundation; either | |
// | version 2.1 of the License, or (at your option) any later version. | |
// | | |
// | This library is distributed in the hope that it will be useful, | |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
// | General Public License for more details. | |
// | | |
// | You should have received a copy of the GNU General Public | |
// | License along with this library; if not, write to the Free Software | |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
// +------------------------------------------------------------------------------------------------------+ |
// CVS : $Id: messages_mois.php,v 1.4 2008-11-04 17:11:10 aperonnet Exp $ |
/** |
* Application projet |
* |
* Action forums |
* |
*@package projet |
//Auteur original : |
*@author Alexandre Granier <alexandre@tela-botanica.org> |
//Autres auteurs : |
*@author Aucun |
*@copyright Tela-Botanica 2000-2008 |
*@version $Revision: 1.4 $ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
include_once 'ezmlm-php-2.0/ezmlm.php' ; |
error_reporting(E_ALL ^ E_NOTICE ^ E_DEPRECATED ^ E_STRICT); |
date_default_timezone_set("Europe/Paris"); |
// extract($_GET); // PHP-5.4, sans register_globals |
// Parametrage de la liste |
$info = new ezmlm_listinfo(); |
if (!$info) return 'Les fichiers de la liste ne sont pas visible sur le serveur' ; |
$info->forcehref = $url; |
$info->listdir = '/home/vpopmail/domains/'.$domaine.'/'.$liste ; |
$info->listname = $liste; |
$info->listdomain = $domaine ; |
/** Calcul du cache */ |
require_once('Cache/Lite.php'); |
// Set a id for this cache |
$id = 'cachemonth_'.$domaine.'_'.$liste.'_'.$actionargs[0]; |
// Set a few options |
$options = array( |
'cacheDir' => 'tmp/', |
'lifeTime' => 360000 |
); |
// Create a Cache_Lite object |
$Cache_Lite = new Cache_Lite($options); |
if ($xml = $Cache_Lite->get($id)) { |
} else { |
include_once 'XML/Util.php' ; |
$xml = XML_Util::getXMLDeclaration('1.0', 'ISO-8859-15', 'no') ; |
$html = $info->show_month($actionargs[0]); |
if (!$html) { |
$xml .= XML_Util::createStartElement ('ezmlm_erreur', array('domaine' => $domaine, 'liste' => $liste, 'langue' => $langue)) ; |
$xml .= '<![CDATA[ \'Les fichiers de la liste ne sont pas visibles sur le serveur\']]>'; |
$xml .= XML_Util::createEndElement('ezmlm_erreur') ; |
} else { |
$xml .= XML_Util::createStartElement ('ezmlm_messages_mois', array('domaine' => $domaine, 'liste' => $liste, 'langue' => $langue)) ; |
$xml .= '<![CDATA[ '.$html.']]>'; |
$xml .= XML_Util::createEndElement('ezmlm_messages_mois') ; |
$Cache_Lite->save($xml); |
} |
} |
header ('Content-type: text/xml'); |
echo $xml ; |
/* +--Fin du code ----------------------------------------------------------------------------------------+ |
* |
* $Log: not supported by cvs2svn $ |
* Revision 1.3 2008-08-25 15:24:09 alexandre_tb |
* ajout de la gestion du cache |
* |
* +-- Fin du code ----------------------------------------------------------------------------------------+ |
*/ |
?> |
/tags/2014_06_04/classes/ezmlm-php-2.0/services_vpopmail/messages_thread.php |
---|
New file |
0,0 → 1,76 |
<?php |
/*vim: set expandtab tabstop=4 shiftwidth=4: */ |
// +------------------------------------------------------------------------------------------------------+ |
// | PHP version 4.1 | |
// +------------------------------------------------------------------------------------------------------+ |
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) | |
// +------------------------------------------------------------------------------------------------------+ |
// | This library is free software; you can redistribute it and/or | |
// | modify it under the terms of the GNU General Public | |
// | License as published by the Free Software Foundation; either | |
// | version 2.1 of the License, or (at your option) any later version. | |
// | | |
// | This library is distributed in the hope that it will be useful, | |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
// | General Public License for more details. | |
// | | |
// | You should have received a copy of the GNU General Public | |
// | License along with this library; if not, write to the Free Software | |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
// +------------------------------------------------------------------------------------------------------+ |
// CVS : $Id: messages_thread.php,v 1.5 2008-11-19 09:28:45 aperonnet Exp $ |
/** |
* Application projet |
* |
* Renvoie les messages d un thread |
* |
*@package projet |
//Auteur original : |
*@author Alexandre Granier <alexandre@tela-botanica.org> |
*@copyright Tela-Botanica 2000-2008 |
*@version $Revision: 1.5 $ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
include_once 'ezmlm-php-2.0/ezmlm.php' ; |
error_reporting(E_ALL ^ E_NOTICE ^ E_DEPRECATED ^ E_STRICT); |
// extract($_GET); // PHP-5.4, sans register_globals |
// Parametrage de la liste |
$info = new ezmlm_threads(); |
if (!$info) return 'Les fichiers de la liste ne sont pas visible sur le serveur' ; |
$info->forcehref = $url; |
$info->listdir = '/home/vpopmail/domains/'.$domaine.'/'.$liste ; |
$info->listname = $liste; |
$info->listdomain = $domaine ; |
$info->tempdir = '/home/vpopmail/www/tmp' ; |
$html = $info->load($actionargs[0]) ; |
if (!$html) { |
if (!$info) return 'Les fichiers de la liste ne sont pas visible sur le serveur' ; |
} |
include_once 'XML/Util.php' ; |
$xml = XML_Util::getXMLDeclaration('1.0', 'ISO-8859-15', 'no') ; |
$xml .= XML_Util::createStartElement ('ezmlm_messages_thread', array('domaine' => $domaine, 'liste' => $liste, 'langue' => $langue)) ; |
$xml .= '<![CDATA[ '.$html.']]>'; |
$xml .= XML_Util::createEndElement('ezmlm_messages_thread') ; |
header ('Content-type: text/xml'); |
echo $xml ; |
/* +--Fin du code ----------------------------------------------------------------------------------------+ |
* |
* $Log: not supported by cvs2svn $ |
* Revision 1.4 2008-11-04 17:11:10 aperonnet |
* correction de bugs dans la liste des derniers messages |
* |
* Revision 1.3 2008-08-26 09:26:41 alexandre_tb |
* ajout commentaire |
* |
* |
* +-- Fin du code ----------------------------------------------------------------------------------------+ |
*/ |
?> |
/tags/2014_06_04/classes/ezmlm-php-2.0/services_vpopmail/calendrier_messages.php |
---|
New file |
0,0 → 1,132 |
<?php |
/*vim: set expandtab tabstop=4 shiftwidth=4: */ |
// +------------------------------------------------------------------------------------------------------+ |
// | PHP version 4.1 | |
// +------------------------------------------------------------------------------------------------------+ |
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) | |
// +------------------------------------------------------------------------------------------------------+ |
// | This library is free software; you can redistribute it and/or | |
// | modify it under the terms of the GNU General Public | |
// | License as published by the Free Software Foundation; either | |
// | version 2.1 of the License, or (at your option) any later version. | |
// | | |
// | This library is distributed in the hope that it will be useful, | |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
// | General Public License for more details. | |
// | | |
// | You should have received a copy of the GNU General Public | |
// | License along with this library; if not, write to the Free Software | |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
// +------------------------------------------------------------------------------------------------------+ |
// CVS : $Id: calendrier_messages.php,v 1.4 2008-08-25 15:25:47 alexandre_tb Exp $ |
/** |
* Application projet |
* |
* Action forums |
* |
*@package projet |
//Auteur original : |
*@author Alexandre Granier <alexandre@tela-botanica.org> |
//Autres auteurs : |
*@author Aucun |
*@copyright Tela-Botanica 2000-2008 |
*@version $Revision: 1.4 $ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
include_once 'ezmlm-php-2.0/ezmlm.php' ; |
error_reporting(E_ALL ^ E_NOTICE ^ E_DEPRECATED ^ E_STRICT); |
date_default_timezone_set("Europe/Paris"); |
// extract($_GET); // PHP-5.4, sans register_globals |
// Parametrage de la liste |
$info = new ezmlm_threads(); |
if (!$info) return 'Les fichiers de la liste ne sont pas visible sur le serveur' ; |
$info->forcehref = $url; |
$info->listdir = '/home/vpopmail/domains/'.$domaine.'/'.$liste ; |
$info->listname = $liste; |
$info->listdomain = $domaine ; |
/** Calcul du cache */ |
/* |
require_once('Cache/Lite.php'); |
// Set a id for this cache |
$id = 'cache_'.$domaine.'_'.$liste; |
// Set a few options |
$options = array( |
'cacheDir' => 'tmp/', |
'lifeTime' => null |
); |
*/ |
include_once 'XML/Util.php' ; |
$xml = XML_Util::getXMLDeclaration('1.0', 'ISO-8859-15', 'no') ; |
if (!file_exists($info->listdir.'/num')) { |
$xml .= XML_Util::createStartElement ('ezmlm_calendrier_messages', array('domaine' => $domaine, 'liste' => $liste, 'langue' => $langue)) ; |
$xml .= '<![CDATA[il n\'y a pas de messages dans cette liste pour le moment.]]>'; |
$xml .= XML_Util::createEndElement('ezmlm_calendrier_messages') ; |
header ('Content-type: text/xml'); |
echo $xml; |
exit(); |
} |
/* |
// Create a Cache_Lite object |
$Cache_Lite = new Cache_Lite($options); |
$recalcule = false ; |
$Cache_Lite->get($id); |
if (@fileatime($info->listdir.'/num') > (int)$Cache_Lite->lastModified()) { |
$recalcule = true; |
} |
// Test if thereis a valide cache for this id |
if (!$recalcule) { |
$xml = $Cache_Lite->get($id); |
} else { // pas de cache, on construit le calendrier |
*/ |
$html = $info->listmessages(); |
if (!$html) { |
$xml .= XML_Util::createStartElement ('ezmlm_erreur', array('domaine' => $domaine, 'liste' => $liste, 'langue' => $langue)) ; |
$xml .= '<![CDATA[Les fichiers de la liste ne sont pas visibles sur le serveur]]>'; |
$xml .= XML_Util::createEndElement('ezmlm_erreur') ; |
} else { |
$xml .= XML_Util::createStartElement ('ezmlm_calendrier_messages', array('domaine' => $domaine, 'liste' => $liste, 'langue' => $langue)) ; |
$xml .= '<![CDATA[ '.$html.']]>'; |
$xml .= XML_Util::createEndElement('ezmlm_calendrier_messages') ; |
/* |
$xml .= XML_Util::createStartElement('cache_time') ; |
$xml .= (int)$Cache_Lite->lastmodified().'#'.fileatime($info->listdir.'/num'); |
$xml .= XML_Util::createEndElement('cache_time') ;*/ |
//$Cache_Lite->save($xml, $id); |
} |
//} |
header ('Content-type: text/xml'); |
echo $xml ; |
/* +--Fin du code ----------------------------------------------------------------------------------------+ |
* |
* $Log: calendrier_messages.php,v $ |
* Revision 1.4 2008-08-25 15:25:47 alexandre_tb |
* optimisation et gestion du cache |
* |
* Revision 1.3 2008-06-09 10:05:28 alexandre_tb |
* Ajout de la gestion du cache |
* dependance avec Cache_Lite |
* |
* +-- Fin du code ----------------------------------------------------------------------------------------+ |
*/ |
?> |
/tags/2014_06_04/classes/ezmlm-php-2.0/services_vpopmail/derniers_messages.php |
---|
New file |
0,0 → 1,93 |
<?php |
/*vim: set expandtab tabstop=4 shiftwidth=4: */ |
// +------------------------------------------------------------------------------------------------------+ |
// | PHP version 4.1 | |
// +------------------------------------------------------------------------------------------------------+ |
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) | |
// +------------------------------------------------------------------------------------------------------+ |
// | This library is free software; you can redistribute it and/or | |
// | modify it under the terms of the GNU General Public | |
// | License as published by the Free Software Foundation; either | |
// | version 2.1 of the License, or (at your option) any later version. | |
// | | |
// | This library is distributed in the hope that it will be useful, | |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
// | General Public License for more details. | |
// | | |
// | You should have received a copy of the GNU General Public | |
// | License along with this library; if not, write to the Free Software | |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
// +------------------------------------------------------------------------------------------------------+ |
// CVS : $Id $ |
/** |
* Application projet |
* |
* Action forums |
* |
*@package projet |
//Auteur original : |
*@author Alexandre Granier <alexandre@tela-botanica.org> |
//Autres auteurs : |
*@author Aucun |
*@copyright Tela-Botanica 2000-2008 |
*@version $Revision: 1.6 $ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
include_once 'ezmlm-php-2.0/ezmlm.php' ; |
error_reporting(E_ALL ^ E_NOTICE ^ E_DEPRECATED ^ E_STRICT); |
date_default_timezone_set("Europe/Paris"); |
// extract($_GET); // PHP-5.4, sans register_globals |
// Parametrage de la liste |
$info = new ezmlm_listinfo(); |
if (!$info) return 'Les fichiers de la liste ne sont pas visible sur le serveur' ; |
$info->forcehref = $url; |
$info->listdir = '/home/vpopmail/domains/'.$domaine.'/'.$liste ; |
$info->listname = $liste; |
$info->listdomain = $domaine ; |
include_once 'XML/Util.php' ; |
$xml = XML_Util::getXMLDeclaration('1.0', 'ISO-8859-15', 'no') ; |
if (!file_exists($info->listdir.'/num')) { |
$xml .= XML_Util::createStartElement ('ezmlm_derniers_messages', array('domaine' => $domaine, 'liste' => $liste, 'langue' => $langue)) ; |
$xml .= '<![CDATA[il n\'y a pas de messages dans cette liste pour le moment.]]>'; |
$xml .= XML_Util::createEndElement('ezmlm_derniers_messages') ; |
header ('Content-type: text/xml'); |
echo $xml; |
exit(); |
} |
$html = $info->show_recentmsgs() ; |
if (!$html) { |
if (!$info) { |
echo 'Les fichiers de la liste ne sont pas visibles sur le serveur' ; |
exit(); |
} |
} |
$xml .= XML_Util::createStartElement ('ezmlm_derniers_messages', array('domaine' => $domaine, 'liste' => $liste, 'langue' => $langue)) ; |
$xml .= '<![CDATA[ '.$html.']]>'; |
$xml .= XML_Util::createEndElement('ezmlm_derniers_messages') ; |
header ('Content-type: text/xml'); |
echo $xml ; |
/* +--Fin du code ----------------------------------------------------------------------------------------+ |
* |
* $Log: not supported by cvs2svn $ |
* Revision 1.5 2008-11-04 17:11:10 aperonnet |
* correction de bugs dans la liste des derniers messages |
* |
* Revision 1.4 2008-08-25 15:25:09 alexandre_tb |
* optimisation et gestion des erreurs |
* |
* |
* +-- Fin du code ----------------------------------------------------------------------------------------+ |
*/ |
?> |
/tags/2014_06_04/classes/ezmlm-php-2.0/services_vpopmail/creation_liste.php |
---|
New file |
0,0 → 1,20 |
<?php |
$repertoire = '/home/vpopmail/domains/'.$domaine.'/'.$liste ; |
$fichier_qmail = '/home/vpopmail/domains/'.$domaine.'/.qmail-'.$liste ; |
// Transformation de ma chaine $parametres ((de aBud en -a -B -u -D) |
$para = '' ; |
for ($i = 0; $i < count ($parametres); $i++) { |
$para .= '-'.$parametres.' ' ; |
} |
echo exec ('ezmlm-make '.$para.' '.$repertoire.' '.$fichier_qmail.' '.$liste.' '.$domaine, $output, $ret) ; |
echo "\n" ; |
echo exec ('ezmlm-reply-to '.$domaine.' '.$liste) ; |
echo "\n" ; |
?> |
/tags/2014_06_04/classes/ezmlm-php-2.0/services_vpopmail/ajout_abonne.php |
---|
New file |
0,0 → 1,6 |
<?php |
$repertoire = '/home/vpopmail/domains/'.$domaine.'/'.$liste ; |
echo exec ('/usr/local/bin/ezmlm-sub '.$repertoire.' '.$mail, $output, $ret) ; |
?> |
/tags/2014_06_04/classes/ezmlm-php-2.0/services_vpopmail/ajout_moderateur.php |
---|
New file |
0,0 → 1,7 |
<?php |
$repertoire = '/home/vpopmail/domains/'.$domaine.'/'.$liste.'/mod' ; |
echo exec ('ezmlm-sub '.$repertoire.' '.$mail, $output, $ret) ; |
echo 'ezmlm-sub '.$repertoire.' '.$mail ; |
?> |
/tags/2014_06_04/classes/ezmlm-php-2.0/ezmlm-errors.def |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/tags/2014_06_04/classes/ezmlm-php-2.0/ezmlm-errors.def |
---|
New file |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/tags/2014_06_04/classes/ezmlm-php-2.0/README |
---|
New file |
0,0 → 1,131 |
ezmlm-php 2.0 |
Nov 13, 2002 |
http://www.unixpimps.org/software/ezmlm-php |
ezmlm-php is a group of files written in php that allow you to fetch messages |
from a ezmlm mailing list archive via a web page. It is fully customizable so |
it can fit into an existing layout design very well, it is also self contained |
so that you can run it with no existing site setup. |
The new version has been rewritten from the ground up to exclude all external |
dependancies (except one which comes with the source, see makehash later on) |
and now implements RFC2045 MIME parsing in pure PHP. |
The system is now also object based to allow greater flexibility within the |
code itself, it also makes the code much more managable and readable. |
INSTALLATION |
~~~~~~~~~~~~ |
*NOTE* |
The installation of ezmlm-php now requires access to a compiler to build the |
included makehash program. See the MAKEHASH section at the end. |
1. Unpack the tarball and copy the files to your webroot in the directory you |
want the list to be accessed from. For example using /home/www/mailinglist |
gzip -d ezmlm-php-2.0.tar.gz |
tar xvf ezmlm-php.2.0.tar |
cd /home/www/mailinglist |
cp ~/ezmlm-php-2.0/*.php . |
cp ~/ezmlm-php-2.0/*.def . |
2. Build the included makehash program. |
cd ~/ezmlm-php-2.0 |
gzip -d makehash.tar.gz |
tar xvf makehash.tar |
cd makehash |
make |
If you do not have compiler access check the binaries directory in the |
makehash.tar file as there are some common binaries there. If you build |
makehash on a new platform please feel free to submit the binary for |
inclusion. |
3. Move the resulting binary to your webroot. |
4. Edit ezmlm.php and change the user configurable options. Search for |
USER-CONFIG to find where to edit. See CONFIGURATION below. |
5. Access www.yoursite.com/mailinglist to test the installation. |
CONFIGURATION |
~~~~~~~~~~~~~ |
This section will explain each variable. If you used the last version most |
of these are the exact same. |
Name Meaning |
~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
listdir This variable should be pointed at the root of the ezmlm |
archive. For instance /usr/home/lists/ragga-jungle |
listname The name of the list (everything before the @) |
listdomain The domain name of the list |
tempdir Where to store the cache files. /var/tmp should be fine |
for most installations. /tmp is another choice. |
sendheaders If set to TRUE then ezmlm will generate the nessesary |
page headers. If set to FALSE your header file needs to |
generate them. See 'includebefore' |
sendbody If set to TRUE then ezmlm will generate the <body></body> |
tags. |
sendfooters If set to TRUE then ezmlm will generate the tage needed |
to finish the document. If set to FALSE your footer file |
needs to generate them. See 'includeafter' |
includebefore This is a file that will be included before ezmlm-php |
generates any output. You can have ezmlm-php generate |
the nessesary headers (sendheaders = TRUE) and still |
include a file of your own. The file is included by the |
include_once function. |
includeafter This is the exact same as includebefore except the file |
is included after ezmlm-php has sent all of it's data. |
href This is a string to prepend to the path whenever an |
<a href= tag is generated. This option was added to fix |
the problem of using a <base href= tag. |
prefertype This is the mime type that you wish to send if the |
current message is a multipart message. If this type isn't |
found it defaults to the first part. |
Some examples are: text/html, text/plain, etc... |
showheaders This is an array of the headers to show. You can add or |
remove any valid RFC822 header you wish to this array. |
Some examples: X-Mailer, Message-ID |
(This is case-insensitive) |
msgtemplate This is a file to use as the message template, if blank |
the internal one is used. See the file MSGTEMPLATE for |
more information as it is to much to describe here. |
tablescolours This is an array of colour hex triplets for use when a |
table is generated. For each row that is generated the |
next colour is used, just use a single element if you |
don't want alternating colours. |
(Yes there is a U in colours, the software was written |
in Canada ;) |
thread_subjlen This is an integer that tells the software how many |
characters to allow the subjects when displayed in |
threads or on the info page. This is useful if you |
want to limit subjects to a certain length so that no |
line wrapping occurs. |
MAKEHASH |
~~~~~~~~ |
So what is this little binary you need to build? Simply put it is a small |
little C program to generate the nessesary ezmlm-idx hashes for cross |
referencing authors. In the last version this was done by recursivley doing |
a grep on the /authors directory which isn't very efficient when the list |
subscriber base grows above 1000 or so. This program computes the hash by |
using the same algorithim the software does and speeds things up a lot. |
-FIN- |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/tags/2014_06_04/classes/ezmlm-php-2.0/index.php |
---|
New file |
0,0 → 1,19 |
<?php |
// An even simpler version of the index page than version 1. All the actual work of |
// determining what needs to be included and what needs to be run is now in the main class. |
// Also, 'register_globals' doesn't need to be 'on' anymore. |
require_once("ezmlm.php"); |
$ezmlm = new ezmlm_php(); |
$action = ($_POST['action'] ? $_POST['action'] : ($_GET['action'] ? $_GET['action'] : "list_info")); |
$actionargs = ($_POST['actionargs'] ? $_POST['actionargs'] : ($_GET['actionargs'] ? $_GET['actionargs'] : "")); |
$ezmlm->set_action($action); |
$ezmlm->set_actionargs($actionargs); |
$ezmlm->run(); |
unset($ezmlm); |
?> |
/tags/2014_06_04/classes/ezmlm-php-2.0/ezmlm-listinfo.php |
---|
New file |
0,0 → 1,235 |
<?php |
// $Id: ezmlm-listinfo.php,v 1.3 2007/04/19 15:34:35 neiluj 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; |
$html = '' ; |
$parser = new ezmlm_parser(); |
$parser->listdir = $this->listdir ; |
$html .= '<table class="table_cadre">'."\n"; |
$html .= '<tr><th class="col1">Num</th><th>De</th><th>Sujet</th><th>Date</th></tr>'."\n"; |
$ctc = 0; |
$recent = $parser->recent_msgs(); |
// le tableau recent est de la forme |
// $recent[numero_message][1] sujet |
// $recent[numero_message][2] date en anglais => (22 May 2006) |
// $recent[numero_message][3] le hash de l auteur |
// $recent[numero_message][4] auteur |
$class = array ('ligne_paire', 'ligne_impaire') ; |
while (list($key,$val) = each($recent)) { |
$html .= '<tr class="'.$class[$ctc].'">'."\n"; |
//print '<td>'.$val->nummessage.'</td>' ; |
// $key contient le numero du message tel que dans les fichiers d index par ex 216 |
// on retrouve le nom du repertoire et le nom du fichier |
$decimal = (string) $key; |
if ($key >= 100) { |
$fichier_message = substr($decimal, -2) ; |
$repertoire_message = substr ($decimal, 0, -2) ; |
} else { |
if ($key < 10) { |
$fichier_message = '0'.$key; |
} else { |
$fichier_message = $decimal; |
} |
$repertoire_message = '0'; |
} |
$html .= '<td>'.$key.'</td>' ; |
$html .= '<td>'; |
$from = $val[4]; |
$html .= $this->makelink("action=show_author_msgs&actionargs[]=".$val[3],$this->decode_iso($this->protect_email($from,false))); |
$html .= "</td>\n"; |
$html .= '<td><b>'; |
$actionargs = preg_split("/\//", $val->msgfile); |
$html .= $this->makelink("action=show_msg&actionargs[]=".$repertoire_message. |
"&actionargs[]=".$fichier_message ,$this->decode_iso($val[1])); |
$html .= "</b></td>\n"; |
//print '<td>'.$this->date_francaise($val[2]).'</td>'."\n"; |
$html .= '<td>'.$val[2].'</td>'."\n"; |
$html .= "</tr>\n"; |
$ctc++; |
if ($ctc == 2) { $ctc = 0; } |
} |
$html .= '</table>'."\n"; |
return $html; |
} |
// month = yyyymm |
function show_month ($month) { |
$html = '' ; |
// on ouvre chaque fichier en lecture |
if(!file_exists($this->listdir . '/archive/threads/' . $month)) { |
return false ; |
} |
$numeros_mails_mois = $this->calculerNumMessagesDansMois($month); |
$html .= '<table class="table_cadre">'."\n"; |
$html .= '<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') ; |
if(count($numeros_mails_mois) > 0) { |
$repertoire_premier_mail = (int) (reset($numeros_mails_mois) / 100) ; |
} |
foreach ($numeros_mails_mois as $num_message) { |
$i = $num_message; |
if ($i > 99) { |
$multiplicateur = (int) ($i / 100) ; |
// pour les mails > 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 ; |
if (file_exists($this->listdir.'/archive/'.$repertoire_premier_mail.'/'.$num_message)) { |
$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; |
} |
$html .= '<tr class="'.$class[$ctc].'">'."\n"; |
$html .= '<td>'.($repertoire_premier_mail != 0 ? $repertoire_premier_mail : '').$num_message.'</td><td>'; |
$hash = $this->makehash($mailDecode->headers['from']); |
$html .= $this->makelink("action=show_author_msgs&actionargs[]=". |
$hash,$this->decode_iso($this->protect_email($mailDecode->headers['from'],TRUE))); |
$html .= "</td>\n"; |
$html .= '<td><b>'; |
$actionargs[0] = $repertoire_premier_mail ; |
$actionargs[1] = $num_message ; |
if (count ($actionargs) > 1) { |
$html .= $this->makelink("action=show_msg&actionargs[]=". |
$actionargs[(count($actionargs) - 2)] . |
"&actionargs[]=". |
$actionargs[(count($actionargs) - 1)] ,$this->decode_iso($mailDecode->headers['subject'])); |
} |
$html .= "</b></td>\n"; |
$html .= '<td>'.$this->date_francaise($mailDecode->headers['date']).'</td>'."\n"; |
$html .= "</tr>\n"; |
$ctc++; |
if ($ctc == 2) { $ctc = 0; } |
} |
} |
$html .= '</table>'."\n"; |
return $html; |
} |
private function calculerNumMessagesDansMois($mois) { |
$fd = file_get_contents($this->listdir . '/archive/threads/'.$mois, 'r'); |
$fichier = explode ("\n", $fd) ; |
$premiere_ligne = $fichier[0] ; |
$nb_lignes_fichier = count($fichier); |
$lignes_messages = array(); |
preg_match ('/[0-9]+/', $premiere_ligne, $match) ; |
$numero_premier_mail = $match[0] ; |
$lignes_messages[$numero_premier_mail] = $numero_premier_mail; |
foreach($fichier as $ligne) { |
if(trim($ligne == '')) { continue ;} |
$ligne_tableau = explode(' ', $ligne); |
$num_mail_sujet = explode(':',$ligne_tableau[0]); |
$num_sujet = $num_mail_sujet[1]; |
$fd_sujet = file_get_contents($this->listdir.'/archive/subjects/'.substr($num_sujet,0,2).'/'.substr($num_sujet,2,strlen($num_sujet) - 1), 'r'); |
$premiere_ligne = true; |
$fichier_sujet = explode ("\n", $fd_sujet) ; |
foreach($fichier_sujet as $ligne_sujet) { |
if($premiere_ligne || trim($ligne_sujet) == '') {$premiere_ligne = false; continue; } |
$ligne_tableau_sujet = explode(':', $ligne_sujet); |
$num_mail = $ligne_tableau_sujet[0]; |
$mois_ligne = $ligne_tableau_sujet[1]; |
if($mois_ligne == $mois) { |
if(is_numeric($num_mail)) { |
$lignes_messages[$num_mail] = $num_mail; |
} else { |
$num_mail = preg_replace('/[^0-9]+/','', $num_mail) ; |
$lignes_messages[$num_mail] = $num_mail; |
} |
} |
} |
} |
asort($lignes_messages); |
return $lignes_messages; |
} |
} |
?> |
/tags/2014_06_04/classes/ezmlm-php-2.0/makehash |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/tags/2014_06_04/classes/ezmlm-php-2.0/makehash |
---|
New file |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/tags/2014_06_04/classes/ezmlm-php-2.0/MSGTEMPLATE |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/tags/2014_06_04/classes/ezmlm-php-2.0/MSGTEMPLATE |
---|
New file |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/tags/2014_06_04/classes/ezmlm-php-2.0/ezmlm-threads.php |
---|
New file |
0,0 → 1,492 |
<?php |
// $Id: ezmlm-threads.php,v 1.7 2008-11-19 09:28:46 aperonnet Exp $ |
// |
// ezmlm-threads.php - ezmlm-php v2.0 |
// -------------------------------------------------------------- |
// Builds, maintains & displays thread caches |
// These cache files live in $ezmlm->tmpdir and are serialized |
// php objects that can be unserialized and displayed easily |
// -------------------------------------------------------------- |
require_once("ezmlm.php"); |
require_once("ezmlm-parser.php"); |
require_once ('ezmlm-langue-fr.php'); |
// CLASS: ezmlm_threads will build, maintain & display thread files (even if a thread is only 1 msg) |
class ezmlm_threads extends ezmlm_php { |
// load: this is the main function that should be called. |
// it first checks to see if the cache files are stale, if they are it calls build |
// other wise it loads them and calls display |
function load($month) { |
if (!is_dir($this->tempdir . "/ezmlm-php-" . $this->listname)) { |
$checksum = $this->tempdir . "/ezmlm-php-" . $this->listname . "-" . $month . "-" . "checksum"; |
} else { |
$checksum = $this->tempdir . "/ezmlm-php-" . $this->listname . "/" . $month . "-" . "checksum"; |
} |
$md5 = '' ; |
if (!is_file($checksum)) { |
$this->build($month); |
} else { |
$fd = fopen($checksum,"r"); |
while (!preg_match('/^md5:/', $md5)) { $md5 = fgets($fd,4096); } |
fclose($fd); |
$md5 = rtrim(preg_replace('/^md5:/', '', $md5), "\n"); |
if ($md5 != $this->md5_of_file($this->listdir . "/archive/threads/" . $month)) { |
print "<!-- $md5 ne " . $this->md5_of_file($this->listdir . "/archive/threads/" . $month) . " -->\n"; |
$this->build($month); |
} |
} |
$html = $this->display($month); |
return $html ; |
} |
// display: this loads each cache file sequentially and displays the messages in them |
// there is no checking of checksum's done here so load() is the preferred method to |
// view the threads |
function display($month) { |
$html = '' ; |
$seq = 0; |
if (!is_dir($this->tempdir . "/ezmlm-php-" . $this->listname)) { |
$cache = $this->tempdir . "/ezmlm-php-" . $this->listname . "-" . $month; |
} else { |
$cache = $this->tempdir . "/ezmlm-php-" . $this->listname . "/" . $month; |
} |
// Le lien par date et par thread |
$html .= '[ '.$this->makelink('action=show_month&actionargs[]='.$month, 'par date').' ]' ; |
$months = array(1 => 'January', 2 => 'February', 3 => 'March', 4 => 'April', 5 => 'May', 6 => 'June', 7 => 'July', 8 => 'August', |
9 => 'September', 10 => 'October', 11 => 'November', 12 => 'December'); |
// remplacé par le tableau globals $mois dans ezmlm.php |
$html .= '<h2>'.FIL_DE_DISCUSSION.' pour '.$GLOBALS['mois'][((int)substr($month,4,2) / 1) -1] .', ' . substr($month,0,4) . '</h2>'."\n"; |
$html .= '<table class="table_cadre">'."\n"; |
$html .= '<tr><th>Num</th><th>De</th><th>Sujet</th><th>Date</th></tr>'."\n"; |
$html .= '<tr><td colspan="3"><hr /></td></tr>'."\n"; |
$ctc .= 0; |
if (is_file($cache)) { |
$html .= file_get_contents($cache); |
} |
$html .= '<tr><td colspan="3"></td></tr>'."\n"; |
$html .= '</table>'."\n"; |
return $html ; |
} |
function thread_to_html($thread) { |
$html = ''; |
$lastdepth = -1; |
$ctc = 0 ; |
$thread_curr = $thread; |
$class = array ('ligne_paire', 'ligne_impaire') ; |
while ($thread_curr != NULL) { |
preg_match ('!/archive/([0-9]*)/([0-9]*)!', $thread_curr->file, $match) ; |
if (!isset($GLOBALS['fichiers_analyses'][$match[1]][$match[2]])) { |
$message = file_get_contents($this->listdir . "/archive/" . $msgdir . "/" . $msgfile) ; |
$mimeDecode = new Mail_mimeDecode($message) ; |
$mailDecode = $mimeDecode->decode() ; |
//$msg = new ezmlm_parser(); |
//$msg->parse_file($this->listdir . $thread_curr->file, TRUE); |
} else { |
$mailDecode = $GLOBALS['fichiers_analyses'][$match[1]][$match[2]] ; |
} |
$actionargs = preg_split("/\//", $thread_curr->file); |
$html .= '<tr class="'.$class[$ctc].'">'."\n"; |
$html .= '<td>'.$actionargs[2].$actionargs[3].'</td><td>'; |
$html .= $this->makelink('action=show_author_msgs&actionargs[]='. |
$this->makehash($this->decode_iso($mailDecode->headers['from'])),$this->decode_iso($this->protect_email($mailDecode->headers['from'],TRUE))); |
$html .= '</td>'."\n"; |
$html .= '<td><b>'; |
//$html .= " <a name=\"" . urlencode($thread_curr->file) . "\">"; A quoi ça sert ? |
for ($i = 0; $i < $thread_curr->depth; $i++) { |
$html .= " "; |
} |
if (($this->thread_subjlen > 0) and (strlen($this->decode_iso($mailDecode->headers['subject'])) > $this->thread_subjlen)) { |
$subject = substr($this->decode_iso($mailDecode->headers['subject']), 0, ($this->thread_subjlen - 3 - ($thread_curr->depth * 2))); |
$subject = $subject . "..."; |
} else { |
$subject = $this->decode_iso($mailDecode->headers['subject']); |
} |
$subject = preg_replace("/\[" . $this->listname . "\]/", "", $subject); |
$html .= $this->makelink("action=show_msg&actionargs[]=" . $actionargs[2] . "&actionargs[]=" . $actionargs[3], $subject); |
$html .= "</b></td>\n"; |
$html .= '<td>' .$this->date_francaise($mailDecode->headers['date']).'</td>'."\n"; |
$html .= "</tr>\n"; |
$ctc++; |
if ($ctc == count($this->tablecolours)) { $ctc = 0; } |
$lastdepth = $thread_curr->depth; |
$thread_curr = $thread_curr->next; |
} |
$html .= '<tr><td colspan="3"><hr noshade size="1" /></td></tr>'."\n"; |
return $html; |
} |
// TODO: Fonction à tester et compléter |
// Construit un index de tous les messages envoyés dans une liste donnée pour un mois |
// au format YYYYMM |
/* // commenté sur le serveur |
function build_month_list($date) |
{ |
$months = array(1 => 'Jan', 2 => 'Feb', 3 => 'Mar', 4 => 'Apr', 5 => 'May', 6 => 'Jun', 7 => 'Jul', 8 => 'Aug', |
9 => 'Sep', 10 => 'Oct', 11 => 'Nov', 12 => 'Dec'); |
$month = $months[((int)substr($month,4,2) / 1) -1] ; |
$year = substr($month,0,4) ; |
$numArchive = $this->getNumArchive(); |
$dernierRepertoire = floor($numArchive / 100); |
$threads = array(); |
for ($rep_courant = $dernierRepertoire; $rep_courant >= 0; $rep_courant--) { |
$fichier_index = file ($this->listdir.'/archive/'.$rep_courant.'/index', FILE_IGNORE_NEW_LINES); |
// On parcourt le fichier a l envers |
for ($j = count($fichier_index)-1; $j >= 0; $j-=2) { |
$match = strpos($fichier_index[$j],$month.' '.$year) ; |
if ($match) { |
$threads[] = $fichier_index[$j-1] ; |
} |
} |
} |
} |
*/ |
// build: takes one argument in the format YYYYMM and builds the thread cache file |
// for that month if the ezmlm thread file exists. The resulting cache file is then |
// stored in $this->tmpdir; |
function build($month) { |
if (!is_file($this->listdir . "/archive/threads/" . $month)) { return FALSE; } |
if (!is_dir($this->tempdir . "/ezmlm-php-" . $this->listname)) { |
$fd2 = fopen($this->tempdir . "/ezmlm-php-" . $this->listname . "-" . $month,"w+"); |
} else { |
$fd2 = fopen($this->tempdir . "/ezmlm-php-" . $this->listname . "/" . $month,"w+"); |
} |
fclose($fd2); |
$i=0; |
// ouverture du fichier thread de ezmlm |
// Ils sont classés mois par mois |
$fd1 = fopen($this->listdir . "/archive/threads/" . $month, "r"); |
while (!feof($fd1)) { |
$line = fgets($fd1,4096); |
if (preg_match('/^[0-9]*\:[a-z]* \[.*/', $line)) { |
// valid ezmlm thread file entry |
// On place dans $subjectfile le chemin vers le fichier sujet |
$subjectfile = preg_replace("/^[0-9]*\:([a-z]*) \[.*/", "\\1", $line); |
$subjectfile = substr($subjectfile,0,2) . '/' . substr($subjectfile,2,18); |
$thread_head = NULL; |
$thread_curr = NULL; |
$thread_temp = NULL; |
$thread_depth = 1; |
if (!is_file($this->listdir . "/archive/subjects/" . $subjectfile)) { continue; } |
// on ouvre le fichier sujet |
// Celui-ci contient sur la première ligne le hash du sujet puis le sujet |
// sur les autres lignes : |
// num_message:annéemois:hash_auteur nom_auteur |
$fd2 = fopen($this->listdir . "/archive/subjects/" . $subjectfile, "r"); |
while (!feof($fd2)) { |
$line2 = fgets($fd2,4096); |
if (preg_match('/^[0-9]/',$line2)) { |
$msgnum = preg_replace('/^([0-9]*):.*/', '\\1', $line2); |
$msgfile = $msgnum % 100; |
$msgdir = (int)($msgnum / 100); |
if ($msgfile < 10) { $msgfile = "0" . $msgfile; } |
//$msg = new ezmlm_parser(); |
//$msg->parse_file_headers($this->listdir . "/archive/" . $msgdir . "/" . $msgfile, TRUE); |
$message = file_get_contents($this->listdir . "/archive/" . $msgdir . "/" . $msgfile) ; |
$mimeDecode = new Mail_mimeDecode($message) ; |
$mailDecode = $mimeDecode->decode() ; |
// On stocke le fichier analysée pour réutilisation ultàrieure |
$GLOBALS['fichiers_analyses'][$msgdir][$msgfile] = $mailDecode ; |
$msgid = (isset ($mailDecode->headers['message-id']) ? $mailDecode->headers['message-id'] : ''); |
$inreply = (isset($mailDecode->headers['in-reply-to']) ? $mailDecode->headers['in-reply-to'] : ''); |
$references = (isset ($mailDecode->headers['references']) ? $mailDecode->headers['references'] : '') ; |
$thread_depth = 1; |
if ($thread_head == NULL) { |
$thread_head = new ezmlm_thread(0,'/archive/' . $msgdir . '/' . $msgfile,$msgid); |
} else { |
$thread_curr = new ezmlm_thread($depth,'/archive/' . $msgdir . '/' . $msgfile,$msgid); |
if ($inreply != '') { $thread_curr->inreply = $inreply; } |
if ($references != '') { $thread_curr->references = $references; } |
$thread_head->append($thread_curr); |
} |
} |
} |
fclose($fd2); |
// so now after all that mess $thread_head contains a full thread tree |
// first build the depth of each message based on 'in-reply-to' and 'references' |
unset($thread_temp); |
$thread_temp = NULL; |
$thread_curr =& $thread_head->next; |
while (get_class($thread_curr) == 'ezmlm_thread') { |
unset($thread_temp); |
$thread_temp = NULL; |
if ($thread_curr->inreply != '') { $thread_temp =& $thread_head->find_msgid($thread_curr->inreply); } |
if ($thread_temp == NULL) { |
if ($thread_curr->references != '') { |
$refs = preg_split('/ /', $thread_curr->references); |
$refs = array_pop($refs); |
$thread_temp =& $thread_head->find_msgid($refs); |
} |
} |
if ($thread_temp == NULL) { |
// we couldn't find anything... set depth to 1, the default |
$thread_curr->depth = 1; |
} else { |
// we found a reference, set it to it's depth + 1 |
$thread_curr->depth = $thread_temp->depth + 1; |
} |
$thread_curr =& $thread_curr->next; |
} |
// now write it to a temp file named MONTH-SEQ where seq is cronologic sequence order of the thread. |
if (!is_dir($this->tempdir . "/ezmlm-php-" . $this->listname)) { |
@mkdir($this->tempdir . "/ezmlm-php-" . $this->listname, 0755); |
if (!is_dir($this->tempdir . "/ezmlm-php-" . $this->listname)) { |
$fd2 = fopen($this->tempdir . "/ezmlm-php-" . $this->listname . "-" . $month, "a"); |
} else { |
$fd2 = fopen($this->tempdir . "/ezmlm-php-" . $this->listname . "/" . $month, "a"); |
} |
} else { |
$fd2 = fopen($this->tempdir . "/ezmlm-php-" . $this->listname . "/" . $month, "a"); |
} |
fputs($fd2,$this->thread_to_html($thread_head)); |
fclose($fd2); |
} |
} |
// finally store our checksum |
if (!is_dir($this->tempdir . "/ezmlm-php-" . $this->listname)) { |
$fd2 = fopen($this->tempdir . "/ezmlm-php-" . $this->listname . "-" . $month . "-" . "checksum","w+"); |
} else { |
$fd2 = fopen($this->tempdir . "/ezmlm-php-" . $this->listname . "/" . $month . "-" . "checksum","w+"); |
} |
fputs($fd2,"md5:" . $this->md5_of_file($this->listdir . "/archive/threads/" . $month) . "\n"); |
fclose($fd2); |
fclose($fd1); |
return TRUE; |
} |
// listmessages: prints out a nice little calendar and displays the message |
// totals for each month. The link jumps to the thread listing. |
// On lit le repertoire archive/threads/ qui contient un fichier par mois avec tous les thread, par sujet |
// Presentes comme suit |
// num_thread:hash [taille_du_thread] Sujet du thread (le dernier) |
// les messages sont ranges par leur numero |
function listmessages() { |
if (!is_dir($this->listdir . "/archive/threads/")) { |
return false ; |
} |
$res = '<table id="petit_calendrier">'."\n"; |
$res .= " <tr>\n"; |
$res .= " <td></td>" ; |
foreach ($GLOBALS['mois'] as $valeur) $res .= '<th>'.$valeur.'</th>' ; |
$res .=" </tr>\n"; |
$res .= $this->calendrierMessage(); |
$res .= "</table>\n"; |
return $res; |
/* |
$threadcount = array(); |
$repertoire_archive = opendir($this->listdir . "/archive/"); |
$tableau_annee = array(); |
while (false !== ($item = readdir($repertoire_archive))) { |
// $item contient les noms des repertoires |
// on ne garde que ceux qui sont des chiffres |
if (preg_match('/[0-9]+/', $item)) { |
// on ouvre le fichier d index de chaque repertoire |
$fichier_index = fopen($this->listdir.'/archive/'.$item.'/index', 'r'); |
$compteur = 0 ; |
while (!feof($fichier_index)) { |
// On ignore la premiere ligne |
$temp = fgets($fichier_index, 4096); |
// dans la seconde on recupere la date |
$temp = fgets($fichier_index, 4096); |
preg_match('/\t([0-9]+) ([a-zA-Z][a-zA-Z][a-zA-Z]) ([0-9][0-9][0-9][0-9])/', $temp, $match) ; |
if ($match[0] != '') { |
$threadmonth = date('n', strtotime($match[0])) ; |
$threadyear = date('Y', strtotime($match[0])) ; |
$threadcount[$threadyear][$threadmonth]++; |
if (!in_array($threadyear, $tableau_annee)) array_push ($tableau_annee, $threadyear); |
} |
} |
fclose ($fichier_index); |
} |
} |
if (count($threadcount) == 0) return 'Il n\y a pas de messages dans les archives'; |
// La partie qui suit, simple, cree la table avec le nombre de message echange chaque mois |
$res = '<table id="petit_calendrier">'."\n"; |
$res .= " <tr>\n"; |
$res .= " <td></td>" ; |
foreach ($GLOBALS['mois'] as $valeur) $res .= '<th>'.$valeur.'</th>' ; |
$res .=" </tr>\n"; |
arsort($tableau_annee); |
foreach ($tableau_annee as $annee) { |
$res .= " <tr>\n"; |
$res .= ' <td class="col_annee">'.$annee.'</td>'; |
for ($i = 1; $i <= 12; $i++) { |
$res .= '<td class="mois">'; |
if (isset($threadcount[$annee][$i]) && $threadcount[$annee][$i] > 0) { |
$res .= $this->makelink('action=show_month&actionargs[]='.$annee.($i < 10 ? '0'.$i:$i),$threadcount[$annee][$i]); |
} |
$res .= '</td>'; |
} |
$res .= '</tr>'."\n"; |
} |
$res .= "</table>\n"; |
return $res ; |
*/ |
} |
/* |
* Cree un fichier liste.calendrierPermanent qui contient |
* le nombre de message par mois pour toutes les annees |
* depuis le debut de la liste sauf la derniere |
* |
*/ |
function calculeCalendrierPermanent($Annnee = '') { |
$numArchive = $this->getNumArchive(); |
$dernierRepertoire = floor($numArchive / 100); |
$threadcount = array(); |
$tableau_annee = array(); |
for ($rep_courant = $dernierRepertoire; $rep_courant >= 0; $rep_courant--) { |
$fichier_index = file ($this->listdir.'/archive/'.$rep_courant.'/index', FILE_IGNORE_NEW_LINES); |
// On parcours le fichier a l envers |
for ($j = count($fichier_index)-1; $j >= 0; $j-=2) { |
preg_match('/\t([0-9]+) ([a-zA-Z]{3}) ([0-9]{4})/', $fichier_index[$j], $match) ; |
if ($match[0] != '') { |
$threadmonth = date('n', strtotime($match[0])); |
$threadyear = date('Y', strtotime($match[0])); |
if ($Annnee != '') { |
if ($threadyear < date('Y')) { |
$sortir = true; |
break; |
} |
} else { |
if ($threadyear == date('Y')) continue; |
} |
$threadcount[$threadyear][$threadmonth]++; |
if (!in_array($threadyear, $tableau_annee)) array_push ($tableau_annee, $threadyear); |
} |
} |
if ($sortir) break; |
} |
$res = ''; |
arsort($tableau_annee); |
foreach ($tableau_annee as $annee) { |
$res .= " <tr>\n"; |
$res .= ' <td class="col_annee">'.$annee.'</td>'; |
for ($i = 1; $i <= 12; $i++) { |
$res .= '<td class="mois">'; |
if (isset($threadcount[$annee][$i]) && $threadcount[$annee][$i] > 0) { |
$res .= $this->makelink('action=show_month&actionargs[]='.$annee.($i < 10 ? '0'.$i:$i),$threadcount[$annee][$i]); |
} |
$res .= '</td>'; |
} |
$res .= '</tr>'."\n"; |
} |
return $res; |
} |
function ecrireFichierCalendrier() { |
$html = $this->calculeCalendrierPermanent(); |
$f = fopen ('tmp/'.$this->listname.'.calendrier', 'w') ; |
fwrite ($f, $html); |
fclose($f); |
return $html; |
} |
function calendrierMessage() { |
$html = ''; |
// On ajoute la derniere annee |
$html .= $this->calculeCalendrierPermanent(date ('Y')); |
if (! $this->isFichierCalendrierExiste()) return $html . $this->ecrireFichierCalendrier(); |
// S'il existe mais qu il est trop vieux, il faut le recalculer et le réécrire |
if ($this->isDoitRecalculerCalendrier()) return $html . $this->ecrireFichierCalendrier(); |
// précédemment, dans ce cas ci-dessus |
// était effectuée un recalcul partiel, mais sans réécriture du fichier: |
/* $annees = $this->getAnneesARecalculer(); |
$html .= $this->calculeCalendrierPermanent($annees); */ |
return $html . file_get_contents('tmp/'.$this->listname.'.calendrier'); |
} |
function isFichierCalendrierExiste() { |
if (file_exists('tmp/'.$this->listname.'.calendrier')) { |
return true; |
} |
return false; |
} |
function isDoitRecalculerCalendrier() { |
return (date ('Y', filemtime('tmp/'.$this->listname.'.calendrier')) <= date('Y') - 1); |
} |
function getAnneesARecalculer() { |
// On suppose que l index de ezmlm est correct |
$anneeFichierCalendrier = date ('Y', filemtime('tmp/'.$this->listname.'.calendrier')); |
return $anneeFichierCalendrier + 1; |
} |
} |
// CLASS: ezmlm-thread is a quick little class to allow us to define |
// a structure of the current thread in a single-linked list. |
// it's a little messy since php doesn't support pointers like C does |
// so we have to use references and a head object to append to the list. |
class ezmlm_thread { |
var $next; |
var $depth; |
var $file; |
var $msgid; |
var $inreply; |
var $references; |
function append($thread) { |
$thread_curr =& $this; |
while ($thread_curr->next != NULL) { |
$thread_curr =& $thread_curr->next; |
} |
$thread_curr->next = $thread; |
} |
function &find_msgid($msgid) { |
$thread_curr =& $this; |
while ($thread_curr->next != NULL) { |
if (trim($thread_curr->msgid) == trim($msgid)) { return $thread_curr; } |
$thread_curr =& $thread_curr->next; |
} |
return NULL; |
} |
function ezmlm_thread($depth,$file,$msgid) { |
$this->depth = $depth; |
$this->file = $file; |
$this->msgid = $msgid; |
$this->next = NULL; |
} |
} |
?> |
/tags/2014_06_04/classes/ezmlm-php-2.0/ezmlm-msgdisplay.php |
---|
New file |
0,0 → 1,396 |
<?php |
// $Id: ezmlm-msgdisplay.php,v 1.11 2008-11-19 09:28:46 aperonnet Exp $ |
// |
// ezmlm-msgdisplay.php - ezmlm-php v2.0 |
// -------------------------------------------------------------- |
// Will parse a template (if specified) and display a message. |
// Includes a default template. |
// -------------------------------------------------------------- |
require_once("ezmlm.php"); |
require_once("Mail/mimeDecode.php") ; |
class ezmlm_msgdisplay extends ezmlm_php { |
// our template |
var $msgtmpl; |
var $message_rendu ; |
var $_auth ; |
// display: parses a message (using ezmlm_parser) and displays it |
// using a template |
var $msgfile; |
function display($msgfile) { |
if (!is_file($msgfile)) { |
if (is_file($this->listdir . "/" . $msgfile)) { $msgfile = $this->listdir . "/" . $msgfile; } |
else if (is_file($this->listdir . "/archive/" . $msgfile)) { $msgfile = $this->listdir . "/archive/" . $msgfile; } |
else { return FALSE; } |
} |
$this->msgfile = $msgfile ; |
$message = file_get_contents($msgfile) ; |
// En cours de codage |
// La fonction display retourne tout simplement le source du mail |
// Il n'y a plus d'analyse a ce niveau |
return $message; |
$mimeDecode = new Mail_mimeDecode($message) ; |
$mailDecode = $mimeDecode->decode(array('decode_bodies' => 'true', 'include_bodies' => 'true')) ; |
// $msg->msgfile contient le chemin du fichier du mail en partant de la racine |
// Le point d'exclamation est le delimiteur de l'expression reguliere |
$relfile = preg_replace('!' . $this->listdir . '!', '', $msgfile); |
$a1 = preg_replace('!/archive/(.*)/.*$!', '\1', $relfile); // $a1 contient le nom du repertoire |
$a2 = preg_replace('!/archive/.*/(.*)$!', '\1', $relfile); // $a2 contient le nom du fichier |
if (isset($mailDecode->headers['date'])) $msgtime = strtotime(preg_replace ('/CEST/', '', $mailDecode->headers['date'])); |
$threadidx = date("Ym", $msgtime); |
if ($a2 <= 10) $numero_precedent = '0'.($a2 - 1) ; else $numero_precedent = ($a2 - 1) ; |
if ($a2 < 9) $numero_suivant = '0'.($a2 + 1) ; else $numero_suivant = ($a2 + 1); |
// On teste si le message suivant existe |
$decoupe = explode ('/', $msgfile) ; |
// Les nom de fichiers sont du format : |
// archive/0/01 |
// archive/0/02 ... 0/99 archive/1/01 ... |
$nom_fichier = $decoupe[count($decoupe)-1] ; |
$nom_repertoire = $decoupe[count($decoupe)-2] ; |
$repertoire_suivant = $nom_repertoire ; $repertoire_precedent = $nom_repertoire ; |
if ($nom_fichier > 8) { |
$fichier_suivant = $nom_fichier + 1 ; |
if ($nom_fichier == 99) { |
$fichier_suivant = '01' ; |
$repertoire_suivant = $nom_repertoire + 1 ; |
} |
} else { |
$fichier_suivant = '0'.($nom_fichier + 1) ; |
} |
if ($nom_fichier > 10) { |
$fichier_precedent = $nom_fichier - 1 ; |
} else { |
if ($nom_fichier == '01') { |
$fichier_precedent = '99' ; |
$repertoire_precedent = $nom_repertoire - 1 ; |
} else { |
$fichier_precedent = '0'.($nom_fichier - 1) ; |
} |
} |
print $this->parse_entete_mail($mailDecode) ; |
$this->parse_template($mailDecode, $a2, $a1); |
print $this->message_rendu; |
//print '</div>' ; |
} |
/** |
* Renvoie les infos des messages suivants |
* |
* |
*/ |
function getInfoSuivant() { |
$relfile = preg_replace('!' . $this->listdir . '!', '', $this->msgfile); |
$nom_repertoire = preg_replace('!/archive/(.*)/.*$!', '\1', $relfile); |
$nom_fichier = preg_replace('!/archive/.*/(.*)$!', '\1', $relfile); |
$repertoire_suivant = $nom_repertoire; |
// On recupere le numero du dernier message |
if (file_exists($this->listdir.'/archnum')) { |
$numero_dernier_message = file_get_contents($this->listdir.'/archnum'); |
} |
// a partir du nom du fichier |
// et du nom du repertoire, on reconstitue |
// le numero du message stocke dans le fichier d index |
// le message 12 du repertoire 2 a le numero 212 |
if ($nom_repertoire == '0') { |
$numero_message = $nom_fichier; |
} else { |
$numero_message = $nom_repertoire.$nom_fichier ; |
} |
// On ouvre le fichier d index |
$fichier_index = fopen ($this->listdir.'/archive/'.$nom_repertoire.'/index', 'r'); |
$compteur_ligne = 1; |
if (preg_match ('/0([1-9][0-9]*)/', $nom_fichier, $match)) { |
$nom_fichier = $match[1]; |
$prefixe = '0' ; |
} else { |
$prefixe = '' ; |
} |
$prefixe = $this->prefixe_nom_message($nom_fichier); |
//echo $numero_message; |
// on cherche la ligne avec le numero du message |
while (!feof($fichier_index)) { |
$temp = fgets($fichier_index,4096); |
$x = preg_match('/(\d+): (\w+) (.*)/', $temp, $matches); |
array_shift($matches); |
list($num, $hash, $sujet) = $matches; |
if ($num == $numero_message) { |
$ligne_message_precedent = $compteur_ligne -2; |
$temp = fgets($fichier_index, 4096); |
$temp = fgets($fichier_index, 4096); |
list ($fichier_suivant,$hash, $sujet) = split(':', $temp); |
// Au cas ou est au dernier message du fichier d index |
// il faut ouvrir le suivant |
if (feof($fichier_index)) { |
$repertoire_suivant++; |
if (file_exists($this->listdir.'/archive/'.$repertoire_suivant.'/index')) { |
$fichier_index_suivant = fopen($this->listdir.'/archive/'.$repertoire_suivant.'/index', 'r'); |
// on recupere le numero du premier message |
list($fichier_suivant, $hash, $sujet) = split (':', fgets($fichier_index_suivant), 4096); |
fclose ($fichier_index_suivant); |
} |
} |
// Si le numero est > 100, il faut decouper et ne retenir |
// que les dizaines et unites |
if ($fichier_suivant >= 100) { |
$decimal = (string) $fichier_suivant; |
$numero = substr($decimal, -2) ; |
$fichier_suivant = $numero ; |
} else { |
if ($fichier_suivant <= 9)$fichier_suivant = '0'.$fichier_suivant; |
} |
break; |
} |
// On avance d une ligne, la 2e ligne contient date hash auteur |
$temp2 = fgets($fichier_index, 4096); |
$compteur_ligne += 2; |
} |
// On utilise $ligne_message_precedent pour recupere le num du message precedent |
// Si $ligne_precedent est negatif soit c le premier message de la liste |
// soit il faut ouvrir le repertoire precedent |
if ($ligne_message_precedent > 0) { |
$compteur = 1; |
rewind($fichier_index); |
while (!feof($fichier_index)) { |
$temp = fgets($fichier_index, 4096); |
if ($ligne_message_precedent == $compteur) { |
list ($fichier_precedent, $hash, $sujet) = split (':', $temp) ; |
} |
$compteur++; |
} |
// Le nom du repertoire precedent est le meme que le repertoire courant |
$repertoire_precedent = $nom_repertoire ; |
// Si $ligne_message_precedent est negatif, alors il faut ouvrir |
// le fichier index du repertoire precedent |
// si le nom du repertoire est 0, alors il n y a pas de repertoire precedent |
// et donc pas de message precedent |
} else { |
if ($nom_repertoire != '0') { |
$repertoire_precedent = $nom_repertoire -1 ; |
// on ouvre le fichier d index et on extraie le numero |
// du dernier message |
$fichier_index_precedent = fopen ($this->listdir.'/archive/'.$repertoire_precedent.'/index', 'r') ; |
while (!feof($fichier_index_precedent)) { |
$temp = fgets($fichier_index_precedent,4096); |
$ligne = split (':', $temp) ; |
if ($ligne[0] != '') $fichier_precedent = $ligne[0]; |
$temp = fgets($fichier_index_precedent,4096); |
} |
fclose ($fichier_index_precedent); |
// on se situe dans le repertoire 0 donc pas de message precedent |
} else { |
$fichier_precedent = null; |
$repertoire_precedent = null; |
} |
} |
if ($fichier_precedent > 100) { |
$decimal = (string) $fichier_precedent; |
$numero = substr($decimal, -2) ; |
$fichier_precedent = $numero ; |
} else { |
if ($fichier_precedent < 10 )$fichier_precedent = '0'.$fichier_precedent; |
} |
fclose ($fichier_index); |
//if ($fichier_precedent != null && $fichier_precedent < 10) $fichier_precedent = '0'.$fichier_precedent; |
return array ('fichier_suivant' => $fichier_suivant, |
'repertoire_suivant' => $repertoire_suivant, |
'fichier_precedent' => $fichier_precedent, |
'repertoire_precedent' => $repertoire_precedent); |
} |
/** |
* analyse l'entete d'un mail pour en extraire les entête |
* to, from, subject, date |
* met à jour la variable $this->msgtmpl |
* |
*/ |
function parse_entete_mail (&$mailDecode) { |
$startpos = strpos(strtolower($this->msgtmpl_entete), '<ezmlm-headers>'); |
$endpos = strpos(strtolower($this->msgtmpl_entete), '</ezmlm-headers>'); |
$headers = substr($this->msgtmpl_entete,$startpos + 15,($endpos - $startpos - 15)); |
$headers_replace = '' ; |
for ($i = 0; $i < count($this->showheaders); $i++) { |
$val = $this->showheaders[$i]; |
$headers_replace .= $headers; |
$hnpos = strpos(strtolower($headers_replace), '<ezmlm-header-name>'); |
$headers_replace = substr_replace($headers_replace, $this->header_en_francais[$val], $hnpos, 19); |
$hvpos = strpos(strtolower($headers_replace), '<ezmlm-header-value'); |
$headers_replace = $this->decode_iso ($headers_replace) ; |
switch ($val) { |
case 'date': |
$headers_replace = substr_replace($headers_replace, $this->date_francaise($mailDecode->headers[strtolower($val)]), $hvpos, 20); |
break; |
case 'from': |
if ($mailDecode->headers[strtolower($val)] == '') $from = $mailDecode->headers['return-path'] ; |
else $from = $mailDecode->headers['from']; |
$headers_replace = substr_replace($headers_replace, $this->protect_email($this->decode_iso($from)), $hvpos, 20); |
//$headers_replace = htmlspecialchars($headers_replace); |
break; |
default: |
$headers_replace = substr_replace($headers_replace, $this->protect_email($this->decode_iso($mailDecode->headers[strtolower($val)])), $hvpos, 20); |
} |
} |
return substr_replace($this->msgtmpl_entete, $headers_replace, $startpos, (($endpos + 16) - $startpos)); |
} |
function parse_template(&$mailDecode, $numero_mail, $numero_mois, $num_part = '') { |
static $profondeur = array(); |
if ($num_part != '') array_push ($profondeur, $num_part) ; |
$corps = '' ; |
if ($mailDecode->ctype_primary == 'multipart') { |
include_once PROJET_CHEMIN_CLASSES.'type_fichier_mime.class.php' ; |
for ($i = 0; $i < count($mailDecode->parts); $i++) { |
switch ($mailDecode->parts[$i]->ctype_secondary) { |
case 'plain' : |
if ($mailDecode->parts[$i]->headers['content-transfer-encoding'] == '8bit') { |
$corps .= $this->_cte_8bit($mailDecode->parts[$i]->body); |
} else if ($mailDecode->parts[$i]->headers['content-transfer-encoding'] == 'quoted-printable') { |
if ($mailDecode->parts[$i]->ctype_parameters['charset'] == 'UTF-8') { |
$corps .= utf8_decode($mailDecode->parts[$i]->body); |
} |
} |
break; |
case 'html' : $corps .= trim(strip_tags ($mailDecode->parts[$i]->body, '<br><p><a><style>')); |
break ; |
case 'mixed' : |
case 'rfc822' : |
case 'alternative' : |
case 'appledouble' : |
$this->parse_template($mailDecode->parts[$i], $numero_mail, $numero_mois, $i) ; |
break ; |
case 'applefile' : continue ; |
break ; |
default : |
if ($mailDecode->parts[$i]->ctype_secondary == 'octet-stream') { |
$nom_piece_jointe = $mailDecode->parts[$i]->ctype_parameters['name'] ; |
$tab = explode ('.', $nom_piece_jointe) ; |
$extension = $tab[count ($tab) - 1] ; |
$mimeType = type_fichier_mime::factory($extension); |
$mimeType->setCheminIcone(PROJET_CHEMIN_ICONES) ; |
} else { |
$nom_piece_jointe = isset ($mailDecode->parts[$i]->d_parameters['filename']) ? |
$mailDecode->parts[$i]->d_parameters['filename'] : $mailDecode->parts[$i]->ctype_parameters['name'] ; |
$mimeType = new type_fichier_mime( $mailDecode->parts[$i]->ctype_primary.'/'. |
$mailDecode->parts[$i]->ctype_secondary, PROJET_CHEMIN_ICONES) ; |
} |
$lien = PROJET_CHEMIN_APPLI.'fichier_attache.php?nom_liste='.$this->listname. |
'&actionargs[]='.$numero_mois. |
'&actionargs[]='.$numero_mail; |
if (count ($profondeur) > 0) { |
array_shift($profondeur) ; |
for ($j= 0; $j < count ($profondeur); $j++) $lien .= '&actionargs[]='.$profondeur[$j]; |
} |
$lien .= '&actionargs[]='.$i ; |
$corps .= '<a href="'.$lien.'">'; |
$corps .= '<img src="'.$mimeType->getCheminIcone().'" alt="'.$nom_piece_jointe.'" /> ' ; |
if ($mailDecode->parts[$i]->ctype_secondary == 'jpg' || $mailDecode->parts[$i]->ctype_secondary == 'jpeg') |
$corps .= '<img src="'.$lien.'" alt="'.$nom_piece_jointe.'" /> ' ; |
$corps .= $nom_piece_jointe; |
$corps .= '</a><br />' ; |
break ; |
} |
} |
$this->message_rendu .= preg_replace('/<ezmlm-body>/i', $this->cleanup_body($corps,TRUE), $this->msgtmpl); |
} else if ($mailDecode->ctype_primary == 'message') { |
$this->message_rendu .= "\n".'<div class="message">'.$this->parse_entete_mail($mailDecode->parts[0]); |
$corps .= $this->parse_template($mailDecode->parts[0], $numero_mail, $numero_mois, 0) ; |
$this->message_rendu .= preg_replace('/<ezmlm-body>/i', $this->cleanup_body($corps,true), $this->msgtmpl).'</div>'; |
} else if ($mailDecode->ctype_primary == 'application' || $mailDecode->ctype_primary == 'image'){ |
if ($mailDecode->ctype_secondary == 'applefile') return ; |
$mimeType = new type_fichier_mime( $mailDecode->ctype_primary.'/'.$mailDecode->ctype_secondary,PROJET_CHEMIN_ICONES) ; |
if ($mimeType->getIdType() != 12) { |
$corps .= '<a href="'.PROJET_CHEMIN_APPLI.'fichier_attache.php?nom_liste='.$this->listname.'&actionargs[]='. |
$numero_mois.'&actionargs[]='. |
$numero_mail.'&actionargs[]='.$i.'">'. |
'<img src="'.$mimeType->getCheminIcone().'" alt="'.$mailDecode->ctype_parameters['name'].'" /> ' ; |
$corps .= $mailDecode->ctype_parameters['name'].'</a><br />' ; |
$this->message_rendu .= preg_replace('/<ezmlm-body>/i', $this->cleanup_body($corps,true), $this->msgtmpl); |
} |
} else { |
if (preg_match('/html/i', $mailDecode->ctype_secondary)) { |
$this->message_rendu .= preg_replace('/<ezmlm-body>/i', $this->cleanup_body($mailDecode->body,TRUE), $this->msgtmpl); |
} else { |
if (isset ($mailDecode->ctype_parameters['charset']) && $mailDecode->ctype_parameters['charset'] == 'UTF-8') { |
$this->message_rendu .= preg_replace('/<ezmlm-body>/i', '<pre>' . utf8_decode($this->cleanup_body($mailDecode->body,TRUE)) . '</pre>', $this->msgtmpl); |
} else { |
$this->message_rendu .= preg_replace('/<ezmlm-body>/i', '<pre>' . $this->cleanup_body($mailDecode->body,TRUE) . '</pre>', $this->msgtmpl); |
} |
} |
} |
array_pop ($profondeur); |
} |
function ezmlm_msgdisplay() { |
$this->ezmlm_php(); |
if (($this->msgtemplate != "") and (is_file($this->msgtemplate))) { |
$fd = fopen($this->msgtemplate, "r"); |
while (!feof($fd)) { $this->msgtmpl .= fgets($fd,4096); } |
fclose($fd); |
} else { |
$this->msgtmpl = '<pre> |
<ezmlm-body> |
</pre> |
'; |
} |
$this->msgtmpl_entete = '<dl><ezmlm-headers> |
<dt><ezmlm-header-name> :</dt> |
<dd><ezmlm-header-value></dd> |
</ezmlm-headers> |
</dl>' ; |
} |
// _cte_8bit: decode a content transfer encoding of 8bit |
// NOTE: this function is a little bit special. Since the end result will be displayed in |
// a web browser _cte_8bit decodes ASCII characters > 127 (the US-ASCII table) into the |
// html ordinal equivilant, it also ensures that the messages content-type is changed |
// to include text/html if it changes anything... |
function _cte_8bit($data,$simple = FALSE) { |
if ($simple) { return $data; } |
$changed = FALSE; |
$out = ''; |
$chars = preg_split('//',$data); |
while (list($key,$val) = each($chars)) { |
if (ord($val) > 127) { $out .= '&#' . ord($val) . ';'; $changed = TRUE; } |
else { $out .= $val; } |
} |
if ($changed) { $this->headers['content-type'][1] = 'text/html'; } |
return $out; |
} |
} |
/tags/2014_06_04/classes/ezmlm-php-2.0/ezmlm-parser.php |
---|
New file |
0,0 → 1,402 |
<?php |
/*vim: set expandtab tabstop=4 shiftwidth=4: */ |
// +------------------------------------------------------------------------------------------------------+ |
// | PHP version 4.1 | |
// +------------------------------------------------------------------------------------------------------+ |
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) | |
// +------------------------------------------------------------------------------------------------------+ |
// | This library is free software; you can redistribute it and/or | |
// | modify it under the terms of the GNU General Public | |
// | License as published by the Free Software Foundation; either | |
// | version 2.1 of the License, or (at your option) any later version. | |
// | | |
// | This library is distributed in the hope that it will be useful, | |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
// | General Public License for more details. | |
// | | |
// | You should have received a copy of the GNU General Public | |
// | License along with this library; if not, write to the Free Software | |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
// +------------------------------------------------------------------------------------------------------+ |
// CVS : $Id: ezmlm-parser.php,v 1.5 2008-11-19 09:28:46 aperonnet Exp $ |
/** |
* Application projet |
* |
* classe ezmlm_parser pour lire les fichiers d index de ezmlm-idx |
* |
*@package projet |
//Auteur original : ?? recupere dans ezmlm-php |
*@author Alexandre Granier <alexandre@tela-botanica.org> |
*@copyright Tela-Botanica 2000-2004 |
*@version $Revision: 1.5 $ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
// +------------------------------------------------------------------------------------------------------+ |
// | ENTETE du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
// $Id: ezmlm-parser.php,v 1.5 2008-11-19 09:28:46 aperonnet Exp $ |
// |
require_once("ezmlm.php"); |
require_once("Mail/mimeDecode.php") ; |
// CLASS: ezmlm-parser |
class ezmlm_parser extends ezmlm_php { |
var $headers; // the full untouched headers of the message |
var $body; // the full untouched (but decoded) body (this is not $this->parts[0]->body) |
var $parts; // all the parts, if it is a multipart message. each part is an ezmlm_parser object... |
// Here's the most accessed headers, everything else can be |
// accessed from the $this->headers array. |
var $to; // To: |
var $from; // From: |
var $date; // Date: |
var $subject; // Subject: |
var $replyto; // Reply-To: |
var $contenttype; // Content-Type: |
var $multipart; // TRUE if the message is a multipart message |
var $msgfile; // if parsed from a file, this is the filename... |
// functions |
/** |
* recent_msgs renvoie les derniers messages de la liste de discussion |
* ezmlm |
* |
* ( |
* [0] => Array |
* ( |
* [1] => sujet |
* [2] => date en anglais |
* [3] => le hash de l auteur |
* [4] => l auteur |
* ) |
* [1] => ... |
* ) |
* @param int le nombre de message a renvoye |
* @return array un tableau contenant les messages |
* @access public |
*/ |
function recent_msgs($show = 20, $month = "") { |
$repertoire_archive = opendir($this->listdir . "/archive/"); |
$repertoire_message = array() ; |
$numArchive = $this->getNumArchive(); |
$dernier_repertoire = floor($numArchive / 100); |
$tableau_message = array() ; |
$compteur_message = 0 ; |
$fichier_index = fopen ($this->listdir.'/archive/'.$dernier_repertoire.'/index', 'r') ; |
while (!feof($fichier_index)) { |
// Recuperation du numero de message, du hash du sujet et du sujet |
$temp = fgets($fichier_index, 4096); |
preg_match('/([0-9]+): ([a-z]+) (.*)/', $temp, $match) ; |
// dans la seconde on recupere la date, hash auteur et auteur |
$temp = fgets($fichier_index, 4096); |
preg_match('/\t([0-9]+) ([a-zA-Z][a-zA-Z][a-zA-Z]) ([0-9][0-9][0-9][0-9]) ([^;]+);([^ ]*) (.*)/', $temp, $match_deuxieme_ligne) ; |
if ($match[1] != '') { |
$tableau_message[$match[1]] = array ($match[2], $match[3], |
$match_deuxieme_ligne[1].' '.$match_deuxieme_ligne[2].' '.$match_deuxieme_ligne[3], |
$match_deuxieme_ligne[5], |
$match_deuxieme_ligne[6]); |
} |
} |
fclose ($fichier_index); |
// on renverse le tableau pour afficher les derniers messages en premier |
$tableau_message = array_reverse($tableau_message, true); |
// On compte le nombre de message, s il est inferieur $show et que l on est |
// pas dans le premier index, on ouvre le fichier precedent et recupere |
// le n dernier message |
if (count ($tableau_message) < $show && $dernier_repertoire != '0') { |
$avant_dernier_repertoire = $dernier_repertoire - 1 ; |
// On utilise file_get_contents pour renverser le fichier |
$fichier_index = array_reverse( |
explode ("\n", |
preg_replace ('/\n$/', '', |
file_get_contents ($this->listdir.'/archive/'.$avant_dernier_repertoire.'/index')) ), true) ; |
reset ($fichier_index); |
//var_dump ($fichier_index); |
for ($i = count ($tableau_message); $i <= $show; $i++) { |
// Recuperation du numero de message, du hash du sujet et du sujet |
// dans la seconde on recupere la date, hash auteur et auteur |
preg_match('/\t([0-9]+) ([a-zA-Z][a-zA-Z][a-zA-Z]) ([0-9][0-9][0-9][0-9]) ([^;]+);([^ ]*) (.*)/', |
current ($fichier_index), $match_deuxieme_ligne) ; |
preg_match('/([0-9]+): ([a-z]+) (.*)/', next($fichier_index), $match) ; |
next ($fichier_index); |
if ($match[1] != '') { |
$tableau_message[$match[1]] = array ($match[2], $match[3], |
$match_deuxieme_ligne[1].' '.$match_deuxieme_ligne[2].' '.$match_deuxieme_ligne[3], |
$match_deuxieme_ligne[5], |
$match_deuxieme_ligne[6]); |
} |
} |
} else { |
// Si le nombre de message est > $show on limite le tableau de retour |
$tableau_message = array_slice($tableau_message, 0, $show, true); |
} |
return $tableau_message ; |
} |
// parse_file - opens a file and feeds the data to parse, file can be relative to the listdir |
function parse_file($file,$simple = FALSE) { |
if (!is_file($file)) { |
if (is_file($this->listdir . "/" . $file)) { $file = $this->listdir . "/" . $file; } |
else if (is_file($this->listdir . "/archive/" . $file)) { $file = $this->listdir . "/archive/" . $file; } |
else { return FALSE; } |
} |
$this->msgfile = $file; |
$data = '' ; |
$fd = fopen($file, "r"); |
while (!feof($fd)) { $data .= fgets($fd,4096); } |
fclose($fd); |
return $this->parse($data,$simple); |
} |
// parse_file_headers - ouvre un fichier et analyse les entête |
function parse_file_headers($file,$simple = FALSE) { |
if (!is_file($file)) { |
if (is_file($this->listdir . "/" . $file)) { $file = $this->listdir . "/" . $file; } |
else if (is_file($this->listdir . "/archive/" . $file)) { $file = $this->listdir . "/archive/" . $file; } |
else { return FALSE; } |
} |
$this->msgfile = $file; |
$data = file_get_contents ($file) ; |
$message = file_get_contents($file) ; |
$mimeDecode = new Mail_mimeDecode($message) ; |
$mailDecode = $mimeDecode->decode() ; |
return $mailDecode ; |
} |
// this does all of the work (well it calls two functions that do all the work :) |
// all the decoding a part breaking follows RFC2045 (http://www.faqs.org/rfcs/rfc2045.html) |
function parse($data,$simple = FALSE) { |
if (($this->_get_headers($data,$simple)) && $this->_get_body($data,$simple)) { return TRUE; } |
return FALSE; |
} |
// all of these are internal functions, you shouldn't call them directly... |
// _ct_parse: parse Content-Type headers -> $ct[0] = Full header, $ct[1] = Content-Type, $ct[2] ... $ct[n] = AP's |
function _ct_parse() { |
$instr = $this->headers['content-type']; |
preg_replace('/\(.*\)/','',$instr); // strip rfc822 comments |
if (preg_match('/: /', $instr)) { |
$ct = preg_split('/:/',trim($instr),2); |
$ct = preg_split('/;/',trim($ct[1])); |
} else { |
$ct = preg_split('/;/',trim($instr)); |
} |
if (isset($ct[1])) $attrs = preg_split('/[\s\n]/',$ct[1]); |
$i = 2; |
$ct[1] = $ct[0]; |
$ct[0] = $this->headers['content-type']; |
if (isset($attrs) && is_array($attrs)) { |
while (list($key, $val) = each($attrs)) { |
if ($val == '') continue; |
$ap = preg_split('/=/',$val,2); |
if (preg_match('/^"/',$ap[1])) { $ap[1] = substr($ap[1],1,strlen($ap[1])-2); } |
$ct[$i] = $ap; |
$i++; |
} |
} |
// are we a multipart message? |
if (preg_match('/^multipart/i', $ct[1])) { $this->multipart = TRUE; } |
return $ct; |
} |
// _get_headers: pulls the headers out of the data and builds the $this->headers array |
function _get_headers($data,$simple = FALSE) { |
$lines = preg_split('/\n/', $data); |
while (list($key, $val) = each($lines)) { |
$val = trim($val); |
if ($val == "") break; |
if (preg_match('/^From[^:].*$/', $val)) continue; /* strips out any From lines added by the MTA */ |
$hdr = preg_split('/: /', $val, 2); |
if (count($hdr) == 1) { |
// this is a continuation of the last header (like a recieved from line) |
$this->headers[$last] .= $val; |
} else { |
$this->headers[strtolower($hdr[0])] = $hdr[1]; |
//echo htmlspecialchars($this->headers['from'])."<br />" ; |
$last = strtolower($hdr[0]); |
} |
} |
// ajout alex |
// pour supprimer le problème des ISO... |
// a déplacer ailleur, et appelé avant affichage |
if (preg_match ('/windows-[0-9][0-9][0-9][0-9]/', $this->headers['subject'], $nombre)) { |
$reg_exp = $nombre[0] ; |
} else { |
$reg_exp = 'ISO-8859-15?' ; |
} |
if (preg_match ('/UTF/i', $this->headers['subject'])) $reg_exp = 'UTF-8' ; |
preg_match_all ("/=\?$reg_exp\?(Q|B)\?(.*?)\?=/i", $this->headers['subject'], $match, PREG_PATTERN_ORDER) ; |
for ($i = 0; $i < count ($match[0]); $i++ ) { |
if ($match[1][$i] == 'Q') { |
$decode = quoted_printable_decode ($match[2][$i]) ; |
} elseif ($match[1][$i] == 'B') { |
$decode = base64_decode ($match[2][$i]) ; |
} |
$decode = preg_replace ("/_/", " ", $decode) ; |
if ($reg_exp == 'UTF-8') { |
$decode = utf8_decode ($decode) ; |
} |
$this->headers['subject'] = str_replace ($match[0][$i], $decode, $this->headers['subject']) ; |
} |
// sanity anyone? |
if (!$this->headers['content-type']) { $this->headers['content-type'] = "text/plain; charset=us-ascii"; } |
if (!$simple) { $this->headers['content-type'] = $this->_ct_parse(); } |
return TRUE; |
} |
// _get_body: pulls the body out of the data and fills $this->body, decoding the data if nessesary. |
function _get_body($data,$simple = FALSE) { |
$lines = preg_split('/\n/', $data); |
$doneheaders = FALSE; |
$data = ""; |
while (list($key,$val) = each($lines)) { |
//echo htmlspecialchars($val)."<br>"; |
if (($val == '') and (!$doneheaders)) { |
$doneheaders = TRUE; |
continue; |
} else if ($doneheaders) { |
$data .= $val . "\n"; |
} |
} |
// now here comes the fun part... decoding. |
switch($this->headers['content-transfer-encoding']) { |
case 'binary': |
$this->body = $this->_cte_8bit($this->_cte_qp($this->_cte_binary($data)),$simple); |
break; |
case 'base64': |
$this->body = $this->_cte_8bit($this->_cte_qp($this->_cte_base64($data)),$simple); |
break; |
case 'quoted-printable': |
$this->body = $this->_cte_8bit($this->_cte_qp($data),$simple); |
break; |
case '8bit': |
$this->body = $this->_cte_8bit($data,$simple); |
break; |
case '7bit': // 7bit doesn't need to be decoded |
default: // And the fall through as well... |
$this->body = $data; |
break; |
} |
//echo $this->headers['content-type'][2][1]; |
if (isset($this->headers['content-type'][2][1]) && $this->headers['content-type'][2][1] == 'UTF-8') { |
//$this->body = utf8_decode ($this->body) ; |
//echo quoted_printable_decode(utf8_decode ($this->body)) ; |
} |
if ($simple) { return TRUE; } |
// if we are a multipart message then break up the parts and decode, set the appropriate variables. |
// here comes the best part about making ezmlm-php OOP. since each part is just really a little message |
// in itself each part becomes a new parser object and all the wheels turn again... :) |
if ($this->multipart) { |
$boundary = ''; |
for ($i = 2; $i <= count($this->headers['content-type']); $i++) { |
if (preg_match('/boundary/i', $this->headers['content-type'][$i][0])) { |
$boundary = $this->headers['content-type'][$i][1]; |
} |
} |
if ($boundary != '') { |
$this->_get_parts($this->body,$boundary); |
} else { |
// whoopps... something's not right here. we were told that the message is supposed |
// to be a multipart message, yet the boundary wasn't set in the content type. |
// mark the message as non multipart and add a message to the top of the body. |
$this->multipart = FALSE; |
$this->body = "PARSER ERROR:\nWHILE PARSING THIS MESSAGE AS A MULTIPART MESSAGE AS DEFINED IN RFC2045 THE BOUNDARY IDENTIFIER WAS NOT FOUND!\nTHIS MESSAGE WILL NOT DISPLAY CORRECTLY!\n\n" . $this->body; |
} |
} |
return TRUE; |
} |
// _get_parts: breaks up $data into parts based on $boundary following the rfc specs |
// detailed in section 5 of RFC2046 (http://www.faqs.org/rfcs/rfc2046.html) |
// After the parts are broken up they are then turned into parser objects and the |
// resulting array of parts is set to $this->parts; |
function _get_parts($data,$boundary) { |
$inpart = -1; |
$lines = preg_split('/\n/', $data); |
// La première partie contient l'avertissement pour les client mail ne supportant pas |
// multipart, elle est stocké dans parts[-1] |
while(list($key,$val) = each($lines)) { |
if ($val == "--" . $boundary) { $inpart++; continue; } // start of a part |
else if ($val == "--" . $boundary . "--") { break; } // the end of the last part |
else { $parts[$inpart] .= $val . "\n"; } |
} |
for ($i = 0; $i < count($parts) - 1; $i++) { // On saute la première partie |
$part[$i] = new ezmlm_parser(); |
$part[$i]->parse($parts[$i]); |
$this->parts[$i] = $part[$i]; |
//echo $this->parts[$i]."<br>" ; |
} |
} |
// _cte_8bit: decode a content transfer encoding of 8bit |
// NOTE: this function is a little bit special. Since the end result will be displayed in |
// a web browser _cte_8bit decodes ASCII characters > 127 (the US-ASCII table) into the |
// html ordinal equivilant, it also ensures that the messages content-type is changed |
// to include text/html if it changes anything... |
function _cte_8bit($data,$simple = FALSE) { |
if ($simple) { return $data; } |
$changed = FALSE; |
$chars = preg_split('//',$data); |
while (list($key,$val) = each($chars)) { |
if (ord($val) > 127) { $out .= '&#' . ord($val) . ';'; $changed = TRUE; } |
else { $out .= $val; } |
} |
if ($changed) { $this->headers['content-type'][1] = 'text/html'; } |
return $out; |
} |
// _cte_binary: decode a content transfer encoding of binary |
function _cte_binary($data) { return $data; } |
// _cte_base64: decode a content transfer encoding of base64 |
function _cte_base64($data) { return base64_decode($data); } |
// _cte_qp: decode a content transfer encoding of quoted_printable |
function _cte_qp($data) { |
// For the time being we'll use PHP's function, it seems to work well enough. |
return quoted_printable_decode($data); |
} |
} |
/tags/2014_06_04/classes/ezmlm-php-2.0/TODO |
---|
New file |
0,0 → 1,5 |
Things left TODO... |
- Implement unique titles for each page |
- Better default header/footer |
- Fix bugs as they appear |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |