What's new

Welcome to Japan Reference (JREF) - the community for all Things Japanese.

Join Today! It is fast, simple, and FREE!

Geo::IP module

  • Thread starter
  • Admin
  • #1

thomas

Unswerving cyclist
Admin
Joined
14 Mar 2002
Messages
9,684
Reaction score
1,354
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?
 

lineartube

free spirit
Joined
29 Oct 2002
Messages
484
Reaction score
9
Great resource link, Thomas. They even have developer APIs. Thanks.
 
Top Bottom