From: x2003bruneau Date: Thu, 27 Jul 2006 10:01:25 +0000 (+0000) Subject: Better duplicated email check X-Git-Tag: xorg/0.9.11~239 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=866f133358783c8a3888309a2bca724dd1445ce4;p=platal.git Better duplicated email check Still have to make the associated admin page git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@675 839d8a87-29fc-0310-9880-83ba4fa771e5 --- diff --git a/bin/cron/checkdb.php b/bin/cron/checkdb.php index 66bca29..c804224 100755 --- a/bin/cron/checkdb.php +++ b/bin/cron/checkdb.php @@ -122,11 +122,12 @@ check("SELECT a.uid, a.country, a.region FROM adresses AS a LEFT JOIN geoloc_reg 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.uidnext()) { + $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"; + } +} + + + +?> diff --git a/configs/platal.cron b/configs/platal.cron index cae5cb4..6bcf68c 100644 --- a/configs/platal.cron +++ b/configs/platal.cron @@ -6,6 +6,7 @@ WD=/home/web/prod/platal/bin/cron 0 5 * * * web cd $WD; ./clean.php 0 21 * * 1-6 web cd $WD; ./checkdb.php | mail -e -s "verifications sur la BDD de plat/al" br@m4x.org 0 21 * * 0 web cd $WD; ./checkdb.php -v | mail -e -s "verifications verbose sur la BDD de plat/al" br@m4x.org +0 20 * * * web cd $WD; ./emails.check.php | mail -e -s "recherche d'usurpateurs" br@m4x.org # inscription report 0 6 * * 1 web cd $WD; ./rapports_inscription.php diff --git a/upgrade/0.9.11/05_email_watch.sql b/upgrade/0.9.11/05_email_watch.sql new file mode 100644 index 0000000..e24f906 --- /dev/null +++ b/upgrade/0.9.11/05_email_watch.sql @@ -0,0 +1,9 @@ +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`) +);