1
lubdub
I'd like smarter polls
  • 2002/10/15 11:16

  • lubdub

  • Just popping in

  • Posts: 64

  • Since: 2002/2/28


Missing features I'd really would appreciate (of course, I could code them myself... but... not time for now )
- choose the way to record votes (for now, I think it's based on ip, but I have several users behind the same firewall, so it should be allowed to be based on username)
- allow/prevent anonymous users to vote
- show the list of voting users with their vote (at least for admin, but some polls could be completely public)

2
onokazu
Re: I'd like smarter polls
  • 2002/10/15 17:34

  • onokazu

  • XOOPS Founder

  • Posts: 617

  • Since: 2001/12/13


Quote:

lubdub wrote:
Missing features I'd really would appreciate (of course, I could code them myself... but... not time for now )
- choose the way to record votes (for now, I think it's based on ip, but I have several users behind the same firewall, so it should be allowed to be based on username)


I think the polls are based on username, if the voter is logged in. For anonymous users, we use IP.

Quote:

- allow/prevent anonymous users to vote
- show the list of voting users with their vote (at least for admin, but some polls could be completely public)


Yes, sounds like some nice ideas.

3
lubdub
Re: I'd like smarter polls
  • 2002/10/15 18:15

  • lubdub

  • Just popping in

  • Posts: 64

  • Since: 2002/2/28


Quote:

I think the polls are based on username, if the voter is logged in. For anonymous users, we use IP.

IMHO, nope... I think there is some logic to correct, here:
here is the code from XoopsPollLog:
$sql "SELECT COUNT(*) FROM ".$db->prefix("xoopspoll_log")." WHERE poll_id=".$poll_id." AND (ip='".$ip."'";
        if ( !empty(
$user_id) ) {
            
$sql .= " OR user_id=".$user_id."";
        }
        
$sql .= ")";
        list(
$count) = $db->fetchRow($db->query($sql));
        if ( 
$count ) {
            return 
true;

The request is thus, for a logged user:
AND ( IP = ... OR UID = ... ) ==> has voted
in other words, when I have 2 users behind the same firewall, the first is able to vote, but for the second, the IP is the same, the OR condition is true and thus he can't vote.

The correct logic should be:
UID not null ==> use it whatever the ip is.
UID null ==> use the ip whichever it is (this will prevent two anonymous from behind the same firewall, but prevents also a logged user from logging out and voting again)

The corrected code should looks like:
$sql "SELECT COUNT(*) FROM ".$db->prefix("xoopspoll_log")." WHERE poll_id=".$poll_id." AND ";
        if ( !empty(
$user_id) ) {
            
$sql .= " user_id=".$user_id;
        } else {
            
$sql .= "ip='".$ip."'";
        }


Quote:

Yes, sounds like some nice ideas.

thanks

4
onokazu
Re: I'd like smarter polls
  • 2002/10/16 22:03

  • onokazu

  • XOOPS Founder

  • Posts: 617

  • Since: 2001/12/13


Which version of XOOPS are you using? I see the following codes in xoopspolllog.php of RC3.0.5.

function hasVoted($poll_id$ip$user_id=NULL){
  
$db =& Database::getInstance();
  
$sql "SELECT COUNT(*) FROM ".$db->prefix("xoopspoll_log").
WHERE poll_id="
.intval($poll_id)." AND";
  if ( !empty(
$user_id) ) {
    
$sql .= " user_id=".intval($user_id);
  } else {
    
$sql .= " ip='".$ip."'";
  }
  list(
$count) = $db->fetchRow($db->query($sql));
  if ( 
$count ) {
    return 
true;
  }
  return 
false;
}

5
lubdub
Re: I'd like smarter polls
  • 2002/10/16 23:59

  • lubdub

  • Just popping in

  • Posts: 64

  • Since: 2002/2/28


Err... mmm... ok, let's forget what I said, then.. I'm still with RC 3.0.4 (I thought the 3.0.5 only included the security fix, which I didn't need, and I was too lazy to upgrade... )

My mistake... (but ... ok, whatever )

6
bmmolloy
Re: I'd like smarter polls
  • 2004/5/10 20:58

  • bmmolloy

  • Friend of XOOPS

  • Posts: 84

  • Since: 2004/4/21


Does anyone know how to remove the User check for the polls? I've got a poll running that I want anonymous users to be able to vote on. I can't understand the code yet...hehehe

Edit: Nevermind, I'm a big dummy.

Login

Who's Online

208 user(s) are online (118 user(s) are browsing Support Forums)


Members: 0


Guests: 208


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