3 /***************************************************************************
4 * Copyright (C) 2003-2008 Polytechnique.org *
5 * http://opensource.polytechnique.org/ *
7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. *
12 * This program is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
17 * You should have received a copy of the GNU General Public License *
18 * along with this program; if not, write to the Free Software *
20 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
21 ***************************************************************************/
23 require('./connect.db.inc.php');
24 ini_set('max_execution_time', '75');
28 while ($sent_mails < $globals->lists
->max_mail_per_min
29 && time() - $handler < 60) {
30 // take a lock on a mail
31 XDB
::execute("UPDATE ml_moderate
36 if (XDB
::affectedRows() == 0) {
39 $query = XDB
::query("SELECT nom, prenom, user_id, password,
40 ml, domain, mid, action, message
41 FROM auth_user_md5 AS u
42 INNER JOIN ml_moderate AS ml ON (u.user_id = ml.uid)
43 WHERE ml.handler = {?}", $handler);
44 list($nom, $prenom, $uid, $password, $list, $domain, $mid, $action, $reason) = $query->fetchOneRow();
47 $client = new MMList($uid, $password, $domain);
50 $mail = $client->get_pending_mail($list, $mid);
51 list($det,$mem,$own) = $client->get_members($list);
55 $action = 1; /** 1 = ACCEPT **/
56 $subject = "Message accepté";
57 $append = "a été accepté par $prenom $nom.\n";
58 $count +
= count($mem) +
count($own);
61 $action = 2; /** 2 = REJECT **/
62 $subject = "Message refusé";
63 $append = "a été refusé par $prenom $nom avec la raison :\n\n" . $reason;
64 $count +
= count($own) +
1;
67 $action = 3; /** 3 = DISCARD **/
68 $subject = "Message supprimé";
69 $append = "a été supprimé par $prenom $nom.\n\n"
70 . "Rappel: il ne faut utiliser cette opération "
71 . "que dans le cas de spams ou de virus !\n";
72 $count +
= count($own);
76 if ($client->handle_request($list, $mid, $action, $reason)) {
77 $sent_mails +
= $count;
78 $texte = "le message suivant :\n\n"
79 . " Auteur: {$mail['sender']}\n"
80 . " Sujet : « {$mail['subj']} »\n"
81 . " Date : ".strftime("le %d %b %Y à %H:%M:%S", (int)$mail['stamp'])."\n\n"
83 $mailer = new PlMailer();
84 $mailer->addTo("$list-owner@{$domain}");
85 $mailer->setFrom("$list-bounces@{$domain}");
86 $mailer->addHeader('Reply-To', "$list-owner@{$domain}");
87 $mailer->setSubject($subject);
88 $mailer->setTxtBody($texte);
93 XDB
::execute("DELETE FROM ml_moderate WHERE handler = {?}",
95 sleep(60 * $count / $globals->lists
->max_mail_per_min
);
98 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: