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.