$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 .= "Please choose an election/referendum on this list.
\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; } } } ?> The GNOME Foundation - Votes ".htmlspecialchars($election["name"])."\n"; } if ($step >= 2) { $votes_array = elec_vote_get_votes_from_post ($choices); $vote = -1; $res = elec_verify_vote_is_valid ($choices, $vote, $votes_array); if ($res != "") { $error .= "The vote you made is not valid: ".htmlspecialchars($res)."
\n"; $step = 2; } } if ($step == 4) { /* vote has been confirmed */ require ("include/step4-commit.php"); $result = step4_do (); } else if ($step == 3) { /* confirm vote */ require ("include/step3-confirm.php"); $result = step3_do (); } else if ($step == 2) { /* choose vote */ require ("include/step2-choose.php"); $result = step2_do (); } else if ($step == 1) { /* login */ require ("include/step1-login.php"); $result = step1_do (); } else { if (!isset ($error) || $error == "") $error = "Unknown error.
\n"; } if (isset ($handle)) elec_sql_close ($handle); if (isset ($error) && $error != "") { echo "
".$error."
\n";; echo "

If you don't understand the error, you should probably contact the Membership and Elections Committee, which can be reached at elections@gnome.org.

\n"; } if ($step != $max_step && $step >= 1) { echo "
\n"; } echo $result; // already HTML escaped if ($step != $max_step && $step >= 1) { if ($step > 1) { echo " \n"; echo " \n"; } if ($step > 2) { $index=0; foreach ($votes_array as $vote) { $index++; $name = "pref".$index; $value = "vote".$vote; echo " \n"; } } echo " \n"; echo " \n"; echo " \n"; echo "
\n"; } ?>