best way to get visitors once

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mcastles
Forum Newbie
Posts: 8
Joined: Thu Oct 21, 2004 6:54 pm

best way to get visitors once

Post by mcastles »

i have a simple voting script with php and mysql that grabs a visitors ip address and stores it in the db. I only want to let the visitor add their ip once a day.

The problem is.. some people are voting from within a network that has a proxy server and it is only possible for anyone from within that network to vote once.

Is there a better option to use to identify users than ip?

I don't particularly want to use cookies because the visitors can cheat with them.

Thanks
Archy
Forum Contributor
Posts: 129
Joined: Fri Jun 18, 2004 2:25 pm
Location: USA

Post by Archy »

Are the people voting members or are they visitors?

You could add their IP address to a database and then search for it when someone votes (could use preg_match for this). If that IP address has already voted, then dont allow the vote, if it hasn't been used, then allow the vote. You could also use a cron job to delete the contents of the cell every 24 hours automatically.
mcastles
Forum Newbie
Posts: 8
Joined: Thu Oct 21, 2004 6:54 pm

Post by mcastles »

sorry, they are visitors, but i don't want to get the ip address because it doesn't work for people behind a proxy server.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Search these forums, this topic has been solved several times.
djot
Forum Contributor
Posts: 313
Joined: Wed Jan 14, 2004 10:21 am
Location: planet earth
Contact:

Post by djot »

-
Hi,

If you don't want to store IP and cookies, there is no way to identify visitors.

If they are members, you could store their voting status in the members database.

Only solution for non members and to not use IP is to use some encrypted cookie data.

djot
-
mcastles
Forum Newbie
Posts: 8
Joined: Thu Oct 21, 2004 6:54 pm

Post by mcastles »

hmmm, ok i thought those two were the only way, thanks
djot
Forum Contributor
Posts: 313
Joined: Wed Jan 14, 2004 10:21 am
Location: planet earth
Contact:

Post by djot »

-
Hi,

You can't get a perfect voting control over your visitors. Some may have a proxy, some a static IP. Same for cookies: most will allow cookies, some not. Users can get a new IP by just reconnecting to the internet, or just delete your cookie to vote again.

My prefered way would be to just check the IP, and forget about cookies and proxy users. (Depends on how serious the voting has to be for sure!)

If you have visitors and members, you can have two different votings, one for unknown visitors and one for known members. The control of members should be perfect, the one for visitors depends on how often they hack your votings. This way you would have two resultig opinions.

djot
-
mcastles
Forum Newbie
Posts: 8
Joined: Thu Oct 21, 2004 6:54 pm

Post by mcastles »

djot wrote:-
My prefered way would be to just check the IP, and forget about cookies and proxy users. (Depends on how serious the voting has to be for sure!)
-
yeah, i had the same idea when i created the script.. I didn't bother about cookies and just used ip addresses.. but now I have had a few complaints from people behind a proxy so I might need to change. Or even use a combination of the two.

Thanks djot,

Marc
rehfeld
Forum Regular
Posts: 741
Joined: Mon Oct 18, 2004 8:14 pm

Post by rehfeld »

you could also limit the daily/hourly etc... votes from a specific ip address. they can still get around it if they try,
but we already know theres no way to do polling perfectly

Code: Select all

<?php


if (unique_cookie && ip_used_less_than_10times in last day) {

} else if (no_cookie && ip_used_less_than_3times in last day) {

}


?>

depending on whats it used for, maybe even assign a truthness value to votes. Votes that come from heavily used ips could be given a value of less than 1 vote, maybe .8 or somthing etc.....
Post Reply