science-ation/admin/fix_judges_autocomplete.php

27 lines
755 B
PHP

<?
require_once ('../common.inc.php');
require_once ('../user.inc.php');
user_auth_required('committee', 'admin');
$q = $pdo->prepare('SELECT * FROM judges WHERE passwordexpiry IS NULL');
$q->execute();
while ($i = $q->fetch(PDO::FETCH_OBJ)) {
echo "Autocompleting Judge {$i->email}<br />";
$id = $i->id;
$p = generatePassword(12);
$stmt = $pdo->prepare("UPDATE judges SET password='$p',complete='yes'");
$stmt->execute();
show_pdo_errors_if_any($pdo);
$stmt = $pdo->prepare("DELETE FROM judges_years WHERE judges_id='$id'");
$stmt->execute();
show_pdo_errors_if_any($pdo);
$stmt = $pdo->prepare("INSERT INTO judges_years (`judges_id`,`year`) VALUES ('$id','{$config['FAIRYEAR']}')");
$stmt->execute();
show_pdo_errors_if_any($pdo);
}
?>