Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Quick and easy way to prevent multiple votes?

by PipTigger (Hermit)
on Jun 08, 2000 at 03:58 UTC ( [id://16991] : note . print w/replies, xml ) Need Help??


in reply to Quick and easy way to prevent multiple votes?

I think it would be valuable to write all IPs to a file. Have a space separating the IP from the USER_AGENT on each line. Then suck each line into a regex like /(\S+)\s(.*)/ so that $1 has the IP and $2 is the rest of the info you'd want to store about each session. Make a hash $visitlog{$1}=$2 for each line. When you get a new submission, check
if (defined $visitlog{$newipadd}) { # maybe check $USER_AGENT && $othrsave stuff to examine # if anything further about unique proxy users can be determined #failure code && error mesg } else { # maybe check $USER_AGENT && $othrsave stuff to further # determine if the user is attempting to revote. #process vote && success mesg $visitlog{$newipadd} = "$USER_AGENT" . $othrsave; }
Then before you end the script, overwrite your logfile with the current visitlog hash with each line containing "$key $value". This is how I'd probably do it. Hope it's helpful. I'd be glad to try to help more if you'd like any. TTFN & Shalom.

-PipTigger

Replies are listed 'Best First'.
RE: Re: Quick and easy way to prevent multiple votes?
by turnstep (Parson) on Jun 08, 2000 at 05:53 UTC

    > Then suck each line into a regex like /(\S+)\s(.*)/ so that $1 has the
    > IP and $2 is the rest of the info you'd want to store...

    Quick note: For a large list like the one potentially generated by such a script, a regex will not be as efficient as a split.

      I was under the impression that split employs regexes to do it's bidding and if no particular one is specified, it defaults to /\s+/. Maybe it also runs a =~ s/^\s+//; before matching the split field. I'm not sure about the underlying implementation but I thought one of my O'Reilly boox described split like this. Is that not the case? TTFN & Shalom.

      -PipTigger