コード例 #1
0
ファイル: lists.php プロジェクト: Ekleog/platal
 function handler_moderate($page, $liste = null)
 {
     if (is_null($liste)) {
         return PL_NOT_FOUND;
     }
     $mlist = $this->prepare_list($liste);
     if (!$this->is_group_admin($page)) {
         $this->verify_list_owner($page, $mlist);
     }
     $page->changeTpl('lists/moderate.tpl');
     $page->register_modifier('hdc', 'list_header_decode');
     if (Env::has('sadd') || Env::has('sdel')) {
         S::assert_xsrf_token();
         if (Env::has('sadd')) {
             // Ensure the moderated request is still active
             $sub = $mlist->getPendingSubscription(Env::v('sadd'));
             $mlist->handleRequest(MailingList::REQ_SUBSCRIBE, Env::v('sadd'));
             $info = "validée";
         }
         if (Post::has('sdel')) {
             // Ensure the moderated request is still active
             $sub = $mlist->getPendingSubscription(Env::v('sdel'));
             $mlist->handleRequest(MailingList::REQ_REJECT, Post::v('sdel'), Post::v('reason'));
             $info = "refusée";
         }
         if ($sub) {
             $mailer = new PlMailer();
             $mailer->setFrom($mlist->getAddress(MailingList::KIND_BOUNCE));
             $mailer->addTo($mlist->getAddress(MailingList::KIND_OWNER));
             $mailer->addHeader('Reply-To', $mlist->getAddress(MailingList::KIND_OWNER));
             $mailer->setSubject("L'inscription de {$sub['name']} a été {$info}");
             $text = "L'inscription de {$sub['name']} à la liste " . $mlist->address . " a été {$info} par " . S::user()->fullName(true) . ".\n";
             if (trim(Post::v('reason'))) {
                 $text .= "\nLa raison invoquée est :\n" . Post::v('reason');
             }
             $mailer->setTxtBody(wordwrap($text, 72));
             $mailer->send();
         }
         if (Env::has('sadd')) {
             pl_redirect('lists/moderate/' . $liste);
         }
     }
     if (Post::has('moderate_mails') && Post::has('select_mails')) {
         S::assert_xsrf_token();
         $mails = array_keys(Post::v('select_mails'));
         foreach ($mails as $mail) {
             $this->moderate_mail($mlist, $mail);
         }
     } elseif (Env::has('mid')) {
         if (Get::has('mid') && !Env::has('mok') && !Env::has('mdel')) {
             require_once 'banana/moderate.inc.php';
             $page->changeTpl('lists/moderate_mail.tpl');
             $params = array('listname' => $mlist->mbox, 'domain' => $mlist->domain, 'artid' => Get::i('mid'), 'part' => Get::v('part'), 'action' => Get::v('action'));
             $params['client'] = $this->prepare_client();
             run_banana($page, 'ModerationBanana', $params);
             $msg = file_get_contents('/etc/mailman/fr/refuse.txt');
             $msg = str_replace("%(adminaddr)s", $mlist->getAddress(MailingList::KIND_OWNER), $msg);
             $msg = str_replace("%(request)s", "<< SUJET DU MAIL >>", $msg);
             $msg = str_replace("%(reason)s", "<< TON EXPLICATION >>", $msg);
             $msg = str_replace("%(listname)s", $liste, $msg);
             $page->assign('msg', $msg);
             return;
         }
         $this->moderate_mail($mlist, Env::i('mid'));
     } elseif (Env::has('sid')) {
         if (list($subs, $mails) = $this->get_pending_ops($mlist)) {
             foreach ($subs as $user) {
                 if ($user['id'] == Env::v('sid')) {
                     $page->changeTpl('lists/moderate_sub.tpl');
                     $page->assign('del_user', $user);
                     return;
                 }
             }
         }
     }
     if (list($subs, $mails) = $this->get_pending_ops($mlist)) {
         foreach ($mails as $key => $mail) {
             $mails[$key]['stamp'] = strftime("%Y%m%d%H%M%S", $mail['stamp']);
             if ($mail['fromx']) {
                 $page->assign('with_fromx', true);
             } else {
                 $page->assign('with_nonfromx', true);
             }
         }
         $page->assign_by_ref('subs', $subs);
         $page->assign_by_ref('mails', $mails);
     } else {
         $page->kill("La liste n'existe pas ou tu n'as pas le droit de la modérer.");
     }
 }
コード例 #2
0
ファイル: cron_ml_moderate.php プロジェクト: Ekleog/platal
    }
    $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('"' . $fullname . '" <web@' . $globals->mail->domain . '>');
        $mailer->setTxtBody($type . ' soumis par ' . $fullname . ' 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 ($mlist->handleRequest($action, $mid, $reason)) {
        $sent_mails += $count;
        $texte = "Le message suivant :\n\n" . "    Auteur: {$mail['sender']}\n" . "    Sujet : « {$mail['subj']} »\n" . "    Date  : " . strftime("le %d %b %Y à %H:%M:%S", (int) $mail['stamp']) . "\n\n" . $append;
        $mailer = new PlMailer();
        $mailer->addTo("{$list}-owner@{$domain}");
        $mailer->setFrom("{$list}-bounces@{$domain}");
        $mailer->addHeader('Reply-To', "{$list}-owner@{$domain}");
        $mailer->setSubject($subject);
        $mailer->setTxtBody($texte);
        $mailer->send();
    }
    // release the lock
    XDB::execute('DELETE FROM  email_list_moderate
                        WHERE  handler = {?}', $handler);
    sleep(60 * $count / $globals->lists->max_mail_per_min);
}
// vim:set et sw=4 sts=4 sws=4 foldmethod=marker fenc=utf-8: