1
cabdi_uk
Xoopspoll 1.2 total voters and votes not match
  • 2009/6/14 16:10

  • cabdi_uk

  • Just popping in

  • Posts: 28

  • Since: 2007/6/12


Hello

I am using XOOPS 2.3.3 and have recently installed xoopspoll 1.2 and it works fine. The only issue I have with it is that some users can vote many times creating more votes than the nu,ber of voters. Is there any way of limiting voters so that each votes once based on IP or Mac address , etc.

Thanks

2
ghia
Re: Xoopspoll 1.2 total voters and votes not match
  • 2009/6/14 18:09

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


Wasn't there a preference for that?

3
cabdi_uk
Re: Xoopspoll 1.2 total voters and votes not match
  • 2009/6/15 0:22

  • cabdi_uk

  • Just popping in

  • Posts: 28

  • Since: 2007/6/12


Yes there was a preference not helpful. The prefernce with this module has the following:

=> Restrict voting from the same IP* Yes No

=>Restricting voting from the same User* Yes No

I have got both selected Yes but I can vote several times and it shows the number of votes more than teh voters. For example if I voted 3 times and I am the only person who voted, it shows the no. of votes as 3 and voters as just 1. I cant set it to one vote for voter.

4
ghia
Re: Xoopspoll 1.2 total voters and votes not match
  • 2009/6/15 7:40

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


What is in your xoops_xoopspoll_log table? Do you have different ID's or IP's for the three votes?

I checked the voting function in /class/xoopspolllog.php and have questiions with this function:
function hasVoted($poll_id$ip$user_id=null)
    {
    global 
$xoopsModuleConfig;
    
//
    
$filter '';
    if (
$xoopsModuleConfig['limit_by_uid'] == 1){
      if (
$user_id 0) { //otherwise anons cannot vote at all.
        
$filter .= ' AND user_id ='.intval($user_id);
      }
    }
    if (
$xoopsModuleConfig['limit_by_ip'] == 1)
      
$filter .= ' AND ip ="'.intval($ip).'"';
    
//if both are set to no then have to default to original behavior otherwise it will break.
    
if ($filter == '') {
      if ( !empty(
$user_id) ) {
        
$filter .= " AND user_id=".intval($user_id);
      } else {
        
$filter .= " AND ip='".$ip."'";
      }
    }
    
// 
        
$db =& Database::getInstance();
    
$sql "SELECT COUNT(*) FROM ".$db->prefix("xoopspoll_log")." WHERE poll_id=".intval($poll_id).$filter;
    
//
        
list($count) = $db->fetchRow($db->query($sql));
        if ( 
$count ) {
            return 
true;
        }
        return 
false;
    }

The function makes to many presumptions on the state of the preferences and the case for both checks is now allowing that eg user1 can not vote more than once from ip1 but can vote again from ip2.
I would say when there is already a vote from user1 or from ip1, the new vote should be refused.

5
Mazarin
Re: Xoopspoll 1.2 total voters and votes not match
  • 2009/9/9 8:15

  • Mazarin

  • Just can't stay away

  • Posts: 533

  • Since: 2008/12/10


Shouldn't a more logical behavior be (in the case of both restrictions being enabled):

If anonymous user
ip has voted=can't vote (if anonymous can vote at all)
else if logged in user
user has voted=can't vote
ip has voted but user has NOT voted=CAN vote

Seems fairly simple to fix this. If I do, should I upload it as a hack or an update to the module or what?

6
sailjapan
Re: Xoopspoll 1.2 total voters and votes not match

seeing how you did it would be informative

7
Mazarin
Re: Xoopspoll 1.2 total voters and votes not match
  • 2009/9/9 20:09

  • Mazarin

  • Just can't stay away

  • Posts: 533

  • Since: 2008/12/10


OK, fixed that (I think). Now I'll just fix some annoying little things with the poll block before I upload things for you people to test

8
Mamba
Re: Xoopspoll 1.2 total voters and votes not match
  • 2009/9/9 21:29

  • Mamba

  • Moderator

  • Posts: 11366

  • Since: 2004/4/23


Thank you for doing it!

We need to have a "XOOPS Classic Pack" with the original modules that were included in XOOPS distribution up to XOOPS 2.0.13, and once they are redone/refactored as envisioned in the "Blue Move", we would release the Classic Pack.

Therefore your work is very much appreciated.

9
Mazarin
Re: Xoopspoll 1.2 total voters and votes not match
  • 2009/9/10 7:17

  • Mazarin

  • Just can't stay away

  • Posts: 533

  • Since: 2008/12/10


I just realized that I'm doing my changes in v1.1 and the link to v1.2 in the repository is down. Can anyone provide me with a link to or send me v1.2?

10
ghia
Re: Xoopspoll 1.2 total voters and votes not match
  • 2009/9/10 23:40

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


Try this one

Login

Who's Online

229 user(s) are online (138 user(s) are browsing Support Forums)


Members: 0


Guests: 229


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Mar 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits