| 1 | <?php |
| 2 | /*************************************************************************** |
| 3 | * Copyright (C) 2003-2006 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 | ini_set('include_path', '../include:/usr/share/php'); |
| 23 | |
| 24 | require_once('../include/xorg.inc.php'); |
| 25 | require_once('../include/emails.inc.php'); |
| 26 | |
| 27 | $opts = getopt('i:'); |
| 28 | if (($opts['i'] && $opts['i'] == '-') || empty($opts['i'])) { |
| 29 | $file = 'php://stdin'; |
| 30 | } else { |
| 31 | $file = $opts['i']; |
| 32 | } |
| 33 | |
| 34 | $emails = explode("\n", file_get_contents($file)); |
| 35 | foreach ($emails as $_email) { |
| 36 | $email = valide_email($_email); |
| 37 | if (empty($email) || $email=='@') { |
| 38 | continue; |
| 39 | } |
| 40 | |
| 41 | $sel = $globals->xdb->query( |
| 42 | "SELECT e1.uid, e1.panne != 0 AS panne, count(e2.uid) AS nb_mails, u.nom, u.prenom, u.promo, a.alias |
| 43 | FROM emails AS e1 |
| 44 | LEFT JOIN emails AS e2 ON (e1.uid = e2.uid AND FIND_IN_SET('active', e2.flags) AND e1.email != e2.email) |
| 45 | INNER JOIN auth_user_md5 AS u ON (e1.uid = u.user_id) |
| 46 | INNER JOIN aliases AS a ON (u.user_id = a.id AND FIND_IN_SET('bestalias',a.flags)) |
| 47 | WHERE e1.email = {?} |
| 48 | GROUP BY e1.uid", $email); |
| 49 | if ($x = $sel->fetchOneAssoc()) { |
| 50 | if (!$x['panne']) { |
| 51 | $globals->xdb->execute("UPDATE emails SET panne=NOW() WHERE email = {?}", $email); |
| 52 | } |
| 53 | |
| 54 | if (empty($x['nb_mails'])) { |
| 55 | echo "$email : seule adresse active de {$x['prenom']} {$x['nom']}\n"; |
| 56 | } else { |
| 57 | $message = " Bonjour ! |
| 58 | |
| 59 | Nous t'écrivons car lors de l'envoi de la lettre d'information mensuelle |
| 60 | de Polytechnique.org à ton adresse polytechnicienne : |
| 61 | |
| 62 | {$x['alias']}@polytechnique.org, |
| 63 | |
| 64 | l'adresse {$email}, sur laquelle tu rediriges ton courrier, ne |
| 65 | fonctionnait pas. |
| 66 | |
| 67 | Estimant que cette information serait susceptible de t'intéresser, nous |
| 68 | avons préféré t'en informer. Il n'est pas impossible qu'il ne s'agisse que |
| 69 | d'une panne temporaire. Si tu souhaites changer la liste des adresses sur |
| 70 | lesquelles tu reçois le courrier qui t'es envoyé à ton adresse |
| 71 | polytechnicienne, il te suffit de te rendre sur la page : |
| 72 | |
| 73 | {$globals->baseurl}/emails/redirect |
| 74 | |
| 75 | |
| 76 | A bientôt sur Polytechnique.org ! |
| 77 | L'équipe d'administration <support@polytechnique.org> |
| 78 | |
| 79 | --------------------------------------------------------------------------- |
| 80 | |
| 81 | PS : si jamais tu ne disposes plus du mot de passe te permettant |
| 82 | d'accéder au site, rends toi sur la page |
| 83 | |
| 84 | {$globals->baseurl}/recovery |
| 85 | |
| 86 | elle te permettra de créer un nouveau mot de passe après avoir rentré ton |
| 87 | login ({$x['alias']}) et ta date de naissance !"; |
| 88 | |
| 89 | require_once("diogenes/diogenes.hermes.inc.php"); |
| 90 | $mail = new HermesMailer(); |
| 91 | $mail->setFrom('"Polytechnique.org" <support@polytechnique.org>'); |
| 92 | $mail->addTo("\"{$x['prenom']} {$x['nom']}\" <{$x['alias']}@polytechnique.org>"); |
| 93 | $mail->setSubject("Une de tes adresse de redirection Polytechnique.org ne marche plus !!"); |
| 94 | $mail->setTxtBody($message); |
| 95 | $mail->send(); |
| 96 | echo "$email : mail envoyé\n"; |
| 97 | } |
| 98 | } else { |
| 99 | echo "$email : cette addresse n'est pas dans la base\n"; |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | ?> |