. Because you’re not a search
engine, you will be shown the picture of Tweety and Sylvester, as shown in Figure 11-1.
The simplest way to test what happens if you’re a search engine is to add your local IP to the
table. Use either the MySQL console or phpMyAdmin to connect to the
database, and execute this query:
INSERT INTO cloak_data (spider_name, record_type, value)
VALUES (‘localtest’, ‘IP’, ‘127.0.0.1’)
again. This time the script will
think you’re a search engine, and will output the text “Tweety and Sylvester” instead of the
picture, as shown in Figure 11-2.
Implementing cloaking is basically a three-step process.
First, you needed to prepare the cloaking database and the cloaking library. The
data about search engine IPs and user agents, and the
table stores data about the last data-
base update. You use this latter table to store the time and version of your last update.
class contains two methods that you can use in your programs:
method retrieves data from
and saves it into the
local database — but not more often than once a week, and only when the version information retrieved
is different than that stored in your
In the pages that need to implement cloaking, you use
, which returns a
positive number representing the “confidence” it has in the request being that of a spider. The confi-
dence has one of these values:
0 if neither the user agent nor the IP match that of a spider
2 if the user agent is that of a spider
3 if the IP address is that of a spider
5 if both the IP address and the user agent are that of a spider
In this example, you verified that the value is greater or equal than 3 to ensure that the IP address is
from a spider. Also, note that
may optionally receive a number of optional parameters,
which you can use to have it verify if the visitor is a particular spider, and/or check only the user
agent or the IP address.
Cloaking Case Studies
Following are a few typical scenarios where cloaking could be used:
Rendering text images as text
Redirecting excluded content to a non-excluded equivalent
Chapter 11: Cloaking, Geo-Targeting, and IP Delivery
c11.qxd:c11 11:01 232