Andrey Andreev | e9ccf74 | 2011-12-25 17:30:10 +0200 | [diff] [blame] | 1 | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 2 | /** |
| 3 | * CodeIgniter |
| 4 | * |
Phil Sturgeon | 07c1ac8 | 2012-03-09 17:03:37 +0000 | [diff] [blame] | 5 | * An open source application development framework for PHP 5.2.4 or newer |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 6 | * |
Derek Jones | f4a4bd8 | 2011-10-20 12:18:42 -0500 | [diff] [blame] | 7 | * NOTICE OF LICENSE |
Andrey Andreev | e9ccf74 | 2011-12-25 17:30:10 +0200 | [diff] [blame] | 8 | * |
Derek Jones | f4a4bd8 | 2011-10-20 12:18:42 -0500 | [diff] [blame] | 9 | * Licensed under the Open Software License version 3.0 |
Andrey Andreev | e9ccf74 | 2011-12-25 17:30:10 +0200 | [diff] [blame] | 10 | * |
Derek Jones | f4a4bd8 | 2011-10-20 12:18:42 -0500 | [diff] [blame] | 11 | * This source file is subject to the Open Software License (OSL 3.0) that is |
| 12 | * bundled with this package in the files license.txt / license.rst. It is |
| 13 | * also available through the world wide web at this URL: |
| 14 | * http://opensource.org/licenses/OSL-3.0 |
| 15 | * If you did not receive a copy of the license and are unable to obtain it |
| 16 | * through the world wide web, please send an email to |
| 17 | * licensing@ellislab.com so we can send you a copy immediately. |
| 18 | * |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 19 | * @package CodeIgniter |
Derek Jones | f4a4bd8 | 2011-10-20 12:18:42 -0500 | [diff] [blame] | 20 | * @author EllisLab Dev Team |
Greg Aker | 0defe5d | 2012-01-01 18:46:41 -0600 | [diff] [blame] | 21 | * @copyright Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/) |
Derek Jones | f4a4bd8 | 2011-10-20 12:18:42 -0500 | [diff] [blame] | 22 | * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 23 | * @link http://codeigniter.com |
| 24 | * @since Version 1.0 |
| 25 | * @filesource |
| 26 | */ |
| 27 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 28 | /** |
| 29 | * User Agent Class |
| 30 | * |
cenk | 115e998 | 2011-09-27 10:07:53 +0300 | [diff] [blame] | 31 | * Identifies the platform, browser, robot, or mobile device of the browsing agent |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 32 | * |
| 33 | * @package CodeIgniter |
| 34 | * @subpackage Libraries |
| 35 | * @category User Agent |
Derek Jones | f4a4bd8 | 2011-10-20 12:18:42 -0500 | [diff] [blame] | 36 | * @author EllisLab Dev Team |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 37 | * @link http://codeigniter.com/user_guide/libraries/user_agent.html |
| 38 | */ |
| 39 | class CI_User_agent { |
| 40 | |
Timothy Warren | 0688ac9 | 2012-04-20 10:25:04 -0400 | [diff] [blame] | 41 | /** |
| 42 | * Current user-agent |
| 43 | * |
| 44 | * @var string |
| 45 | */ |
| 46 | public $agent = NULL; |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 47 | |
Timothy Warren | 0688ac9 | 2012-04-20 10:25:04 -0400 | [diff] [blame] | 48 | /** |
| 49 | * Flag for if the user-agent belongs to a browser |
| 50 | * |
| 51 | * @var bool |
| 52 | */ |
| 53 | public $is_browser = FALSE; |
Andrey Andreev | ca7d822 | 2012-05-11 10:59:09 +0300 | [diff] [blame] | 54 | |
Timothy Warren | 0688ac9 | 2012-04-20 10:25:04 -0400 | [diff] [blame] | 55 | /** |
| 56 | * Flag for if the user-agent is a robot |
| 57 | * |
| 58 | * @var bool |
| 59 | */ |
| 60 | public $is_robot = FALSE; |
Andrey Andreev | ca7d822 | 2012-05-11 10:59:09 +0300 | [diff] [blame] | 61 | |
Timothy Warren | 0688ac9 | 2012-04-20 10:25:04 -0400 | [diff] [blame] | 62 | /** |
| 63 | * Flag for if the user-agent is a mobile browser |
| 64 | * |
| 65 | * @var bool |
| 66 | */ |
| 67 | public $is_mobile = FALSE; |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 68 | |
Timothy Warren | 0688ac9 | 2012-04-20 10:25:04 -0400 | [diff] [blame] | 69 | /** |
| 70 | * Languages accepted by the current user agent |
| 71 | * |
| 72 | * @var array |
| 73 | */ |
| 74 | public $languages = array(); |
Andrey Andreev | ca7d822 | 2012-05-11 10:59:09 +0300 | [diff] [blame] | 75 | |
Timothy Warren | 0688ac9 | 2012-04-20 10:25:04 -0400 | [diff] [blame] | 76 | /** |
| 77 | * Character sets accepted by the current user agent |
| 78 | * |
| 79 | * @var array |
| 80 | */ |
| 81 | public $charsets = array(); |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 82 | |
Timothy Warren | 0688ac9 | 2012-04-20 10:25:04 -0400 | [diff] [blame] | 83 | /** |
| 84 | * List of platforms to compare against current user agent |
| 85 | * |
| 86 | * @var array |
| 87 | */ |
| 88 | public $platforms = array(); |
Andrey Andreev | ca7d822 | 2012-05-11 10:59:09 +0300 | [diff] [blame] | 89 | |
Timothy Warren | 0688ac9 | 2012-04-20 10:25:04 -0400 | [diff] [blame] | 90 | /** |
| 91 | * List of browsers to compare against current user agent |
| 92 | * |
| 93 | * @var array |
| 94 | */ |
| 95 | public $browsers = array(); |
Andrey Andreev | ca7d822 | 2012-05-11 10:59:09 +0300 | [diff] [blame] | 96 | |
Timothy Warren | 0688ac9 | 2012-04-20 10:25:04 -0400 | [diff] [blame] | 97 | /** |
| 98 | * List of mobile browsers to compare against current user agent |
| 99 | * |
| 100 | * @var array |
| 101 | */ |
| 102 | public $mobiles = array(); |
Andrey Andreev | ca7d822 | 2012-05-11 10:59:09 +0300 | [diff] [blame] | 103 | |
Timothy Warren | 0688ac9 | 2012-04-20 10:25:04 -0400 | [diff] [blame] | 104 | /** |
| 105 | * List of robots to compare against current user agent |
| 106 | * |
| 107 | * @var array |
| 108 | */ |
| 109 | public $robots = array(); |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 110 | |
Timothy Warren | 0688ac9 | 2012-04-20 10:25:04 -0400 | [diff] [blame] | 111 | /** |
| 112 | * Current user-agent platform |
| 113 | * |
| 114 | * @var string |
| 115 | */ |
| 116 | public $platform = ''; |
Andrey Andreev | ca7d822 | 2012-05-11 10:59:09 +0300 | [diff] [blame] | 117 | |
Timothy Warren | 0688ac9 | 2012-04-20 10:25:04 -0400 | [diff] [blame] | 118 | /** |
| 119 | * Current user-agent browser |
| 120 | * |
| 121 | * @var string |
| 122 | */ |
| 123 | public $browser = ''; |
Andrey Andreev | ca7d822 | 2012-05-11 10:59:09 +0300 | [diff] [blame] | 124 | |
Timothy Warren | 0688ac9 | 2012-04-20 10:25:04 -0400 | [diff] [blame] | 125 | /** |
| 126 | * Current user-agent version |
| 127 | * |
| 128 | * @var string |
| 129 | */ |
| 130 | public $version = ''; |
Andrey Andreev | ca7d822 | 2012-05-11 10:59:09 +0300 | [diff] [blame] | 131 | |
Timothy Warren | 0688ac9 | 2012-04-20 10:25:04 -0400 | [diff] [blame] | 132 | /** |
| 133 | * Current user-agent mobile name |
| 134 | * |
| 135 | * @var string |
| 136 | */ |
| 137 | public $mobile = ''; |
Andrey Andreev | ca7d822 | 2012-05-11 10:59:09 +0300 | [diff] [blame] | 138 | |
Timothy Warren | 0688ac9 | 2012-04-20 10:25:04 -0400 | [diff] [blame] | 139 | /** |
| 140 | * Current user-agent robot name |
| 141 | * |
| 142 | * @var string |
| 143 | */ |
| 144 | public $robot = ''; |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 145 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 146 | /** |
| 147 | * Constructor |
| 148 | * |
| 149 | * Sets the User Agent and runs the compilation routine |
| 150 | * |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 151 | * @return void |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 152 | */ |
Greg Aker | a926328 | 2010-11-10 15:26:43 -0600 | [diff] [blame] | 153 | public function __construct() |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 154 | { |
| 155 | if (isset($_SERVER['HTTP_USER_AGENT'])) |
| 156 | { |
| 157 | $this->agent = trim($_SERVER['HTTP_USER_AGENT']); |
| 158 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 159 | |
Andrey Andreev | d3bc53d | 2012-04-03 16:37:19 +0300 | [diff] [blame] | 160 | if ( ! is_null($this->agent) && $this->_load_agent_file()) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 161 | { |
Andrey Andreev | d3bc53d | 2012-04-03 16:37:19 +0300 | [diff] [blame] | 162 | $this->_compile_data(); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 163 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 164 | |
Andrey Andreev | d3bc53d | 2012-04-03 16:37:19 +0300 | [diff] [blame] | 165 | log_message('debug', 'User Agent Class Initialized'); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 166 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 167 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 168 | // -------------------------------------------------------------------- |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 169 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 170 | /** |
| 171 | * Compile the User Agent Data |
| 172 | * |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 173 | * @return bool |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 174 | */ |
Andrey Andreev | 75c5efb | 2011-12-26 16:28:40 +0200 | [diff] [blame] | 175 | protected function _load_agent_file() |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 176 | { |
Andrey Andreev | d3bc53d | 2012-04-03 16:37:19 +0300 | [diff] [blame] | 177 | if (defined('ENVIRONMENT') && is_file(APPPATH.'config/'.ENVIRONMENT.'/user_agents.php')) |
Greg Aker | d96f882 | 2011-12-27 16:23:47 -0600 | [diff] [blame] | 178 | { |
| 179 | include(APPPATH.'config/'.ENVIRONMENT.'/user_agents.php'); |
| 180 | } |
| 181 | elseif (is_file(APPPATH.'config/user_agents.php')) |
| 182 | { |
| 183 | include(APPPATH.'config/user_agents.php'); |
| 184 | } |
| 185 | else |
bubbafoley | 0ea0414 | 2011-03-17 14:55:41 -0500 | [diff] [blame] | 186 | { |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 187 | return FALSE; |
| 188 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 189 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 190 | $return = FALSE; |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 191 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 192 | if (isset($platforms)) |
| 193 | { |
| 194 | $this->platforms = $platforms; |
| 195 | unset($platforms); |
| 196 | $return = TRUE; |
| 197 | } |
| 198 | |
| 199 | if (isset($browsers)) |
| 200 | { |
| 201 | $this->browsers = $browsers; |
| 202 | unset($browsers); |
| 203 | $return = TRUE; |
| 204 | } |
| 205 | |
| 206 | if (isset($mobiles)) |
| 207 | { |
| 208 | $this->mobiles = $mobiles; |
| 209 | unset($mobiles); |
| 210 | $return = TRUE; |
| 211 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 212 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 213 | if (isset($robots)) |
| 214 | { |
| 215 | $this->robots = $robots; |
| 216 | unset($robots); |
| 217 | $return = TRUE; |
| 218 | } |
| 219 | |
| 220 | return $return; |
| 221 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 222 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 223 | // -------------------------------------------------------------------- |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 224 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 225 | /** |
| 226 | * Compile the User Agent Data |
| 227 | * |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 228 | * @return bool |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 229 | */ |
Andrey Andreev | 75c5efb | 2011-12-26 16:28:40 +0200 | [diff] [blame] | 230 | protected function _compile_data() |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 231 | { |
| 232 | $this->_set_platform(); |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 233 | |
Phil Sturgeon | 2c547df | 2011-08-10 08:36:02 -0600 | [diff] [blame] | 234 | foreach (array('_set_robot', '_set_browser', '_set_mobile') as $function) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 235 | { |
| 236 | if ($this->$function() === TRUE) |
| 237 | { |
| 238 | break; |
| 239 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 240 | } |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 241 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 242 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 243 | // -------------------------------------------------------------------- |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 244 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 245 | /** |
| 246 | * Set the Platform |
| 247 | * |
Andrey Andreev | d3bc53d | 2012-04-03 16:37:19 +0300 | [diff] [blame] | 248 | * @return bool |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 249 | */ |
Andrey Andreev | 75c5efb | 2011-12-26 16:28:40 +0200 | [diff] [blame] | 250 | protected function _set_platform() |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 251 | { |
Andrey Andreev | d3bc53d | 2012-04-03 16:37:19 +0300 | [diff] [blame] | 252 | if (is_array($this->platforms) && count($this->platforms) > 0) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 253 | { |
| 254 | foreach ($this->platforms as $key => $val) |
| 255 | { |
Andrey Andreev | d3bc53d | 2012-04-03 16:37:19 +0300 | [diff] [blame] | 256 | if (preg_match('|'.preg_quote($key).'|i', $this->agent)) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 257 | { |
| 258 | $this->platform = $val; |
| 259 | return TRUE; |
| 260 | } |
| 261 | } |
| 262 | } |
Andrey Andreev | d3bc53d | 2012-04-03 16:37:19 +0300 | [diff] [blame] | 263 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 264 | $this->platform = 'Unknown Platform'; |
Andrey Andreev | d3bc53d | 2012-04-03 16:37:19 +0300 | [diff] [blame] | 265 | return FALSE; |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 266 | } |
| 267 | |
| 268 | // -------------------------------------------------------------------- |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 269 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 270 | /** |
| 271 | * Set the Browser |
| 272 | * |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 273 | * @return bool |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 274 | */ |
Andrey Andreev | 75c5efb | 2011-12-26 16:28:40 +0200 | [diff] [blame] | 275 | protected function _set_browser() |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 276 | { |
Andrey Andreev | d3bc53d | 2012-04-03 16:37:19 +0300 | [diff] [blame] | 277 | if (is_array($this->browsers) && count($this->browsers) > 0) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 278 | { |
| 279 | foreach ($this->browsers as $key => $val) |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 280 | { |
Andrey Andreev | d3bc53d | 2012-04-03 16:37:19 +0300 | [diff] [blame] | 281 | if (preg_match('|'.preg_quote($key).'.*?([0-9\.]+)|i', $this->agent, $match)) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 282 | { |
| 283 | $this->is_browser = TRUE; |
| 284 | $this->version = $match[1]; |
| 285 | $this->browser = $val; |
| 286 | $this->_set_mobile(); |
| 287 | return TRUE; |
| 288 | } |
| 289 | } |
| 290 | } |
Andrey Andreev | d3bc53d | 2012-04-03 16:37:19 +0300 | [diff] [blame] | 291 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 292 | return FALSE; |
| 293 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 294 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 295 | // -------------------------------------------------------------------- |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 296 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 297 | /** |
| 298 | * Set the Robot |
| 299 | * |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 300 | * @return bool |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 301 | */ |
Andrey Andreev | 75c5efb | 2011-12-26 16:28:40 +0200 | [diff] [blame] | 302 | protected function _set_robot() |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 303 | { |
Andrey Andreev | d3bc53d | 2012-04-03 16:37:19 +0300 | [diff] [blame] | 304 | if (is_array($this->robots) && count($this->robots) > 0) |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 305 | { |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 306 | foreach ($this->robots as $key => $val) |
| 307 | { |
Andrey Andreev | d3bc53d | 2012-04-03 16:37:19 +0300 | [diff] [blame] | 308 | if (preg_match('|'.preg_quote($key).'|i', $this->agent)) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 309 | { |
| 310 | $this->is_robot = TRUE; |
| 311 | $this->robot = $val; |
| 312 | return TRUE; |
| 313 | } |
| 314 | } |
| 315 | } |
Andrey Andreev | d3bc53d | 2012-04-03 16:37:19 +0300 | [diff] [blame] | 316 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 317 | return FALSE; |
| 318 | } |
| 319 | |
| 320 | // -------------------------------------------------------------------- |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 321 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 322 | /** |
| 323 | * Set the Mobile Device |
| 324 | * |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 325 | * @return bool |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 326 | */ |
Andrey Andreev | 75c5efb | 2011-12-26 16:28:40 +0200 | [diff] [blame] | 327 | protected function _set_mobile() |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 328 | { |
Andrey Andreev | d3bc53d | 2012-04-03 16:37:19 +0300 | [diff] [blame] | 329 | if (is_array($this->mobiles) && count($this->mobiles) > 0) |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 330 | { |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 331 | foreach ($this->mobiles as $key => $val) |
| 332 | { |
Andrey Andreev | ca7d822 | 2012-05-11 10:59:09 +0300 | [diff] [blame] | 333 | if (FALSE !== (stripos($this->agent, $key))) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 334 | { |
| 335 | $this->is_mobile = TRUE; |
| 336 | $this->mobile = $val; |
| 337 | return TRUE; |
| 338 | } |
| 339 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 340 | } |
Andrey Andreev | d3bc53d | 2012-04-03 16:37:19 +0300 | [diff] [blame] | 341 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 342 | return FALSE; |
| 343 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 344 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 345 | // -------------------------------------------------------------------- |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 346 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 347 | /** |
| 348 | * Set the accepted languages |
| 349 | * |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 350 | * @return void |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 351 | */ |
Andrey Andreev | 75c5efb | 2011-12-26 16:28:40 +0200 | [diff] [blame] | 352 | protected function _set_languages() |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 353 | { |
Andrey Andreev | d3bc53d | 2012-04-03 16:37:19 +0300 | [diff] [blame] | 354 | if ((count($this->languages) === 0) && ! empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 355 | { |
Andrey Andreev | e9ccf74 | 2011-12-25 17:30:10 +0200 | [diff] [blame] | 356 | $this->languages = explode(',', preg_replace('/(;q=[0-9\.]+)/i', '', strtolower(trim($_SERVER['HTTP_ACCEPT_LANGUAGE'])))); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 357 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 358 | |
Andrey Andreev | e9ccf74 | 2011-12-25 17:30:10 +0200 | [diff] [blame] | 359 | if (count($this->languages) === 0) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 360 | { |
| 361 | $this->languages = array('Undefined'); |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 362 | } |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 363 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 364 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 365 | // -------------------------------------------------------------------- |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 366 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 367 | /** |
| 368 | * Set the accepted character sets |
| 369 | * |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 370 | * @return void |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 371 | */ |
Andrey Andreev | 75c5efb | 2011-12-26 16:28:40 +0200 | [diff] [blame] | 372 | protected function _set_charsets() |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 373 | { |
Andrey Andreev | d3bc53d | 2012-04-03 16:37:19 +0300 | [diff] [blame] | 374 | if ((count($this->charsets) === 0) && ! empty($_SERVER['HTTP_ACCEPT_CHARSET'])) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 375 | { |
Andrey Andreev | e9ccf74 | 2011-12-25 17:30:10 +0200 | [diff] [blame] | 376 | $this->charsets = explode(',', preg_replace('/(;q=.+)/i', '', strtolower(trim($_SERVER['HTTP_ACCEPT_CHARSET'])))); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 377 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 378 | |
Andrey Andreev | e9ccf74 | 2011-12-25 17:30:10 +0200 | [diff] [blame] | 379 | if (count($this->charsets) === 0) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 380 | { |
| 381 | $this->charsets = array('Undefined'); |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 382 | } |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 383 | } |
| 384 | |
| 385 | // -------------------------------------------------------------------- |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 386 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 387 | /** |
| 388 | * Is Browser |
| 389 | * |
Timothy Warren | 0688ac9 | 2012-04-20 10:25:04 -0400 | [diff] [blame] | 390 | * @param string $key |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 391 | * @return bool |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 392 | */ |
Phil Sturgeon | dac1b46 | 2011-01-06 17:40:10 +0000 | [diff] [blame] | 393 | public function is_browser($key = NULL) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 394 | { |
Phil Sturgeon | dac1b46 | 2011-01-06 17:40:10 +0000 | [diff] [blame] | 395 | if ( ! $this->is_browser) |
| 396 | { |
| 397 | return FALSE; |
| 398 | } |
| 399 | |
| 400 | // No need to be specific, it's a browser |
| 401 | if ($key === NULL) |
| 402 | { |
| 403 | return TRUE; |
| 404 | } |
| 405 | |
| 406 | // Check for a specific browser |
Andrey Andreev | d3bc53d | 2012-04-03 16:37:19 +0300 | [diff] [blame] | 407 | return (isset($this->browsers[$key]) && $this->browser === $this->browsers[$key]); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 408 | } |
| 409 | |
| 410 | // -------------------------------------------------------------------- |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 411 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 412 | /** |
| 413 | * Is Robot |
| 414 | * |
Timothy Warren | 0688ac9 | 2012-04-20 10:25:04 -0400 | [diff] [blame] | 415 | * @param string $key |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 416 | * @return bool |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 417 | */ |
Phil Sturgeon | dac1b46 | 2011-01-06 17:40:10 +0000 | [diff] [blame] | 418 | public function is_robot($key = NULL) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 419 | { |
Phil Sturgeon | dac1b46 | 2011-01-06 17:40:10 +0000 | [diff] [blame] | 420 | if ( ! $this->is_robot) |
| 421 | { |
| 422 | return FALSE; |
| 423 | } |
| 424 | |
| 425 | // No need to be specific, it's a robot |
| 426 | if ($key === NULL) |
| 427 | { |
| 428 | return TRUE; |
| 429 | } |
| 430 | |
| 431 | // Check for a specific robot |
Andrey Andreev | d3bc53d | 2012-04-03 16:37:19 +0300 | [diff] [blame] | 432 | return (isset($this->robots[$key]) && $this->robot === $this->robots[$key]); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 433 | } |
| 434 | |
| 435 | // -------------------------------------------------------------------- |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 436 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 437 | /** |
| 438 | * Is Mobile |
| 439 | * |
Timothy Warren | 0688ac9 | 2012-04-20 10:25:04 -0400 | [diff] [blame] | 440 | * @param string $key |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 441 | * @return bool |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 442 | */ |
Phil Sturgeon | dac1b46 | 2011-01-06 17:40:10 +0000 | [diff] [blame] | 443 | public function is_mobile($key = NULL) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 444 | { |
Phil Sturgeon | dac1b46 | 2011-01-06 17:40:10 +0000 | [diff] [blame] | 445 | if ( ! $this->is_mobile) |
| 446 | { |
| 447 | return FALSE; |
| 448 | } |
| 449 | |
| 450 | // No need to be specific, it's a mobile |
| 451 | if ($key === NULL) |
| 452 | { |
| 453 | return TRUE; |
| 454 | } |
| 455 | |
| 456 | // Check for a specific robot |
Andrey Andreev | d3bc53d | 2012-04-03 16:37:19 +0300 | [diff] [blame] | 457 | return (isset($this->mobiles[$key]) && $this->mobile === $this->mobiles[$key]); |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 458 | } |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 459 | |
| 460 | // -------------------------------------------------------------------- |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 461 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 462 | /** |
| 463 | * Is this a referral from another site? |
| 464 | * |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 465 | * @return bool |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 466 | */ |
Phil Sturgeon | dac1b46 | 2011-01-06 17:40:10 +0000 | [diff] [blame] | 467 | public function is_referral() |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 468 | { |
Andrey Andreev | a0836b9 | 2012-10-24 22:03:42 +0300 | [diff] [blame] | 469 | if (empty($_SERVER['HTTP_REFERER'])) |
| 470 | { |
| 471 | return FALSE; |
| 472 | } |
| 473 | |
| 474 | $referer = parse_url($_SERVER['HTTP_REFERER']); |
| 475 | return ! (empty($referer['host']) && strpos(config_item('base_url'), $referer['host']) !== FALSE); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 476 | } |
| 477 | |
| 478 | // -------------------------------------------------------------------- |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 479 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 480 | /** |
| 481 | * Agent String |
| 482 | * |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 483 | * @return string |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 484 | */ |
Phil Sturgeon | dac1b46 | 2011-01-06 17:40:10 +0000 | [diff] [blame] | 485 | public function agent_string() |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 486 | { |
| 487 | return $this->agent; |
| 488 | } |
| 489 | |
| 490 | // -------------------------------------------------------------------- |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 491 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 492 | /** |
| 493 | * Get Platform |
| 494 | * |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 495 | * @return string |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 496 | */ |
Phil Sturgeon | dac1b46 | 2011-01-06 17:40:10 +0000 | [diff] [blame] | 497 | public function platform() |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 498 | { |
| 499 | return $this->platform; |
| 500 | } |
| 501 | |
| 502 | // -------------------------------------------------------------------- |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 503 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 504 | /** |
| 505 | * Get Browser Name |
| 506 | * |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 507 | * @return string |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 508 | */ |
Phil Sturgeon | dac1b46 | 2011-01-06 17:40:10 +0000 | [diff] [blame] | 509 | public function browser() |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 510 | { |
| 511 | return $this->browser; |
| 512 | } |
| 513 | |
| 514 | // -------------------------------------------------------------------- |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 515 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 516 | /** |
| 517 | * Get the Browser Version |
| 518 | * |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 519 | * @return string |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 520 | */ |
Phil Sturgeon | dac1b46 | 2011-01-06 17:40:10 +0000 | [diff] [blame] | 521 | public function version() |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 522 | { |
| 523 | return $this->version; |
| 524 | } |
| 525 | |
| 526 | // -------------------------------------------------------------------- |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 527 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 528 | /** |
| 529 | * Get The Robot Name |
| 530 | * |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 531 | * @return string |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 532 | */ |
Phil Sturgeon | dac1b46 | 2011-01-06 17:40:10 +0000 | [diff] [blame] | 533 | public function robot() |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 534 | { |
| 535 | return $this->robot; |
| 536 | } |
| 537 | // -------------------------------------------------------------------- |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 538 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 539 | /** |
| 540 | * Get the Mobile Device |
| 541 | * |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 542 | * @return string |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 543 | */ |
Phil Sturgeon | dac1b46 | 2011-01-06 17:40:10 +0000 | [diff] [blame] | 544 | public function mobile() |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 545 | { |
| 546 | return $this->mobile; |
| 547 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 548 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 549 | // -------------------------------------------------------------------- |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 550 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 551 | /** |
| 552 | * Get the referrer |
| 553 | * |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 554 | * @return bool |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 555 | */ |
Phil Sturgeon | dac1b46 | 2011-01-06 17:40:10 +0000 | [diff] [blame] | 556 | public function referrer() |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 557 | { |
Andrey Andreev | d3bc53d | 2012-04-03 16:37:19 +0300 | [diff] [blame] | 558 | return empty($_SERVER['HTTP_REFERER']) ? '' : trim($_SERVER['HTTP_REFERER']); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 559 | } |
| 560 | |
| 561 | // -------------------------------------------------------------------- |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 562 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 563 | /** |
| 564 | * Get the accepted languages |
| 565 | * |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 566 | * @return array |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 567 | */ |
Phil Sturgeon | dac1b46 | 2011-01-06 17:40:10 +0000 | [diff] [blame] | 568 | public function languages() |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 569 | { |
Andrey Andreev | e9ccf74 | 2011-12-25 17:30:10 +0200 | [diff] [blame] | 570 | if (count($this->languages) === 0) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 571 | { |
| 572 | $this->_set_languages(); |
| 573 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 574 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 575 | return $this->languages; |
| 576 | } |
| 577 | |
| 578 | // -------------------------------------------------------------------- |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 579 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 580 | /** |
| 581 | * Get the accepted Character Sets |
| 582 | * |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 583 | * @return array |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 584 | */ |
Phil Sturgeon | dac1b46 | 2011-01-06 17:40:10 +0000 | [diff] [blame] | 585 | public function charsets() |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 586 | { |
Andrey Andreev | e9ccf74 | 2011-12-25 17:30:10 +0200 | [diff] [blame] | 587 | if (count($this->charsets) === 0) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 588 | { |
| 589 | $this->_set_charsets(); |
| 590 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 591 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 592 | return $this->charsets; |
| 593 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 594 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 595 | // -------------------------------------------------------------------- |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 596 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 597 | /** |
| 598 | * Test for a particular language |
| 599 | * |
Timothy Warren | 0688ac9 | 2012-04-20 10:25:04 -0400 | [diff] [blame] | 600 | * @param string $lang |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 601 | * @return bool |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 602 | */ |
Phil Sturgeon | dac1b46 | 2011-01-06 17:40:10 +0000 | [diff] [blame] | 603 | public function accept_lang($lang = 'en') |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 604 | { |
Andrey Andreev | d3bc53d | 2012-04-03 16:37:19 +0300 | [diff] [blame] | 605 | return in_array(strtolower($lang), $this->languages(), TRUE); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 606 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 607 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 608 | // -------------------------------------------------------------------- |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 609 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 610 | /** |
| 611 | * Test for a particular character set |
| 612 | * |
Andrey Andreev | ca7d822 | 2012-05-11 10:59:09 +0300 | [diff] [blame] | 613 | * @param string $charset |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 614 | * @return bool |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 615 | */ |
Phil Sturgeon | dac1b46 | 2011-01-06 17:40:10 +0000 | [diff] [blame] | 616 | public function accept_charset($charset = 'utf-8') |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 617 | { |
Andrey Andreev | d3bc53d | 2012-04-03 16:37:19 +0300 | [diff] [blame] | 618 | return in_array(strtolower($charset), $this->charsets(), TRUE); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 619 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 620 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 621 | } |
| 622 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 623 | /* End of file User_agent.php */ |
Andrey Andreev | d3bc53d | 2012-04-03 16:37:19 +0300 | [diff] [blame] | 624 | /* Location: ./system/libraries/User_agent.php */ |