blob: 2cdaf509d08b22353c59e010ef2688f1e4b889df [file] [log] [blame]
Derek Jones37f4b9c2011-07-01 17:56:50 -05001<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
Derek Allard2067d1a2008-11-13 22:59:24 +00002/**
3 * CodeIgniter
4 *
Greg Aker741de1c2010-11-10 14:52:57 -06005 * An open source application development framework for PHP 5.1.6 or newer
Derek Allard2067d1a2008-11-13 22:59:24 +00006 *
7 * @package CodeIgniter
8 * @author ExpressionEngine Dev Team
Greg Aker0711dc82011-01-05 10:49:40 -06009 * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
Derek Allard2067d1a2008-11-13 22:59:24 +000010 * @license http://codeigniter.com/user_guide/license.html
11 * @link http://codeigniter.com
12 * @since Version 1.0
13 * @filesource
14 */
15
16// ------------------------------------------------------------------------
17
18/**
19 * User Agent Class
20 *
cenk115e9982011-09-27 10:07:53 +030021 * Identifies the platform, browser, robot, or mobile device of the browsing agent
Derek Allard2067d1a2008-11-13 22:59:24 +000022 *
23 * @package CodeIgniter
24 * @subpackage Libraries
25 * @category User Agent
26 * @author ExpressionEngine Dev Team
27 * @link http://codeigniter.com/user_guide/libraries/user_agent.html
28 */
29class CI_User_agent {
30
31 var $agent = NULL;
Barry Mienydd671972010-10-04 16:33:58 +020032
Derek Allard2067d1a2008-11-13 22:59:24 +000033 var $is_browser = FALSE;
34 var $is_robot = FALSE;
35 var $is_mobile = FALSE;
36
37 var $languages = array();
38 var $charsets = array();
Barry Mienydd671972010-10-04 16:33:58 +020039
Derek Allard2067d1a2008-11-13 22:59:24 +000040 var $platforms = array();
41 var $browsers = array();
42 var $mobiles = array();
43 var $robots = array();
Barry Mienydd671972010-10-04 16:33:58 +020044
Derek Allard2067d1a2008-11-13 22:59:24 +000045 var $platform = '';
46 var $browser = '';
47 var $version = '';
48 var $mobile = '';
49 var $robot = '';
Barry Mienydd671972010-10-04 16:33:58 +020050
Derek Allard2067d1a2008-11-13 22:59:24 +000051 /**
52 * Constructor
53 *
54 * Sets the User Agent and runs the compilation routine
55 *
56 * @access public
57 * @return void
Barry Mienydd671972010-10-04 16:33:58 +020058 */
Greg Akera9263282010-11-10 15:26:43 -060059 public function __construct()
Derek Allard2067d1a2008-11-13 22:59:24 +000060 {
61 if (isset($_SERVER['HTTP_USER_AGENT']))
62 {
63 $this->agent = trim($_SERVER['HTTP_USER_AGENT']);
64 }
Barry Mienydd671972010-10-04 16:33:58 +020065
Derek Allard2067d1a2008-11-13 22:59:24 +000066 if ( ! is_null($this->agent))
67 {
68 if ($this->_load_agent_file())
69 {
70 $this->_compile_data();
71 }
72 }
Barry Mienydd671972010-10-04 16:33:58 +020073
Derek Allard2067d1a2008-11-13 22:59:24 +000074 log_message('debug', "User Agent Class Initialized");
75 }
Barry Mienydd671972010-10-04 16:33:58 +020076
Derek Allard2067d1a2008-11-13 22:59:24 +000077 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +020078
Derek Allard2067d1a2008-11-13 22:59:24 +000079 /**
80 * Compile the User Agent Data
81 *
82 * @access private
83 * @return bool
Barry Mienydd671972010-10-04 16:33:58 +020084 */
Phil Sturgeondac1b462011-01-06 17:40:10 +000085 private function _load_agent_file()
Derek Allard2067d1a2008-11-13 22:59:24 +000086 {
Greg Aker3a746652011-04-19 10:59:47 -050087 if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/user_agents.php'))
bubbafoley0ea04142011-03-17 14:55:41 -050088 {
Greg Aker3a746652011-04-19 10:59:47 -050089 include(APPPATH.'config/'.ENVIRONMENT.'/user_agents.php');
Eric Barnesfdd5b112011-03-21 21:28:58 -040090 }
Greg Aker3a746652011-04-19 10:59:47 -050091 elseif (is_file(APPPATH.'config/user_agents.php'))
Eric Barnesfdd5b112011-03-21 21:28:58 -040092 {
Greg Aker3a746652011-04-19 10:59:47 -050093 include(APPPATH.'config/user_agents.php');
bubbafoley0ea04142011-03-17 14:55:41 -050094 }
95 else
96 {
Derek Allard2067d1a2008-11-13 22:59:24 +000097 return FALSE;
98 }
Barry Mienydd671972010-10-04 16:33:58 +020099
Derek Allard2067d1a2008-11-13 22:59:24 +0000100 $return = FALSE;
Barry Mienydd671972010-10-04 16:33:58 +0200101
Derek Allard2067d1a2008-11-13 22:59:24 +0000102 if (isset($platforms))
103 {
104 $this->platforms = $platforms;
105 unset($platforms);
106 $return = TRUE;
107 }
108
109 if (isset($browsers))
110 {
111 $this->browsers = $browsers;
112 unset($browsers);
113 $return = TRUE;
114 }
115
116 if (isset($mobiles))
117 {
118 $this->mobiles = $mobiles;
119 unset($mobiles);
120 $return = TRUE;
121 }
Barry Mienydd671972010-10-04 16:33:58 +0200122
Derek Allard2067d1a2008-11-13 22:59:24 +0000123 if (isset($robots))
124 {
125 $this->robots = $robots;
126 unset($robots);
127 $return = TRUE;
128 }
129
130 return $return;
131 }
Barry Mienydd671972010-10-04 16:33:58 +0200132
Derek Allard2067d1a2008-11-13 22:59:24 +0000133 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200134
Derek Allard2067d1a2008-11-13 22:59:24 +0000135 /**
136 * Compile the User Agent Data
137 *
138 * @access private
139 * @return bool
Barry Mienydd671972010-10-04 16:33:58 +0200140 */
Phil Sturgeondac1b462011-01-06 17:40:10 +0000141 private function _compile_data()
Derek Allard2067d1a2008-11-13 22:59:24 +0000142 {
143 $this->_set_platform();
Barry Mienydd671972010-10-04 16:33:58 +0200144
Phil Sturgeon2c547df2011-08-10 08:36:02 -0600145 foreach (array('_set_robot', '_set_browser', '_set_mobile') as $function)
Derek Allard2067d1a2008-11-13 22:59:24 +0000146 {
147 if ($this->$function() === TRUE)
148 {
149 break;
150 }
Barry Mienydd671972010-10-04 16:33:58 +0200151 }
Derek Allard2067d1a2008-11-13 22:59:24 +0000152 }
Barry Mienydd671972010-10-04 16:33:58 +0200153
Derek Allard2067d1a2008-11-13 22:59:24 +0000154 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200155
Derek Allard2067d1a2008-11-13 22:59:24 +0000156 /**
157 * Set the Platform
158 *
159 * @access private
160 * @return mixed
Barry Mienydd671972010-10-04 16:33:58 +0200161 */
Phil Sturgeondac1b462011-01-06 17:40:10 +0000162 private function _set_platform()
Derek Allard2067d1a2008-11-13 22:59:24 +0000163 {
164 if (is_array($this->platforms) AND count($this->platforms) > 0)
165 {
166 foreach ($this->platforms as $key => $val)
167 {
168 if (preg_match("|".preg_quote($key)."|i", $this->agent))
169 {
170 $this->platform = $val;
171 return TRUE;
172 }
173 }
174 }
175 $this->platform = 'Unknown Platform';
176 }
177
178 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200179
Derek Allard2067d1a2008-11-13 22:59:24 +0000180 /**
181 * Set the Browser
182 *
183 * @access private
184 * @return bool
Barry Mienydd671972010-10-04 16:33:58 +0200185 */
Phil Sturgeondac1b462011-01-06 17:40:10 +0000186 private function _set_browser()
Derek Allard2067d1a2008-11-13 22:59:24 +0000187 {
188 if (is_array($this->browsers) AND count($this->browsers) > 0)
189 {
190 foreach ($this->browsers as $key => $val)
Barry Mienydd671972010-10-04 16:33:58 +0200191 {
Derek Allard2067d1a2008-11-13 22:59:24 +0000192 if (preg_match("|".preg_quote($key).".*?([0-9\.]+)|i", $this->agent, $match))
193 {
194 $this->is_browser = TRUE;
195 $this->version = $match[1];
196 $this->browser = $val;
197 $this->_set_mobile();
198 return TRUE;
199 }
200 }
201 }
202 return FALSE;
203 }
Barry Mienydd671972010-10-04 16:33:58 +0200204
Derek Allard2067d1a2008-11-13 22:59:24 +0000205 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200206
Derek Allard2067d1a2008-11-13 22:59:24 +0000207 /**
208 * Set the Robot
209 *
210 * @access private
211 * @return bool
Barry Mienydd671972010-10-04 16:33:58 +0200212 */
Phil Sturgeondac1b462011-01-06 17:40:10 +0000213 private function _set_robot()
Derek Allard2067d1a2008-11-13 22:59:24 +0000214 {
215 if (is_array($this->robots) AND count($this->robots) > 0)
Barry Mienydd671972010-10-04 16:33:58 +0200216 {
Derek Allard2067d1a2008-11-13 22:59:24 +0000217 foreach ($this->robots as $key => $val)
218 {
219 if (preg_match("|".preg_quote($key)."|i", $this->agent))
220 {
221 $this->is_robot = TRUE;
222 $this->robot = $val;
223 return TRUE;
224 }
225 }
226 }
227 return FALSE;
228 }
229
230 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200231
Derek Allard2067d1a2008-11-13 22:59:24 +0000232 /**
233 * Set the Mobile Device
234 *
235 * @access private
236 * @return bool
Barry Mienydd671972010-10-04 16:33:58 +0200237 */
Phil Sturgeondac1b462011-01-06 17:40:10 +0000238 private function _set_mobile()
Derek Allard2067d1a2008-11-13 22:59:24 +0000239 {
240 if (is_array($this->mobiles) AND count($this->mobiles) > 0)
Barry Mienydd671972010-10-04 16:33:58 +0200241 {
Derek Allard2067d1a2008-11-13 22:59:24 +0000242 foreach ($this->mobiles as $key => $val)
243 {
244 if (FALSE !== (strpos(strtolower($this->agent), $key)))
245 {
246 $this->is_mobile = TRUE;
247 $this->mobile = $val;
248 return TRUE;
249 }
250 }
Barry Mienydd671972010-10-04 16:33:58 +0200251 }
Derek Allard2067d1a2008-11-13 22:59:24 +0000252 return FALSE;
253 }
Barry Mienydd671972010-10-04 16:33:58 +0200254
Derek Allard2067d1a2008-11-13 22:59:24 +0000255 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200256
Derek Allard2067d1a2008-11-13 22:59:24 +0000257 /**
258 * Set the accepted languages
259 *
260 * @access private
261 * @return void
Barry Mienydd671972010-10-04 16:33:58 +0200262 */
Phil Sturgeondac1b462011-01-06 17:40:10 +0000263 private function _set_languages()
Derek Allard2067d1a2008-11-13 22:59:24 +0000264 {
265 if ((count($this->languages) == 0) AND isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) AND $_SERVER['HTTP_ACCEPT_LANGUAGE'] != '')
266 {
267 $languages = preg_replace('/(;q=[0-9\.]+)/i', '', strtolower(trim($_SERVER['HTTP_ACCEPT_LANGUAGE'])));
Barry Mienydd671972010-10-04 16:33:58 +0200268
Derek Allard2067d1a2008-11-13 22:59:24 +0000269 $this->languages = explode(',', $languages);
270 }
Barry Mienydd671972010-10-04 16:33:58 +0200271
Derek Allard2067d1a2008-11-13 22:59:24 +0000272 if (count($this->languages) == 0)
273 {
274 $this->languages = array('Undefined');
Barry Mienydd671972010-10-04 16:33:58 +0200275 }
Derek Allard2067d1a2008-11-13 22:59:24 +0000276 }
Barry Mienydd671972010-10-04 16:33:58 +0200277
Derek Allard2067d1a2008-11-13 22:59:24 +0000278 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200279
Derek Allard2067d1a2008-11-13 22:59:24 +0000280 /**
281 * Set the accepted character sets
282 *
283 * @access private
284 * @return void
Barry Mienydd671972010-10-04 16:33:58 +0200285 */
Phil Sturgeondac1b462011-01-06 17:40:10 +0000286 private function _set_charsets()
Barry Mienydd671972010-10-04 16:33:58 +0200287 {
Derek Allard2067d1a2008-11-13 22:59:24 +0000288 if ((count($this->charsets) == 0) AND isset($_SERVER['HTTP_ACCEPT_CHARSET']) AND $_SERVER['HTTP_ACCEPT_CHARSET'] != '')
289 {
290 $charsets = preg_replace('/(;q=.+)/i', '', strtolower(trim($_SERVER['HTTP_ACCEPT_CHARSET'])));
Barry Mienydd671972010-10-04 16:33:58 +0200291
Derek Allard2067d1a2008-11-13 22:59:24 +0000292 $this->charsets = explode(',', $charsets);
293 }
Barry Mienydd671972010-10-04 16:33:58 +0200294
Derek Allard2067d1a2008-11-13 22:59:24 +0000295 if (count($this->charsets) == 0)
296 {
297 $this->charsets = array('Undefined');
Barry Mienydd671972010-10-04 16:33:58 +0200298 }
Derek Allard2067d1a2008-11-13 22:59:24 +0000299 }
300
301 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200302
Derek Allard2067d1a2008-11-13 22:59:24 +0000303 /**
304 * Is Browser
305 *
306 * @access public
307 * @return bool
Barry Mienydd671972010-10-04 16:33:58 +0200308 */
Phil Sturgeondac1b462011-01-06 17:40:10 +0000309 public function is_browser($key = NULL)
Derek Allard2067d1a2008-11-13 22:59:24 +0000310 {
Phil Sturgeondac1b462011-01-06 17:40:10 +0000311 if ( ! $this->is_browser)
312 {
313 return FALSE;
314 }
315
316 // No need to be specific, it's a browser
317 if ($key === NULL)
318 {
319 return TRUE;
320 }
321
322 // Check for a specific browser
323 return array_key_exists($key, $this->browsers) AND $this->browser === $this->browsers[$key];
Derek Allard2067d1a2008-11-13 22:59:24 +0000324 }
325
326 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200327
Derek Allard2067d1a2008-11-13 22:59:24 +0000328 /**
329 * Is Robot
330 *
331 * @access public
332 * @return bool
Barry Mienydd671972010-10-04 16:33:58 +0200333 */
Phil Sturgeondac1b462011-01-06 17:40:10 +0000334 public function is_robot($key = NULL)
Derek Allard2067d1a2008-11-13 22:59:24 +0000335 {
Phil Sturgeondac1b462011-01-06 17:40:10 +0000336 if ( ! $this->is_robot)
337 {
338 return FALSE;
339 }
340
341 // No need to be specific, it's a robot
342 if ($key === NULL)
343 {
344 return TRUE;
345 }
346
347 // Check for a specific robot
348 return array_key_exists($key, $this->robots) AND $this->robot === $this->robots[$key];
Derek Allard2067d1a2008-11-13 22:59:24 +0000349 }
350
351 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200352
Derek Allard2067d1a2008-11-13 22:59:24 +0000353 /**
354 * Is Mobile
355 *
356 * @access public
357 * @return bool
Barry Mienydd671972010-10-04 16:33:58 +0200358 */
Phil Sturgeondac1b462011-01-06 17:40:10 +0000359 public function is_mobile($key = NULL)
Derek Allard2067d1a2008-11-13 22:59:24 +0000360 {
Phil Sturgeondac1b462011-01-06 17:40:10 +0000361 if ( ! $this->is_mobile)
362 {
363 return FALSE;
364 }
365
366 // No need to be specific, it's a mobile
367 if ($key === NULL)
368 {
369 return TRUE;
370 }
371
372 // Check for a specific robot
373 return array_key_exists($key, $this->mobiles) AND $this->mobile === $this->mobiles[$key];
Barry Mienydd671972010-10-04 16:33:58 +0200374 }
Derek Allard2067d1a2008-11-13 22:59:24 +0000375
376 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200377
Derek Allard2067d1a2008-11-13 22:59:24 +0000378 /**
379 * Is this a referral from another site?
380 *
381 * @access public
382 * @return bool
Barry Mienydd671972010-10-04 16:33:58 +0200383 */
Phil Sturgeondac1b462011-01-06 17:40:10 +0000384 public function is_referral()
Derek Allard2067d1a2008-11-13 22:59:24 +0000385 {
Eric Barnesf6f51a62011-02-05 21:41:17 -0500386 if ( ! isset($_SERVER['HTTP_REFERER']) OR $_SERVER['HTTP_REFERER'] == '')
387 {
388 return FALSE;
389 }
390 return TRUE;
Derek Allard2067d1a2008-11-13 22:59:24 +0000391 }
392
393 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200394
Derek Allard2067d1a2008-11-13 22:59:24 +0000395 /**
396 * Agent String
397 *
398 * @access public
399 * @return string
Barry Mienydd671972010-10-04 16:33:58 +0200400 */
Phil Sturgeondac1b462011-01-06 17:40:10 +0000401 public function agent_string()
Derek Allard2067d1a2008-11-13 22:59:24 +0000402 {
403 return $this->agent;
404 }
405
406 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200407
Derek Allard2067d1a2008-11-13 22:59:24 +0000408 /**
409 * Get Platform
410 *
411 * @access public
412 * @return string
Barry Mienydd671972010-10-04 16:33:58 +0200413 */
Phil Sturgeondac1b462011-01-06 17:40:10 +0000414 public function platform()
Derek Allard2067d1a2008-11-13 22:59:24 +0000415 {
416 return $this->platform;
417 }
418
419 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200420
Derek Allard2067d1a2008-11-13 22:59:24 +0000421 /**
422 * Get Browser Name
423 *
424 * @access public
425 * @return string
Barry Mienydd671972010-10-04 16:33:58 +0200426 */
Phil Sturgeondac1b462011-01-06 17:40:10 +0000427 public function browser()
Derek Allard2067d1a2008-11-13 22:59:24 +0000428 {
429 return $this->browser;
430 }
431
432 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200433
Derek Allard2067d1a2008-11-13 22:59:24 +0000434 /**
435 * Get the Browser Version
436 *
437 * @access public
438 * @return string
Barry Mienydd671972010-10-04 16:33:58 +0200439 */
Phil Sturgeondac1b462011-01-06 17:40:10 +0000440 public function version()
Derek Allard2067d1a2008-11-13 22:59:24 +0000441 {
442 return $this->version;
443 }
444
445 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200446
Derek Allard2067d1a2008-11-13 22:59:24 +0000447 /**
448 * Get The Robot Name
449 *
450 * @access public
451 * @return string
Barry Mienydd671972010-10-04 16:33:58 +0200452 */
Phil Sturgeondac1b462011-01-06 17:40:10 +0000453 public function robot()
Derek Allard2067d1a2008-11-13 22:59:24 +0000454 {
455 return $this->robot;
456 }
457 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200458
Derek Allard2067d1a2008-11-13 22:59:24 +0000459 /**
460 * Get the Mobile Device
461 *
462 * @access public
463 * @return string
Barry Mienydd671972010-10-04 16:33:58 +0200464 */
Phil Sturgeondac1b462011-01-06 17:40:10 +0000465 public function mobile()
Derek Allard2067d1a2008-11-13 22:59:24 +0000466 {
467 return $this->mobile;
468 }
Barry Mienydd671972010-10-04 16:33:58 +0200469
Derek Allard2067d1a2008-11-13 22:59:24 +0000470 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200471
Derek Allard2067d1a2008-11-13 22:59:24 +0000472 /**
473 * Get the referrer
474 *
475 * @access public
476 * @return bool
Barry Mienydd671972010-10-04 16:33:58 +0200477 */
Phil Sturgeondac1b462011-01-06 17:40:10 +0000478 public function referrer()
Derek Allard2067d1a2008-11-13 22:59:24 +0000479 {
480 return ( ! isset($_SERVER['HTTP_REFERER']) OR $_SERVER['HTTP_REFERER'] == '') ? '' : trim($_SERVER['HTTP_REFERER']);
481 }
482
483 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200484
Derek Allard2067d1a2008-11-13 22:59:24 +0000485 /**
486 * Get the accepted languages
487 *
488 * @access public
489 * @return array
Barry Mienydd671972010-10-04 16:33:58 +0200490 */
Phil Sturgeondac1b462011-01-06 17:40:10 +0000491 public function languages()
Derek Allard2067d1a2008-11-13 22:59:24 +0000492 {
493 if (count($this->languages) == 0)
494 {
495 $this->_set_languages();
496 }
Barry Mienydd671972010-10-04 16:33:58 +0200497
Derek Allard2067d1a2008-11-13 22:59:24 +0000498 return $this->languages;
499 }
500
501 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200502
Derek Allard2067d1a2008-11-13 22:59:24 +0000503 /**
504 * Get the accepted Character Sets
505 *
506 * @access public
507 * @return array
Barry Mienydd671972010-10-04 16:33:58 +0200508 */
Phil Sturgeondac1b462011-01-06 17:40:10 +0000509 public function charsets()
Derek Allard2067d1a2008-11-13 22:59:24 +0000510 {
511 if (count($this->charsets) == 0)
512 {
513 $this->_set_charsets();
514 }
Barry Mienydd671972010-10-04 16:33:58 +0200515
Derek Allard2067d1a2008-11-13 22:59:24 +0000516 return $this->charsets;
517 }
Barry Mienydd671972010-10-04 16:33:58 +0200518
Derek Allard2067d1a2008-11-13 22:59:24 +0000519 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200520
Derek Allard2067d1a2008-11-13 22:59:24 +0000521 /**
522 * Test for a particular language
523 *
524 * @access public
525 * @return bool
Barry Mienydd671972010-10-04 16:33:58 +0200526 */
Phil Sturgeondac1b462011-01-06 17:40:10 +0000527 public function accept_lang($lang = 'en')
Derek Allard2067d1a2008-11-13 22:59:24 +0000528 {
Phil Sturgeondac1b462011-01-06 17:40:10 +0000529 return (in_array(strtolower($lang), $this->languages(), TRUE));
Derek Allard2067d1a2008-11-13 22:59:24 +0000530 }
Barry Mienydd671972010-10-04 16:33:58 +0200531
Derek Allard2067d1a2008-11-13 22:59:24 +0000532 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200533
Derek Allard2067d1a2008-11-13 22:59:24 +0000534 /**
535 * Test for a particular character set
536 *
537 * @access public
538 * @return bool
Barry Mienydd671972010-10-04 16:33:58 +0200539 */
Phil Sturgeondac1b462011-01-06 17:40:10 +0000540 public function accept_charset($charset = 'utf-8')
Derek Allard2067d1a2008-11-13 22:59:24 +0000541 {
Phil Sturgeondac1b462011-01-06 17:40:10 +0000542 return (in_array(strtolower($charset), $this->charsets(), TRUE));
Derek Allard2067d1a2008-11-13 22:59:24 +0000543 }
Barry Mienydd671972010-10-04 16:33:58 +0200544
Derek Allard2067d1a2008-11-13 22:59:24 +0000545}
546
547
548/* End of file User_agent.php */
cenk115e9982011-09-27 10:07:53 +0300549/* Location: ./system/libraries/User_agent.php */