$max_step || $step < 1) {
$step = 1;
}
$result = "";
$error = "";
$handle = elec_sql_open ();
if ($handle === FALSE) {
$error .= "Can not open the database.
\n";
$step = 0;
}
$election_id = -1;
if ($step == 1) {
if (isset ($_GET["election_id"]) && is_numeric ($_GET["election_id"])) {
$election_id = $_GET["election_id"];
} else if (isset ($_GET["id"]) && is_numeric ($_GET["id"])) {
$election_id = $_GET["id"]; //FIXME: Remove this else path after 2009 elections
}
} else if ($step >= 1) {
if (isset ($_POST["election_id"]) && is_numeric ($_POST["election_id"]))
$election_id = $_POST["election_id"];
}
if ($election_id == -1) {
$error .= "A menu of elections is not available. A URL that includes the election id is required. This should have been given to you when you were asked to vote.
\n";
$step = 0;
} else {
$election = elec_get_election ($handle, $election_id);
if ($election === FALSE) {
$error .= "The specified election/referendum does not exist.
\n";
$step = 0;
} else if (!elec_election_is_current ($election)) {
$error .= "The voting period for the specified ".htmlspecialchars(elec_election_get_type ($election))." starts on ".htmlspecialchars($election["voting_start"])." (UTC) and ends on ".htmlspecialchars($election["voting_end"])." (UTC). It is not possible to vote now.
\n";
$step = 0;
}
}
if ($step > 1) {
$email = "";
$tmp_token = "";
if (isset ($_POST["email"]) && isset ($_POST["tmp_token"])) {
$email = $_POST["email"];
$tmp_token = $_POST["tmp_token"];
}
if (!elec_verify_email_tmp_token ($handle, $election_id, $email, $tmp_token)) {
$step = 1;
$error .= "The e-mail address and token you gave do not match an existing voter, or you have already voted.
\n";
} else {
$choices = elec_choices_get ($handle, $election_id);
if (!elec_verify_elections ($choices)) {
$error .= "The ".htmlspecialchars(elec_election_get_type ($election))." is not properly set up.\n";
$step = 0;
}
}
}
?>
If you don't understand the error, you should probably contact the $committee_name, which can be reached at $committee_email.
\n"; } if ($step != $max_step && $step >= 1) { echo "\n"; } ?>