I cant stand tabs anymore
[platal.git] / htdocs / emails / broken.php
1 <?php
2 /***************************************************************************
3 * Copyright (C) 2003-2004 Polytechnique.org *
4 * http://opensource.polytechnique.org/ *
5 * *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the Free Software *
18 * Foundation, Inc., *
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
20 ***************************************************************************/
21
22 require_once('xorg.inc.php');
23 new_skinned_page('emails/broken.tpl',AUTH_COOKIE);
24 require_once('emails.inc.php');
25
26 if (Get::has('email') && Get::has('action')) {
27 $email = valide_email(Get::get('email'));
28 // vérifications d'usage
29 $sel = $globals->xdb->query(
30 "SELECT e.uid, a.alias
31 FROM emails AS e
32 INNER JOIN auth_user_md5 AS u ON e.uid = u.user_id
33 INNER JOIN aliases AS a ON (e.uid = a.id AND type!='homonyme' AND FIND_IN_SET('bestalias',a.flags))
34 WHERE e.email={?}", $email);
35
36 if (list($uid, $dest) = $sel->fetchOneRow()) {
37 // envoi du mail
38 $message = "Bonjour !
39
40 Ce mail a été généré automatiquement par le service de patte cassée de
41 Polytechnique.org car un autre utilisateur, ".Session::get('prenom').' '.Session::get('nom').",
42 nous a signalé qu'en t'envoyant un mail, il avait reçu un message d'erreur
43 indiquant que ton adresse de redirection $email
44 ne fonctionnait plus !
45
46 Nous te suggérons de vérifier cette adresse, et le cas échéant de mettre
47 à jour sur le site <{$globals->baseurl}/emails.php> tes adresses
48 de redirection...
49
50 Pour plus de rensignements sur le service de patte cassée, n'hésites pas à
51 consulter la page <{$globals->baseurl}/emails/broken.php>.
52
53
54 A bientôt sur Polytechnique.org !
55 L'équipe d'administration <support@polytechnique.org>";
56
57 require_once("diogenes/diogenes.hermes.inc.php");
58 $mail = new HermesMailer();
59 $mail->setFrom('"Polytechnique.org" <support@polytechnique.org>');
60 $mail->addTo("$dest@polytechnique.org");
61 $mail->setSubject("Une de tes adresse de redirection Polytechnique.org ne marche plus !!");
62 $mail->setTxtBody($message);
63 $mail->send();
64 $page->trig("Mail envoyé ! :o)");
65 }
66 } elseif (Post::has('email')) {
67 $email = valide_email(Post::get('email'));
68
69 list(,$fqdn) = split('@', $email);
70 $fqdn = strtolower($fqdn);
71 if ($fqdn == 'polytechnique.org' || $fqdn == 'melix.org' || $fqdn == 'm4x.org' || $fqdn == 'melix.net') {
72 $page->assign('neuneu', true);
73 } else {
74 $page->assign('email',$email);
75 $sel = $globals->xdb->query(
76 "SELECT e1.uid, e1.panne != 0 AS panne, count(e2.uid) AS nb_mails, u.nom, u.prenom, u.promo
77 FROM emails as e1
78 LEFT JOIN emails as e2 ON(e1.uid = e2.uid AND FIND_IN_SET('active', e2.flags) AND e1.email != e2.email)
79 INNER JOIN auth_user_md5 as u ON(e1.uid = u.user_id)
80 WHERE e1.email = {?}
81 GROUP BY e1.uid", $email);
82 if ($x = $sel->fetchOneAssoc()) {
83 // on écrit dans la base que l'adresse est cassée
84 if (!$x['panne']) {
85 $globals->xdb->execute("UPDATE emails SET panne=NOW() WHERE email = {?}", $email);
86 }
87 $page->assign_by_ref('x', $x);
88 }
89 }
90 }
91
92 $page->run();
93 ?>