Move isvalid_email_redirection in emails.inc.php.
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Sun, 10 Aug 2008 19:50:42 +0000 (21:50 +0200)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Sun, 10 Aug 2008 19:50:42 +0000 (21:50 +0200)
Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
core
include/emails.inc.php
modules/marketing.php
modules/register.php

diff --git a/core b/core
index 12ccfec..ab6d7d8 160000 (submodule)
--- a/core
+++ b/core
@@ -1 +1 @@
-Subproject commit 12ccfec732e22546728674652a0a4caeeec08f60
+Subproject commit ab6d7d83467fc5e19755550d36144b26a9a29fb7
index be0b6fd..792d099 100644 (file)
@@ -63,6 +63,17 @@ function valide_email($str)
     return $ident . '@' . $dom;
 }
 
+// function isvalid_email_redirection() {{{1
+/** vĂ©rifie si une adresse email convient comme adresse de redirection
+ * @param $email l'adresse email a verifier
+ * @return BOOL
+ */
+function isvalid_email_redirection($email)
+{
+    return isvalid_email($email) &&
+        !preg_match("/@(polytechnique\.(org|edu)|melix\.(org|net)|m4x\.org)$/", $email);
+}
+
 // class Bogo {{{1
 // The Bogo class represents a spam filtering level in plat/al architecture.
 class Bogo
index c854069..9507cf5 100644 (file)
@@ -198,8 +198,8 @@ class MarketingModule extends PLModule
         $page->assign('user', $user);
 
         $email = null;
+        require_once 'emails.inc.php';
         if (Post::has('mail')) {
-            require_once 'emails.inc.php';
             $email = valide_email(Post::v('mail'));
         }
         if (Post::has('valide') && isvalid_email_redirection($email)) {
@@ -270,6 +270,7 @@ class MarketingModule extends PLModule
                 S::assert_xsrf_token();
                 $email = trim(Post::v('mail'));
 
+                require_once 'emails.inc.php';
                 if (!isvalid_email_redirection($email)) {
                     $page->trigError("Email invalide !");
                 } else {
index cb15051..dab11eb 100644 (file)
@@ -137,6 +137,7 @@ class RegisterModule extends PLModule
             case 3:
                 if (count($_POST)) {
                     require_once(dirname(__FILE__) . '/register/register.inc.php');
+                    require_once 'emails.inc.php';
                     if (!isvalid_email(Post::v('email'))) {
                         $err[] = "Le champ 'E-mail' n'est pas valide.";
                     } elseif (!isvalid_email_redirection(Post::v('email'))) {