diff options
author | Ahmedul Haque Abid <a_h_abid@hotmail.com> | 2014-01-09 10:57:02 +0100 |
---|---|---|
committer | Ahmedul Haque Abid <a_h_abid@hotmail.com> | 2014-01-09 10:57:02 +0100 |
commit | 34cf49043465e41ff776443edfd0e6888277bd14 (patch) | |
tree | 2afac8bc42f36dca1157209f30654010a99efca7 /system/libraries/User_agent.php | |
parent | df3bda56796ae27f98cd6b9fe5c7d9d3bcb756ac (diff) | |
parent | 27e91a07ed66308ba02833b104ca8ca6a05e7be8 (diff) |
Merge branch 'develop' into feature/form_validation/custom_error_per_field
Diffstat (limited to 'system/libraries/User_agent.php')
-rw-r--r-- | system/libraries/User_agent.php | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/system/libraries/User_agent.php b/system/libraries/User_agent.php index 50ac9be98..3a6b6bc98 100644 --- a/system/libraries/User_agent.php +++ b/system/libraries/User_agent.php @@ -282,7 +282,7 @@ class CI_User_agent { { foreach ($this->browsers as $key => $val) { - if (preg_match('|'.preg_quote($key).'.*?([0-9\.]+)|i', $this->agent, $match)) + if (preg_match('|'.$key.'.*?([0-9\.]+)|i', $this->agent, $match)) { $this->is_browser = TRUE; $this->version = $match[1]; @@ -634,6 +634,34 @@ class CI_User_agent { return in_array(strtolower($charset), $this->charsets(), TRUE); } + // -------------------------------------------------------------------- + + /** + * Parse a custom user-agent string + * + * @param string $string + * @return void + */ + public function parse($string) + { + // Reset values + $this->is_browser = FALSE; + $this->is_robot = FALSE; + $this->is_mobile = FALSE; + $this->browser = ''; + $this->version = ''; + $this->mobile = ''; + $this->robot = ''; + + // Set the new user-agent string and parse it, unless empty + $this->agent = $string; + + if ( ! empty($string)) + { + $this->_compile_data(); + } + } + } /* End of file User_agent.php */ |