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

Commit

Permalink
OnePLus
Browse files Browse the repository at this point in the history
  • Loading branch information
zsxsoft committed Apr 17, 2016
1 parent 4632ac0 commit dd42415
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 1 deletion.
Binary file added img/16/device/oneplus.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/24/device/oneplus.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 14 additions & 1 deletion lib/useragent_detect_device.php
Expand Up @@ -315,7 +315,20 @@ public static function analyze($useragent) {
$brand = "OPPO";
$image_url = "oppo";
}

// Oneplus
elseif (preg_match('/A0001|A2005|E1003|One [A-Z]\d{4}/i', $useragent)) {
$link = "http://www.oneplus.cn/";
$brand = "OnePlus";
$image_url = "oneplus";

if (preg_match('/A0001/i', $useragent)) {
$model = "One";
} else if (preg_match('/A2005/i', $useragent)) {
$model = "Two";
} else if (preg_match('/E1003/i', $useragent)) {
$model = "X";
}
}
// Palm
elseif (preg_match('/\ Pixi\//i', $useragent)) {
$link = "http://en.wikipedia.org/wiki/Palm_Pixi";
Expand Down
3 changes: 3 additions & 0 deletions readme.md
Expand Up @@ -62,5 +62,8 @@ $useragent = UserAgentFactory::analyze($_SERVER['HTTP_USER_AGENT']);
</html>
```

##TODO
* Move out RegExps like useragent.js from the PHP file

##License
* @license GNU/GPL http://www.gnu.org/copyleft/gpl.html
12 changes: 12 additions & 0 deletions tests/UserAgentList.php
@@ -1,4 +1,16 @@
<?php return array(
array(
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'),
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'),
),
array(
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'),
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'),
),
array(
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'),
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'),
),
array(
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'),
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'),
Expand Down

0 comments on commit dd42415

Please sign in to comment.