Ajax software
Free javascripts
↑
Main Page
The
SimpleGeoTarget
class contains three methods to be used by an application:
?
getRegion()
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.
?
isRegion()
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.
?
importGeoTargetingData()
loads MaxMind’s geo-targeting file into your
geo_target_data
database table.
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 (
http://www.maxmind.com/
).
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.
Figure 11-5
Figure 11-6
235
Chapter 11: Cloaking, Geo-Targeting, and IP Delivery
c11.qxd:c11 11:01 235
Ajax software
Free javascripts
→