Forum Moderators: coopster & phranque

Message Too Old, No Replies

getting pc ip

getting pc ip

         

RED SCORPiON

11:16 am on Feb 4, 2004 (gmt 0)

10+ Year Member



Hello,
how to get the pc ip of the visitor
i mean X_FORWARDED_FOR ,i want an example please
Thanks

coopster

11:49 am on Feb 4, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



You could check the
REMOTE_ADDR
environment variable. Here is a little snippet to show you ALL the environment variables:

#!/usr/local/bin/perl -wT
use strict;
use CGI ':standard';
print "Content-type: text/html\n\n";
print "<html><head><title>Environment Variables</title></head><body>";
foreach (keys %ENV) {
print "<br /><font color=red>$_</font> is set to <font color=blue>$ENV{$_}</font>";
}
print "</body></html>";

coopster

12:09 pm on Feb 4, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



After reading your post again, I think you may be looking for something other than what I offered. Are you referring to the ip addresses in your logs? If so, you may want to have a look at these threads:
How to log the real client ip [webmasterworld.com]
A few .htaccess challenges [webmasterworld.com]
Password Cracking [webmasterworld.com]

GeorgeGG

10:51 pm on Feb 4, 2004 (gmt 0)

10+ Year Member



Not sure if proper syntax, just what I use:

my $http_x_forward_far;
my $http_x_forward;

$http_x_forward_far = $ENV{'HTTP_X_FORWARDED_FOR'};
$http_x_forward_far = "" if!defined($http_x_forward_far);

$http_x_forward = $ENV{'HTTP_X_FORWARDED'};
$http_x_forward = "" if!defined($http_x_forward);

if ($http_x_forward_far)
{
print "ForFarX :: $http_x_forward_far\n";
}
if ($http_x_forward)
{
print "ForX :: $http_x_forward\n";
}

GGG