Quick CF debugging switcher

If you're like me, you turn debugging on/off often on your development box. I got tired of going into the CFAdmin to do this, so I built a little script that lets me put in my CF Admin password, and then toggle the debugging output.

The only weird thing is that if you turn debugging on, it doesn't show on this page immediately, but it will show up after a page refresh. I thought other people might find this useful:

<body onload="document.getElementById('pwd').focus();">
<form name="debugSwitch" method="post">
   <input type="password" name="pwd" id="pwd" size="8">
   <input type="submit" name="submit" value="On">
   <input type="submit" name="submit" value="Off">
</form>

<cfif structKeyExists(form,"submit")>
   <cfparam name="form.submit" default="">
   <cfif form.submit eq "On">
      <cfset debugToggle = 1>
   <cfelse>
      <cfset debugToggle = 0>
   </cfif>
   <cftry>
      <cfscript>
         adminObj = createObject("component","cfide.adminapi.administrator");
         adminObj.login(form.pwd);
         myObj = createObject("component","cfide.adminapi.debugging");
         myObj.setDebugProperty("enableDebug",debugToggle);
         <cfif form.submit eq "On">
            myObj.setIP(cgi.remote_addr);
         <cfelse>
            myObj.deleteIP(cgi.remote_addr);
         </cfif>
      </cfscript>
      <cfcatch type="cfadminapiSecurityError">
         Couldn't log you in...please try again
      </cfcatch>
   </cftry>
</cfif>
</body>

Also, I think this is a perfect example of where frameworks/OO do not make sense. Oh, and please don't put this in a public location, and make sure your CF admin password is strong. ;)

Comments
Pretty slick! I added this, and moments later someone in our office added it to their toolbar, and now it's just an on/off button in firefox in the links toolbar:

javascript:(function(){var debug=window.open('http://localhost/debugFlip.cfm?debug=off');debug.close();})()

javascript:(function(){var debug=window.open('http://localhost/debugFlip.cfm?debug=on');debug.close();})()

Code change should be obvious enough, and with the password hardcoded it's that much faster.
# Posted By Adam Fortuna | 12/29/06 10:47 AM
hrm, that didn't come out too well. How about

javascript:(function(){var debug=window.open('http/link/to/debugFlip.cfm?debug=off');debug.close();})()
# Posted By Adam Fortuna | 12/29/06 10:49 AM
Sweet! I won't tell anybody, but it sounds like you're storing your CF password in your debFlip.cfm file.... ;)
# Posted By yacoubean | 12/29/06 12:18 PM
Nice !!
# Posted By Kevin Jones | 1/31/07 9:44 AM
BlogCFC was created by Raymond Camden. This blog is running version 5.9. Contact Blog Owner