info("select e.matricule,e.nom,e.prenom,e.promo from envoidirect as e inner join auth_user_md5 as a on (e.matricule = a.matricule and a.perms = 'user') order by promo,nom;");
/* donne la liste des emails qui apparaissent 2 fois dans la table emails pour des personnes différentes */
-info("SELECT a1.alias, a2.alias, e1.email, e2.flags
+info("SELECT a1.alias, a2.alias, e1.email, e2.flags, w.state, w.description
FROM emails AS e1
INNER JOIN emails AS e2 ON(e1.email = e2.email AND e1.uid!=e2.uid AND
(e1.uid<e2.uid OR NOT FIND_IN_SET(e2.flags,'active'))
)
+ INNER JOIN emails_watch AS w ON(w.email = e1.email AND w.state != 'safe')
INNER JOIN aliases AS a1 ON(a1.id=e1.uid AND a1.type='a_vie')
INNER JOIN aliases AS a2 ON(a2.id=e2.uid AND a2.type='a_vie')
INNER JOIN auth_user_md5 AS u1 ON(a1.id=u1.user_id)
--- /dev/null
+#!/usr/bin/php4 -q
+<?php
+/***************************************************************************
+ * 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 *
+ ***************************************************************************/
+
+require('./connect.db.inc.php');
+
+$sql = "SELECT a1.alias, a2.alias, e1.email
+ FROM emails AS e1
+ INNER JOIN emails AS e2 ON (e1.email = e2.email AND e1.uid != e2.uid
+ AND (e1.uid < e2.uid OR NOT FIND_IN_SET(e2.flags, 'active')))
+ LEFT JOIN emails_watch AS w ON (e1.email = w.email)
+ INNER JOIN aliases AS a1 ON (a1.id = e1.uid AND a1.type = 'a_vie')
+ INNER JOIN aliases AS a2 ON (a2.id = e2.uid AND a2.type = 'a_vie')
+ INNER JOIN auth_user_md5 AS u1 ON (a1.id = u1.user_id)
+ INNER JOIN auth_user_md5 AS u2 ON (a2.id = u2.user_id)
+ WHERE FIND_IN_SET(e1.flags, 'active') AND u1.nom != u2.nom_usage AND u2.nom != u1.nom_usage AND w.email IS NULL
+ ORDER BY a1.alias";
+
+$it = Xdb::iterRow($sql);
+
+$insert = array();
+$conflits = array();
+while (list($alias1, $alias2, $mail) = $it->next()) {
+ $insert[] = "('$mail', 'pending', CURDATE(), NOW())";
+ $conflits[] = "* $mail sur $alias1 et $alias2";
+}
+
+if (count($conflits) > 0) {
+ echo "Nouvelles adresses en doublon détectées :\n" . join("\n", $conflits)
+ . "\n\nVous pouvez entrer les informations collectées à ce sujet sur la page :\n"
+ . "http://www.polytechnique.org/admin/doublons";
+
+ echo "\n\n";
+ $sql = "INSERT IGNORE INTO emails_watch (email, state, detection, last)
+ VALUES " . join(", ", $insert);
+ Xdb::execute($sql);
+ if (mysql_errno() != 0) {
+ echo 'Error : ' . mysql_error() . "\n$sql";
+ }
+}
+
+
+
+?>
--- /dev/null
+CREATE TABLE `emails_watch` (
+ `email` CHAR(60) NOT NULL,
+ `state` ENUM('pending', 'safe', 'unsafe', 'dangerous') NOT NULL DEFAULT 'pending',
+ `detection` DATE DEFAULT 0,
+ `last` TIMESTAMP DEFAULT 0,
+ `uid` SMALLINT(5) DEFAULT NULL,
+ `description` TEXT NOT NULL,
+ PRIMARY KEY(`email`)
+);