-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');\r
-/**\r
- * CodeIgniter\r
- *\r
- * An open source application development framework for PHP 4.3.2 or newer\r
- *\r
- * @package CodeIgniter\r
- * @author ExpressionEngine Dev Team\r
- * @copyright Copyright (c) 2008, EllisLab, Inc.\r
- * @license http://codeigniter.com/user_guide/license.html\r
- * @link http://codeigniter.com\r
- * @since Version 1.0\r
- * @filesource\r
- */\r
-\r
-// ------------------------------------------------------------------------\r
-\r
-/**\r
- * User Agent Class\r
- *\r
- * Identifies the platform, browser, robot, or mobile devise of the browsing agent\r
- *\r
- * @package CodeIgniter\r
- * @subpackage Libraries\r
- * @category User Agent\r
- * @author ExpressionEngine Dev Team\r
- * @link http://codeigniter.com/user_guide/libraries/user_agent.html\r
- */\r
-class CI_User_agent {\r
-\r
- var $agent = NULL;\r
- \r
- var $is_browser = FALSE;\r
- var $is_robot = FALSE;\r
- var $is_mobile = FALSE;\r
-\r
- var $languages = array();\r
- var $charsets = array();\r
- \r
- var $platforms = array();\r
- var $browsers = array();\r
- var $mobiles = array();\r
- var $robots = array();\r
- \r
- var $platform = '';\r
- var $browser = '';\r
- var $version = '';\r
- var $mobile = '';\r
- var $robot = '';\r
- \r
- /**\r
- * Constructor\r
- *\r
- * Sets the User Agent and runs the compilation routine\r
- *\r
- * @access public\r
- * @return void\r
- */ \r
- function CI_User_agent()\r
- {\r
- if (isset($_SERVER['HTTP_USER_AGENT']))\r
- {\r
- $this->agent = trim($_SERVER['HTTP_USER_AGENT']);\r
- }\r
- \r
- if ( ! is_null($this->agent))\r
- {\r
- if ($this->_load_agent_file())\r
- {\r
- $this->_compile_data();\r
- }\r
- }\r
- \r
- log_message('debug', "User Agent Class Initialized");\r
- }\r
- \r
- // --------------------------------------------------------------------\r
- \r
- /**\r
- * Compile the User Agent Data\r
- *\r
- * @access private\r
- * @return bool\r
- */ \r
- function _load_agent_file()\r
- {\r
- if ( ! @include(APPPATH.'config/user_agents'.EXT))\r
- {\r
- return FALSE;\r
- }\r
- \r
- $return = FALSE;\r
- \r
- if (isset($platforms))\r
- {\r
- $this->platforms = $platforms;\r
- unset($platforms);\r
- $return = TRUE;\r
- }\r
-\r
- if (isset($browsers))\r
- {\r
- $this->browsers = $browsers;\r
- unset($browsers);\r
- $return = TRUE;\r
- }\r
-\r
- if (isset($mobiles))\r
- {\r
- $this->mobiles = $mobiles;\r
- unset($mobiles);\r
- $return = TRUE;\r
- }\r
- \r
- if (isset($robots))\r
- {\r
- $this->robots = $robots;\r
- unset($robots);\r
- $return = TRUE;\r
- }\r
-\r
- return $return;\r
- }\r
- \r
- // --------------------------------------------------------------------\r
- \r
- /**\r
- * Compile the User Agent Data\r
- *\r
- * @access private\r
- * @return bool\r
- */ \r
- function _compile_data()\r
- {\r
- $this->_set_platform();\r
- \r
- foreach (array('_set_browser', '_set_robot', '_set_mobile') as $function)\r
- {\r
- if ($this->$function() === TRUE)\r
- {\r
- break;\r
- }\r
- } \r
- }\r
- \r
- // --------------------------------------------------------------------\r
- \r
- /**\r
- * Set the Platform\r
- *\r
- * @access private\r
- * @return mixed\r
- */ \r
- function _set_platform()\r
- {\r
- if (is_array($this->platforms) AND count($this->platforms) > 0)\r
- {\r
- foreach ($this->platforms as $key => $val)\r
- {\r
- if (preg_match("|".preg_quote($key)."|i", $this->agent))\r
- {\r
- $this->platform = $val;\r
- return TRUE;\r
- }\r
- }\r
- }\r
- $this->platform = 'Unknown Platform';\r
- }\r
-\r
- // --------------------------------------------------------------------\r
- \r
- /**\r
- * Set the Browser\r
- *\r
- * @access private\r
- * @return bool\r
- */ \r
- function _set_browser()\r
- {\r
- if (is_array($this->browsers) AND count($this->browsers) > 0)\r
- {\r
- foreach ($this->browsers as $key => $val)\r
- { \r
- if (preg_match("|".preg_quote($key).".*?([0-9\.]+)|i", $this->agent, $match))\r
- {\r
- $this->is_browser = TRUE;\r
- $this->version = $match[1];\r
- $this->browser = $val;\r
- $this->_set_mobile();\r
- return TRUE;\r
- }\r
- }\r
- }\r
- return FALSE;\r
- }\r
- \r
- // --------------------------------------------------------------------\r
- \r
- /**\r
- * Set the Robot\r
- *\r
- * @access private\r
- * @return bool\r
- */ \r
- function _set_robot()\r
- {\r
- if (is_array($this->robots) AND count($this->robots) > 0)\r
- { \r
- foreach ($this->robots as $key => $val)\r
- {\r
- if (preg_match("|".preg_quote($key)."|i", $this->agent))\r
- {\r
- $this->is_robot = TRUE;\r
- $this->robot = $val;\r
- return TRUE;\r
- }\r
- }\r
- }\r
- return FALSE;\r
- }\r
-\r
- // --------------------------------------------------------------------\r
- \r
- /**\r
- * Set the Mobile Device\r
- *\r
- * @access private\r
- * @return bool\r
- */ \r
- function _set_mobile()\r
- {\r
- if (is_array($this->mobiles) AND count($this->mobiles) > 0)\r
- { \r
- foreach ($this->mobiles as $key => $val)\r
- {\r
- if (FALSE !== (strpos(strtolower($this->agent), $key)))\r
- {\r
- $this->is_mobile = TRUE;\r
- $this->mobile = $val;\r
- return TRUE;\r
- }\r
- }\r
- } \r
- return FALSE;\r
- }\r
- \r
- // --------------------------------------------------------------------\r
- \r
- /**\r
- * Set the accepted languages\r
- *\r
- * @access private\r
- * @return void\r
- */ \r
- function _set_languages()\r
- {\r
- if ((count($this->languages) == 0) AND isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) AND $_SERVER['HTTP_ACCEPT_LANGUAGE'] != '')\r
- {\r
- $languages = preg_replace('/(;q=[0-9\.]+)/i', '', strtolower(trim($_SERVER['HTTP_ACCEPT_LANGUAGE'])));\r
- \r
- $this->languages = explode(',', $languages);\r
- }\r
- \r
- if (count($this->languages) == 0)\r
- {\r
- $this->languages = array('Undefined');\r
- } \r
- }\r
- \r
- // --------------------------------------------------------------------\r
- \r
- /**\r
- * Set the accepted character sets\r
- *\r
- * @access private\r
- * @return void\r
- */ \r
- function _set_charsets()\r
- { \r
- if ((count($this->charsets) == 0) AND isset($_SERVER['HTTP_ACCEPT_CHARSET']) AND $_SERVER['HTTP_ACCEPT_CHARSET'] != '')\r
- {\r
- $charsets = preg_replace('/(;q=.+)/i', '', strtolower(trim($_SERVER['HTTP_ACCEPT_CHARSET'])));\r
- \r
- $this->charsets = explode(',', $charsets);\r
- }\r
- \r
- if (count($this->charsets) == 0)\r
- {\r
- $this->charsets = array('Undefined');\r
- } \r
- }\r
-\r
- // --------------------------------------------------------------------\r
- \r
- /**\r
- * Is Browser\r
- *\r
- * @access public\r
- * @return bool\r
- */ \r
- function is_browser()\r
- {\r
- return $this->is_browser;\r
- }\r
-\r
- // --------------------------------------------------------------------\r
- \r
- /**\r
- * Is Robot\r
- *\r
- * @access public\r
- * @return bool\r
- */ \r
- function is_robot()\r
- {\r
- return $this->is_robot;\r
- }\r
-\r
- // --------------------------------------------------------------------\r
- \r
- /**\r
- * Is Mobile\r
- *\r
- * @access public\r
- * @return bool\r
- */ \r
- function is_mobile()\r
- {\r
- return $this->is_mobile;\r
- } \r
-\r
- // --------------------------------------------------------------------\r
- \r
- /**\r
- * Is this a referral from another site?\r
- *\r
- * @access public\r
- * @return bool\r
- */ \r
- function is_referral()\r
- {\r
- return ( ! isset($_SERVER['HTTP_REFERER']) OR $_SERVER['HTTP_REFERER'] == '') ? FALSE : TRUE;\r
- }\r
-\r
- // --------------------------------------------------------------------\r
- \r
- /**\r
- * Agent String\r
- *\r
- * @access public\r
- * @return string\r
- */ \r
- function agent_string()\r
- {\r
- return $this->agent;\r
- }\r
-\r
- // --------------------------------------------------------------------\r
- \r
- /**\r
- * Get Platform\r
- *\r
- * @access public\r
- * @return string\r
- */ \r
- function platform()\r
- {\r
- return $this->platform;\r
- }\r
-\r
- // --------------------------------------------------------------------\r
- \r
- /**\r
- * Get Browser Name\r
- *\r
- * @access public\r
- * @return string\r
- */ \r
- function browser()\r
- {\r
- return $this->browser;\r
- }\r
-\r
- // --------------------------------------------------------------------\r
- \r
- /**\r
- * Get the Browser Version\r
- *\r
- * @access public\r
- * @return string\r
- */ \r
- function version()\r
- {\r
- return $this->version;\r
- }\r
-\r
- // --------------------------------------------------------------------\r
- \r
- /**\r
- * Get The Robot Name\r
- *\r
- * @access public\r
- * @return string\r
- */ \r
- function robot()\r
- {\r
- return $this->robot;\r
- }\r
- // --------------------------------------------------------------------\r
- \r
- /**\r
- * Get the Mobile Device\r
- *\r
- * @access public\r
- * @return string\r
- */ \r
- function mobile()\r
- {\r
- return $this->mobile;\r
- }\r
- \r
- // --------------------------------------------------------------------\r
- \r
- /**\r
- * Get the referrer\r
- *\r
- * @access public\r
- * @return bool\r
- */ \r
- function referrer()\r
- {\r
- return ( ! isset($_SERVER['HTTP_REFERER']) OR $_SERVER['HTTP_REFERER'] == '') ? '' : trim($_SERVER['HTTP_REFERER']);\r
- }\r
-\r
- // --------------------------------------------------------------------\r
- \r
- /**\r
- * Get the accepted languages\r
- *\r
- * @access public\r
- * @return array\r
- */ \r
- function languages()\r
- {\r
- if (count($this->languages) == 0)\r
- {\r
- $this->_set_languages();\r
- }\r
- \r
- return $this->languages;\r
- }\r
-\r
- // --------------------------------------------------------------------\r
- \r
- /**\r
- * Get the accepted Character Sets\r
- *\r
- * @access public\r
- * @return array\r
- */ \r
- function charsets()\r
- {\r
- if (count($this->charsets) == 0)\r
- {\r
- $this->_set_charsets();\r
- }\r
- \r
- return $this->charsets;\r
- }\r
- \r
- // --------------------------------------------------------------------\r
- \r
- /**\r
- * Test for a particular language\r
- *\r
- * @access public\r
- * @return bool\r
- */ \r
- function accept_lang($lang = 'en')\r
- {\r
- return (in_array(strtolower($lang), $this->languages(), TRUE)) ? TRUE : FALSE;\r
- }\r
- \r
- // --------------------------------------------------------------------\r
- \r
- /**\r
- * Test for a particular character set\r
- *\r
- * @access public\r
- * @return bool\r
- */ \r
- function accept_charset($charset = 'utf-8')\r
- {\r
- return (in_array(strtolower($charset), $this->charsets(), TRUE)) ? TRUE : FALSE;\r
- }\r
- \r
- \r
-}\r
-\r
-\r
-/* End of file User_agent.php */\r
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author ExpressionEngine Dev Team
+ * @copyright Copyright (c) 2008, EllisLab, Inc.
+ * @license http://codeigniter.com/user_guide/license.html
+ * @link http://codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * User Agent Class
+ *
+ * Identifies the platform, browser, robot, or mobile devise of the browsing agent
+ *
+ * @package CodeIgniter
+ * @subpackage Libraries
+ * @category User Agent
+ * @author ExpressionEngine Dev Team
+ * @link http://codeigniter.com/user_guide/libraries/user_agent.html
+ */
+class CI_User_agent {
+
+ var $agent = NULL;
+
+ var $is_browser = FALSE;
+ var $is_robot = FALSE;
+ var $is_mobile = FALSE;
+
+ var $languages = array();
+ var $charsets = array();
+
+ var $platforms = array();
+ var $browsers = array();
+ var $mobiles = array();
+ var $robots = array();
+
+ var $platform = '';
+ var $browser = '';
+ var $version = '';
+ var $mobile = '';
+ var $robot = '';
+
+ /**
+ * Constructor
+ *
+ * Sets the User Agent and runs the compilation routine
+ *
+ * @access public
+ * @return void
+ */
+ function CI_User_agent()
+ {
+ if (isset($_SERVER['HTTP_USER_AGENT']))
+ {
+ $this->agent = trim($_SERVER['HTTP_USER_AGENT']);
+ }
+
+ if ( ! is_null($this->agent))
+ {
+ if ($this->_load_agent_file())
+ {
+ $this->_compile_data();
+ }
+ }
+
+ log_message('debug', "User Agent Class Initialized");
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Compile the User Agent Data
+ *
+ * @access private
+ * @return bool
+ */
+ function _load_agent_file()
+ {
+ if ( ! @include(APPPATH.'config/user_agents'.EXT))
+ {
+ return FALSE;
+ }
+
+ $return = FALSE;
+
+ if (isset($platforms))
+ {
+ $this->platforms = $platforms;
+ unset($platforms);
+ $return = TRUE;
+ }
+
+ if (isset($browsers))
+ {
+ $this->browsers = $browsers;
+ unset($browsers);
+ $return = TRUE;
+ }
+
+ if (isset($mobiles))
+ {
+ $this->mobiles = $mobiles;
+ unset($mobiles);
+ $return = TRUE;
+ }
+
+ if (isset($robots))
+ {
+ $this->robots = $robots;
+ unset($robots);
+ $return = TRUE;
+ }
+
+ return $return;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Compile the User Agent Data
+ *
+ * @access private
+ * @return bool
+ */
+ function _compile_data()
+ {
+ $this->_set_platform();
+
+ foreach (array('_set_browser', '_set_robot', '_set_mobile') as $function)
+ {
+ if ($this->$function() === TRUE)
+ {
+ break;
+ }
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set the Platform
+ *
+ * @access private
+ * @return mixed
+ */
+ function _set_platform()
+ {
+ if (is_array($this->platforms) AND count($this->platforms) > 0)
+ {
+ foreach ($this->platforms as $key => $val)
+ {
+ if (preg_match("|".preg_quote($key)."|i", $this->agent))
+ {
+ $this->platform = $val;
+ return TRUE;
+ }
+ }
+ }
+ $this->platform = 'Unknown Platform';
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set the Browser
+ *
+ * @access private
+ * @return bool
+ */
+ function _set_browser()
+ {
+ if (is_array($this->browsers) AND count($this->browsers) > 0)
+ {
+ foreach ($this->browsers as $key => $val)
+ {
+ if (preg_match("|".preg_quote($key).".*?([0-9\.]+)|i", $this->agent, $match))
+ {
+ $this->is_browser = TRUE;
+ $this->version = $match[1];
+ $this->browser = $val;
+ $this->_set_mobile();
+ return TRUE;
+ }
+ }
+ }
+ return FALSE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set the Robot
+ *
+ * @access private
+ * @return bool
+ */
+ function _set_robot()
+ {
+ if (is_array($this->robots) AND count($this->robots) > 0)
+ {
+ foreach ($this->robots as $key => $val)
+ {
+ if (preg_match("|".preg_quote($key)."|i", $this->agent))
+ {
+ $this->is_robot = TRUE;
+ $this->robot = $val;
+ return TRUE;
+ }
+ }
+ }
+ return FALSE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set the Mobile Device
+ *
+ * @access private
+ * @return bool
+ */
+ function _set_mobile()
+ {
+ if (is_array($this->mobiles) AND count($this->mobiles) > 0)
+ {
+ foreach ($this->mobiles as $key => $val)
+ {
+ if (FALSE !== (strpos(strtolower($this->agent), $key)))
+ {
+ $this->is_mobile = TRUE;
+ $this->mobile = $val;
+ return TRUE;
+ }
+ }
+ }
+ return FALSE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set the accepted languages
+ *
+ * @access private
+ * @return void
+ */
+ function _set_languages()
+ {
+ if ((count($this->languages) == 0) AND isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) AND $_SERVER['HTTP_ACCEPT_LANGUAGE'] != '')
+ {
+ $languages = preg_replace('/(;q=[0-9\.]+)/i', '', strtolower(trim($_SERVER['HTTP_ACCEPT_LANGUAGE'])));
+
+ $this->languages = explode(',', $languages);
+ }
+
+ if (count($this->languages) == 0)
+ {
+ $this->languages = array('Undefined');
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set the accepted character sets
+ *
+ * @access private
+ * @return void
+ */
+ function _set_charsets()
+ {
+ if ((count($this->charsets) == 0) AND isset($_SERVER['HTTP_ACCEPT_CHARSET']) AND $_SERVER['HTTP_ACCEPT_CHARSET'] != '')
+ {
+ $charsets = preg_replace('/(;q=.+)/i', '', strtolower(trim($_SERVER['HTTP_ACCEPT_CHARSET'])));
+
+ $this->charsets = explode(',', $charsets);
+ }
+
+ if (count($this->charsets) == 0)
+ {
+ $this->charsets = array('Undefined');
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Is Browser
+ *
+ * @access public
+ * @return bool
+ */
+ function is_browser()
+ {
+ return $this->is_browser;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Is Robot
+ *
+ * @access public
+ * @return bool
+ */
+ function is_robot()
+ {
+ return $this->is_robot;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Is Mobile
+ *
+ * @access public
+ * @return bool
+ */
+ function is_mobile()
+ {
+ return $this->is_mobile;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Is this a referral from another site?
+ *
+ * @access public
+ * @return bool
+ */
+ function is_referral()
+ {
+ return ( ! isset($_SERVER['HTTP_REFERER']) OR $_SERVER['HTTP_REFERER'] == '') ? FALSE : TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Agent String
+ *
+ * @access public
+ * @return string
+ */
+ function agent_string()
+ {
+ return $this->agent;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Get Platform
+ *
+ * @access public
+ * @return string
+ */
+ function platform()
+ {
+ return $this->platform;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Get Browser Name
+ *
+ * @access public
+ * @return string
+ */
+ function browser()
+ {
+ return $this->browser;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Get the Browser Version
+ *
+ * @access public
+ * @return string
+ */
+ function version()
+ {
+ return $this->version;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Get The Robot Name
+ *
+ * @access public
+ * @return string
+ */
+ function robot()
+ {
+ return $this->robot;
+ }
+ // --------------------------------------------------------------------
+
+ /**
+ * Get the Mobile Device
+ *
+ * @access public
+ * @return string
+ */
+ function mobile()
+ {
+ return $this->mobile;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Get the referrer
+ *
+ * @access public
+ * @return bool
+ */
+ function referrer()
+ {
+ return ( ! isset($_SERVER['HTTP_REFERER']) OR $_SERVER['HTTP_REFERER'] == '') ? '' : trim($_SERVER['HTTP_REFERER']);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Get the accepted languages
+ *
+ * @access public
+ * @return array
+ */
+ function languages()
+ {
+ if (count($this->languages) == 0)
+ {
+ $this->_set_languages();
+ }
+
+ return $this->languages;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Get the accepted Character Sets
+ *
+ * @access public
+ * @return array
+ */
+ function charsets()
+ {
+ if (count($this->charsets) == 0)
+ {
+ $this->_set_charsets();
+ }
+
+ return $this->charsets;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Test for a particular language
+ *
+ * @access public
+ * @return bool
+ */
+ function accept_lang($lang = 'en')
+ {
+ return (in_array(strtolower($lang), $this->languages(), TRUE)) ? TRUE : FALSE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Test for a particular character set
+ *
+ * @access public
+ * @return bool
+ */
+ function accept_charset($charset = 'utf-8')
+ {
+ return (in_array(strtolower($charset), $this->charsets(), TRUE)) ? TRUE : FALSE;
+ }
+
+
+}
+
+
+/* End of file User_agent.php */
/* Location: ./system/libraries/User_agent.php */
\ No newline at end of file