=10) && ($nextChar < 36)){ // uppercase letters $nextChar -= 10; // bases the number at 0 instead of 10 $nextChar = chr($nextChar + 65); // ord('A') == 65 } else if($nextChar >= 36){ // lowercase letters $nextChar -= 36; // bases the number at 0 instead of 36 $nextChar = chr($nextChar + 97); // ord('a') == 97 } else { // 0-9 $nextChar = chr($nextChar + 48); // ord('0') == 48 } $retVal .= $nextChar; } return $retVal; } function step4_do () { global $error; global $handle; global $election_id; global $choices_nb; global $vote; global $votes_array; global $email; global $tmp_token; $result = ""; $res = elec_sql_start_transaction ($handle); if (!$res) { $error .= "Can not start a SQL transaction for the vote.
\n"; return $result; } $i = 0; do { $anon_token = randomCode (32); $anon_token_id = elec_insert_new_anon_token ($handle, $election_id, $anon_token); $i++; } while ($anon_token_id === FALSE && $i < 10); if ($anon_token_id === FALSE) { $error .= "Can not create an anonymous token: ".mysql_error ($handle)."
\n"; elec_sql_rollback ($handle); return $result; } if ($choices_nb == 1) { if ($vote != -1) { //FIXME verify that $vote is valid for this election/referendum $res = elec_insert_new_vote ($handle, $anon_token_id, $vote); if (!$res) { $error .= "Can not insert a vote: ".mysql_error ($handle)."
\n"; elec_sql_rollback ($handle); return $result; } } } else { foreach ($votes_array as $vote) { //FIXME verify that $vote is valid for this election/referendum $res = elec_insert_new_vote ($handle, $anon_token_id, $vote); if (!$res) { $error .= "Can not insert a vote: ".mysql_error ($handle)."
\n"; elec_sql_rollback ($handle); return $result; } } } $res = elec_sql_remove_tmp_token ($handle, $election_id, $email, $tmp_token); if (!$res) { $error .= "Can not remove temporary token: ".mysql_error ($handle)."
\n"; elec_sql_rollback ($handle); return $result; } $res = elec_sql_commit ($handle); if (!$res) { $error .= "Can not commit the vote: ".mysql_error ($handle)."
\n"; return $result; } $result .= "

Step 4/4 - Keep your anonymous token

\n"; $result .= "

Your vote has been received.

\n"; $result .= "

Please write this anonymous token somewhere:

\n"; $result .= "

".$anon_token."

\n"; $result .= "

This anonymous token will enable you to verify your vote when the preliminary results will be published. Nobody, even the Membership and Elections Committee, except you knows that this token is associated with you and only you will be able to verify your vote. It is not possible to request this anonymous token later.

\n"; return $result; } ?>