2 |
ddelon |
1 |
<?php
|
164 |
alexandre_ |
2 |
// $Id: ezmlm.php,v 1.3.2.1 2007-02-16 10:43:43 alexandre_tb Exp $
|
2 |
ddelon |
3 |
//
|
|
|
4 |
// ezmlm.php - ezmlm-php v2.0
|
|
|
5 |
// --------------------------------------------------------------
|
|
|
6 |
// As the site that ezmlm-php was developed for grew, and grew
|
|
|
7 |
// the old system used had to be bandaid fixed more, and more
|
|
|
8 |
// because the site started moving to an object oriented design
|
|
|
9 |
// for all the backend systems and ezmlm wasn't playing nice
|
|
|
10 |
// with the new design. So, ezmlm was redesigned too, and here
|
|
|
11 |
// it is.
|
|
|
12 |
//
|
|
|
13 |
// It may look a little more confusing if you're not used to
|
|
|
14 |
// working with objects but it actually is much more effiecient
|
|
|
15 |
// and organized in it's new incarnation.
|
|
|
16 |
// Simply edit the variables in the ezmlm-php constructor below
|
|
|
17 |
// just like you would with the old ezmlm-php-config.php file,
|
|
|
18 |
// if you're unsure howto do this check out the file CONFIG,
|
|
|
19 |
// then check the USAGE file for how you should include and use
|
|
|
20 |
// the new classes if you are integrating ezmlm-php into your
|
|
|
21 |
// site.
|
|
|
22 |
// (SEARCH FOR: USER-CONFIG to find where to edit.)
|
|
|
23 |
// --------------------------------------------------------------
|
|
|
24 |
|
|
|
25 |
require_once("ezmlm-errors.def");
|
|
|
26 |
require_once("ezmlm-parser.php");
|
|
|
27 |
require_once("ezmlm-threads.php");
|
|
|
28 |
require_once("ezmlm-listinfo.php");
|
|
|
29 |
require_once("ezmlm-msgdisplay.php");
|
|
|
30 |
require_once("ezmlm-repondre.php");
|
|
|
31 |
require_once("ezmlm-author.php");
|
|
|
32 |
|
164 |
alexandre_ |
33 |
$GLOBALS['mois'] = array ('Janvier', 'Février', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Août', 'Septembre', 'Octobre', 'Novembre', 'Décembre') ;
|
2 |
ddelon |
34 |
|
|
|
35 |
// CLASS: ezmlm_php
|
|
|
36 |
// the base class, contains common functions and the config
|
|
|
37 |
class ezmlm_php {
|
|
|
38 |
var $listdir; // the root directory of the list
|
|
|
39 |
var $listname; // the list address upto the @
|
|
|
40 |
var $listdomain; // the domain for the list
|
|
|
41 |
|
|
|
42 |
var $tempdir; // a directory in which the webserver can write cache files
|
|
|
43 |
|
|
|
44 |
var $sendheaders; // send generic page headers
|
|
|
45 |
var $sendbody; // send generic body definitions
|
|
|
46 |
var $sendfooters; // send generic page footers
|
|
|
47 |
var $includebefore; // a file to include before the content
|
|
|
48 |
var $includeafter; // a file to include after the content
|
|
|
49 |
|
|
|
50 |
var $href; // what to add before the '?param=value' in links
|
|
|
51 |
|
|
|
52 |
var $prefertype; // what mime type do you prefer?
|
|
|
53 |
var $showheaders; // what headers should we show?
|
|
|
54 |
|
|
|
55 |
var $msgtemplate; // the template for displaying messages (see the file TEMPLATE)
|
|
|
56 |
|
|
|
57 |
var $tablecolours; // what are the colours for the table rows?
|
|
|
58 |
|
|
|
59 |
var $thread_subjlen; // the maximum length of subjects in the thread view (0 = no limit)
|
|
|
60 |
|
|
|
61 |
var $forcehref; // force the base of makelink();
|
|
|
62 |
|
|
|
63 |
// --------- END USER CONFIGURATION ---------
|
|
|
64 |
|
|
|
65 |
// Internal variables
|
|
|
66 |
var $action = '';
|
|
|
67 |
var $actionargs;
|
|
|
68 |
|
|
|
69 |
function ezmlm_php() {
|
|
|
70 |
|
|
|
71 |
// USER-CONFIG section
|
|
|
72 |
// these variables act the same way ezmlm-php-config.php did in the first release
|
|
|
73 |
// simply edit these variables to match your setup
|
|
|
74 |
|
|
|
75 |
$this->listdir = "/home/telabotap/sd/testv4/client/synchroliste/liste/tela-botanica.org/equipe";
|
|
|
76 |
$this->listname = "equipe";
|
|
|
77 |
$this->listdomain = "tela-botanica.org";
|
|
|
78 |
|
|
|
79 |
$this->tempdir = "/home/telabotap/www/tmp";
|
|
|
80 |
|
|
|
81 |
$this->sendheaders = TRUE;
|
|
|
82 |
$this->sendbody = TRUE;
|
|
|
83 |
$this->sendfooters = TRUE;
|
|
|
84 |
$this->includebefore = "";
|
|
|
85 |
$this->includeafter = "";
|
|
|
86 |
|
|
|
87 |
$this->href = "";
|
|
|
88 |
|
|
|
89 |
$this->prefertype = "text/html";
|
|
|
90 |
$this->showheaders = array(
|
|
|
91 |
"to",
|
|
|
92 |
"from",
|
|
|
93 |
"subject",
|
|
|
94 |
"date"
|
|
|
95 |
);
|
|
|
96 |
$this->header_en_francais = array ('to' => 'A',
|
|
|
97 |
'from' => 'De',
|
|
|
98 |
'subject' => 'Sujet',
|
|
|
99 |
'date' => 'Date') ;
|
|
|
100 |
|
|
|
101 |
$this->msgtemplate = "<pre><ezmlm-body></pre>"; // if blank it will use the internal one
|
|
|
102 |
|
|
|
103 |
$this->tablecolours = array(
|
|
|
104 |
// delete the next line if you don't want alternating colours
|
|
|
105 |
"#eeeeee",
|
|
|
106 |
"#ffffff"
|
|
|
107 |
);
|
|
|
108 |
|
|
|
109 |
$this->thread_subjlen = 55;
|
|
|
110 |
|
|
|
111 |
// --- STOP EDITING HERE ---
|
|
|
112 |
// some sanity checking
|
|
|
113 |
if ((!is_dir($this->listdir . "/archive")) or
|
|
|
114 |
(!is_dir($this->listdir . "/archive/authors")) or
|
|
|
115 |
(!is_dir($this->listdir . "/archive/threads")) or
|
|
|
116 |
(!is_dir($this->listdir . "/archive/subjects"))) {
|
|
|
117 |
return false ;
|
|
|
118 |
/*$this->error(EZMLM_INVALID_DIR,TRUE);*/
|
|
|
119 |
}
|
|
|
120 |
}
|
|
|
121 |
|
|
|
122 |
function set_action($action) {
|
|
|
123 |
if (is_array($action)) { $this->error(EZMLM_INVALID_SYNTAX,TRUE); }
|
|
|
124 |
$this->action = $action;
|
|
|
125 |
}
|
|
|
126 |
function set_actionargs($actionargs) {
|
|
|
127 |
if ($this->action == '') { $this->error(EZMLM_INVALID_SYNTAX,TRUE); }
|
|
|
128 |
$this->actionargs = $actionargs;
|
|
|
129 |
}
|
|
|
130 |
|
|
|
131 |
function run() {
|
|
|
132 |
if ($this->action == '') { $this->error(EZMLM_INVALID_SYNTAX,TRUE); }
|
|
|
133 |
|
|
|
134 |
if ($this->sendheaders) { $this->sendheaders(); }
|
|
|
135 |
if ($this->sendbody) { $this->sendbody(); }
|
|
|
136 |
if ($this->includebefore != '') { @include_once($this->includebefore); }
|
|
|
137 |
|
|
|
138 |
switch ($this->action) {
|
|
|
139 |
case "list_info":
|
|
|
140 |
$info = new ezmlm_listinfo();
|
|
|
141 |
$info->display();
|
|
|
142 |
break;
|
|
|
143 |
case "show_msg":
|
|
|
144 |
if (count($this->actionargs) < 2) {
|
|
|
145 |
$this->error(EZMLM_INVALID_SYNTAX,TRUE);
|
|
|
146 |
}
|
|
|
147 |
$show_msg = new ezmlm_msgdisplay();
|
|
|
148 |
$show_msg->display($this->actionargs[0] . "/" . $this->actionargs[1]);
|
|
|
149 |
break;
|
|
|
150 |
case "show_threads":
|
|
|
151 |
$threads = new ezmlm_threads();
|
|
|
152 |
$threads->load($this->actionargs[0]);
|
|
|
153 |
break;
|
|
|
154 |
case "show_author_msgs":
|
|
|
155 |
$author = new ezmlm_author();
|
|
|
156 |
$author->display($this->actionargs[0]);
|
|
|
157 |
break;
|
|
|
158 |
}
|
|
|
159 |
|
|
|
160 |
if ($this->includeafter != '') { @include_once($this->includeafter); }
|
|
|
161 |
if ($this->sendfooters) { $this->sendfooters(); }
|
|
|
162 |
}
|
|
|
163 |
|
|
|
164 |
function sendheaders() {
|
|
|
165 |
print "<html><head>\n";
|
|
|
166 |
print "<style type=\"text/css\">\n";
|
|
|
167 |
print "<!--\n";
|
|
|
168 |
print ".heading { font-family: helvetica; font-size: 16px; line-height: 18px; font-weight: bold; }\n";
|
|
|
169 |
print "//-->\n";
|
|
|
170 |
print "</style>\n";
|
|
|
171 |
print "</head>\n";
|
|
|
172 |
}
|
|
|
173 |
|
|
|
174 |
function sendbody() {
|
|
|
175 |
print "<body>\n";
|
|
|
176 |
}
|
|
|
177 |
|
|
|
178 |
function sendfooters() {
|
|
|
179 |
print "</body>\n";
|
|
|
180 |
print "</html>\n";
|
|
|
181 |
}
|
|
|
182 |
|
|
|
183 |
|
|
|
184 |
// begin common functions
|
|
|
185 |
|
|
|
186 |
// makehash - generates an author hash using the included makehash program
|
|
|
187 |
function makehash($str) {
|
|
|
188 |
$str = preg_replace ('/>/', '', $str) ;
|
|
|
189 |
$handle = popen ('/usr/local/lib/safe_mode/makehash \''.$str.'\'', 'r') ;
|
|
|
190 |
$hash = fread ($handle, 256) ;
|
|
|
191 |
pclose ($handle) ;
|
|
|
192 |
return $hash;
|
|
|
193 |
}
|
|
|
194 |
|
|
|
195 |
// makelink - writes the <a href=".."> tag
|
|
|
196 |
function makelink($params,$text) {
|
|
|
197 |
if ($this->forcehref != "") {
|
|
|
198 |
$basehref = $this->forcehref;
|
|
|
199 |
} else {
|
|
|
200 |
$basehref = preg_replace('/^(.*)\?.*/', '\\1', $_SERVER['REQUEST_URI']);
|
|
|
201 |
}
|
|
|
202 |
$link = '<a href="'. $basehref . '&' . $params . '">' . $text . '</a>';
|
|
|
203 |
return $link;
|
|
|
204 |
}
|
|
|
205 |
|
|
|
206 |
// md5_of_file - provides wrapper function that emulates md5_file for PHP < 4.2.0
|
|
|
207 |
function md5_of_file($file) {
|
|
|
208 |
if (function_exists("md5_file")) { // php >= 4.2.0
|
|
|
209 |
return md5_file($file);
|
|
|
210 |
} else {
|
|
|
211 |
if (is_file($file)) {
|
|
|
212 |
$fd = fopen($file, "rb");
|
|
|
213 |
$filecontents = fread($fd, filesize($file));
|
|
|
214 |
fclose ($fd);
|
|
|
215 |
return md5($filecontents);
|
|
|
216 |
} else {
|
|
|
217 |
return FALSE;
|
|
|
218 |
}
|
|
|
219 |
}
|
|
|
220 |
}
|
|
|
221 |
|
|
|
222 |
// protect_email - protects email address turns user@domain.com into user@d...
|
|
|
223 |
function protect_email($str,$short = FALSE) {
|
|
|
224 |
if (preg_match("/[a-zA-Z0-9\-\.]\@[a-zA-Z0-9\-\.]*\./", $str)) {
|
|
|
225 |
$outstr = preg_replace("/([a-zA-Z0-9\-\.]*\@)([a-zA-Z0-9\-\.])[a-zA-Z0-9\-\.]*\.[a-zA-Z0-9\-\.]*/","\\1\\2...",$str);
|
|
|
226 |
$outstr = preg_replace("/\</", '<', $outstr);
|
|
|
227 |
$outstr = preg_replace("/\>/", '>', $outstr);
|
|
|
228 |
} else {
|
|
|
229 |
$outstr = $str;
|
|
|
230 |
}
|
|
|
231 |
|
|
|
232 |
if ($short) {
|
|
|
233 |
$outstr = preg_replace("/<.*>/", '', $outstr);
|
|
|
234 |
$outstr = preg_replace("/[\"']/", '', $outstr);
|
|
|
235 |
}
|
|
|
236 |
return trim($outstr);
|
|
|
237 |
}
|
|
|
238 |
|
|
|
239 |
// cleanup_body: sortta like protect_email, just for message bodies
|
|
|
240 |
function cleanup_body($str) {
|
|
|
241 |
$outstr = preg_replace("/([a-zA-Z0-9\-\.]*\@)([a-zA-Z0-9\-\.])[a-zA-Z0-9\-\.]*\.[a-zA-Z0-9\-\.]*/","\\1\\2...",$str);
|
|
|
242 |
return $outstr;
|
|
|
243 |
}
|
|
|
244 |
|
|
|
245 |
function error($def, $critical = FALSE) {
|
|
|
246 |
global $ezmlm_error;
|
|
|
247 |
|
|
|
248 |
print "\n\n";
|
|
|
249 |
print "<table width=600 border=1 cellpadding=3 cellspacing=0>\n";
|
|
|
250 |
print "<tr bgcolor=\"#cccccc\"><td><b>EZMLM-PHP Error: " . $ezmlm_error[$def]['title'] . "</td></tr>\n";
|
|
|
251 |
print "<tr bgcolor=\"#aaaaaa\"><td>" . $ezmlm_error[$def]['body'] . "</td></tr>\n";
|
|
|
252 |
print "</table>\n\n";
|
|
|
253 |
|
|
|
254 |
if ($critical) { die; }
|
|
|
255 |
}
|
|
|
256 |
/**
|
|
|
257 |
* Parse une chaime et supprime les problême d'encodage de type ISO-4 ...
|
|
|
258 |
*
|
|
|
259 |
* @return string
|
|
|
260 |
*/
|
|
|
261 |
|
|
|
262 |
function decode_iso ($chaine) {
|
|
|
263 |
|
|
|
264 |
if (preg_match ('/windows-[0-9][0-9][0-9][0-9]/i', $chaine, $nombre)) {
|
|
|
265 |
$reg_exp = $nombre[0] ;
|
|
|
266 |
} else {
|
|
|
267 |
$reg_exp = 'ISO-8859-15?' ;
|
|
|
268 |
}
|
|
|
269 |
if (preg_match ('/UTF/i', $chaine)) $reg_exp = 'UTF-8' ;
|
|
|
270 |
preg_match_all ("/=\?$reg_exp\?(Q|B)\?(.*?)\?=/i", $chaine, $match, PREG_PATTERN_ORDER) ;
|
|
|
271 |
for ($i = 0; $i < count ($match[0]); $i++ ) {
|
|
|
272 |
|
164 |
alexandre_ |
273 |
if (strtoupper($match[1][$i]) == 'Q') {
|
2 |
ddelon |
274 |
$decode = quoted_printable_decode ($match[2][$i]) ;
|
|
|
275 |
} elseif ($match[1][$i] == 'B') {
|
|
|
276 |
$decode = base64_decode ($match[2][$i]) ;
|
|
|
277 |
}
|
|
|
278 |
$decode = preg_replace ("/_/", " ", $decode) ;
|
|
|
279 |
if ($reg_exp == 'UTF-8') {
|
|
|
280 |
$decode = utf8_decode ($decode) ;
|
|
|
281 |
}
|
|
|
282 |
$chaine = str_replace ($match[0][$i], $decode, $chaine) ;
|
|
|
283 |
}
|
|
|
284 |
return $chaine ;
|
|
|
285 |
}
|
|
|
286 |
|
|
|
287 |
/**
|
|
|
288 |
*
|
|
|
289 |
*
|
|
|
290 |
* @return
|
|
|
291 |
*/
|
|
|
292 |
|
|
|
293 |
function date_francaise ($date_mail) {
|
|
|
294 |
$date_mail = preg_replace ('/CEST/', '', $date_mail) ;
|
|
|
295 |
$numero_mois = date('m ', strtotime($date_mail)) - 1 ;
|
|
|
296 |
$date = date ('d ', strtotime($date_mail)).$GLOBALS['mois'][$numero_mois] ; // Le jour et le mois
|
|
|
297 |
$date .= date(' Y ', strtotime($date_mail)) ; // l'année
|
|
|
298 |
if (date('a', strtotime($date_mail)) == 'pm') {
|
|
|
299 |
$date .= (int) date('g', strtotime($date_mail)) + 12 ; // Les heures
|
|
|
300 |
} else {
|
|
|
301 |
$date .= date('g', strtotime($date_mail)) ;
|
|
|
302 |
}
|
|
|
303 |
$date .= date(':i', strtotime($date_mail)) ; // Les minutes
|
|
|
304 |
return $date ;
|
|
|
305 |
}
|
|
|
306 |
}
|
|
|
307 |
|
|
|
308 |
//
|
|
|
309 |
// --- END OF CLASS DEFINITION ---
|
|
|
310 |
//
|
|
|
311 |
|
|
|
312 |
// FIN
|