IP-Based Cloaking in ASP Hi everyone.
I finally have the chance to sit down and begin this small tutorial in ASP Cloaking.
Before beginning, I will state some brief definitions.
Cloaking – The ability to display web content to one user while displaying different content to another without having to change the page URL.
You can get a better explanation here [searchengineworld.com].
Robots/ Spiders – I’ll let SearchEngineWorld.com [searchengineworld.com] explain this one as well.
Now, let’s start talking about how IP-Based Cloaking works.
IP-Based Cloaking works by grabbing the IP Address of a robot/spider or user (users = humans throughout this whole thread). Then it takes the IP Address and compares it with a database full of robot/spider IP’s. If it finds a match, the script then pulls up the specified content for that robot/spider. If it does not find a match, the script pulls up the user content.
That’s the concept of IP-Based Cloaking. You can write the script with almost any language. Most people do it in Perl. While some do it in PHP or even ASP. The point is it can be done with any server-side scripting language. All you need to do is grab the IP Address, check it with a database and determine whether or not the IP matches. After that’s determined give them the specified content. That sounds easy enough. The hard part is getting your database filled with spider info. You can go about doing that either of two ways. One is search and find the info yourself or buy it from someone else. Once you have the robot/spider database ready you can start building the script. All of this takes time. First you build it then you maintain it. Both the script and the database have to be kept up. But that’s another story.
OK, this first post is just to get anyone that is not familiar with IP-Based Cloaking to get an understanding of how it works. Check out the links given here and ask away. You should also read this thread here [webmasterworld.com].
Now we will talk a little about the script
ASP
Below are the variables we will be using and there values.
' Set Variables
Dim spider_check, ipaddress, data_source
' Request the IP Address
ipaddress = Request.ServerVariables("REMOTE_ADDR")
' This SQL statement checks the IP address with IP address of spiders in your DB
spider_check = "select ipaddress from data where ipaddress = '" & ipaddress & "'"
' This SQL statement uses the spiders IP address to grab that spiders information.
spider_info = "select * from data where ipaddress = '" & ipaddress & "'"
'This is where the path to the directory that holds your Database goes
data_source = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & _ Server.MapPath("/directory/path/accessDB/cloak.mdb")
The above is pretty basic. You declare the variables then you set up the values. You have your SQL statements that will be used to pull information from the database and at the bottom you have a variable holding the path to the database.
The one to pay close attention to is the one in red
ipaddress = Request.ServerVariables("REMOTE_ADDR")
This variable holds the IP-Address. Here we are using one of the properties of the Request Object, the ServerVariables collection. Anytime you need to find out anything about your server, this is the collection you will be using. What goes inside the ( ) is what is called the server environment variable. In this case we are using “REMOTE_ADDR”. This will grab the IP Address of the user requesting the page. Now we have the users IP Address.
This is one of the reasons ASP is in the cloaking business. In the next post I will talk about making the connection to the database and checking the IP-Address we have obtained with the database.
Thanks