X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=bin%2Fcron%2Femails.check.php;h=61c68674380d506e3d133ee69e2f037697b3603e;hb=fe13bc1d7ba9f72d452ec07baf8538a74b7c67b8;hp=b237e524fdf39fd3ce339ad1bf01523a1dabb219;hpb=ecf2b474289f94932ff60ab18674610979d0e0db;p=platal.git diff --git a/bin/cron/emails.check.php b/bin/cron/emails.check.php index b237e52..61c6867 100755 --- a/bin/cron/emails.check.php +++ b/bin/cron/emails.check.php @@ -1,7 +1,7 @@ #!/usr/bin/php5 -q 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 email_watch AS w ON (e1.email = w.email) + INNER JOIN aliases AS a1 ON (a1.uid = e1.uid AND a1.type = 'a_vie') + INNER JOIN aliases AS a2 ON (a2.uid = e2.uid AND a2.type = 'a_vie') + INNER JOIN auth_user_md5 AS u1 ON (a1.uid = u1.user_id) + INNER JOIN auth_user_md5 AS u2 ON (a2.uid = 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 email_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,27 @@ 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: ?>