JavaScript Editor Ajax software     Free javascripts 



Main Page

14.
Load
http://seophp.example.com/cloaking_test.php
. Because you’re not a search
engine, you will be shown the picture of Tweety and Sylvester, as shown in Figure 11-1.
15.
The simplest way to test what happens if you’re a search engine is to add your local IP to the
simple_cloak
table. Use either the MySQL console or phpMyAdmin to connect to the
seophp
database, and execute this query:
INSERT INTO cloak_data (spider_name, record_type, value)
VALUES (‘localtest’, ‘IP’, ‘127.0.0.1’)
16.
Load
http://seophp.example.com/cloaking_test.php
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
cloak_data
table stores
data about search engine IPs and user agents, and the
cloak_update
table stores data about the last data-
base update. You use this latter table to store the time and version of your last update.
The
SimpleCloak
class contains two methods that you can use in your programs:
updateAll()
and
isSpider()
. The
updateAll()
method retrieves data from
www.iplists.com
and saves it into the
local database — but not more often than once a week, and only when the version information retrieved
from
www.iplists.com
is different than that stored in your
cloak_update
table.
In the pages that need to implement cloaking, you use
SimpleCloak::isSpider()
, 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
isSpider()
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
232
Chapter 11: Cloaking, Geo-Targeting, and IP Delivery
c11.qxd:c11 11:01 232


JavaScript Editor Ajax software     Free javascripts