$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);
. "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";
*/
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";
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:
?>
# 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
*/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