diff options
author | Andrey Andreev <narf@devilix.net> | 2014-01-09 00:00:48 +0100 |
---|---|---|
committer | Andrey Andreev <narf@devilix.net> | 2014-01-09 00:00:48 +0100 |
commit | 27e91a07ed66308ba02833b104ca8ca6a05e7be8 (patch) | |
tree | e7c7f0b258052afe1be45e3d35f2d1a3a492b7cb /system/libraries | |
parent | 10925d27adac84634cc527d7298b1add0d54ba7c (diff) |
Add CI_User_agent::parse() to allow parsing a custom user-agent string
Based on PR #970
Diffstat (limited to 'system/libraries')
-rw-r--r-- | system/libraries/User_agent.php | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/system/libraries/User_agent.php b/system/libraries/User_agent.php index e13bf8513..3a6b6bc98 100644 --- a/system/libraries/User_agent.php +++ b/system/libraries/User_agent.php @@ -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 */ |