New spam submission form
authorx2003bruneau <x2003bruneau@839d8a87-29fc-0310-9880-83ba4fa771e5>
Sun, 24 Dec 2006 11:13:29 +0000 (11:13 +0000)
committerx2003bruneau <x2003bruneau@839d8a87-29fc-0310-9880-83ba4fa771e5>
Sun, 24 Dec 2006 11:13:29 +0000 (11:13 +0000)
git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@1313 839d8a87-29fc-0310-9880-83ba4fa771e5

ChangeLog
modules/email.php
templates/emails/submit_spam.tpl [new file with mode: 0644]
templates/skin/common.menu.tpl

index c1fdbd1..b3b2b05 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -12,6 +12,9 @@ New:
         - Signal bug send to OTRS and not trackers.                        -Car
         - New CSV-Importer                                                 -FRU
 
+    * Emails:
+        - New spam submission form                                         -FRU
+
     * Events:
         - Tips.                                                         -FRU/Car
         - Split Events in 2 modules: events and newsletter                 -FRU
index 6d690eb..c053cfb 100644 (file)
@@ -30,6 +30,7 @@ class EmailModule extends PLModule
             'emails/broken'   => $this->make_hook('broken', AUTH_COOKIE),
             'emails/redirect' => $this->make_hook('redirect', AUTH_MDP),
             'emails/send'     => $this->make_hook('send', AUTH_MDP),
+            'emails/antispam/submit'  => $this->make_hook('submit', AUTH_COOKIE),
 
             'admin/emails/duplicated' => $this->make_hook('duplicated', AUTH_MDP, 'admin')
         );
@@ -263,6 +264,33 @@ class EmailModule extends PLModule
         $page->assign('filtre',$bogo->level());
     }
 
+    function handler_submit(&$page)
+    {
+        $page->changeTpl('emails/submit_spam.tpl');
+
+        if (Post::has('send_email')) {
+            $upload = $_FILES['mail']['tmp_name'];
+            if (!is_uploaded_file($upload)) {
+                $page->trig('Une erreur a été rencontrée lors du transfert du fichier');
+                return;
+            }
+            $mime = mime_content_type($upload);
+            if ($mime != 'text/x-mail' && $mime != 'message/rfc822') {
+                $page->trig('Le fichier ne contient pas un mail complet');
+                return;
+            }
+            global $globals;
+            $box    = Post::v('type') . '@' . $globals->mail->domain;
+            $mailer = new PlMailer();
+            $mailer->addTo($box);
+            $mailer->setFrom('"' . S::v('prenom') . ' ' . S::v('nom') . '" <web@' . $globals->mail->domain . '>');
+            $mailer->setTxtBody(Post::v('type') . ' soumis par ' . S::v('forlife') . ' via le web');
+            $mailer->addAttachment($upload, 'message/rfc822', $_FILES['mail']['name']);
+            $mailer->send();
+            $page->trig('Le message a été transmis à ' . $box);
+        }
+    }
+
     function handler_send(&$page)
     {
         global $globals;
diff --git a/templates/emails/submit_spam.tpl b/templates/emails/submit_spam.tpl
new file mode 100644 (file)
index 0000000..dd44780
--- /dev/null
@@ -0,0 +1,51 @@
+{**************************************************************************}
+{*                                                                        *}
+{*  Copyright (C) 2003-2006 Polytechnique.org                             *}
+{*  http://opensource.polytechnique.org/                                  *}
+{*                                                                        *}
+{*  This program is free software; you can redistribute it and/or modify  *}
+{*  it under the terms of the GNU General Public License as published by  *}
+{*  the Free Software Foundation; either version 2 of the License, or     *}
+{*  (at your option) any later version.                                   *}
+{*                                                                        *}
+{*  This program is distributed in the hope that it will be useful,       *}
+{*  but WITHOUT ANY WARRANTY; without even the implied warranty of        *}
+{*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *}
+{*  GNU General Public License for more details.                          *}
+{*                                                                        *}
+{*  You should have received a copy of the GNU General Public License     *}
+{*  along with this program; if not, write to the Free Software           *}
+{*  Foundation, Inc.,                                                     *}
+{*  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA               *}
+{*                                                                        *}
+{**************************************************************************}
+
+<h1>Soumettre un spam</h1>
+
+<p>Ce formulaire permet de soumettre à l'antispam les mails mal filtrés.</p>
+
+<form method="post" action="{$platal->pl_self()}" enctype="multipart/form-data">
+  <table class="tinybicol">
+    <tr>
+      <td>
+        Soumettre un
+        <select name="type">
+          <option value="spam" {if $smarty.request.type neq 'spam'}selected="selected"{/if}>spam</option>
+          <option value="nonspam" {if $smarty.request.type eq 'nonspam'}selected="selected"{/if}>non-spam</option>
+        </select>
+        mal filtré.
+      </td>
+    </tr>
+    <tr>
+      <td>
+        <input type="file" name="mail" />
+      </td>
+    </tr>
+  </table>
+
+  <p class="center">
+    <input type="submit" name="send_email" value="Envoyer" />
+  </p>
+</form>
+
+{* vim:set et sw=2 sts=2 sws=2: *}
index 5066cdc..1904db5 100644 (file)
@@ -57,6 +57,7 @@
 <div class="menu_item"><a href="banana/">Forums &amp; PA</a></div>
 <div class="menu_item"><a href="lists">Listes de diffusion</a></div>
 <div class="menu_item"><a href="payment">Télépaiements</a></div>
+<div class="menu_item"><a href="emails/antispam/submit">Soumettre un spam</a></div>
 <div class="menu_item"><a href="emails/broken">Patte cassée</a></div>
 
 <div class="menu_title">Communauté X</div>