JavaScript Editor Ajax software     Free javascripts 



Main Page

Implementing Geo-Targeting
1.
Connect to your
seophp
database, as you did in the previous exercise, and execute the following
SQL command. It will create the
geo_target_data
table:
CREATE TABLE `geo_target_data` (
`id` int(11) NOT NULL auto_increment,
`start_ip_text` varchar(15) NOT NULL default ‘’,
`end_ip_text` varchar(15) NOT NULL default ‘’,
`start_ip_numeric` bigint(20) NOT NULL default ‘0’,
`end_ip_numeric` bigint(20) NOT NULL default ‘0’,
`country_code` char(2) NOT NULL default ‘’,
`country_name` varchar(50) NOT NULL default ‘’,
PRIMARY KEY (`id`),
KEY `start_ip_numeric` (`start_ip_numeric`,`end_ip_numeric`),
KEY `country_code` (`country_code`)
);
2.
Create a folder named
geo_target_data
in your
seophp
folder. Then download
http://
www.maxmind.com/download/geoip/database/GeoIPCountryCSV.zip
, and unzip the
file in the
geo_target_data
folder you’ve just created. You should end up with a file named
GeoIPCountryWhois.csv
in your
geo_target_data
folder.
Note that we’re not including the
GeoIPCountryWhois.csv
file in the book’s code download. You
need to download and unzip that file for yourself even when using the code download.
3.
Add the following constant definitions to your
include/config.inc.php
file:
<?php
// defines database connection data
define(“DB_HOST”, “localhost”);
define(“DB_USER”, “seouser”);
define(“DB_PASSWORD”, “seomaster”);
define(“DB_DATABASE”, “seophp”);
// the geo-targeting file name
define(‘GEO_TARGETING_CSV’, ‘geo_target_data/GeoIPCountryWhois.csv’);
?>
4.
Create a new file named
simple_geo_target.inc.php
in your
include
folder, and type
this code:
<?php
/*
// +----------------------------------------------------------------------+
// | SimpleGeoTarget |
// | Class for targeting content for specific geographical regions |
// | http://www.SEOEgghead.com |
// +----------------------------------------------------------------------+
// | Copyright (c) 2004-2006 Jaimie Sirovich <jsirovic@gmail.com> |
// +----------------------------------------------------------------------+
*/
236
Chapter 11: Cloaking, Geo-Targeting, and IP Delivery
c11.qxd:c11 11:01 236


JavaScript Editor Ajax software     Free javascripts