#!/software/php/bin/php $votes[$max]) $max = $i; } return $max; } // read in data from votedata file and check if already cast vote if(($handle = @fopen(VOTE_DATA_FILE, "r")) != false) { while(($line = fgetcsv($handle, 1000, ",")) != false) { // line is of form [ "pbeshai", 1 ] (userid, time) vote($line[0], $line[1]); } fclose($handle); } // process vote if the form was submitted and this user hasn't already voted if(VOTE_RUNNING && !$voted && $_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['reviewTime'])) { // write to the file if(($handle = fopen(VOTE_DATA_FILE, "a")) != false) { $time = $_POST['reviewTime']; fwrite($handle, USER_ID.",$time\n"); fclose($handle); vote(USER_ID, $time); } // redirect (lazy solution to get this to work as an include in shtml files) $host = $_SERVER['HTTP_HOST']; $uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\'); header("Location: https://$host$uri/".REDIRECT_AFTER_POST_FILE); } ?>

Your Vote ()

Voting is now over. The winner was $winner.

"; } if($voted) { echo "

You voted for ".$times[$userVote].".

"; } else { // not already voted if if(VOTE_RUNNING) { ?>

Results

10) $pixPerVote = 10; if(!VOTE_RUNNING) { $winner = findWinner(); } for($i = 0; $i < $numTimes; $i++) { $style = "clear: both"; $class = "votebar"; // the vote is over, so make it pretty. if(!VOTE_RUNNING) { if($i == $winner) { $class = "win $class"; $style .= "; font-weight: bold"; } else { $class = "lose $class"; } } echo ""; } ?>
Option Votes
".$times[$i].""; echo "
 
"; echo $votes[$i]."