Search Blog

Recent Comments
Re: Stats plugin ported to Model-Glue (by J.mihai at 12/14 8:52 AM)
Re: CFC DAO Generator (by rui at 7/04 5:42 AM)
Re: Updates to the DAO, Bean and Gateway generator (by rui at 7/04 4:49 AM)
Re: CFC DAO Generator (by fwscott at 6/22 7:03 PM)
Re: CFC DAO Generator (by dan at 6/22 12:38 PM)
Re: Trip to Thailand (by fwscott at 3/27 2:10 AM)
Re: CFC DAO Generator (by fwscott at 3/27 2:03 AM)
Re: CFC DAO Generator (by Garry Harstad at 3/26 12:30 PM)
Re: Trip to Thailand (by Niqui Merret at 3/23 4:51 PM)
Re: Adding a blogger ping utility to BlogCFM (by fwscott at 2/20 9:01 PM)
Categories
Annoucements (1 entries)
BlogCFM (3 entries)
CFC Generator (5 entries)
Coldfusion (11 entries)
Fusebox (2 entries)
Greasemonkey (1 entries)
Misc (3 entries)
Archives
November 2005 (2 entries)
October 2005 (1 entries)
August 2005 (1 entries)
July 2005 (4 entries)
June 2005 (5 entries)
May 2005 (7 entries)

Powered by
BlogCFM v1.01

July 2005
Fusebox Plugin for stats... take two already!
Post a Comment
Sorry, I do this alot but I was thinking about ways to change the plugin on the way home from work...

Got to thinking that site paths still would not work or quite a few other things.  In order to be more flexible I changed things around to where it creates a parsed file and the invisible image will be served from the parsed file.

So when you look at your stats now, you will see that circuit.fuseaction.cfm was hit and then they went to anothercircuit.anotherfuseaction in your site paths.  Also doing this, your stats program does not have to support reports by query strings.

Here is the modified code, if anyone has a better way of checking/creating the parsed files... please let me know.

<cfsilent>
<!--- The full path to where the CFM files should be stored for stats --->
<cfset plugin.statsdir = "#application.fusebox.rootdirectory#fbstats\" />
<!--- The relative path to where the CFM files should be stored for stats --->
<cfset plugin.statsrelpath = "/fbstats/" />
<!--- The full path to the invisible image --->
<cfset plugin.fullimagepath = "#application.fusebox.rootdirectory#images\spacer.gif" />
<!--- Current fuseaction file to create, example: mycircuit.myfuseaction.cfm --->
<cfset plugin.currentfusefilename = myfusebox.originalcircuit & "." & myfusebox.originalfuseaction & ".cfm" />
<!--- The file to create to keep track of total client resolution, example: clientresolution.cfm --->
<cfset plugin.clientresolutionfilename = "clientresolution.cfm" />
<!--- The file to create to keep track of viewable browser client resolution, example: clientviewableres.cfm --->
<cfset plugin.clientviewableresolutionfilename = "clientviewableres.cfm" />

<!--- Create the output for the coldfusion image files
This should be just enough to serve the image.
Currently just inserting <cfcontent file="#plugin.fullimagepath#" type="image/gif"  deletefile="no" />
 --->
<cfset plugin.imageout = "">
<cfset plugin.imageout = plugin.imageout & '<cfcontent file="#plugin.fullimagepath#" type="image/gif"  deletefile="no" />' />

<!--- Check to see if our image serving files exist, if not create them with the code to serve
the blank image
--->
<cfif not(directoryexists(plugin.statsdir))>
    <cfdirectory action="create" directory="#plugin.statsdir#" />
</cfif>
<cfif not(fileexists(plugin.statsdir & plugin.currentfusefilename))>
    <cffile action="write" file="#plugin.statsdir & plugin.currentfusefilename#" output="#plugin.imageout#" />
</cfif>
<cfif not(fileexists(plugin.statsdir & plugin.clientviewableresolutionfilename))>
    <cffile action="write" file="#plugin.statsdir & plugin.clientviewableresolutionfilename#" output="#plugin.imageout#" />
</cfif>
<cfif not(fileexists(plugin.statsdir & plugin.clientresolutionfilename))>
    <cffile action="write" file="#plugin.statsdir & plugin.clientresolutionfilename#" output="#plugin.imageout#" />
</cfif>
<cfsavecontent variable="request.fbstats">
<script language="javascript" type="text/javascript">
<!--
var fbstatsscreenW = 640, fbstatsscreenH = 480;
if (parseInt(navigator.appVersion)>3) {
 fbstatsscreenW = screen.width;
 fbstatsscreenH = screen.height;
}
else if (navigator.appName == "Netscape"
    && parseInt(navigator.appVersion)==3
    && navigator.javaEnabled()
   )
{
 var fbstatsjToolkit = java.awt.Toolkit.getDefaultToolkit();
 var fbstatsjScreenSize = jToolkit.getScreenSize();
 fbstatsscreenW = fbstatsjScreenSize.width;
 fbstatsscreenH = fbstatsjScreenSize.height;
}

var fbstatsinnerwidth= 640, fbstatsinnerheight= 480; // defaults
if (self.innerHeight)
    // all except Explorer
    {
    fbstatsinnerwidth= self.innerWidth;
    fbstatsinnerheight= self.innerHeight;
    }

    else if (document.documentElement && document.documentElement.clientHeight)
    // Explorer 6 Strict Mode
    {
    fbstatsinnerwidth= document.documentElement.clientWidth;
    fbstatsinnerheight= document.documentElement.clientHeight;
    }

    else if (document.body)
    // other Explorers
    {
    fbstatsinnerwidth= document.body.clientWidth;
    fbstatsinnerheight= document.body.clientHeight;
    }

<cfoutput>
fbstatsclientviewableresimage = new Image(1,1);
fbstatsclientviewableresimage.src = "#plugin.statsrelpath##plugin.clientviewableresolutionfilename#?resolution=" + fbstatsinnerwidth + "x" + fbstatsinnerheight;
fbstatsclientresolutionimage = new Image(1,1);
fbstatsclientresolutionimage.src = "#plugin.statsrelpath##plugin.clientresolutionfilename#?resolution=" + fbstatsscreenW + "x" + fbstatsscreenH;
</cfoutput>
// -->
</script>
<cfoutput>
<img src="#plugin.statsrelpath##plugin.currentfusefilename#" height="1" width="1" border="0"  />
</cfoutput>
</cfsavecontent>
</cfsilent>

One thing to remember... If you use the application.cfm from the Fusebox downloads, you must allow the directory through the filter.

Something like:

application.cfm
<cfsilent>
<cfif right(cgi.script_name, Len("index.cfm")) NEQ "index.cfm" AND right(cgi.script_name, 3) NEQ "cfc" and  not (cgi.PATH_INFO contains "/fbstats")>
    <cflocation url="index.cfm" addtoken="no">
<cfelse>
</cfif>
</cfsilent>

Add it to your fusebox.xml.cfm. I have mine as a preFuseaction plugin, but should work in preProcess also.
           
<plugin name="fbstats" template="fbstats.cfm" />

Then just reference request.fbstats in your layout file.

You can download the zipped version here.
Posted by fwscott at 10:04 PM | Comments (0)
 
Subscription Options

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

No comments found.

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.

Anti-spam key

Type in the text that you see in the above image:

Your comment:

Sorry, no HTML allowed!