class contains three methods to be used by an application:
receives an optional IP address, and returns the country code of that IP. If no IP is
specified, the method returns the region of the current visitor.
receives a region code and an optional IP address. It returns true if the region code
corresponds to the region of the IP address, or false otherwise. If no IP address is provided, the
address of the current visitor is used.
loads MaxMind’s geo-targeting file into your
Because the geo-targeting database isn’t likely to change as frequently as search engine spider data, in
this case you won’t implement an automatic update feature. Instead, the exercise assumes that you’ll
populate your database with geo-targeting data once, and then update periodically.
You’ll use the free geo-target database provided by MaxMind (
At the end of the exercise you’ll test your geo-targeting library by displaying a geo-targeted welcome mes-
sage to your visitor. A person from the United States would get the greeting that’s shown in Figure 11-5,
and a person from Romania would be shown the message that appears in Figure 11-6.
Put this to work in the following exercise.
Chapter 11: Cloaking, Geo-Targeting, and IP Delivery
c11.qxd:c11 11:01 235