3 /***************************************************************************
4 * Copyright (C) 2003-2006 Polytechnique.org *
5 * http://opensource.polytechnique.org/ *
7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. *
12 * This program is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
17 * You should have received a copy of the GNU General Public License *
18 * along with this program; if not, write to the Free Software *
20 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
21 ***************************************************************************/
23 require('./connect.db.inc.php');
25 $sql = "SELECT a1.alias, a2.alias, e1.email
27 INNER JOIN emails AS e2 ON (e1.email = e2.email AND e1.uid != e2.uid
28 AND (e1.uid < e2.uid OR NOT FIND_IN_SET(e2.flags, 'active')))
29 LEFT JOIN emails_watch AS w ON (e1.email = w.email)
30 INNER JOIN aliases AS a1 ON (a1.id = e1.uid AND a1.type = 'a_vie')
31 INNER JOIN aliases AS a2 ON (a2.id = e2.uid AND a2.type = 'a_vie')
32 INNER JOIN auth_user_md5 AS u1 ON (a1.id = u1.user_id)
33 INNER JOIN auth_user_md5 AS u2 ON (a2.id = u2.user_id)
34 WHERE FIND_IN_SET(e1.flags, 'active') AND u1.nom != u2.nom_usage AND u2.nom != u1.nom_usage AND w.email IS NULL
37 $it = Xdb
::iterRow($sql);
41 while (list($alias1, $alias2, $mail) = $it->next()) {
42 $insert[] = "('$mail', 'pending', CURDATE(), NOW())";
43 $conflits[] = "* $mail sur $alias1 et $alias2";
46 if (count($conflits) > 0) {
47 echo "Nouvelles adresses en doublon détectées :\n" . join("\n", $conflits)
48 . "\n\nVous pouvez entrer les informations collectées à ce sujet sur la page :\n"
49 . "http://www.polytechnique.org/admin/emails/duplicated";
52 $sql = "INSERT IGNORE INTO emails_watch (email, state, detection, last)
53 VALUES " . join(", ", $insert);
55 if (mysql_errno() != 0) {
56 echo 'Error : ' . mysql_error() . "\n$sql";