-
Notifications
You must be signed in to change notification settings - Fork 0
/
identification.php
86 lines (81 loc) · 1.9 KB
/
identification.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
/**
* Work out which OS it is.
*
* @param string $user_agent
* @return void
*/
function getOS2($user_agent)
{
// global $user_agent;
$os_platform = "Unknown OS";
$os_array = array(
'/windows nt 6.2/i' => 'Windows 8',
'/windows nt 6.1/i' => 'Windows 7',
'/windows nt 6.0/i' => 'Windows Vista',
'/windows nt 5.2/i' => 'Windows Server 2003/XP x64',
'/windows nt 5.1/i' => 'Windows XP',
'/windows xp/i' => 'Windows XP',
'/windows nt 5.0/i' => 'Windows 2000',
'/windows me/i' => 'Windows ME',
'/win98/i' => 'Windows 98',
'/win95/i' => 'Windows 95',
'/win16/i' => 'Windows 3.11',
'/macintosh|mac os x/i' => 'macOS',
'/mac_powerpc/i' => 'Mac OS 9',
'/linux/i' => 'Linux',
'/ubuntu/i' => 'Ubuntu',
'/iphone/i' => 'iPhone',
'/ipod/i' => 'iPod',
'/ipad/i' => 'iPad',
'/android/i' => 'Android',
'/blackberry/i' => 'BlackBerry',
'/webos/i' => 'Mobile',
);
foreach ($os_array as $regex => $value) {
if (preg_match($regex, $user_agent)) {
$os_platform = $value;
}
}
return $os_platform;
}
/**
* Get Browser name.
*
* @param string $user_agent
* @return void
*/
function getBrowser($user_agent)
{
$browser = "Unknown Browser";
$browser_array = array(
'/safari/i' => 'Safari',
'/chrome/i' => 'Chrome',
'/msie/i' => 'Internet Explorer',
'/firefox/i' => 'Mozilla Firefox',
'/opera/i' => 'Opera',
'/netscape/i' => 'Netscape',
'/maxthon/i' => 'Maxthon',
'/konqueror/i' => 'Konqueror',
'/ucbrowser/i' => 'UC Browser',
'/edg/i' => 'Microsoft Edge',
'/mobile/i' => 'Handheld Browser',
);
foreach ($browser_array as $regex => $value) {
if (preg_match($regex, $user_agent)) {
$browser = $value;
}
}
return $browser;
}
/**
* Get Browser Version
*
* @param string $user_agent
* @return void
*/
function getBrowserVersion($user_agent){
// Only works with Firefox?
preg_match('/rv\s*:\s*([^;)\s]+)/i', $user_agent , $matches);
return $matches[1] ?? '';
}