$ENV{'REMOTE_ADDR'} - ??? (Posted by fairhousing)
hello:
currently when i use $ENV{'REMOTE_ADDR'} to record an ip i get something like this 271.3.47.10 Is there any way to stop the number after the last period from being logged, if so how?
some sample code would be greatly appreciated
thanks in advance
----------
My Site Got Hacked, Check It Out!
http://www.birminghamnet.com
Traffic-Website.com free traffic, affiliate programs, hosting, & domain names.
My Site got hacked, but i'm coming back?
Federico Carnales posted this at 04:06 — 8th November 1999.
They have: 69 posts
Joined: Apr 1999
Code:
$IP = $ENV{'REMOTE_ADDR'};
$IP =~ s/(.+?)\.(.+?)\.(.+?)\.(.+?)/$1.$2.$3/;
Haven't tested it but should work just fine
----------
Reviews of the best resources for webmasters in your e-mail every week!
Subscribe for [red]FREE[/red] by going to http://www.web-reviews.com/
Stefen Enns posted this at 04:14 — 8th November 1999.
He has: 150 posts
Joined: Apr 1999
Here's some simple code that should do what you want.
-------------------
#!/usr/bin/perl
$ip=$ENV{'REMOTE_ADDR'};
@numbers=split(/\./,$ip);
$newip="@numbers[0].@numbers[1].@numbers[2]";
print "Content-Type: text/plain\n\n";
print "Your real IP address: $ip\n";
print "Here's how it looks now: $newip\n";
-------------------
I'm sure there are better ways to do it, but this is the simplest way.
Hope this helps!
Federico Carnales posted this at 04:31 — 8th November 1999.
They have: 69 posts
Joined: Apr 1999
My code was shorter
BTW... I just tested and it works.
----------
Reviews of the best resources for webmasters in your e-mail every week!
Subscribe for [red]FREE[/red] by going to http://www.web-reviews.com/
fairhousing posted this at 19:07 — 8th November 1999.
They have: 1,587 posts
Joined: Mar 1999
whow! wish all my post got this quick of a helpful response.
thanks to the both of u
----------
My Site Got Hacked, Check It Out!
http://www.birminghamnet.com
Traffic-Website.com free traffic, affiliate programs, hosting, & domain names.
My Site got hacked, but i'm coming back?
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.