From: Stéphane Jacob Date: Sun, 28 Jun 2009 08:44:25 +0000 (+0200) Subject: Retrieve dead redirections thanks to inactive redirections (Closes #680). X-Git-Tag: xorg/0.10.1~33 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=4f970ab081dfb75e7595d98c61e1660f76edab65;hp=180627f3cd482a50406a3ad8d01e260a16e69957;p=platal.git Retrieve dead redirections thanks to inactive redirections (Closes #680). --- diff --git a/bin/cron/emails.check.php b/bin/cron/emails.check.php index b237e52..520bb6a 100755 --- a/bin/cron/emails.check.php +++ b/bin/cron/emails.check.php @@ -25,21 +25,39 @@ $panne_level = 3; require('./connect.db.inc.php'); +require("Console/Getopt.php"); + +/* + * Parse the command-line options. + */ +$opts = Console_GetOpt::getopt($argv, 'v'); +$opt_verbose = false; + +if (PEAR::isError($opts)) { + echo $opts->getMessage(); +} else { + $opts = $opts[0]; + foreach ($opts as $opt) { + if ($opt[0] == 'v') { + $opt_verbose = true; + } + } +} /* * Check duplicated addresses */ -$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 +$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('active', e2.flags))) - 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('active', e1.flags) AND u1.nom != u2.nom_usage AND u2.nom != u1.nom_usage AND w.email IS NULL - ORDER BY a1.alias"; + 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('active', e1.flags) 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); @@ -56,8 +74,8 @@ if (count($conflits) > 0) { . "https://www.polytechnique.org/admin/emails/duplicated"; echo "\n\n"; - $sql = "INSERT IGNORE INTO emails_watch (email, state, detection, last) - VALUES " . join(", ", $insert); + $sql = "INSERT IGNORE INTO emails_watch (email, state, detection, last) + VALUES " . join(", ", $insert); XDB::execute($sql); if (XDB::errno() != 0) { echo 'Error : ' . XDB::error() . "\n$sql"; @@ -69,7 +87,7 @@ if (count($conflits) > 0) { */ if ($panne_level > 0) { $sql = "SELECT e.email, u.hruid - FROM emails AS e + FROM emails AS e INNER JOIN auth_user_md5 AS u ON u.user_id = e.uid WHERE e.panne_level = $panne_level AND e.flags = 'active' ORDER BY u.hruid"; @@ -93,5 +111,26 @@ if ($panne_level > 0) { WHERE panne_level > $panne_level"); } +/* + * Retrieve the users with no active redirection, but still one working + * inactive redirection. + */ +if ($opt_verbose) { + $res = XDB::query("SELECT u.hruid, ei.email + FROM auth_user_md5 AS u + LEFT JOIN emails AS ea ON (ea.uid = u.user_id AND ea.flags='active') + INNER JOIN emails AS ei ON (ei.uid = u.user_id AND ei.flags='') + WHERE FIND_IN_SET('googleapps', u.mail_storage) = 0 AND ea.email IS NULL + GROUP BY u.user_id"); + + if ($res->numRows()) { + $result = $res->fetchAllAssoc(); + echo "Camarades n'ayant plus d'adresses actives, mais ayant une adresse inactive :\n"; + foreach ($result as $user) { + echo '* ' . $user['email'] . ' pour ' . $user['hruid'] . "\n"; + } + echo "\n"; +} + // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: ?> diff --git a/configs/platal.cron.in b/configs/platal.cron.in index fafa58b..a931d67 100644 --- a/configs/platal.cron.in +++ b/configs/platal.cron.in @@ -4,15 +4,16 @@ WD=/home/web/prod/platal/bin/cron # db 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 @VERSION@" br@staff.m4x.org -0 21 * * 0 web cd $WD; ./checkdb.php -v | mail -e -s "verifications verbose sur la BDD de plat/al @VERSION@" br@staff.m4x.org -0 20 * * * web cd $WD; ./emails.check.php | mail -e -s "qualite de l'annuaire" br@staff.m4x.org +0 21 * * 1-6 web cd $WD; ./checkdb.php | mail -e -s "Verifications sur la BDD de plat/al @VERSION@" br@staff.m4x.org +0 21 * * 0 web cd $WD; ./checkdb.php -v | mail -e -s "Verifications verbeuses sur la BDD de plat/al @VERSION@" br@staff.m4x.org +0 20 2-31 * * web cd $WD; ./emails.check.php | mail -e -s "Qualite de l'annuaire" br@staff.m4x.org +0 20 1 * * web cd $WD; ./emails.check.php -v | mail -e -s "Qualite de l'annuaire : verbeux" br@staff.m4x.org # inscription report 0 6 * * 1 web cd $WD; ./rapports_inscription.php # notifs -0 2 * * * web cd $WD; ./notifs.birthday.php +0 2 * * * web cd $WD; ./notifs.birthday.php 0 4 * * 6 web cd $WD; ./notifs.send.php # validations @@ -22,7 +23,7 @@ WD=/home/web/prod/platal/bin/cron */5 * * * * www-data cd $WD; ./banana.feedgen.php > /dev/null # AX spammer -15 * * * * web cd $WD; ./axletter.send.php | mail -e -s "envoi d'un mail de l'AX" br@staff.m4x.org +15 * * * * web cd $WD; ./axletter.send.php | mail -e -s "Envoi d'un email de l'AX" br@staff.m4x.org # homonymes 0 0 4 * * web cd $WD; ./homonymes.php