summaryrefslogtreecommitdiffstats
path: root/system
diff options
context:
space:
mode:
authoradmin <devnull@localhost>2006-10-04 09:50:05 +0200
committeradmin <devnull@localhost>2006-10-04 09:50:05 +0200
commit078fb91f6b58233066d96a3ff0b4cde19d8e4db2 (patch)
treed4766b9302f03061ec907ecb76d6858e07bdb4be /system
parent492a70e6f5643f2b12ac0b61666ba7c5ec59c644 (diff)
Diffstat (limited to 'system')
-rw-r--r--system/helpers/user_agent_helper.php89
1 files changed, 89 insertions, 0 deletions
diff --git a/system/helpers/user_agent_helper.php b/system/helpers/user_agent_helper.php
new file mode 100644
index 000000000..3c6085e77
--- /dev/null
+++ b/system/helpers/user_agent_helper.php
@@ -0,0 +1,89 @@
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * Code Igniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, pMachine, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Code Igniter User Agent Helper
+ *
+ * @package CodeIgniter
+ * @subpackage Helpers
+ * @category Helpers
+ * @author Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/helpers/array_helper.html
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Get the OS of the user currently browsing the site
+ *
+ * @access public
+ * @return string
+ */
+function get_OS()
+{
+ if ( ! isset($_SERVER['HTTP_USER_AGENT']))
+ {
+ return 'Unknown OS';
+ }
+
+ $os = array (
+ 'windows nt 6.0' => 'Windows Longhorn',
+ 'windows nt 5.2' => 'Windows 2003',
+ 'windows nt 5.0' => 'Windows 2000',
+ 'windows nt 5.1' => 'Windows XP',
+ 'windows nt 4.0' => 'Windows NT 4.0',
+ 'winnt4.0' => 'Windows NT 4.0',
+ 'winnt 4.0' => 'Windows NT',
+ 'winnt' => 'Windows NT',
+ 'windows 98' => 'Windows 98',
+ 'win98' => 'Windows 98',
+ 'windows 95' => 'Windows 95',
+ 'win95' => 'Windows 95',
+ 'windows' => 'Unknown Windows OS',
+ 'mac os x' => 'Mac OS X',
+ 'freebsd' => 'FreeBSD',
+ 'ppc' => 'Macintosh',
+ 'sunos' => 'Sun Solaris',
+ 'linux' => 'Linux',
+ 'debian' => 'Debian',
+ 'beos' => 'BeOS',
+ 'apachebench' => 'ApacheBench',
+ 'aix' => 'AIX',
+ 'irix' => 'Irix',
+ 'osf' => 'DEC OSF',
+ 'hp-ux' => 'HP-UX',
+ 'netbsd' => 'NetBSD',
+ 'bsdi' => 'BSDi',
+ 'openbsd' => 'OpenBSD',
+ 'gnu' => 'GNU/Linux',
+ 'unix' => 'Unknown Unix OS'
+ );
+
+
+ foreach ($os as $key => $val)
+ {
+ if (preg_match("|$key|i", $_SERVER['HTTP_USER_AGENT']))
+ {
+ return $val;
+ }
+ }
+
+ return 'Unknown OS';
+}
+
+
+?> \ No newline at end of file