Mozilla user agent escapes detection

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



PHP List,

I have a script, part of which is taken from a script I found on the 'net, which tries to detect the user agent of the browser accessing the site. One of the reasons I'm doing this is to find out if the browser is a desktop or mobile.

Part of the code looks like this:

$ua = strtolower($_SERVER['HTTP_USER_AGENT']);
$isDesktop = (strpos($ua, 'firefox') !== false)
|| (strpos($ua,'mosaic') !== false)
|| (strpos($ua,'msie') !== false)
|| (strpos($ua,'opera') !== false)
|| (strpos($ua,'mozilla') !== false)
|| (strpos($ua,'w3c_css_validator') !== false)
|| (strpos($ua,'w3c_validator') !== false);

What's driving me crazy is that it successfully determines all the browsers listed there, *except* mozilla.

I have a log file which alerts me when an unknown browser comes through my site, and it's chock full of messages telling me that a Mozilla based browser has come by. There are a *lot* of Mozilla based browsers.

Some examples from my logs of the browsers slipping by my test:

HTTP_USER_AGENT: Mozilla/5.0 compatible; Yahoo! Slurp
HTTP_USER_AGENT: Mozilla/5.0 compatible; Googlebot/2.1
HTTP_USER_AGENT: Mozilla/5.0 X11; U; Linux i686

In each case, the strpos() should have seen the mozilla agent and not bothered logging it.

It's not complicated code, especially considering it's successfully finding msie and firefox.

I can't imagine why Mozilla would be different.

Any suggestions? Is there something about my code right in front of my face that I'm not seeing?

Any suggestions would be greatly appreciated.

Thanks.

--
Dave M G

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux