A couple weeks ago when Mozilla released Firefox v1.0 PR I was sure to grab it. After using it a little I noticed their versioning scheme in the User Agent changed (rather than go to v1.00 they decided to display it as v0.10 (mind you there used to actually be a v0.1). This breaks the current getUserBrowser.cfm (not giving a CF error, but incorrect results in your stats logs).

So I wrote a fix (attached) and submitted it to Daemon. They're a little busy wrapping up Farcry v2.3 at the moment, but I thought some of you would want to grab this for now.

Rather than retype my explanation for the fix I'll just repaste the email I sent to Daemon. (btw: There are two newer version of this file in CVS for v2.3, but I can't find any changes made. Not sure why).

-Jeff

________________________________________
From: Jeff Coughlin [mailto:<snip>]
Sent: Thursday, September 16, 2004 1:22 PM
To: '<snip>'
Subject: New version of getUserBrowser.cfm

New version of getUserBrowser.cfm (farcry_core/packages/farcry/_stats/getUserBrowser.cfm)

The new release of Firefox this week breaks the Firefox detection script (fix provided - attached).

In my last update a few months ago I added many common browsers (like Firefox and Camino) to the detection script and told the code to properly detect older versions of NS (v1.x-3.x – Old yes, but easy enough to add). In this version I changed the way I was detecting Firefox. The new version of Firefox released this week (v 1.0PR) is displayed as 0.10 in the User_Agent. CF was assuming the programmers at Mozilla were using proper decimal techniques and the CF engine returned the version as 0.1. Um yeah, this is not good. Now we’re not sure if people are using Firefox v0.1 or Firefox 0.10.

Either way I changed the script to display whatever number is returned. So if in the future Mozilla does what I think they’re going to do (ex. 0.10.3) you will see that entire result (it can suck if they decide to do something like “0.10.3.2.11” because it will display the whole thing rather than just “0.10” (which would be cleaner for the major release versions)).

Also I added a line at the top of the script to set the local variable user_agent to equal cgi.http_user_agent (this way CF doesn’t have to scroll through all of the variables scopes to find the user_agent each time).

I did not modify the CVS info at the top of the file. Keep this in mind if/when updating.

Best regards,

Jeff Coughlin browserName="Unknown: "; Variables.user_agent = cgi.http_user_agent; if (Len(user_agent)) { browserVersion=user_agent; if (FindNoCase("MSIE",user_agent) AND NOT findNoCase("opera",user_agent) ) { browserName="MSIE"; browserVersion=Val(RemoveChars(user_agent,1,FindNoCase("MSIE",user_agent)+4)); } else if (findNoCase("opera",user_agent)) { browserName = "Opera"; browserVersion = Val(RemoveChars(user_agent,1,FindNoCase("Opera",user_agent)+5)); } else if (findNoCase("safari",user_agent)) // Safari (Macintosh) { browsername = "Safari"; browserVersion = DecimalFormat(Int(Val(RemoveChars(user_agent,1,FindNoCase("Safari/",user_agent)+6)))/100); // browserVersion = Left(DecimalFormat(browserVersion), Evaluate(Len(DecimalFormat(browserVersion))-1)); // If you'd prefer browser version to be displayed as 1.2 instead of 1.25 (since Apple releases new builds often) Then use BOTH lines (don't remark the first one). } else if (findNoCase("Camino/",user_agent)) // Camino (Macintosh) { browsername = "Camino"; browserVersion = Val(RemoveChars(user_agent,1,FindNoCase("Camino/",user_agent)+6)); } else if (findNoCase("Galeon/",user_agent)) // Galeon (Gnome browser) { browsername = "Galeon"; browserVersion = Val(RemoveChars(user_agent,1,FindNoCase("Galeon/",user_agent)+6)); //browserVersion = ListGetAt(RemoveChars(user_agent,1,FindNoCase("Galeon/",user_agent)+6),1," "); // If you'd prefer browser version to be displayed as 1.3.11a instead of 1.3, then use the above line instead. } else if (findNoCase("Googlebot",user_agent)) { browsername = "Googlebot"; browserVersion = Val(RemoveChars(user_agent,1,FindNoCase("Googlebot",user_agent)+9)); } else if (findNoCase("ia_archiver",user_agent)) { browsername = "ia archiver"; browserVersion = "";// Not sure about how to disect the user_agent string for version just yet. } else { if (FindNoCase("Mozilla/",user_agent)) { if (Int(Val(RemoveChars(user_agent,1,FindNoCase("Mozilla/",user_agent)+7))) LTE 4) { // Netscape Navigator Browsers (v1.x - 4.x) browserName = "Netscape"; browserVersion = DecimalFormat(Val(RemoveChars(user_agent,1,FindNoCase("Mozilla/",user_agent)+7))); } else if (FindNoCase("Netscape6/",user_agent)) { // Netscape 6 browsers browserName = "Netscape"; browserVersion = DecimalFormat(Val(RemoveChars(user_agent,1,FindNoCase("Netscape6/",user_agent)+9))); } else if (FindNoCase("Netscape/",user_agent)) { // All other (newer) Netscape Browsers browserName = "Netscape"; browserVersion = DecimalFormat(Val(RemoveChars(user_agent,1,FindNoCase("Netscape/",user_agent)+8))); } else if (not FindNoCase("compatible",user_agent)) { browserVersion=Val(RemoveChars(user_agent,1,Find("/",user_agent))); if (browserVersion lt 5) { //netscape browsers browserName="Netscape"; } else { if (FindNoCase("Firefox/",user_agent)) { // Firefox Browsers (by Mozilla) browserName = "Firefox"; browserVersion = ListGetAt(RemoveChars(user_agent,1,FindNoCase("Firefox/",user_agent)+7),1," "); } else if (FindNoCase("Firebird/",user_agent)) { // Firebird Browsers (now replaced by FireFox) browserName = "Firebird"; browserVersion = Val(RemoveChars(user_agent,1,FindNoCase("Firebird/",user_agent)+8)); } else { //mozilla browsers browserName = "Mozilla"; browserVersion = Val(RemoveChars(user_agent,1,FindNoCase("rv:",user_agent)+2)); } } } else { browserName="compatible"; } } if (Find("ColdFusion",user_agent)) { browserName="ColdFusion"; } } } else { browserVersion = "unknown"; } stBroswer = structNew(); stBrowser.name = trim(browsername); stBrowser.version = trim(browserversion);
---
You are currently subscribed to farcry-dev as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]

Aussie Macromedia Developers: http://lists.daemon.com.au/

Reply via email to