Re: Checking user's IP....
by davorg (Chancellor) on Feb 02, 2000 at 01:31 UTC
|
Doing it with an IP address is no good as:
- All AOL users come from a limited number of IPs.
- Many ISPs allocate users a new IP each time they
connect.
Far better to do some kind of user login.
hth davorg
| [reply] |
Re: Checking user's IP....
by turnstep (Parson) on Mar 30, 2000 at 05:05 UTC
|
User logins will drastically reduce your number of respondants, of course.
You could use a simple cookie. Something like
VotedPoll1=451234221
where the number represents the time, to make it easy
to allow voting again at a later time. Although it might be
easier just to number the polls if a new one is created
every day.
| [reply] [d/l] |
RE: Checking user's IP....
by vroom (His Eminence) on Jan 23, 2000 at 05:02 UTC
|
You could log the IP addresses to a file and then search it. If you're running your site with a database you could log them to a table.
$address=$ENV{REMOTE_ADDR};
open FILE, "<logaddresses.dat";
my $addresses;
{
local $/=undef;
$addresses=<FILE>;
}
close FILE;
if($addresses=~/\Q$address/){
print "You already voted\n";
} else{
open FILE, ">>logaddresses.dat";
print " $address\n";
close FILE;
# update poll;
}
#display results;
if you want code for a database solution let me know | [reply] [d/l] |
|
I had the code checking user IP but I need the code to search IP address and if IP address is found, redirect to the found IP address by connecting open connection to telnet using the found IP address.
I would appreciate if you could help me with this code.
Thanks
| [reply] |
Re: Checking user's IP....
by dlc (Acolyte) on Jan 24, 2000 at 17:00 UTC
|
if you are using a database, then use the voter's I
address as the key, and declare (in the database
description) that the key be unique.
this isn't really the best idea, though--you'll shut out
(potentially) tons of visitors that come from the same IP,
such as a proxy server (ahem, *AOL*, ahem) and allow the
same user to vote if he is coming from an ISP which uses
dhcp to assign addresses.
| [reply] |
Re: Checking user's IP....
by Anonymous Monk on Jan 23, 2000 at 11:54 UTC
|
vroom, thanks for that code. I have one more question, is there a possible way to clear the log file after one day so people can vote once a day or would I have to clear it myself daily? | [reply] |
|
You have several options here.
- Have the name of the file contain the date.
- Have the date as the first line of the file.
If the dates are different, remove the file.
- Have the perl script accept the poll's name
from a form hidden. Search only that file.
Of these options, I like the last one best. This will allow
you to accurately track the results of your polls. (as a
back up to the main mechanisim.) And it would allow you to
keep up past polls. And you could leave a poll up for
longer than a day.
Crulx
| [reply] |
|
| [reply] |