123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497 |
- <?php
- namespace WhichBrowser\Analyser\Header\Useragent;
- use WhichBrowser\Constants;
- use WhichBrowser\Data;
- use WhichBrowser\Model\Family;
- use WhichBrowser\Model\Using;
- use WhichBrowser\Model\Version;
- trait Application
- {
- private function &detectApplication($ua)
- {
- /* Detect applications */
- $this->detectSpecificApplications($ua);
- $this->detectRemainingApplications($ua);
- return $this;
- }
- private function detectSpecificApplications($ua)
- {
- /* Sony Updatecenter */
- if (preg_match('/^(.*) Build\/.* (?:com.sonyericsson.updatecenter|UpdateCenter)\/[A-Z0-9\.]+$/iu', $ua, $match)) {
- $this->data->browser->name = 'Sony Update Center';
- $this->data->browser->version = null;
- $this->data->browser->type = Constants\BrowserType::APP;
- $this->data->os->reset([
- 'name' => 'Android'
- ]);
- $this->data->device->model = $match[1];
- $this->data->device->identified |= Constants\Id::PATTERN;
- $this->data->device->type = Constants\DeviceType::MOBILE;
- $device = Data\DeviceModels::identify('android', $match[1]);
- if ($device->identified) {
- $device->identified |= $this->data->device->identified;
- $this->data->device = $device;
- }
- }
- /* Sony Select SDK */
- if (preg_match('/Android [0-9\.]+; (.*) Sony\/.*SonySelectSDK\/([0-9\.]+)/iu', $ua, $match)) {
- $this->data->browser->reset();
- $this->data->browser->type = Constants\BrowserType::APP;
- $this->data->browser->using = new \WhichBrowser\Model\Using([
- 'name' => 'Sony Select SDK',
- 'version' => new Version([ 'value' => $match[2], 'details' => 2 ])
- ]);
- $this->data->device->model = $match[1];
- $this->data->device->identified |= Constants\Id::PATTERN;
- $this->data->device->type = Constants\DeviceType::MOBILE;
- $device = Data\DeviceModels::identify('android', $match[1]);
- if ($device->identified) {
- $device->identified |= $this->data->device->identified;
- $this->data->device = $device;
- }
- }
- /* Samsung Mediahub */
- if (preg_match('/^Stamhub [^\/]+\/([^;]+);.*:([0-9\.]+)\/[^\/]+\/[^:]+:user\/release-keys$/iu', $ua, $match)) {
- $this->data->browser->name = 'Mediahub';
- $this->data->browser->version = null;
- $this->data->browser->type = Constants\BrowserType::APP_MEDIAPLAYER;
- $this->data->os->reset([
- 'name' => 'Android',
- 'version' => new Version([ 'value' => $match[2] ])
- ]);
- $this->data->device->model = $match[1];
- $this->data->device->identified |= Constants\Id::PATTERN;
- $this->data->device->type = Constants\DeviceType::MOBILE;
- $device = Data\DeviceModels::identify('android', $match[1]);
- if ($device->identified) {
- $device->identified |= $this->data->device->identified;
- $this->data->device = $device;
- }
- }
- /* "Android Application" */
- if (preg_match('/Android Application/iu', $ua)) {
- if (preg_match('/^(.+) Android Application \([0-9]+, .+ v[0-9\.]+\) - [a-z-]+ (.*) [a-z_-]+ - [0-9A-F]{8,8}-[0-9A-F]{4,4}-[0-9A-F]{4,4}-[0-9A-F]{4,4}-[0-9A-F]{12,12}$/iu', $ua, $match)) {
- $this->data->browser->name = $match[1];
- $this->data->browser->version = null;
- $this->data->browser->type = Constants\BrowserType::APP;
- $this->data->os->reset([
- 'name' => 'Android'
- ]);
- $this->data->device->model = $match[2];
- $this->data->device->identified |= Constants\Id::PATTERN;
- $this->data->device->type = Constants\DeviceType::MOBILE;
- $device = Data\DeviceModels::identify('android', $match[2]);
- if ($device->identified) {
- $device->identified |= $this->data->device->identified;
- $this->data->device = $device;
- }
- }
- if (preg_match('/^(.+) Android Application - (.*) Build\/(.+) - [0-9A-F]{8,8}-[0-9A-F]{4,4}-[0-9A-F]{4,4}-[0-9A-F]{4,4}-[0-9A-F]{12,12}$/iu', $ua, $match)) {
- $this->data->browser->name = $match[1];
- $this->data->browser->version = null;
- $this->data->browser->type = Constants\BrowserType::APP;
- $this->data->os->reset([
- 'name' => 'Android'
- ]);
- $version = Data\BuildIds::identify($match[3]);
- if ($version) {
- $this->data->os->version = $version;
- }
- $this->data->device->model = $match[2];
- $this->data->device->identified |= Constants\Id::PATTERN;
- $this->data->device->type = Constants\DeviceType::MOBILE;
- $device = Data\DeviceModels::identify('android', $match[2]);
- if ($device->identified) {
- $device->identified |= $this->data->device->identified;
- $this->data->device = $device;
- }
- }
- if (preg_match('/^(.+) Android Application - [a-z-]+ (.*) [a-z_-]+$/iu', $ua, $match)) {
- $this->data->browser->name = $match[1];
- $this->data->browser->version = null;
- $this->data->browser->type = Constants\BrowserType::APP;
- $this->data->os->reset([
- 'name' => 'Android'
- ]);
- $this->data->device->model = $match[2];
- $this->data->device->identified |= Constants\Id::PATTERN;
- $this->data->device->type = Constants\DeviceType::MOBILE;
- $device = Data\DeviceModels::identify('android', $match[2]);
- if ($device->identified) {
- $device->identified |= $this->data->device->identified;
- $this->data->device = $device;
- }
- }
- }
- /* AiMeiTuan */
- if (preg_match('/^AiMeiTuan \/[^\-]+\-([0-9\.]+)\-(.*)\-[0-9]+x[0-9]+\-/iu', $ua, $match)) {
- $this->data->browser->name = 'AiMeiTuan';
- $this->data->browser->version = null;
- $this->data->browser->type = Constants\BrowserType::APP;
- $this->data->os->reset([
- 'name' => 'Android',
- 'version' => new Version([ 'value' => $match[1] ])
- ]);
- $this->data->device->model = $match[2];
- $this->data->device->identified |= Constants\Id::PATTERN;
- $this->data->device->type = Constants\DeviceType::MOBILE;
- $device = Data\DeviceModels::identify('android', $match[2]);
- if ($device->identified) {
- $device->identified |= $this->data->device->identified;
- $this->data->device = $device;
- }
- }
- /* Instagram */
- if (preg_match('/^Instagram ([0-9\.]+) Android (?:IC )?\([0-9]+\/([0-9\.]+); [0-9]+dpi; [0-9]+x[0-9]+; [^;]+; ([^;]*);/iu', $ua, $match)) {
- $this->data->browser->name = 'Instagram';
- $this->data->browser->version = new Version([ 'value' => $match[1] ]);
- $this->data->browser->type = Constants\BrowserType::APP_SOCIAL;
- $this->data->os->reset([
- 'name' => 'Android',
- 'version' => new Version([ 'value' => $match[2] ])
- ]);
- $this->data->device->model = $match[3];
- $this->data->device->identified |= Constants\Id::PATTERN;
- $this->data->device->type = Constants\DeviceType::MOBILE;
- $device = Data\DeviceModels::identify('android', $match[3]);
- if ($device->identified) {
- $device->identified |= $this->data->device->identified;
- $this->data->device = $device;
- }
- }
- /* Pinterest */
- if (preg_match('/^Pinterest for Android( Tablet)?\/([0-9\.]+) \(([^;]+); ([0-9\.]+)\)/iu', $ua, $match)) {
- $this->data->browser->name = 'Pinterest';
- $this->data->browser->version = new Version([ 'value' => $match[2] ]);
- $this->data->browser->type = Constants\BrowserType::APP_SOCIAL;
- $this->data->os->reset([
- 'name' => 'Android',
- 'version' => new Version([ 'value' => $match[4] ])
- ]);
- $this->data->device->model = $match[3];
- $this->data->device->identified |= Constants\Id::PATTERN;
- $this->data->device->type = $match[1] == ' Tablet' ? Constants\DeviceType::TABLET : Constants\DeviceType::MOBILE;
- $device = Data\DeviceModels::identify('android', $match[3]);
- if ($device->identified) {
- $device->identified |= $this->data->device->identified;
- $this->data->device = $device;
- }
- }
- /* Dr. Web Anti-Virus */
- if (preg_match('/Dr\.Web anti\-virus Light Version: ([0-9\.]+) Device model: (.*) Firmware version: ([0-9\.]+)/u', $ua, $match)) {
- $this->data->browser->name = 'Dr. Web Light';
- $this->data->browser->version = new Version([ 'value' => $match[1], 'details' => 2 ]);
- $this->data->browser->type = Constants\BrowserType::APP_ANTIVIRUS;
- $this->data->os->reset([
- 'name' => 'Android',
- 'version' => new Version([ 'value' => $match[3] ])
- ]);
- $this->data->device->type = Constants\DeviceType::MOBILE;
- $device = Data\DeviceModels::identify('android', $match[2]);
- if ($device->identified) {
- $device->identified |= $this->data->device->identified;
- $this->data->device = $device;
- }
- }
- /* Google Earth */
- if (preg_match('/GoogleEarth\/([0-9\.]+)\(Android;Android \((.+)\-[^\-]+\-user-([0-9\.]+)\);/u', $ua, $match)) {
- $this->data->browser->name = 'Google Earth';
- $this->data->browser->version = new Version([ 'value' => $match[1], 'details' => 2 ]);
- $this->data->browser->type = Constants\BrowserType::APP;
- $this->data->os->reset([
- 'name' => 'Android',
- 'version' => new Version([ 'value' => $match[3] ])
- ]);
- $this->data->device->type = Constants\DeviceType::MOBILE;
- $device = Data\DeviceModels::identify('android', $match[2]);
- if ($device->identified) {
- $device->identified |= $this->data->device->identified;
- $this->data->device = $device;
- }
- }
- /* Groupon */
- if (preg_match('/Groupon\/([0-9\.]+) \(Android ([0-9\.]+); [^\/]+ \/ [A-Z][a-z]+ ([^;]*);/u', $ua, $match)) {
- $this->data->browser->name = 'Groupon';
- $this->data->browser->version = new Version([ 'value' => $match[1], 'details' => 2 ]);
- $this->data->browser->type = Constants\BrowserType::APP_SHOPPING;
- $this->data->os->reset([
- 'name' => 'Android',
- 'version' => new Version([ 'value' => $match[2] ])
- ]);
- $this->data->device->type = Constants\DeviceType::MOBILE;
- $this->data->device->model = $match[3];
- $device = Data\DeviceModels::identify('android', $match[3]);
- if ($device->identified) {
- $device->identified |= $this->data->device->identified;
- $this->data->device = $device;
- }
- }
- /* Whatsapp */
- if (preg_match('/WhatsApp\+?\/([0-9\.]+) (Android|S60Version|WP7)\/([0-9\.\_]+) Device\/([^\-]+)\-(.*)(?:-\([0-9]+\.[0-9]+\))?(?:\-H[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)?$/uU', $ua, $match)) {
- $this->data->browser->name = 'WhatsApp';
- $this->data->browser->version = new Version([ 'value' => $match[1], 'details' => 2 ]);
- $this->data->browser->type = Constants\BrowserType::APP_CHAT;
- $this->data->device->type = Constants\DeviceType::MOBILE;
- $this->data->device->manufacturer = $match[4];
- $this->data->device->model = $match[5];
- $this->data->device->identified |= Constants\Id::PATTERN;
- if ($match[2] == 'Android') {
- $this->data->os->reset([
- 'name' => 'Android',
- 'version' => new Version([ 'value' => str_replace('_', '.', $match[3]) ])
- ]);
- $device = Data\DeviceModels::identify('android', $match[5]);
- if ($device->identified) {
- $device->identified |= $this->data->device->identified;
- $this->data->device = $device;
- }
- }
- if ($match[2] == 'WP7') {
- $this->data->os->reset([
- 'name' => 'Windows Phone',
- 'version' => new Version([ 'value' => $match[3], 'details' => 2 ])
- ]);
- $device = Data\DeviceModels::identify('wp', $match[5]);
- if ($device->identified) {
- $device->identified |= $this->data->device->identified;
- $this->data->device = $device;
- }
- }
- if ($match[2] == 'S60Version') {
- $this->data->os->reset([
- 'name' => 'Series60',
- 'version' => new Version([ 'value' => $match[3] ]),
- 'family' => new Family([ 'name' => 'Symbian' ])
- ]);
- $device = Data\DeviceModels::identify('symbian', $match[5]);
- if ($device->identified) {
- $device->identified |= $this->data->device->identified;
- $this->data->device = $device;
- }
- }
- if ($match[2] == 'WP7') {
- $this->data->os->reset([
- 'name' => 'Windows Phone',
- 'version' => new Version([ 'value' => $match[3], 'details' => 2 ])
- ]);
- $device = Data\DeviceModels::identify('wp', $match[5]);
- if ($device->identified) {
- $device->identified |= $this->data->device->identified;
- $this->data->device = $device;
- }
- }
- }
- /* Yahoo */
- if (preg_match('/YahooMobile(?:Messenger|Mail|Weather)\/1.0 \(Android (Messenger|Mail|Weather); ([0-9\.]+)\) \([^;]+; ?[^;]+; ?([^;]+); ?([0-9\.]+)\/[^\;\)\/]+\)/u', $ua, $match)) {
- $this->data->browser->name = 'Yahoo ' . $match[1];
- $this->data->browser->version = new Version([ 'value' => $match[2], 'details' => 3 ]);
- switch ($match[1]) {
- case 'Messenger':
- $this->data->browser->type = Constants\BrowserType::APP_CHAT;
- break;
- case 'Mail':
- $this->data->browser->type = Constants\BrowserType::APP_EMAIL;
- break;
- case 'Weather':
- $this->data->browser->type = Constants\BrowserType::APP_NEWS;
- break;
- }
- $this->data->os->reset([
- 'name' => 'Android',
- 'version' => new Version([ 'value' => $match[4] ])
- ]);
- $this->data->device->type = Constants\DeviceType::MOBILE;
- $device = Data\DeviceModels::identify('android', $match[3]);
- if ($device->identified) {
- $device->identified |= $this->data->device->identified;
- $this->data->device = $device;
- }
- }
- /* Yahoo Mobile App */
- if (preg_match('/YahooJMobileApp\/[0-9\.]+ \(Android [a-z]+; ([0-9\.]+)\) \([^;]+; ?[^;]+; ?[^;]+; ?([^;]+); ?([0-9\.]+)\/[^\;\)\/]+\)/u', $ua, $match)) {
- $this->data->browser->name = 'Yahoo Mobile';
- $this->data->browser->version = new Version([ 'value' => $match[1], 'details' => 3 ]);
- $this->data->browser->type = Constants\BrowserType::APP_SEARCH;
- $this->data->os->reset([
- 'name' => 'Android',
- 'version' => new Version([ 'value' => $match[3] ])
- ]);
- $this->data->device->type = Constants\DeviceType::MOBILE;
- $device = Data\DeviceModels::identify('android', $match[2]);
- if ($device->identified) {
- $device->identified |= $this->data->device->identified;
- $this->data->device = $device;
- }
- }
- /* ICQ */
- if (preg_match('/ICQ_Android\/([0-9\.]+) \(Android; [0-9]+; ([0-9\.]+); [^;]+; ([^;]+);/u', $ua, $match)) {
- $this->data->browser->name = 'ICQ';
- $this->data->browser->version = new Version([ 'value' => $match[1], 'details' => 3 ]);
- $this->data->browser->type = Constants\BrowserType::APP_CHAT;
- $this->data->os->reset([
- 'name' => 'Android',
- 'version' => new Version([ 'value' => $match[2] ])
- ]);
- $this->data->device->type = Constants\DeviceType::MOBILE;
- $device = Data\DeviceModels::identify('android', $match[3]);
- if ($device->identified) {
- $device->identified |= $this->data->device->identified;
- $this->data->device = $device;
- }
- }
- /* Facebook for Android */
- if (preg_match('/^\[FBAN\/(FB4A|PAAA);.*FBDV\/([^;]+);.*FBSV\/([0-9\.]+);/u', $ua, $match)) {
- if ($match[1] == 'FB4A') {
- $this->data->browser->name = 'Facebook';
- $this->data->browser->version = null;
- $this->data->browser->type = Constants\BrowserType::APP_SOCIAL;
- }
- if ($match[1] == 'PAAA') {
- $this->data->browser->name = 'Facebook Pages';
- $this->data->browser->version = null;
- $this->data->browser->type = Constants\BrowserType::APP_SOCIAL;
- }
- $this->data->os->reset([
- 'name' => 'Android',
- 'version' => new Version([ 'value' => $match[3] ])
- ]);
- $this->data->device->type = Constants\DeviceType::MOBILE;
- $device = Data\DeviceModels::identify('android', $match[2]);
- if ($device->identified) {
- $device->identified |= $this->data->device->identified;
- $this->data->device = $device;
- }
- }
- /* VK */
- if (preg_match('/^VKAndroidApp\/([0-9\.]+)-[0-9]+ \(Android ([^;]+); SDK [^;]+; [^;]+; [a-z]+ ([^;]+);/iu', $ua, $match)) {
- $this->data->browser->name = 'VK';
- $this->data->browser->version = new Version([ 'value' => $match[1], 'details' => 2 ]);
- $this->data->browser->type = Constants\BrowserType::APP_SOCIAL;
- $this->data->os->reset([
- 'name' => 'Android',
- 'version' => new Version([ 'value' => $match[2] ])
- ]);
- $this->data->device->model = $match[3];
- $this->data->device->identified |= Constants\Id::PATTERN;
- $this->data->device->type = Constants\DeviceType::MOBILE;
- $device = Data\DeviceModels::identify('android', $match[3]);
- if ($device->identified) {
- $device->identified |= $this->data->device->identified;
- $this->data->device = $device;
- }
- }
- }
- private function detectRemainingApplications($ua)
- {
- if ($data = Data\Applications::identifyOther($ua)) {
- $this->data->browser->set($data['browser']);
- if (!empty($data['device'])) {
- $this->data->device->set($data['device']);
- }
- }
- }
- }
|