X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;ds=inline;f=bin%2Fcron%2Fcron_ml_moderate.php;h=30ffde82aa819e8d42799c0af79b5f8c3ba74776;hb=12a587df92f7bc9efeb91c1a2d27f763070b8609;hp=03f2c711fdd1b1203c86cc3d014eeb8ed88d5617;hpb=a7c55d519321b6ef6d45fc133b51410cf8581edf;p=platal.git diff --git a/bin/cron/cron_ml_moderate.php b/bin/cron/cron_ml_moderate.php index 03f2c71..30ffde8 100755 --- a/bin/cron/cron_ml_moderate.php +++ b/bin/cron/cron_ml_moderate.php @@ -22,6 +22,7 @@ require('./connect.db.inc.php'); ini_set('max_execution_time', '75'); +ini_set('memory_limit', '128M'); $sent_mails = 0; $handler = time(); @@ -76,7 +77,28 @@ while ($sent_mails < $globals->lists->max_mail_per_min 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" @@ -92,24 +114,6 @@ while ($sent_mails < $globals->lists->max_mail_per_min $mailer->send(); } - // 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(); - } - // release the lock XDB::execute("DELETE FROM ml_moderate WHERE handler = {?}", $handler);