This is for a voting function I have on my website.
I am wondering which part I have to remove to be able to vote mutiple times on the same item. At the moment if you try and vote more than once it does not allow voting... very thankful for help.. //Dave
<?php
if(is_numeric($_POST['id'])){
include_once('Smarty.class.php');
$main_smarty = new Smarty;
include('config.php');
include(mnminclude.'link.php');
include(mnminclude.'html1.php');
include(mnminclude.'smartyvariables.php');
$link = new Link;
$link->id=$_POST['id'];
$link->read_basic();
if ($current_user->user_id == 0 && !anonymous_vote) {
error($main_smarty->get_config_vars('PLIGG_Visual_Vote_NoAnon'));
}
if($current_user->user_id != $_POST['user']) {
error($main_smarty->get_config_vars('PLIGG_Visual_Vote_BadUser'). $current_user->user_id . '-'. $_POST['user']);
}
$md5=md5($_POST['user'].$link->randkey);
if($md5 !== $_POST['md5']){
error($main_smarty->get_config_vars('PLIGG_Visual_Vote_BadKey'));
}
if($link->votes($current_user->user_id) > 0 || $link->reports($current_user->user_id) > 0) {
}
$value = $_POST['value'];
if($_POST['unvote'] == 'true')
{
if($link->votes($current_user->user_id) > 0 || $link->reports($current_user->user_id) > 0)
{
$link->remove_vote($current_user->user_id, $value);
}
else
{
error($main_smarty->get_config_vars('PLIGG_Visual_Vote_AlreadyUnVoted'));
}
//error($main_smarty->get_config_vars('PLIGG_Visual_Vote_AlreadyVoted'));
}
else
{
if($link->votes($current_user->user_id) > 0 || $link->reports($current_user->user_id) > 0)
{
error($main_smarty->get_config_vars('PLIGG_Visual_Vote_AlreadyVoted'));
}
$link->insert_vote($current_user->user_id, $value);
}
// TODO
if ($link->status == 'discard') {
$link->read();
$link->status = 'queued';
$link->store();
}
if(Voting_Method == 1){
$count=$link->votes;
echo "$count ~--~".$_POST['id'];
}
if(Voting_Method == 2){
$link_rating = $link->rating($link->id)/2;
$rating_width = $link_rating * 25;
$vote_count = $link->countvotes();
echo $rating_width . "~" . $link_rating . "~" . $vote_count . "~<li class='one-star-noh'>1</li><li class='two-stars-noh'>2</li><li class='three-stars-noh'>3</li><li class='four-stars-noh'>4</li><li class='five-stars-noh'>5</li>";
}
$link->evaluate_formulas();
}
function error($mess) {
header('Content-Type: text/plain; charset=UTF-8');
echo "ERROR: $mess";
die;
}
?>