919 - 926 - 9847

FarCry: admin redirect for Railo, and error handler update

So, first item of business. The /farcry/core/webtop folder for FarCry is a real pain to remember, and clients loath having to type that out all the time. To get around this, you're going to need to make the following edits. NOTE: This assumes that you have Apache, rewriting enabled and Railo as your CFML engine. It can be easily adapted to other engines and webservers.

You'll need to open up the webroot/farcryConstructor.cfm file first.

<!--- find this --->
<cfset THIS.webtopURL = "/farcry/core/webtop" />

<!--- change to this --->
<cfset THIS.webtopURL = "/cmsadmin" />

Next, we're going to add an Alias to our web server. You'll need to adjust this if you're using IIS

Alias /cmsadmin "C:\<sitehomes>\<myproject>\farcry\core\webtop"

Our last step is going to be a CFML mapping. In Railo, you visit your http://site/railo-context/admin/web.cfm. Go to the mappings link, and add a resource for /cmsadmin and C:\\\farcry\core\webtop. If it doesn't exist, you'll see a nice red tinge to the box that you entered the path into.

Update your FarCry application, or restart your CFML engine

Bob's your uncle, you should now be able to now browse http://site/cmsadmin and see the FarCry admin!

Second order of business, dealing with the default error handling. It's really great to see what's going when something breaks, it's really BAD for other people to see this in production. It's pretty simple to resolve. The below code will still allow for you to see errors when running test locally, but send all server based errors to email.

Find your webroot/Application.cfc and make the following edit

<!--- find this --->
<cfset super.OnError(argumentCollection=arguments) />

<!--- replace with --->
<cfset var machineName = createObject("java", "java.net.InetAddress").localhost.getHostName() />
        <cfif machinename contains("<server name... use cgi variable to get this>")>
            <cfmail from="<valid mail>" to="<valid mail>" subject="ERROR - <sitename>" type="html">
            <cfdump var="#url#">
            <cfdump var="#session#">
            <cfdump var="#arguments#">
<!--- send to an error page... need to make this--->
            <cflocation url="/site-error" addtoken="false">
            <cfset super.OnError(argumentCollection=arguments) />

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
jason's Gravatar I notice your email doesn't have the stack trace? The email dump we use here is:

         <cfset variables.machineName = createObject("java", "java.net.InetAddress").localhost.getHostName() />
         <cfsavecontent variable="errordump">
               <h3>Error Overview</h3>
               Machine:   #variables.machineName#
               Message:   #arguments.exception.Message#
               Browser:   #cgi.HTTP_USER_AGENT#
               DateTime:   #now()#
               Host:      #cgi.HTTP_HOST#
               HTTPReferer:   #cgi.HTTP_Referer#
               QueryString:   #cgi.Query_String#
               RemoteAddress:   #cgi.Remote_Addr#
               <h3>Root Cause</h3>
               <cfdump var="#arguments.exception#" label="Error Diagnostics">

Even with that I keep meaning to trim down the exception so that it is a little "lighter" but still has the core line numbers etc.
# Posted By jason | 9/6/11 9:48 PM
Matthew Williams's Gravatar Showoff ;).
# Posted By Matthew Williams | 9/6/11 10:11 PM
# Posted By Matthew Williams | 9/6/11 10:55 PM