+/*
+ * 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
+ */
+$it = Xdb::iterRow("SELECT al1.alias, al2.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)))
+ INNER JOIN aliases AS al1 ON (al1.uid = e1.uid AND al1.type = 'a_vie')
+ INNER JOIN aliases AS al2 ON (al2.uid = e2.uid AND al2.type = 'a_vie')
+ INNER JOIN accounts AS a1 ON (al1.uid = a1.uid)
+ INNER JOIN accounts AS a2 ON (al2.uid = a2.uid)
+ LEFT JOIN email_watch AS w ON (e1.email = w.email)
+ WHERE FIND_IN_SET('active', e1.flags) AND w.email IS NULL
+ ORDER BY al1.alias");