Ticket #541 (closed Feature Request: fixed)

Opened 6 months ago

Last modified 3 months ago

Upgrade Kohana::user-agent() detection

Reported by: brettalton Owned by: Geert
Priority: minor Milestone: 2.2
Component: Core Version: SVN HEAD
Keywords: user_agent Cc:

Description

I found this User-agent detection library written in PHP that may be of some use: http://id.ziew.info/

The actual download contains many icons for browsers and operating systems (which Kohana doesn't need), but what it could use is its main function "function parse_user_agent($user_agent)".

Hope it helps!

Change History

  Changed 6 months ago by brettalton

Of course, there's always http://browsers.garykeith.com/downloads.asp (browscap.ini)

  Changed 6 months ago by Shadowhand

  • priority changed from minor to trivial

follow-up: ↓ 5   Changed 5 months ago by brettalton

  • priority changed from trivial to major
  • type changed from Bug to Feature Request
  • summary changed from User agent detection library add-on to Upgrade Kohana::user-agent() detection

Test

echo 'agent: '.Kohana::debug(Kohana::user_agent()).'<br />';
echo 'browser: '.Kohana::debug(Kohana::user_agent('browser')).'<br />';
echo 'version: '.Kohana::debug(Kohana::user_agent('version')).'<br />';
echo 'platform: '.Kohana::debug(Kohana::user_agent('platform')).'<br />';

Results

Firefox 3.0b5/Ubuntu Linux

agent:
(string) Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9b5) Gecko/2008041514 Firefox/3.0b5
browser:
(string) Firefox
version:
(string) 3.0
platform:
(string) Linux

version should be 3.0b5 (unless you intend to keep it numerical...)

Gecko Epiphany 2.22/Ubuntu Linux

agent:
(string) Mozilla/5.0 (X11; U; Linux i686; en; rv:1.9b5) Gecko Epiphany/2.22
browser:
(string) Mozilla
version:
(string) 5.0
platform:
(string) Linux

browser should be Epiphany
version should be 2.22

Opera 9.27/Ubuntu Linux

agent: 
(string) Opera/9.27 (X11; Linux i686; U; en)
browser: 
(string) Opera
version: 
(string) 9.27
platform: 
(string) Linux

Firefox 2.0.0.14/Ubuntu Linux

agent:
(string) Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.14) Gecko/20080419 Ubuntu/8.04 (hardy) Firefox/2.0.0.14
browser:
(string) Firefox
version:
(string) 2.0.0.14
platform:
(string) Linux

Correct, BUT platform could be 'Ubuntu' instead of 'Linux'

Galeon 2.0.4/Ubuntu Linux

agent:
(string) Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.13) Gecko/20080311 (Debian-1.8.1.13+nobinonly-0ubuntu1) Galeon/2.0.4 (Ubuntu 2.0.4-1ubuntu1)
browser:
(string) Mozilla
version:
(string) 5.0
platform:
(string) Linux

browser should be Galeon
version should be 2.0.4
platform could be 'Ubuntu' instead of 'Linux'

Konqueror 4.0/Ubuntu Linux

agent: 
(string) Mozilla/5.0 (compatible; Konqueror/4.0; Linux) KHTML/4.0.3 (like Gecko)
browser: 
(string) Konqueror
version: 
(string) 4.0
platform: 
(string) Linux

Lynx 2.8.6rel.4/Ubuntu Linux

agent:
(string) Lynx/2.8.6rel.4 libwww-FM/2.14 SSL-MM/1.4.1 GNUTLS/2.0.4
browser:
(string) Lynx
version:
(string) 2.8.6
platform:
(NULL)

version should be 2.8.6rel.4 (unless you intend to keep it numerical...)

Links 2.1pre32/Ubuntu Linux

agent:
(string) Links (2.1pre32; Linux 2.6.24-17-generic i686)
browser:
(string) Links
version:
(string) 2.1
platform:
(string) Linux

version should be 2.1pre32 (unless you intend to keep it numerical...)

Internet Explorer 6/Ubuntu Linux (using ies4linux)

agent: 
(string) Mozilla/4.0 (compatible; MSIE 6.0; Windows 98)
browser: 
(string) Internet Explorer
version: 
(string) 6.0
platform: 
(string) Windows 98

Notes

For a database of user_agent strings, see http://id.ziew.info/showdb.php

I will try and make some patches here in the near future.

  Changed 5 months ago by brettalton

More user-agent strings

Mozilla Firefox 1.0/Windows 2000 (Through Wine in Ubuntu Linux)

agent:
(string) Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0
browser:
(string) Firefox
version:
(string) 1.0
platform:
(string) Windows 2000

Mozilla Firefox 1.5.0.12/Windows 2000 (Through Wine in Ubuntu Linux)

agent:
(string) Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8.0.12) Gecko/20070508 Firefox/1.5.0.12
browser:
(string) Firefox
version:
(string) 1.5.0.12
platform:
(string) Windows 2000

in reply to: ↑ 3 ; follow-up: ↓ 7   Changed 5 months ago by Nowaker

Replying to brettalton:

=== Firefox 2.0.0.14/Ubuntu Linux ===

Correct, BUT platform could be 'Ubuntu' instead of 'Linux'

If I need to check if a user is using Windows, Linux, Unix or MAC I don't want the method to return Ubuntu. What for? Ubuntu is Linux, isn't it?

Yet it would be a good idea to add index 'distro' with the name of the distrubution (Ubuntu, Debian, Slackware and so on).

  Changed 3 months ago by Geert

  • keywords user_agent added; user-agent, detection, library, function removed
  • owner changed from Shadowhand to Geert
  • status changed from new to assigned
  • priority changed from major to minor

Started fix in r2995. Most of the cases above are solved now: Epiphany and Galeon added, also letters in versions accepted.

The issue with Linux vs Ubuntu remains for now. Need some clarification for that one.

in reply to: ↑ 5   Changed 3 months ago by Geert

  • status changed from assigned to closed
  • resolution set to fixed

Replying to Nowaker:

If I need to check if a user is using Windows, Linux, Unix or MAC I don't want the method to return Ubuntu. What for? Ubuntu is Linux, isn't it?

I'm going to agree with that and close this ticket.

  Changed 3 months ago by Shadowhand

  • status changed from closed to reopened
  • resolution deleted

  Changed 3 months ago by Shadowhand

  • status changed from reopened to closed
  • resolution set to fixed

Oops, I swear I didn't mean to do that.

Note: See TracTickets for help on using tickets.