Page 1 of 1
Allow multiple votes from same IP in Ajax Voting Script
Posted: 17 Feb 2016, 14:54
by purcelly
Sorry, one last one from me as I just keep breaking the JS, it's not my stong point.
Is there a way to allow multiple votes from the same IP address, in the Ajax Voting script?
One of the pages we want to use this on is an internal website so all the PCs share an IP address and once the first person has voted, no one else can vote.
It doesn't matter if someone can vote more than once either, just that it's not restricted.
Allow multiple votes from same IP in Ajax Voting Script
Posted: 17 Feb 2016, 15:50
by Admin
Hi
If it doesn't matter that someone can vote multiple times the same item; make these changes in the "class.voting.php" file:
1. Line 247 (in votstdyDb(), for mysql). Replace:
With this code:
2. Line 269 (in votstdyTxt()). Replace:
With this code:
Code: Select all
return array('all'=>array(), $this->tdy=>array());
Allow multiple votes from same IP in Ajax Voting Script
Posted: 17 Feb 2016, 16:12
by purcelly
Sorry to be a pain, that worked perfectly in allowing to vote from different PCs thanks!
It's made the "Thanks" message disappear really quickly, is there anyway that can be extended to show for longer? Or indefinitely after a vote.
If I have four buttons on one page is the code simple enough to change to only allow someone to vote on one of them, not all four, but still allowing any PC on the network to do it? If not that's fine.
Allow multiple votes from same IP in Ajax Voting Script
Posted: 17 Feb 2016, 18:13
by Admin
1. You can display an alert box with the "Thanks" message. For that, replace this two lines of code in voting.js (line 66-67):
Code: Select all
ivot.parentNode.innerHTML = '<i><b>Thanks</b></i>';
votAjax(elm, vote);
With this:
Code: Select all
votAjax(elm, vote);
alert('Thanks');
2. In the readme.php page it is:
- If you want the user to can vote only a single item in one day, change the value of the constant NRVOT from 0 to 1.
define('NRVOT', 0);
So, set the value of NRVOT to 1, in voting.php.
Allow multiple votes from same IP in Ajax Voting Script
Posted: 18 Feb 2016, 09:41
by purcelly
This worked perfectly! You're a star, thank you!