Have you ever wanted to have access to your debug code in your ColdFusion Server, but you don't want to go into the ColdFusion Administrator every time your home IP changes?

Here's a simple script that uses <cfregistry> to check for your IP, if the IP is not in the list it will add it to the debug IP list and give you access to debug code instantly. This tutorial is intended more than anything  to demonstrate how to use <cfregistry>, however this does work and can be implemented on server that allow <cfregistry>.

Let's begin:

First, Let's define a variable that we will define as FALSE be default, this will be used later to see if the current IP is already in the Deubug List.

	<!--- define that value is not found --->
    <cfset IPIsFound ="FALSE" />

Next, let's specify the Registry branch where the IP's are listed, we will define it here so we can work with it later on.

  <!--- define the registry branch --->
  <cfset reg_branch ="HKEY_LOCAL_MACHINE\SOFTWARE\Allaire\ColdFusion\CurrentVersion\Debug\DebugIPList" />

Now, let's go into our registry and get a listing of all the IP's that are currently listed for debug.

  <!--- look in the registry for this IP address --->
  <cfregistry action="GETALL"
    type="any" />

Now, let's go through the results of the <cfregistry> call above and see if the current IP is in the list, if it is then set the variable "IPIsFound" to TRUE.

  <cfoutput query="IsFound">
<cfif #trim(Entry)# eq"#remote_addr#"> <cfset IPIsFound ="TRUE" /> </cfif> </cfoutput>

Now, check the variable "IPIsFound" to see if the users IP is there or not. If the variable has a value of TRUE then simply display a notice that that IP is already listed, if it still has a value of FALSE, then add the IP to the list and alert the user that their IP has been added!

  <cfif IPIsFound neq"TRUE">
  	<!--- add this IP --->
    <cfregistry action="SET"
        value="" />

    	alert("Your IP has been added to the Debug List!");
    	alert("Your IP is already in the Debug List!");

That's it, you now can call this script via a browser on your machine and it'll automatically add your current IP to the list, if it doesn't already exist.

Questions? Comments? Email Me....

About This Tutorial
Author: Pablo Varando
Skill Level: Advanced 
Platforms Tested: CF5
Total Views: 138,279
Submission Date: November 06, 2002
Last Update Date: August 25, 2011
All Tutorials By This Autor: 47
Discuss This Tutorial

Website Designed and Developed by Pablo Varando.