X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=bin%2Fcron%2Fcron_ml_moderate.php;h=044635a4e87108ec0ca09fca605152095448f50d;hb=8d84c630f353ef0534e02325507ed35cc2f0d28f;hp=d4b581f869c312bd75ee7fea9e3f5f6b2632c8df;hpb=ceb2a271a647d92967fa0f0810181b06733d3472;p=platal.git diff --git a/bin/cron/cron_ml_moderate.php b/bin/cron/cron_ml_moderate.php index d4b581f..044635a 100755 --- a/bin/cron/cron_ml_moderate.php +++ b/bin/cron/cron_ml_moderate.php @@ -1,7 +1,7 @@ #!/usr/bin/php5 -q lists->max_mail_per_min $action = 1; /** 1 = ACCEPT **/ $subject = "Message accepté"; $append = "a été accepté par $prenom $nom.\n"; + $type = 'nonspam'; $count += count($mem) + count($own); break; case 'refuse': $action = 2; /** 2 = REJECT **/ $subject = "Message refusé"; $append = "a été refusé par $prenom $nom avec la raison :\n\n" . $reason; + $type = 'nonspam'; $count += count($own) + 1; break; case 'delete': @@ -69,11 +72,33 @@ while ($sent_mails < $globals->lists->max_mail_per_min $append = "a été supprimé par $prenom $nom.\n\n" . "Rappel: il ne faut utiliser cette opération " . "que dans le cas de spams ou de virus !\n"; + $type = 'spam'; $count += count($own); break; } - if ($client->handle_request($list, $mid, $action, $reason)) { + // if the mail was classified as Unsure, feed bogo + $raw_mail = html_entity_decode($client->get_pending_mail($list, $mid, 1)); + // search for the X-Spam-Flag header + $end_of_headers = strpos($raw_mail, "\r\n\r\n"); + if ($end_of_headers === false) { // sometimes headers are separated by \n + $end_of_headers = strpos($raw_mail, "\n\n"); + } + $x_spam_flag = ''; + if (preg_match('/^X-Spam-Flag: ([a-zA-Z]+), tests=bogofilter/m', substr($raw_mail, 0, $end_of_headers + 1), $matches)) { + $x_spam_flag = $matches[1]; + } + if ($x_spam_flag == 'Unsure') { + $mailer = new PlMailer(); + $mailer->addTo($type . '@' . $globals->mail->domain); + $mailer->setFrom('"' . $prenom . ' ' . $nom . '" mail->domain . '>'); + $mailer->setTxtBody($type . ' soumis par ' . $prenom . ' ' . $nom . ' via la modération de la liste ' . $list . '@' . $domain); + $mailer->addAttachment($raw_mail, 'message/rfc822', $type . '.mail', false); + $mailer->send(); + } + + // send feedback to the mailing list owners + if ($client->handle_request($list, $mid, $action, utf8_decode($reason))) { $sent_mails += $count; $texte = "le message suivant :\n\n" . " Auteur: {$mail['sender']}\n"