Skip to content
This repository has been archived by the owner on Nov 30, 2017. It is now read-only.

Commit

Permalink
Use Opera Mini Phone header for model detection
Browse files Browse the repository at this point in the history
  • Loading branch information
NielsLeenheer committed Aug 17, 2014
1 parent 1a08638 commit e0138e8
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
37 changes: 37 additions & 0 deletions libraries/whichbrowser.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ function __construct($options) {
if ($this->hasHeader('X-Device-User-Agent')) $this->analyseAlternativeUserAgent($this->getHeader('X-Device-User-Agent'));
if ($this->hasHeader('Device-Stock-UA')) $this->analyseAlternativeUserAgent($this->getHeader('Device-Stock-UA'));
if ($this->hasHeader('X-OperaMini-Phone-UA')) $this->analyseAlternativeUserAgent($this->getHeader('X-OperaMini-Phone-UA'));
if ($this->hasHeader('X-OperaMini-Phone')) $this->analyseOperaMiniPhone($this->getHeader('X-OperaMini-Phone'));
if ($this->hasHeader('X-UCBrowser-Device-UA')) $this->analyseAlternativeUserAgent($this->getHeader('X-UCBrowser-Device-UA'));
if ($this->hasHeader('X-UCBrowser-Phone-UA')) $this->analyseOldUCUserAgent($this->getHeader('X-UCBrowser-Phone-UA'));
if ($this->hasHeader('X-UCBrowser-UA')) $this->analyseNewUCUserAgent($this->getHeader('X-UCBrowser-UA'));
Expand Down Expand Up @@ -574,6 +575,42 @@ function analysePuffinUserAgent($ua) {
}
}

function analyseOperaMiniPhone($ua) {
@list($manufacturer, $model) = explode(' # ', $ua);

if ($manufacturer != '?' && $model != '?') {
if (!$this->device->identified && $this->os->name == 'Bada') {
$device = DeviceModels::identify('bada', $model);
if ($device->identified) {
$device->identified |= $this->device->identified;
$this->device = $device;
}
}

if (!$this->device->identified && $this->os->name == 'Blackberry') {
$device = DeviceModels::identify('blackberry', $model);
if ($device->identified) {
$device->identified |= $this->device->identified;
$this->device = $device;
}
}

if (!$this->device->identified && $this->os->name == 'Windows Mobile') {
$device = DeviceModels::identify('wm', $model);
if ($device->identified) {
$device->identified |= $this->device->identified;
$this->device = $device;
}
}

if (!$this->device->identified) {
$this->device->manufacturer = $manufacturer;
$this->device->model = $model;
$this->device->identified = true;
}
}
}

function analyseUserAgent($ua) {

/****************************************************
Expand Down
8 changes: 8 additions & 0 deletions tests/mobile/os-brew.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@
name: Brew
device:
type: mobile
manufacturer: KDDI
model: FJ31
- headers: |
User-Agent: Mozilla/5.0_(Smartfren-E781A/E2_SQID_V0.1.6; U; REX/4.3;BREW/3.1.5.189; Profile/MIDP-2.0_Configuration/CLDC-1.1; 240*320; CTC/2.0)_Obigo Browser/Q7
result:
Expand Down Expand Up @@ -365,6 +367,8 @@
name: Brew
device:
type: mobile
manufacturer: ZTE
model: F-450
- headers: |
User-Agent: Opera/9.80 (BREW; Opera Mini/5.1/27.2338; U; xx) Presto/2.8.119 400X240 LG VN271
X-OperaMini-Features: advanced, download
Expand Down Expand Up @@ -399,6 +403,8 @@
name: Brew
device:
type: mobile
manufacturer: ZTE
model: F-450
- headers: |
User-Agent: Opera/9.80 (BREW; Opera Mini/6.0.0/27.2354; U; xx) Presto/2.8.119 240X320 Casio C781
X-OperaMini-Features: advanced, download, file_system, folding
Expand All @@ -415,6 +421,8 @@
name: Brew
device:
type: mobile
manufacturer: Casio
model: C781
- headers: |
User-Agent: Opera/9.80 (BREW; Opera Mini/6.0.3/27.2338; U; xx) Presto/2.8.119 240X320 Samsung SCH-U380
X-OperaMini-Features: advanced, download, file_system, touch, folding
Expand Down
2 changes: 2 additions & 0 deletions tests/mobile/os-windowsmobile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1354,6 +1354,8 @@
name: Windows Mobile
device:
type: mobile
manufacturer: Motorola
model: A1000
- headers: |
User-Agent: Opera/9.80 (Windows Mobile; Opera Mini/5.1.21595/34.1606; U; xx) Presto/2.8.119 Version/11.10
Device-Stock-UA: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; HTC_HD2_T8585; Windows Phone 6.5)
Expand Down

0 comments on commit e0138e8

Please sign in to comment.