englishextra
Status: Curious
Joined: 25 Dec 2007
Posts: 9
Location: Moscow, Russian Federation
Back to top
Posted: May 28, 08, 7:24    Weird IE7 User-Agent string
Well, this is about the Browser Detection Script.

On Windows XP with IE6 I had installed IE7. But what is (now it isn't) strange that the script detects IE7 as IE6. How come...

The trouble isn't new: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) )

As it is commented at the bottom of the script:

:: Code ::
// there are some cases of double msie id's, first in string and then with then number
//this test covers you for multiple occurrences of string, only with ie though


So my solution is to get the first occurance: MSIE 7.0

:: Code ::
    if (preg_match("/msie 7\.0/i",$browser_user_agent) && preg_match("/msie 6\.0/i",$browser_user_agent)) {//shimansky
         $browser_number="7.0";
    } elseif (preg_match("/msie 5\.5/i",$browser_user_agent) && preg_match("/msie 6\.0/i",$browser_user_agent)) {//shimansky
         $browser_number="5.5";
    } elseif (preg_match("/msie 5\.01/i",$browser_user_agent) && preg_match("/msie 6\.0/i",$browser_user_agent)) {//shimansky
         $browser_number="5.01";
    }


However, this is obviously not comfortable.

So, what would you recommend?

Oh, by the way, the matrix-style of the code field is very hard to read, IMHO. Thank you for your script: it does a lot of work on my site.
jeffd
Status: Assistant
Joined: 04 Oct 2003
Posts: 587
Back to top
Posted: May 28, 08, 10:21    
Your question is unclear.

Here is a native MSIE 7 XP SP2 user agent string:

:: Code ::
Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)

No changes, this is a vanilla install, with msie 7 upgraded from 6.

So it sounds like you have some very specific issue which isn't related at all to the script, unless I'm missing something.

I try to avoid those cascading number tests, because ideally the script should not require manual updates for browser number versioning.

It sounds like maybe you are running 6 and 7 together? Anyway, I can't say, whatever you're seeing on your system appears to be unique.

How to fix your single case I can't really say, usually I don't spend much time if it's a unique case.

:: Quote ::
the matrix-style of the code field is very hard to read, IMHO

I'm not sure what a 'matrix style' refers to, the code field is pretty standard style. I assume you're using a real code editor, with syntax highlighting and all the other features? If not, time to upgrade to any one of a number of free or non-free editors. Crimson editor is a nice free one. In free operating systems, linux or bsd based, kate/kwrite is pleasant.

I will happily admit that the script got a bit long over the years, but since it never really requires tweaking after it's set up, except for rare bug fixes, I've never worried about it.
englishextra
Status: Curious
Joined: 25 Dec 2007
Posts: 9
Location: Moscow, Russian Federation
Back to top
Posted: May 28, 08, 13:25    
The question is quite clear. The doubling of user-agent-string after installing msie7 (the installer taken from Microsoft site). So the script takes second occurance and thus presenting msie7 as msie6.

:: jeffd wrote ::
So it sounds like you have some very specific issue which isn't related at all to the script, unless I'm missing something


Yes... but now it is related.

Hum I'm not asking for rewriting the code. I'm just showing the trouble and the solution.

By matrix code I ment the appearance of the bbcode's CODE tags:
green on black is hard to read. I'm not asking for editor. By the way for PHP I use Blumentals RapidPHP, for Javascript - 1st Javascript Editor and for textfiles array tables NoteTab Light. Also a very good editor -
Programmer's Notepad, which is free.

Your answer sounded too bureaucratic. No-one's trying undermining the script, which is clearly read in your reply.
jeffd
Status: Assistant
Joined: 04 Oct 2003
Posts: 587
Back to top
Posted: May 28, 08, 13:38    
Ah, ok, I really had no idea what you were talking about re matrix code, that's an incorrect use of the term matrix I believe.

Re the colors, I guess it's subjective, for me, reading green on black is easy, and other common code box colors are hard. That's why I use green on black in terminals too, but since it's subjective, it's just a matter of making some of the people happy some of the time, I can't make everyone happy all of the time. So my response was just a guess re what your question was, sounded like a code editor related thing, but if it's just a matter of CSS color selection, which is what the [ code ] boxes set, that's fine, the colors and fonts have to be something, so they might as well be something we like...

However, the original question is still unclear, as I noted, my test xp had the ie 6 upgraded via windows update to ie 7, and does not show such an anomoly.

Are you saying that you downloaded the actual full msie 7 installer executable, ran it, and it shows this? Did you keep your msie 6? Some configurations, like browsers.evolt.org, let you have strange msie setups, but I don't really know any safe way to handle both your exception and the standard msie 7 user agent safely.

