Skip to content
This repository was archived by the owner on Apr 23, 2024. It is now read-only.

Commit dd42415

Browse files
committed
OnePLus
1 parent 4632ac0 commit dd42415

File tree

5 files changed

+29
-1
lines changed

5 files changed

+29
-1
lines changed

img/16/device/oneplus.png

119 Bytes
Loading

img/24/device/oneplus.png

146 Bytes
Loading

lib/useragent_detect_device.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,20 @@ public static function analyze($useragent) {
315315
$brand = "OPPO";
316316
$image_url = "oppo";
317317
}
318-
318+
// Oneplus
319+
elseif (preg_match('/A0001|A2005|E1003|One [A-Z]\d{4}/i', $useragent)) {
320+
$link = "http://www.oneplus.cn/";
321+
$brand = "OnePlus";
322+
$image_url = "oneplus";
323+
324+
if (preg_match('/A0001/i', $useragent)) {
325+
$model = "One";
326+
} else if (preg_match('/A2005/i', $useragent)) {
327+
$model = "Two";
328+
} else if (preg_match('/E1003/i', $useragent)) {
329+
$model = "X";
330+
}
331+
}
319332
// Palm
320333
elseif (preg_match('/\ Pixi\//i', $useragent)) {
321334
$link = "http://en.wikipedia.org/wiki/Palm_Pixi";

readme.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,8 @@ $useragent = UserAgentFactory::analyze($_SERVER['HTTP_USER_AGENT']);
6262
</html>
6363
```
6464

65+
##TODO
66+
* Move out RegExps like useragent.js from the PHP file
67+
6568
##License
6669
* @license GNU/GPL http://www.gnu.org/copyleft/gpl.html

tests/UserAgentList.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
11
<?php return array(
2+
array(
3+
array('Mozilla/5.0 (Linux; Android 4.4.4; A0001 Build/KTU84Q) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.93 Mobile Safari/537.36'),
4+
array('img/16/browser/chrome.png', 'img/16/device/oneplus.png', 'Google Chrome', '39.0.2171.93', 'Google Chrome 39.0.2171.93', 'Android', '4.4.4', 'Android 4.4.4', 'OnePlus One', 'device'),
5+
),
6+
array(
7+
array('Mozilla/5.0 (Linux; Android 5.1.1; ONE A2005 Build/LMY47V) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.83 Mobile Safari/537.36'),
8+
array('img/16/browser/chrome.png', 'img/16/device/oneplus.png', 'Google Chrome', '47.0.2526.83', 'Google Chrome 47.0.2526.83', 'Android', '5.1.1', 'Android 5.1.1', 'OnePlus Two', 'device'),
9+
),
10+
array(
11+
array('Mozilla/5.0 (Linux; Android 5.1; ONE E1003 Build/LMY47V) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.76 Mobile Safari/537.36'),
12+
array('img/16/browser/chrome.png', 'img/16/device/oneplus.png', 'Google Chrome', '46.0.2490.76', 'Google Chrome 46.0.2490.76', 'Android', '5.1', 'Android 5.1', 'OnePlus X', 'device'),
13+
),
214
array(
315
array('Mozilla/5.0 (Linux; Android 5.0.1; Letv X3-50 UHD Build/V760R360C162B10235T; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/45.0.2454.25 Safari/537.36'),
416
array('img/16/browser/chrome.png', 'img/16/device/letv.png', 'Google Chrome', '45.0.2454.25', 'Google Chrome 45.0.2454.25', 'Android', '5.0.1', 'Android 5.0.1', 'Letv X3', 'device'),

0 commit comments

Comments
 (0)