What's new

Geo::IP module

thomas

Unswerving cyclist
Admin
Joined
Mar 14, 2002
Messages
8,772
Ratings
1 762
Hm, basically japanreference.com is a non-profite site, I have never thought of making money. However, a few days ago I unexpectedly received our first significant ad revenue and noticed that it's not so bad to cover some of our recurrent fees by additional "income". That's why I've added banners to a few selected forums (may our visitors forgive us!).
:)

The problem is how to serve banners according to people's location. I just read about CPAN's Geo::IP perl module.

GeoIP enables you to easily lookup countries by IP addresses, even when Reverse DNS entries don't exist. The GeoIP database contains IP Network Blocks as keys and countries as values, covering every public IP address. GeoIP can be used to:
  • Detect credit card fraud.
  • Manage export controls.
  • Automatically select the geographically closest mirror.
  • Analyze your web server logs to determine the countries of your visitors.
The Client APIs are open source, and a database that is updated every year is free, available for the C and Java APIs.
The code would work something like this:

Code:
my $gi = new Geo::IP('/usr/local/Geo-IP/current.db');
$country = $gi->lookup_country($ENV{REMOTE_ADDR});

if ($country eq 'US') {
# display US advertisement
} elsif ($country eq 'JP') {
# display JP advertisement
} else {
# display default advertisement
}
They also offer a stand-alone PHP module.

Has anyone worked already with that module?
 
Top