browser-os-functie
Code (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
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
<?
function useragent ()
{
$Browsers = array
(
'MSIE 5.5' => 'Internet Explorer 5.5',
'MSIE 6.0' => 'Internet Explorer 6.0',
'Konqueror' => 'Konqueror',
'Netscape' => 'Netscape',
'MSIE' => 'Internet Explorer',
'Firefox' => 'Mozilla Firefox',
'Safari' => 'Safari'
);
$OperatingSystems = array
(
'Win98' => 'Microsoft Windows 98',
'Windows NT 5.0' => 'Microsoft Windows 2000',
'Win95' => 'Microsoft Windows 95',
'Windows NT 5.1' => 'Microsoft Windows XP',
'Linux' => 'Linux',
);
$Res['Browser'] = _find (&$Browsers, $_SERVER['HTTP_USER_AGENT']);
$Res['OS'] = _find (&$OperatingSystems, $_SERVER['HTTP_USER_AGENT']);
return $Res;
}
function _find (&$Array, $Haystack)
{
foreach ($Array as $Key => $Value)
{
if (strstr ($Haystack, $Key) !== false)
{
return $Value;
}
}
}
list ($Browser, $OS) = useragent();
print_r(user_agent());
?>
function useragent ()
{
$Browsers = array
(
'MSIE 5.5' => 'Internet Explorer 5.5',
'MSIE 6.0' => 'Internet Explorer 6.0',
'Konqueror' => 'Konqueror',
'Netscape' => 'Netscape',
'MSIE' => 'Internet Explorer',
'Firefox' => 'Mozilla Firefox',
'Safari' => 'Safari'
);
$OperatingSystems = array
(
'Win98' => 'Microsoft Windows 98',
'Windows NT 5.0' => 'Microsoft Windows 2000',
'Win95' => 'Microsoft Windows 95',
'Windows NT 5.1' => 'Microsoft Windows XP',
'Linux' => 'Linux',
);
$Res['Browser'] = _find (&$Browsers, $_SERVER['HTTP_USER_AGENT']);
$Res['OS'] = _find (&$OperatingSystems, $_SERVER['HTTP_USER_AGENT']);
return $Res;
}
function _find (&$Array, $Haystack)
{
foreach ($Array as $Key => $Value)
{
if (strstr ($Haystack, $Key) !== false)
{
return $Value;
}
}
}
list ($Browser, $OS) = useragent();
print_r(user_agent());
?>