admin | 078fb91 | 2006-10-04 07:50:05 +0000 | [diff] [blame] | 1 | <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); |
| 2 | /** |
| 3 | * Code Igniter |
| 4 | * |
| 5 | * An open source application development framework for PHP 4.3.2 or newer |
| 6 | * |
| 7 | * @package CodeIgniter |
| 8 | * @author Rick Ellis |
| 9 | * @copyright Copyright (c) 2006, pMachine, Inc. |
| 10 | * @license http://www.codeignitor.com/user_guide/license.html |
| 11 | * @link http://www.codeigniter.com |
| 12 | * @since Version 1.0 |
| 13 | * @filesource |
| 14 | */ |
| 15 | |
| 16 | // ------------------------------------------------------------------------ |
| 17 | |
| 18 | /** |
| 19 | * Code Igniter User Agent Helper |
| 20 | * |
| 21 | * @package CodeIgniter |
| 22 | * @subpackage Helpers |
| 23 | * @category Helpers |
| 24 | * @author Rick Ellis |
| 25 | * @link http://www.codeigniter.com/user_guide/helpers/array_helper.html |
| 26 | */ |
| 27 | |
| 28 | // ------------------------------------------------------------------------ |
| 29 | |
| 30 | /** |
| 31 | * Get the OS of the user currently browsing the site |
| 32 | * |
| 33 | * @access public |
| 34 | * @return string |
| 35 | */ |
| 36 | function get_OS() |
| 37 | { |
| 38 | if ( ! isset($_SERVER['HTTP_USER_AGENT'])) |
| 39 | { |
| 40 | return 'Unknown OS'; |
| 41 | } |
| 42 | |
| 43 | $os = array ( |
| 44 | 'windows nt 6.0' => 'Windows Longhorn', |
| 45 | 'windows nt 5.2' => 'Windows 2003', |
| 46 | 'windows nt 5.0' => 'Windows 2000', |
| 47 | 'windows nt 5.1' => 'Windows XP', |
| 48 | 'windows nt 4.0' => 'Windows NT 4.0', |
| 49 | 'winnt4.0' => 'Windows NT 4.0', |
| 50 | 'winnt 4.0' => 'Windows NT', |
| 51 | 'winnt' => 'Windows NT', |
| 52 | 'windows 98' => 'Windows 98', |
| 53 | 'win98' => 'Windows 98', |
| 54 | 'windows 95' => 'Windows 95', |
| 55 | 'win95' => 'Windows 95', |
| 56 | 'windows' => 'Unknown Windows OS', |
| 57 | 'mac os x' => 'Mac OS X', |
| 58 | 'freebsd' => 'FreeBSD', |
| 59 | 'ppc' => 'Macintosh', |
| 60 | 'sunos' => 'Sun Solaris', |
| 61 | 'linux' => 'Linux', |
| 62 | 'debian' => 'Debian', |
| 63 | 'beos' => 'BeOS', |
| 64 | 'apachebench' => 'ApacheBench', |
| 65 | 'aix' => 'AIX', |
| 66 | 'irix' => 'Irix', |
| 67 | 'osf' => 'DEC OSF', |
| 68 | 'hp-ux' => 'HP-UX', |
| 69 | 'netbsd' => 'NetBSD', |
| 70 | 'bsdi' => 'BSDi', |
| 71 | 'openbsd' => 'OpenBSD', |
| 72 | 'gnu' => 'GNU/Linux', |
| 73 | 'unix' => 'Unknown Unix OS' |
| 74 | ); |
| 75 | |
| 76 | |
| 77 | foreach ($os as $key => $val) |
| 78 | { |
| 79 | if (preg_match("|$key|i", $_SERVER['HTTP_USER_AGENT'])) |
| 80 | { |
| 81 | return $val; |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | return 'Unknown OS'; |
| 86 | } |
| 87 | |
| 88 | |
| 89 | ?> |