- <?php
- function OS($Agent=false)
- {
- if(!$Agent) $Agent = $_SERVER['HTTP_USER_AGENT'];
- $os = null;
- $OS_arr = Array('Windows NT 6.0' => 'Windows Vista',
- 'Windows NT 5.2' => 'Windows Server 2003',
- 'Windows NT 5.1' => 'Windows XP',
- 'Windows NT 5.0' => 'Windows 2000',
- 'Win 9x 4.90' => 'Windows Me.',
- 'Windows 98' => 'Windows 98',
- 'Win98' => 'Windows 98',
- 'Win95' => 'Windows 95',
- 'Mac' => 'Macintosh',
- 'PPC' => 'Macintosh',
- 'Linux' => 'Linux',
- 'FreeBSD' => 'FreeBSD',
- 'Unix' => 'Unix',
- 'SunOS' => 'SunOS',
- 'IRIX' => 'IRIS',
- 'BeOS' => 'BeOS',
- 'OS/2' => 'OS/2',
- 'AIX' => 'AIX');
- foreach($OS_arr as $key_OS => $value_OS)
- {
- if(eregi($key_OS, $Agent))
- {
- $os = $value_OS;
- }
- }
- if(empty($os)) return 'Inconnu';
- else return $os;
- }
-
- # Exemple d'utilisation :
- echo OS($_SERVER['HTTP_USER_AGENT']);
- ?>
<?php
function OS($Agent=false)
{
if(!$Agent) $Agent = $_SERVER['HTTP_USER_AGENT'];
$os = null;
$OS_arr = Array('Windows NT 6.0' => 'Windows Vista',
'Windows NT 5.2' => 'Windows Server 2003',
'Windows NT 5.1' => 'Windows XP',
'Windows NT 5.0' => 'Windows 2000',
'Win 9x 4.90' => 'Windows Me.',
'Windows 98' => 'Windows 98',
'Win98' => 'Windows 98',
'Win95' => 'Windows 95',
'Mac' => 'Macintosh',
'PPC' => 'Macintosh',
'Linux' => 'Linux',
'FreeBSD' => 'FreeBSD',
'Unix' => 'Unix',
'SunOS' => 'SunOS',
'IRIX' => 'IRIS',
'BeOS' => 'BeOS',
'OS/2' => 'OS/2',
'AIX' => 'AIX');
foreach($OS_arr as $key_OS => $value_OS)
{
if(eregi($key_OS, $Agent))
{
$os = $value_OS;
}
}
if(empty($os)) return 'Inconnu';
else return $os;
}
# Exemple d'utilisation :
echo OS($_SERVER['HTTP_USER_AGENT']);
?>