By: Rhino

Check for an IP Address...

<CFIF #left(cgi.remote_addr,7)# is "192.168">
    <!--- Your code goes here --->
<cfelseif #left(cgi.remote_addr,7)# is not "192.168">
    <CFlocation url = "http://www.yahoo.com">
</cfif>


The CFIF tag checks the left "7" digits of the incoming IP which is the cgi.remote_addr variable. If it meets the condition, the code is executed, if not and it meets the cfelseif then the page is redirected to Yahoo.com.

Pretty simple security to make sure requests only come from certain IPs.

About This Tutorial
Author: Rhino
Skill Level: Beginner 
 
 
 
Platforms Tested: CF5
Total Views: 35,645
Submission Date: December 13, 2002
Last Update Date: June 05, 2009
All Tutorials By This Autor: 10
Discuss This Tutorial
  • I did something similar at work on our intranet server. We have hundreds of people who access our site and my office was strictly against remembering usernames and passwords for the admin side of our site, so what i did was created a table called authorized and listed ip addresses of computers that had authorization to use the administration side of our intranet site. Then I did something similar to this below on a global variables form (we use fuseactions so this was called on every page): Select ipaddress From authorized then I wanted to make sure the computer was authorized, I'd do something like:

    Sorry, You don't have access to this information

    I'm sure you get the gist... I created a form to add ip's to this and modify them or delete them as well.

Advertisement

Sponsored By...
Powered By...