<?

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();
	echo $pdo->errorInfo();
	$stmt = $pdo->prepare("DELETE FROM judges_years WHERE judges_id='$id'");
	$stmt->execute();
	echo $pdo->errorInfo();
	$stmt = $pdo->prepare("INSERT INTO judges_years (`judges_id`,`year`) VALUES ('$id','{$config['FAIRYEAR']}')");
	$stmt->execute();
	echo $pdo->errorInfo();
}

?>
