| 1 | #!/usr/bin/php5 |
| 2 | <?php |
| 3 | |
| 4 | require_once 'connect.db.inc.php'; |
| 5 | |
| 6 | // Fetches the list of unregistered users. |
| 7 | $users = XDB::iterRow( |
| 8 | "SELECT user_id, prenom, nom, promo |
| 9 | FROM auth_user_md5 |
| 10 | WHERE hruid IS NULL"); |
| 11 | |
| 12 | // Creates missing human readable uids. |
| 13 | while (list($user_id, $prenom, $nom, $promo) = $users->next()) { |
| 14 | $forlife = make_forlife($prenom, $nom, $promo); |
| 15 | $hruid = XDB::query('SELECT * FROM auth_user_md5 WHERE hruid = {?} AND user_id != {?}', $forlife, $user_id); |
| 16 | if ($hruid->numRows() > 0) { |
| 17 | echo "WARNING: Duplicate forlife for user $user_id and forlife '$forlife'. Please check manually the entry.\n"; |
| 18 | } else { |
| 19 | XDB::execute('UPDATE auth_user_md5 SET hruid = {?} WHERE user_id = {?}', $forlife, $user_id); |
| 20 | } |
| 21 | } |
| 22 | ?> |