1 | <?php |
||
9 | class UAgent |
||
10 | { |
||
11 | // General token that says the browser is Mozilla compatible, |
||
12 | // and is common to almost every browser today. |
||
13 | const MOZILLA = 'Mozilla/5.0 '; |
||
14 | |||
15 | /** |
||
16 | * Processors by Arch. |
||
17 | */ |
||
18 | public static $processors = array( |
||
19 | 'lin' => array( 'i686', 'x86_64' ), |
||
20 | 'mac' => array( 'Intel', 'PPC', 'U; Intel', 'U; PPC' ), |
||
21 | 'win' => array( 'foo' ) |
||
22 | ); |
||
23 | |||
24 | /** |
||
25 | * Browsers |
||
26 | * |
||
27 | * Weighting is based on market share to determine frequency. |
||
28 | */ |
||
29 | public static $browsers = array( |
||
30 | 34 => array( |
||
31 | 89 => array( 'chrome', 'win' ), |
||
32 | 9 => array( 'chrome', 'mac' ), |
||
33 | 2 => array( 'chrome', 'lin' ) |
||
34 | ), |
||
35 | 32 => array( |
||
36 | 100 => array( 'iexplorer', 'win' ) |
||
37 | ), |
||
38 | 25 => array( |
||
39 | 83 => array( 'firefox', 'win' ), |
||
40 | 16 => array( 'firefox', 'mac' ), |
||
41 | 1 => array( 'firefox', 'lin' ) |
||
42 | ), |
||
43 | 7 => array( |
||
44 | 95 => array( 'safari', 'mac' ), |
||
45 | 4 => array( 'safari', 'win' ), |
||
46 | 1 => array( 'safari', 'lin' ) |
||
47 | ), |
||
48 | 2 => array( |
||
49 | 91 => array( 'opera', 'win' ), |
||
50 | 6 => array( 'opera', 'lin' ), |
||
51 | 3 => array( 'opera', 'mac' ) |
||
52 | ) |
||
53 | ); |
||
54 | |||
55 | /** |
||
56 | * List of Lanuge Culture Codes (ISO 639-1) |
||
57 | * |
||
58 | * @see: http://msdn.microsoft.com/en-gb/library/ee825488(v=cs.20).aspx |
||
59 | */ |
||
60 | public static $languages = array( |
||
61 | 'af-ZA', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-IQ', 'ar-JO', 'ar-KW', 'ar-LB', |
||
62 | 'ar-LY', 'ar-MA', 'ar-OM', 'ar-QA', 'ar-SA', 'ar-SY', 'ar-TN', 'ar-YE', 'be-BY', |
||
63 | 'bg-BG', 'ca-ES', 'cs-CZ', 'Cy-az-AZ', 'Cy-sr-SP', 'Cy-uz-UZ', 'da-DK', 'de-AT', |
||
64 | 'de-CH', 'de-DE', 'de-LI', 'de-LU', 'div-MV', 'el-GR', 'en-AU', 'en-BZ', 'en-CA', |
||
65 | 'en-CB', 'en-GB', 'en-IE', 'en-JM', 'en-NZ', 'en-PH', 'en-TT', 'en-US', 'en-ZA', |
||
66 | 'en-ZW', 'es-AR', 'es-BO', 'es-CL', 'es-CO', 'es-CR', 'es-DO', 'es-EC', 'es-ES', |
||
67 | 'es-GT', 'es-HN', 'es-MX', 'es-NI', 'es-PA', 'es-PE', 'es-PR', 'es-PY', 'es-SV', |
||
68 | 'es-UY', 'es-VE', 'et-EE', 'eu-ES', 'fa-IR', 'fi-FI', 'fo-FO', 'fr-BE', 'fr-CA', |
||
69 | 'fr-CH', 'fr-FR', 'fr-LU', 'fr-MC', 'gl-ES', 'gu-IN', 'he-IL', 'hi-IN', 'hr-HR', |
||
70 | 'hu-HU', 'hy-AM', 'id-ID', 'is-IS', 'it-CH', 'it-IT', 'ja-JP', 'ka-GE', 'kk-KZ', |
||
71 | 'kn-IN', 'kok-IN', 'ko-KR', 'ky-KZ', 'Lt-az-AZ', 'lt-LT', 'Lt-sr-SP', 'Lt-uz-UZ', |
||
72 | 'lv-LV', 'mk-MK', 'mn-MN', 'mr-IN', 'ms-BN', 'ms-MY', 'nb-NO', 'nl-BE', 'nl-NL', |
||
73 | 'nn-NO', 'pa-IN', 'pl-PL', 'pt-BR', 'pt-PT', 'ro-RO', 'ru-RU', 'sa-IN', 'sk-SK', |
||
74 | 'sl-SI', 'sq-AL', 'sv-FI', 'sv-SE', 'sw-KE', 'syr-SY', 'ta-IN', 'te-IN', 'th-TH', |
||
75 | 'tr-TR', 'tt-RU', 'uk-UA', 'ur-PK', 'vi-VN', 'zh-CHS', 'zh-CHT', 'zh-CN', 'zh-HK', |
||
76 | 'zh-MO', 'zh-SG', 'zh-TW', |
||
77 | ); |
||
78 | |||
79 | /** |
||
80 | * Generate Device Platform |
||
81 | * |
||
82 | * Uses a random result with a weighting related to frequencies. |
||
83 | */ |
||
84 | public static function generate_platform() |
||
112 | |||
113 | private static function array_random( $array ) |
||
119 | |||
120 | private static function get_language( $lang = array() ) |
||
124 | |||
125 | private static function get_processor( $os ) |
||
129 | |||
130 | private static function get_version_nt() |
||
135 | |||
136 | private static function get_version_osx() |
||
140 | |||
141 | private static function get_version_webkit() |
||
145 | |||
146 | private static function get_verison_chrome() |
||
150 | |||
151 | private static function get_version_gecko() |
||
155 | |||
156 | private static function get_version_ie() |
||
160 | |||
161 | private static function get_version_trident() |
||
166 | |||
167 | private static function get_version_net() |
||
180 | |||
181 | private static function get_version_safari() |
||
194 | |||
195 | private static function get_version_opera() |
||
199 | |||
200 | /** |
||
201 | * Opera |
||
202 | * |
||
203 | * @see: http://dev.opera.com/blog/opera-user-agent-strings-opera-15-and-beyond/ |
||
204 | */ |
||
205 | public static function opera( $arch ) |
||
229 | |||
230 | /** |
||
231 | * Safari |
||
232 | * |
||
233 | */ |
||
234 | public static function safari( $arch ) |
||
256 | |||
257 | /** |
||
258 | * Internet Explorer |
||
259 | * |
||
260 | * @see: http://msdn.microsoft.com/en-gb/library/ms537503(v=vs.85).aspx |
||
261 | */ |
||
262 | public static function iexplorer( $arch ) |
||
277 | |||
278 | /** |
||
279 | * Firefox User-Agent |
||
280 | * |
||
281 | * @see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Gecko_user_agent_string_reference |
||
282 | */ |
||
283 | public static function firefox( $arch ) |
||
308 | |||
309 | public static function chrome( $arch ) |
||
332 | |||
333 | public static function random( $lang = array( 'en-US' ) ) |
||
339 | |||
340 | public static function generate( $browser = 'chrome', $os = 'win', $lang = array( 'en-US' ) ) |
||
353 | } |
||
354 | ?> |
||
355 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.