Doug's Resume
OO Lexicon
Chat with Doug!
Recent Entries
You may also be interested in...

heaters
hotels boeken in 7 sec
Engagement Rings
Online Dating Australia




SURF'S UP!
You:
Your Web Site:
<< May, 2008 >>
SMTWTFS
123
45678910
11121314151617
18192021222324
25262728293031
Search Blog

ColdFusion Jobs
Recent Comments
Re: Viewing Option Text (in IE7) that's Wider than the Select List (by Dan Roberts at 5/15 2:38 PM)
Re: Viewing Option Text (in IE7) that's Wider than the Select List (by Dan Roberts at 5/15 10:06 AM)
Re: Inline CSS and Ajax Issue with IE (by Ben Nadel at 5/14 11:50 AM)
Re: The Perfect Alternative to Gas Powered Vehicles (by Thomas Messier at 5/09 12:47 PM)
Re: Promoting Family Unity: Lowering Your Utility Bills! (by Fernando Lopez at 5/07 10:12 PM)
Re: Why I Hate ORMs (a solicited rant) (by Richard at 5/06 10:56 AM)
Re: Why I Hate ORMs (a solicited rant) (by dougboude at 5/06 10:27 AM)
Re: Why I Hate ORMs (a solicited rant) (by Richard at 5/06 6:50 AM)
Re: Why I Hate ORMs (a solicited rant) (by Sean Corfield at 5/06 1:40 AM)
Re: Why I Hate ORMs (a solicited rant) (by Steve Bryant at 5/05 5:07 PM)
Categories
Archives
Photo Albums
Funnies (5)
Family (3)
RSS
Reciprocal Links

Powered by
BlogCFM v1.11

16 June 2006
Managing ColdFusion Mappings through the BACK DOOR
Often when hosting a site somewhere, it can be a slow process to get a mapping created or modified. Then there are also those times when all you really need to be able to do is SEE them so you can verify paths and what not.

Using snippets harvested from google, I wrote myself a simple little MappingUtil.cfm page that I use to perform the tasks previously mentioned, and now i share it here with those who may be interested.

WARNING:
A few things you should think about before using this tool:
  1. This code uses undocumented methods and is not supported by Adobe. It is not guaranteed to work against every version of ColdFusion server.
  2. Most of the time, yours isn't the only site living on a particular host server. This tool will allow you to see and manage ALL mappings, whether yours or not, therefore you must be very careful not to delete someone else's mapping.
  3. Performing your own back door mapping management without the admin's knowledge could get you kicked off of your current host.
  4. Never drink and manage mappings at the same time.

Okay, cautions out of the way, below is the code. It should be saved in a template name that matches the form action. Currently that is "mappingutil.cfm". If you wish to save it as a different name, be sure to edit the form action as well.


********************************  The Code  ***********************************************************
<cfparam name="url.action" default="false">
<cfparam name="form.mapping" default="">
<cfset factory=createObject("java","coldfusion.server.ServiceFactory")>
<cfset mappings = factory.runtimeService.getMappings()>
<cfset actionmessage = "">
<cfif url.action>
    <cfif form.mapping IS NOT "">
        <cfloop index="m" list="#form.mapping#">
            <cfset tmp= structdelete(mappings,m)>
        </cfloop>
        <cfset actionmessage = "<h3>Items Deleted.</h3>">
    </cfif>
    <cfif form.mapname IS NOT "" and form.mappath IS NOT "">
        <cfset mappings[form.mapname] = form.mappath>
        <cfset actionmessage = actionmessage & "<h3>Mapping added.</h3>">
    </cfif>
</cfif>

<cfoutput>
#actionmessage#
<h2>Mapping Admin</h2>
<form action="mappingutil.cfm?action=true" method="post">
<table cellpadding="5" cellspacing="5" bgcolor="##FFFFFF">
<tr><th>Delete</th><th colspan="2" align="center">Mapping</th></tr>
<cfloop collection="#mappings#" item="thismapping">
<tr>
    <td>
        <input type="checkbox" name="mapping" value="#thismapping#">
    </td>
    <td>
         <strong>#thismapping#</strong>
     </td>
     <td>
         (#mappings[thismapping]#)
     </td>
</tr>
</cfloop>
<tr><td colspan="3">Enter new mapping: name<input type="text" value="" name="mapname" size="15">&nbsp;&nbsp;path<input type="text" name="mappath" value="#expandpath(".")#" size="45"></td></tr>
<tr><td colspan="3" align="center"><input type="submit" value="Save Changes"></td></tr>
</table>
</form>
</cfoutput>



Posted by dougboude at 12:00 AM | PRINT THIS POST! |Link | 1 comment
Subscription Options

You are not logged in, so your subscription status for this entry is unknown. You can login or register here.

Re: Managing ColdFusion Mappings through the BACK DOOR
Nice work Doug. Just one small pointer, the action "mappingutil.cfm?action=true" should probably say "#cgi.script_name#?action=true" instead so I can name the file whatever I want.
Posted by Boyan on September 21, 2007 at 4:20 PM

Name:   Required
Email:   Required your email address will not be publicly displayed.

Want to receive notifications when new comments are added? Login/Register for an account.

Time to take the Turing Test!!!

What letter comes one place(s) before the letter I?
Type your answer exactly two time(s) in the designated box.

Type in the answer to the question you see above:

Your comment:

Sorry, no HTML allowed!