in reply to Re^2: mod-perl2 re-using $ENV{REMOTE_ADDR}
in thread mod-perl2 re-using $ENV{REMOTE_ADDR}
use Data::Validate::IP qw(is_ip is_public_ip is_loopback_ip); my $ip; my @IPs; if (defined $ENV{HTTP_X_FORWARDED_FOR}) { @IPs=split /,/, $ENV{HTTP_X_FORWARDED_FOR}; }; unshift (@IPs, $ENV{REMOTE_ADDR}); foreach $check (@IPs) { $check =~ s/^\s*(.*?)\s*$/\1/g; if (is_ip($check)) { if (defined $ip) { if ( (not is_public_ip($check)) or (is_loopback_ip($check)) or ($check eq "41.79.21.90") ) { $check = $ip; } } $ip = $check; } } print "Content-type: text/html\nCache-Control: max-age=0,no-cache,no-s +tore,post-check=0,pre-check=0\n\n<html><head><title>Current IP Check< +/title></head><body>Current IP Address: $ip</body></html>";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: mod-perl2 re-using $ENV{REMOTE_ADDR}
by hv (Prior) on May 02, 2023 at 23:13 UTC | |
by bbs2web (Acolyte) on May 03, 2023 at 19:32 UTC |