0) {
$poll = $sql->query_first("SELECT * FROM iworks_poll WHERE pollid='$_REQUEST[results]'");
$total_vote_count = $sql->get_count("rowid","iworks_poll_votes","pollid=$poll[pollid]");
if($total_vote_count == "0") $total_vote_count = "1";
eval ("\$pollresults .= \"".gettemplate("pollresultslist_details")."\";");
$result = $sql->query("SELECT * FROM iworks_poll_options WHERE pollid='$poll[pollid]' ORDER BY votecount DESC");
while ($row = $sql->fetch_array($result)) {
//if($pollresults) $pollresults.="
";
if($row['votecount'] == "0") {
$pollwidth2 = "0";
$pollwidth = "1";
} else {
$tmpvote = $row['votecount'];
$tmpwidth = $tmpvote/$total_vote_count;
$pollwidth = $tmpwidth*100;
$pollwidth = round($pollwidth);
$pollwidth2 = $pollwidth;
}
eval ("\$pollresults .= \"".gettemplate("pollresultslist")."\";");
}
$sql->free_result($result);
require ("my.query.fpd");
eval("dooutput(\"".gettemplate("pollresults")."\");");
exit();
}
//first check to see if the user is a guest...if they are, deny them access to vote.
if(!$user_info['userid']) {
$output="You must be registered and logged in to vote.";
$link="index.fpd";
require ("my.query.fpd");
eval("dooutput(\"".gettemplate("redirect")."\");");
exit();
}
//Make sure they selected an option...
if(!$_REQUEST['optionid']) {
$output="Please make a selection...";
$link="index.fpd";
require ("my.query.fpd");
eval("dooutput(\"".gettemplate("redirect")."\");");
exit();
}
//check to see if they have already voted...
$votecheck = $sql->query_first("SELECT * FROM iworks_poll_votes WHERE userid='$user_info[userid]' AND pollid='$_REQUEST[pollid]'");
if($votecheck['userid']) {
$output="You can only vote once.";
$link="index.fpd";
require ("my.query.fpd");
eval("dooutput(\"".gettemplate("redirect")."\");");
exit();
}
//insert their vote
$sql->query("INSERT INTO iworks_poll_votes (pollid,userid,optionid) VALUES ('$_REQUEST[pollid]','$user_info[userid]','$_REQUEST[optionid]')");
//count up the number of votes the submission has and update the vote count.
$votecount = $sql->get_count("rowid","iworks_poll_votes","optionid='$_REQUEST[optionid]'");
$sql->query("UPDATE iworks_poll_options SET votecount='$votecount' WHERE rowid='$_REQUEST[optionid]'");
header("LOCATION: vote.fpd?results=$_REQUEST[pollid]");
exit();
?>