CFLib.org – Common Function Library Project

addRemoveDebuggingIPAddress(ipAddress [, action])

Last updated February 17, 2004

Version: 1 | Requires: ColdFusion MX | Library: UtilityLib

 
Rated 1 time(s). Average Rating: 5.0

Description:
This function will either add or remove an IP address to the list of debugging ip addresses if you do not have an administrator access. It accepts two parameters, IPaddress to be added or removed and the action i.e either add or remove.

Return Values:
Returns a list of IP addresses.

Example:

view plain print about
<cfoutput>#addRemoveDebuggingIPAddress("127.0.0.2","remove")#</cfoutput>

Parameters:

Name Description Required
ipAddress IP Address Yes
action Add or Remove. Defaults to Add. No

Full UDF Source:

view plain print about
<!---
 This function will either add or remove an IP address to the list of debugging ip addresses if you do not have an administrator access.
 
 @param ipAddress      IP Address (Required)
 @param action      Add or Remove. Defaults to Add. (Optional)
 @return Returns a list of IP addresses. 
 @author Qasim Rasheed (qasim_1976@yahoo.com) 
 @version 1, February 17, 2004 
--->

<cffunction name="addRemoveDebuggingIPAddress" output="false" returnType="string">
    <cfargument name="IPaddress" type="string" required="Yes" />
    <cfargument name="action" type="string" default="Add" />
    <cfscript>
        var factory = CreateObject("Java","coldfusion.server.ServiceFactory");
        var debuggingService  ="";
    
</cfscript>
    <cflock name="factory_debuggingservice" type="exclusive" timeout="5">
        <cfset debuggingService = factory.getDebuggingService()>
        <cfswitch expression="#arguments.action#">
            <cfcase value="Add">
                <cfif not listcontainsnocase(debuggingService.iplist.ipList,arguments.IPaddress)>
                    <cfset debuggingService.iplist.ipList = ListAppend(debuggingService.iplist.ipList,arguments.IPaddress)>
                </cfif>
            </cfcase>
            <cfcase value="Remove">
                <cfif listcontainsnocase(debuggingService.iplist.ipList,arguments.IPaddress)>
                    <cfset debuggingService.iplist.ipList = ListDeleteAt(debuggingService.iplist.ipList,ListFindNoCase(debuggingService.iplist.ipList,arguments.IPaddress))>
                </cfif>
            </cfcase>
        </cfswitch>
        <cfreturn debuggingService.iplist.ipList />
    </cflock>
</cffunction>
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Tayo Akinmade Tayo Akinmade added
arrayTrim
3 day(s) ago

Will Belden Will Belden added
longTime
9 day(s) ago

James Sleeman James Sleeman added
quickSort
19 day(s) ago

Ben Forta Ben Forta added
GetHostAddress
22 day(s) ago

Top Rated

Darwan Leonardo Sitepu EksporSQLData
Rated 5.0, 16 time(s)

Darwan Leonardo Sitepu backupDatabase
Rated 5.0, 13 time(s)

Barney Boisvert indentXml
Rated 5.0, 10 time(s)

Kevin Pepperman generateSsccAsn
Rated 5.0, 4 time(s)

Created by Raymond Camden / Design by Justin Johnson