Author |
Message |
cloud2424
New Member
![New Member New Member](modules/Forums/images/ranks/1star.gif)
![](modules/Forums/images/avatars/gallery/blank.gif)
Joined: Oct 17, 2005
Posts: 6
|
Posted:
Thu Oct 20, 2005 8:43 am |
|
ok one more question raven with the survey block how can i set it up that people are only allowed to vote once. Some reason mine lets them keep voting. |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Raven
Site Admin/Owner
![](modules/Forums/images/avatars/45030c033f18773153cd2.gif)
Joined: Aug 27, 2002
Posts: 17088
|
Posted:
Sat Oct 22, 2005 11:04 am |
|
I have rewritten the code for v6.9. Edit modules/Surveys/index.php. Find function pollCollector($pollID, $voteID, $forwarder) {. Replace withCode:function pollCollector($pollID, $voteID, $forwarder) {
// Reworked by Raven - http://ravenphpscripts.com
global $HTTP_COOKIE_VARS, $prefix, $db, $index;
$pollID = intval($pollID);
$voteID = intval($voteID);
$past = time()-86400;
$voteValid = 1; // Assume Valid
$ctime = time();
if (empty($ip)) {
$ip = $_SERVER["REMOTE_ADDR"];
if (empty($ip)) $voteValid = 0;
}
$sql = "SELECT ip FROM ".$prefix."_poll_check WHERE ip='$ip' AND pollID='$pollID' LIMIT 1";
$row = $db->sql_query($sql);
if ($db->sql_numrows($row)) {
$voteValid=0;
$sql = "UPDATE ".$prefix."_poll_check set time='$ctime' WHERE ip='$ip' AND pollID='$pollID'";
$db->sql_query($sql);
}
else {
$sql = "INSERT INTO ".$prefix."_poll_check (ip, time, pollID) VALUES ('$ip', '$ctime', '$pollID')";
$db->sql_query($sql);
}
$db->sql_query("DELETE FROM ".$prefix."_poll_check WHERE time < '$past'");
/* update database if the vote is valid */
if ($voteValid==1) {
$db->sql_query("UPDATE ".$prefix."_poll_data SET optionCount=optionCount+1 WHERE pollID='$pollID' AND voteID='$voteID'");
if (!empty($voteID)) {
$sql = "UPDATE ".$prefix."_poll_desc SET voters=voters+1 WHERE pollID='$pollID'";
$db->sql_query($sql);
}
}
else {
$index=1;
include_once('header.php');
OpenTable();
echo "<center>Our records show that you have already voted in this poll.<br /><br />This is not Chicago.<br /><br />You may only vote once :lol:</center>";
CloseTable();
include_once('footer.php');
die();
}
Header("Location: $forwarder");
die();
}
|
|
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
JediStryker
Hangin' Around
![](modules/Forums/images/avatars/4140ae7d43591e681bcb8.jpg)
Joined: Jun 27, 2004
Posts: 38
Location: San Antonio, TX
|
Posted:
Fri Mar 17, 2006 10:33 pm |
|
Thanks for this, Raven! Just put it to good use. Your skills are enviable. ![Smile](modules/Forums/images/smiles/icon_smile.gif) |
_________________ http://minetworks.net
A Technician Community/Reference Place |
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Raven
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Sat Mar 18, 2006 12:48 am |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
bugsTHoR
Involved
![Involved Involved](modules/Forums/images/ranks/4stars.gif)
![](modules/Forums/images/avatars/568e5f374449c41c190ed.gif)
Joined: Apr 05, 2006
Posts: 263
|
Posted:
Fri Jun 23, 2006 6:52 pm |
|
hi
i would like to know how you set the poll up for the oposite , multiple answers
thx |
_________________ LUV RAVEN DISTROBUTION BEBE
Clanthemes.com are great (free advertisements for now until i get to 20,000 posts LoL) |
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Raven
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Fri Jun 23, 2006 10:25 pm |
|
Multiple answers and multiple voting by the same IP are not the same thing. Are you requesting how to have a user select more than one option at the same time? If so, you have to replace the radio buttons with check boxes and the corresponding logic. Or are you asking how to make it so the same IP could vote 1,000 times for the same answer/question? |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
bugsTHoR
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Sat Jun 24, 2006 1:03 am |
|
aahh i see , confusing ,, for me anyways lol
the radio buttons one ,how do i do those with check boxes?? please.
one of the site Admins would like
a poll about all things ...Beer what is your favourite beer/s so that the guys can do more than one ..2 or 3 maybe out 15 beers as our guys are from all over europe so there is lots of beer to chose from. |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
shotokan
Worker
![Worker Worker](modules/Forums/images/ranks/3stars.gif)
![](modules/Forums/images/avatars/aba1a00a45919606b5248.gif)
Joined: Aug 27, 2006
Posts: 172
|
Posted:
Wed Oct 04, 2006 3:36 pm |
|
Raven wrote: | Multiple answers and multiple voting by the same IP are not the same thing. Are you requesting how to have a user select more than one option at the same time? If so, you have to replace the radio buttons with check boxes and the corresponding logic. Or are you asking how to make it so the same IP could vote 1,000 times for the same answer/question? |
Hey Raven
what about the possibility to make the survey won;t show if the user has voted already? I would like the user now to see the survey anymore if he had voted. |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Raven
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Wed Oct 04, 2006 9:12 pm |
|
You mean to just show the results? |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
shotokan
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Thu Oct 05, 2006 6:48 am |
|
Yes. that's a posibility. What i am really interest is that a particular survey the he had voted already do not show up for him again, this way he wouldn't vote twice. |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
kaine
New Member
![New Member New Member](modules/Forums/images/ranks/1star.gif)
![](modules/Forums/images/avatars/gallery/blank.gif)
Joined: Dec 12, 2006
Posts: 11
|
Posted:
Sat Dec 23, 2006 11:38 am |
|
Hi,
Having the same problem too - I see this post relates to v6.9 and I am using RavenNuke76 v1.x Distro however I tried it anyway - didn't work
Basically I just want to stop multiple votes
Thanks in advance for any help
Kaine |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
kaine
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Sat Dec 30, 2006 6:54 am |
|
sorry to bump this, however I've still not been able to resolve it
Thanks in advance
Kaine |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
kaine
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Sat Dec 30, 2006 7:08 am |
|
done - think I was having a blonde moment
fyi I wasn't replacing the whole pollCollector section - I just replaced the first line - do'h |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
shotokan
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Sat Dec 30, 2006 10:42 am |
|
kaine wrote: | done - think I was having a blonde moment
fyi I wasn't replacing the whole pollCollector section - I just replaced the first line - do'h |
Sorry to ask but i still have the problem. How did you solve it. My pools stay there for me to vote how many times i want.
The only one that works ok is the one inside the forums but the one on the nuke portal allow people to vote as many times as they want so the voting thing loses its purpose. |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
kaine
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Sat Dec 30, 2006 10:48 am |
|
Basically you need to modify the module/surveys/index.php file as per Raven's info
However dont follow the info word for word as I did - you need to find the whole piece of code under pollCollection and replace it with the code Raven provided
That worked for me
Kaine |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
shotokan
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Sat Dec 30, 2006 12:28 pm |
|
Raven wrote: | I have rewritten the code for v6.9. Edit modules/Surveys/index.php. Find function pollCollector($pollID, $voteID, $forwarder) {. Replace withCode:function pollCollector($pollID, $voteID, $forwarder) {
// Reworked by Raven - http://ravenphpscripts.com
global $HTTP_COOKIE_VARS, $prefix, $db, $index;
$pollID = intval($pollID);
$voteID = intval($voteID);
$past = time()-86400;
$voteValid = 1; // Assume Valid
$ctime = time();
if (empty($ip)) {
$ip = $_SERVER["REMOTE_ADDR"];
if (empty($ip)) $voteValid = 0;
}
$sql = "SELECT ip FROM ".$prefix."_poll_check WHERE ip='$ip' AND pollID='$pollID' LIMIT 1";
$row = $db->sql_query($sql);
if ($db->sql_numrows($row)) {
$voteValid=0;
$sql = "UPDATE ".$prefix."_poll_check set time='$ctime' WHERE ip='$ip' AND pollID='$pollID'";
$db->sql_query($sql);
}
else {
$sql = "INSERT INTO ".$prefix."_poll_check (ip, time, pollID) VALUES ('$ip', '$ctime', '$pollID')";
$db->sql_query($sql);
}
$db->sql_query("DELETE FROM ".$prefix."_poll_check WHERE time < '$past'");
/* update database if the vote is valid */
if ($voteValid==1) {
$db->sql_query("UPDATE ".$prefix."_poll_data SET optionCount=optionCount+1 WHERE pollID='$pollID' AND voteID='$voteID'");
if (!empty($voteID)) {
$sql = "UPDATE ".$prefix."_poll_desc SET voters=voters+1 WHERE pollID='$pollID'";
$db->sql_query($sql);
}
}
else {
$index=1;
include_once('header.php');
OpenTable();
echo "<center>Our records show that you have already voted in this poll.<br /><br />This is not Chicago.<br /><br />You may only vote once :lol:</center>";
CloseTable();
include_once('footer.php');
die();
}
Header("Location: $forwarder");
die();
}
| |
I have a phpnuke 7.8 patched 3.2b would that solution work for me too? Asking because my function pollCollector looks different.
Mine is like that
function pollCollector($pollID, $voteID)
and Ravens is like that
function pollCollector($pollID, $voteID, $forwarder) |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
kaine
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Sat Dec 30, 2006 12:50 pm |
|
$forwarder just returns the voter to the results page once voted (I think), so shouldn't be a problem
can you test it on a local server first? just make sure you back up the original index.php and test it
Kaine |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
warren-the-ape
Worker
![Worker Worker](modules/Forums/images/ranks/3stars.gif)
![](modules/Forums/images/avatars/5064660247507d6711183.jpg)
Joined: Nov 19, 2007
Posts: 196
Location: Netherlands
|
Posted:
Sat Dec 29, 2007 10:57 am |
|
Many thnx for this fix Raven 1 of those little annoying nuke thingies that was making the surveys/polls quite useless to use (in a 'legal' way).
But i did notice that the code in ravennuke 2.10.01 looks almost the same as my original one (php-nuke 7.9), and looks nothing like the fix you provided above.
Anyway i hope there arent any security holes in it?
I also needed to rewrite it a bit to make it work in PHP-Nuke 7.9 (patched 3.3)
Code:
function pollCollector($pollID, $voteID) {
// Reworked by Raven - http://ravenphpscripts.com
global $HTTP_COOKIE_VARS, $prefix, $db, $index, $module_name;
$pollID = intval($pollID);
$voteID = intval($voteID);
$past = time()-86400;
$voteValid = 1; // Assume Valid
$ctime = time();
if (empty($ip)) {
$ip = $_SERVER["REMOTE_ADDR"];
if (empty($ip)) $voteValid = 0;
}
$sql = "SELECT ip FROM ".$prefix."_poll_check WHERE ip='$ip' AND pollID='$pollID' LIMIT 1";
$row = $db->sql_query($sql);
if ($db->sql_numrows($row)) {
$voteValid=0;
$sql = "UPDATE ".$prefix."_poll_check set time='$ctime' WHERE ip='$ip' AND pollID='$pollID'";
$db->sql_query($sql);
}
else {
$sql = "INSERT INTO ".$prefix."_poll_check (ip, time, pollID) VALUES ('$ip', '$ctime', '$pollID')";
$db->sql_query($sql);
}
$db->sql_query("DELETE FROM ".$prefix."_poll_check WHERE time < '$past'");
/* update database if the vote is valid */
if ($voteValid==1) {
$db->sql_query("UPDATE ".$prefix."_poll_data SET optionCount=optionCount+1 WHERE pollID='$pollID' AND voteID='$voteID'");
if (!empty($voteID)) {
$sql = "UPDATE ".$prefix."_poll_desc SET voters=voters+1 WHERE pollID='$pollID'";
$db->sql_query($sql);
}
}
else {
$index=1;
include_once('header.php');
OpenTable();
echo "<center>Our records show that you have already voted in this poll.<br /><br />You may only vote once!<br /><br />[ <a href=\"/\">Go Back</a> | <a href=\"modules.php?name=$module_name&op=results&pollID=$pollID\">Poll Results</a> ]</center>";
CloseTable();
include_once('footer.php');
die();
}
Header("Location: modules.php?name=$module_name&op=results&pollID=$pollID");
die();
}
|
Added $module_name (since i dont have that $forwarder) to make the redirect link to the results work.
Hope i did it correct ![Very Happy](modules/Forums/images/smiles/icon_biggrin.gif) |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
warren-the-ape
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Fri Jan 11, 2008 6:27 am |
|
After running this modification for 2 weeks now i noticed that after some time i was still able to vote again. At first i thought it was cause of the year change but later experienced the same thing after a couple of days.
I wondered if it has anything to do with this line (?);
Code:$past = time()-86400;
|
If so, could i just enter a higher number? |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
evaders99
Former Moderator in Good Standing
![](modules/Forums/images/avatars/803d73f6452557b947721.jpg)
Joined: Apr 30, 2004
Posts: 3221
|
Posted:
Fri Jan 11, 2008 12:09 pm |
|
86400 is the number of seconds in one day. Changing the number higher should create a longer cookie, which could last for longer than a day. (Of course, if users clear their cookies, they can bypass this step rather easily) |
_________________ - Only registered users can see links on this board! Get registered or login! -
Need help? Only registered users can see links on this board! Get registered or login! |
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
warren-the-ape
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Fri Jan 11, 2008 12:47 pm |
|
Aah okay I see now, so the votes are based on the user's cookie?
But that would mean its not completely watertight.
I guess it would need quite some re-coding to make a vote from a user really permanent? |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
evaders99
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Fri Jan 11, 2008 1:44 pm |
|
Yes - there really is no watertight solution. The best you could do is some kind of 'smart' consolidation with cookies, IP address, maybe browser User-agent or making it require a Nuke user login. Checking an online identity is a problem throughout the web |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
|