Part of the code in show_poll.php attempts to stop a user from voting on the same poll more than once by setting a cookie.
However this code fails (at least when you include it straight from within a theme), because headers have already been sent, so PHP can't set cookies.
To get around this, I have put a little code in that generates a cookie via javascript client side.
more or less it goes like this:
// JOHN
// if(isset($_REQUEST['action']) and $_REQUEST['action']) { // Poll Results.
if(( isset($_REQUEST['action']) AND $_REQUEST['action']) || array_key_exists('poll'.$question_id,$_COOKIE)) {
$user_answer = $_REQUEST['answer'];
if($_REQUEST['action'] != 'show_result' and isset($_REQUEST['answer']) and $_REQUEST['answer'] || array_key_exists('poll'.$question_id,$_COOKIE)) { //Register a vote
// JOHN
// if(!in_array($question_id, $voted_for_polls)) {
if(!array_key_exists('poll'.$question_id,$_COOKIE)) {
$wpdb->query($wpdb->prepare("UPDATE {$wpdb->prefix}pollin_answer SET votes=votes+1 WHERE ID=%d", $user_answer));
// JOHN
// @setcookie('pollin_voted', implode(';', $voted_for_polls) . ";$_REQUEST[question_id]", time() + 60*60*24*365, '/');
?>
<script type="text/javascript">
var exdate=new Date();
exdate.setDate(exdate.getDate()+5);
document.cookie="poll<? echo $question_id; ?>=1; expires="+exdate.toGMTString()+"; path=/";
</script>
<?
echo "Gracias por votar en la encuesta";
} else {
echo "Nuestros lectores opinan";
}
print "
";
}
You can see it in action here: http://aecor.hispamarc.com
Hope this helps.