- Timestamp:
- 10/09/2017 05:35:09 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/api.wordpress.org/public_html/core/browse-happy/1.0/parse.php
r6010 r6011 42 42 // Identify platform/OS in user-agent string. 43 43 if ( preg_match( 44 '/^.+?(?P<platform>Windows Phone( OS)?| Android|iPhone|iPad|Windows|Linux|Macintosh|RIM Tablet OS|PlayBook)(?: (NT|zvav))*(?: [ix]?[0-9._]+)*(;|\))/im',44 '/^.+?(?P<platform>Windows Phone( OS)?|Symbian|SymbOS|Android|iPhone|iPad|Windows|Linux|Macintosh|RIM Tablet OS|PlayBook)(?: (NT|zvav))*(?: [ix]?[0-9._]+)*(;|\))/im', 45 45 $user_agent, 46 46 $regs … … 51 51 // Find tokens of interest in user-agent string. 52 52 preg_match_all( 53 '%(?P<name>Opera Mini|Opera|OPR|Edge|UCBrowser|UCWEB|QQBrowser| Trident|Silk|Camino|Kindle|Firefox|SamsungBrowser|(?:Mobile )?Safari|NokiaBrowser|MSIE|RockMelt|AppleWebKit|Chrome|IEMobile|Version)(?:[/ ])(?P<version>[0-9.]+)%im',53 '%(?P<name>Opera Mini|Opera|OPR|Edge|UCBrowser|UCWEB|QQBrowser|SymbianOS|Symbian|S40OviBrowser|Trident|Silk|Camino|Kindle|Firefox|SamsungBrowser|(?:Mobile )?Safari|NokiaBrowser|MSIE|RockMelt|AppleWebKit|Chrome|IEMobile|Version)(?:[/ ])(?P<version>[0-9.]+)%im', 54 54 $user_agent, 55 55 $result, … … 68 68 elseif ( 'Windows Phone' === $data['platform'] ) { 69 69 $data['platform'] = 'Windows Phone OS'; 70 } 71 // Standardize Symbian OS name. 72 elseif ( 73 in_array( $data['platform'], array( 'Symbian', 'SymbOS' ) ) 74 || 75 false !== ( $key = array_search( 'SymbianOS', $result['name'] ) ) 76 || 77 false !== ( $key = array_search( 'Symbian', $result['name'] ) ) 78 ) { 79 if ( ! in_array( $data['platform'], array( 'Symbian', 'SymbOS' ) ) ) { 80 unset( $result['name'][ $key ] ); 81 unset( $result['version'][ $key ] ); 82 } 83 $data['platform'] = 'Symbian'; 70 84 } 71 85 // Generically detect some mobile devices. … … 80 94 81 95 // Flag known mobile platforms as mobile. 82 if ( in_array( $data['platform'], array( 'Android', 'Fire OS', 'iPad', 'iPhone', 'Mobile', 'PlayBook', 'RIM Tablet OS', ' Windows Phone OS' ) ) ) {96 if ( in_array( $data['platform'], array( 'Android', 'Fire OS', 'iPad', 'iPhone', 'Mobile', 'PlayBook', 'RIM Tablet OS', 'Symbian', 'Windows Phone OS' ) ) ) { 83 97 $data['mobile'] = true; 84 98 } … … 217 231 if ( 'Android' === $data['platform'] ) { 218 232 $data['name'] = 'Android Browser'; 233 } elseif ( 'Symbian' === $data['platform'] ) { 234 $data['name'] = 'Nokia Browser'; 235 $result['version'][ $key ] = ''; 219 236 } else { 220 237 $data['name'] = 'Safari'; … … 227 244 } 228 245 $data['version'] = $result['version'][ $key ]; 246 } 247 // Ovi Browser 248 elseif ( false !== ( $key = array_search( 'S40OviBrowser', $result['name'] ) ) ) { 249 $data['name'] = 'Ovi Browser'; 250 $data['version'] = $result['version'][ $key ]; 251 $data['platform'] = 'Symbian'; 252 $data['mobile'] = true; 229 253 } 230 254 // Fall back to whatever is being reported.
Note: See TracChangeset
for help on using the changeset viewer.