New PlMailer based on Hermes code:
[platal.git] / include / register.inc.php
index e4e1c3b..d073be3 100644 (file)
@@ -125,7 +125,7 @@ function check_old_mat($promo, $mat, $nom, $prenom, &$ourmat, &$ourid)
         if (user_cmp($prenom, $nom, $_prenom, $_nom)) {
             $ourid  = $_uid;
             $ourmat = $_mat;
-            return "Tu es vraissemblablement déjà inscrit !";
+            return "Tu es vraisemblablement déjà inscrit !";
         }
     }
     return "erreur: vérifie que tu as bien orthographié ton nom !";
@@ -185,7 +185,6 @@ function create_aliases (&$sub)
     if ( $res->numRows() ) {
 
         list($h_id, $h_type, $expire) = $res->fetchOneRow();
-        $res->free();
 
         if ( $h_type != 'homonyme' and empty($expire) ) {
             XDB::execute('UPDATE aliases SET expire=ADDDATE(NOW(),INTERVAL 1 MONTH) WHERE alias={?}', $mailorg);
@@ -194,8 +193,7 @@ function create_aliases (&$sub)
             $res = XDB::query("SELECT alias FROM aliases WHERE id={?} AND expire IS NULL", $h_id);
             $als = $res->fetchColumn();
 
-            require_once('diogenes/diogenes.hermes.inc.php');
-            $mailer = new HermesMailer();
+            $mailer = new PlMailer();
             $mailer->setFrom('"Support Polytechnique.org" <support@polytechnique.org>');
             $mailer->addTo("$mailorg@polytechnique.org");
             $mailer->setSubject("perte de ton alias $mailorg dans un mois !");
@@ -241,6 +239,22 @@ function create_aliases (&$sub)
 }
 
 // }}}
+// {{{ function send_alert_mail
+
+function send_alert_mail($state, $body)
+{
+    $mailer = new PlMailer();
+    $mailer->setFrom("webmaster@polytechnique.org");
+    $mailer->addTo("hotliners@staff.polytechnique.org");
+    $mailer->setSubject("ALERTE LORS DE L'INSCRIPTION de "
+        . $state['prenom'] . ' ' . $state['nom'] . '(' . $promo . ')');
+    $mailer->setTxtBody($body
+        . "\n\nIndentifiants :\n" . var_export($state, true)
+        . "\n\nInformations de connexion :\n" . var_export($_SERVER, true));
+    $mailer->send();
+}
+
+// }}}
 // {{{ function finish_ins
 
 function finish_ins($sub_state)
@@ -260,8 +274,7 @@ function finish_ins($sub_state)
                    VALUES  ({?}, {?}, {?}, {?}, {?}, {?}, NOW(), 0, {?}, {?})",
             $uid, $forlife, $bestalias, $mailorg2, $pass_encrypted, $email, $naissance, $hash);
 
-    require_once('xorg.mailer.inc.php');
-    $mymail = new XOrgMailer('register/inscrire.mail.tpl');
+    $mymail = new PlMailer('register/inscrire.mail.tpl');
     $mymail->assign('mailorg', $bestalias);
     $mymail->assign('lemail',  $email);
     $mymail->assign('pass',    $pass);