#!/usr/bin/php5 -q debug = 0; // Do not store backtraces $opts = getopt('f:p:'); if (empty($opts['f']) || empty($opts['p'])) { print "File name missing (-f=file_name) or promotion missing (-p=file_name).\n"; exit; } $file = $opts['f']; $handle = fopen($file, 'r'); $promo_year = $opts['p']; $already = array(); $new = array(); $ambiguous = array(); while ($line = trim(fgets($handle))) { $data = explode(';', $line); $cond = new PFC_And(new UFC_NameTokens(split_name_for_search($data[0]), array(), false, false, Profile::LASTNAME)); $cond->addChild(new UFC_NameTokens(split_name_for_search($data[1]), array(), false, false, Profile::FIRSTNAME)); $uf = new UserFilter($cond); $profiles = $uf->getProfiles(); switch (count($profiles)) { case 0: $new[] = $line; break; case 1: foreach ($profiles as $profile) { $already[] = $profile->hrid(); } break; default: $hrids = array(); foreach ($profiles as $profile) { $hrids[] = $profile->hrid(); } $ambiguous[] = $line . ': ' . implode(', ', $hrids); break; } } $cond = new UFC_Promo('=', UserFilter::GRADE_MST, $promo_year); $uf = new UserFilter($cond); $profiles = $uf->getProfiles(); $promo = array(); foreach ($profiles as $profile) { $promo[] = $profile->hrid(); } $intersect = array_intersect($promo, $already); if (count($intersect) != count($already)) { print "There seems to be a problem: intersection of this promo and already found users differ.\n"; } $to_remove = array_diff($promo, $intersect); sort($new); sort($ambiguous); sort($to_remove); print "New users:\n" . implode("\n", $new) . "\n\n"; print "Ambiguous users:\n" . implode("\n", $ambiguous) . "\n\n"; print "Users to remove (louk out for ambiguous users before!):\n" . implode("\n", $to_remove) . "\n"; // vim:set et sw=4 sts=4 sws=4 foldmethod=marker fenc=utf-8: ?>