What makes it more difficult is that both occurances use msie compatible in their strings.

The solution you posted is not something I'd use personally, although of course, you're free to modify the code as much as you want for yourself. I gave up on such static methods a while ago, I prefer more dynamic detections that work for pretty much all cases.

If you think of something that would handle your case and the standard, without hard coding in detection numerical values, let me know, and if I think of one, I'll implement it, easy enough to test and debug with firefox user agent switcher.

Let's see what the official user agent strings for msie 7 are supposed to look like, from the msdn blogs:

:: Quote ::
A quick recap:

* On Windows XP SP2, IE7 will send the following User-Agent header: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)
* On Windows 2003 Server, IE7 will send the following User-Agent header: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.2)
* On Windows Vista, IE7 will send the following User-Agent header: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)


Here's another page with long lists of possible MSIE 7 user agents

As you see, there is no doubling in any case. My guess is that something didn't go right in the install, that also happened to me once when I was upgrading a friends MSIE from 5 to 6, the information field insisted it was MSIE 5, even though it was in fact 6.

You can edit your registry to correct this error in your user agent, I can't remember the exact path, I think it's hkey local machine -> software -> microsoft -> internet explorer, or something like that.
englishextra
Status: Curious
Joined: 25 Dec 2007
Posts: 9
Location: Moscow, Russian Federation
Back to top
Posted: May 28, 08, 13:46    
Oh yes. browsers.evolt.org - I use their packages of IE - 6.0 5.5 and 5.0 So I'll have to dig the registry, i suppose. Many thanks.

Yes. It's there:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\User Agent\Post Platform

And the key NAME is : Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) TYPE: REG_SZ VALUE: (empty) - DELETED

and here:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\User Agent ADDED: Mozilla/4.0 (compatible; MSIE 7.0; Win32) So now the script says 'IE 7.0 NT 5.1' FINE

But this happend (the doubling). So I'll have to keep my changes to the script: I'm not the only one, I guess. Thanks for your help.

Also I should add that the Browser Detection Script is used widely by myself. And not only for swithcing CSS, but for security purposes.

For instance, if visitor's BROWSER (the script) and HTTP REFERER (php) don't get detected, there's no chance for him to carry on. Goes without saying that your bots like ATOMZ should be added to the array.

As for Linux, in Russia, even Moscow and St. Petersburg visitors 'sit' on WINXP using IE6/7. It's a delicious thing to strike upon a unix visitor. As I can recall, one visitor per two days comes from LIN.

I use Fedora 8 in pair with WINXP and WINE stuff is to be exploited.

PS:
:: Quote ::
01:55:05
XXX.hsd 1.ca.comcast.net [?]
XXX [?] [?] [?]
[+]
KONQ 3.5
LIN DEBIAN from: xxx
to: xxx /home.xhtml Access denied for REFERER:/HOST: \.comcast\.net. Data: data/spam_referers.d at.


Sorry, comcast visitors are banned, for there are too many spammers from this host

< Edited by englishextra :: May 28, 08, 14:29 >
jeffd
Status: Assistant
Joined: 04 Oct 2003
Posts: 587
Back to top
Posted: May 28, 08, 13:53    
now it makes sense, glad evolt was mentioned, I used to use that stuff all the time, running multiple msie's is always fun, though now I do it in linux with wine, and in virtual machines, one browser per machine, to avoid the exact types of problems you had, the emulation stuff just never works quite right for testing and debugging.

Look into vmware, you can get msie 5 and 6 running fine in two windows 2000 installs, and with xp, you can get 6, 7 and 8, running, in 3 installs.

I recommend vmware because it lets you easily clone OS installs, virtualbox, which is otherwise very pleasant, doesn't let you clone installs.
englishextra
Status: Curious
Joined: 25 Dec 2007
Posts: 9
Location: Moscow, Russian Federation
Back to top
Posted: May 31, 08, 1:14    
A useful addon for Firefox that can switch user-agent string to anything you customize can be installed here: [link]

Bad news about that addon is that the CSS is still rendered by Mozilla engine. So you can only test the Browser Detection Script output, not CSS.

Also please notice that each time you launch a standalone version of old browser (see discussion above) downloaded at [link] the user agent-string is changed at:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\User Agent\Post Platform

to (initially empty):

'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)'

as a registry key name - not value,

which ends up in this weird string (for ie7 on Windows XP SP2, e.g.):

Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) )
Display posts from previous:   

All times are GMT - 8 Hours