blob: 4a29d7d9474827ed4cfd904517b7081ba17a41d5 [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 *
Derek Jonesf4a4bd82011-10-20 12:18:42 -05007 * NOTICE OF LICENSE
8 *
9 * Licensed under the Open Software License version 3.0
10 *
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 Allard2067d1a2008-11-13 22:59:24 +000019 * @package CodeIgniter
Derek Jonesf4a4bd82011-10-20 12:18:42 -050020 * @author EllisLab Dev Team
21 * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. (http://ellislab.com/)
22 * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
Derek Allard2067d1a2008-11-13 22:59:24 +000023 * @link http://codeigniter.com
24 * @since Version 1.0
25 * @filesource
26 */
27
28// ------------------------------------------------------------------------
29
30/**
31 * User Agent Class
32 *
cenk115e9982011-09-27 10:07:53 +030033 * Identifies the platform, browser, robot, or mobile device of the browsing agent
Derek Allard2067d1a2008-11-13 22:59:24 +000034 *
35 * @package CodeIgniter
36 * @subpackage Libraries
37 * @category User Agent
Derek Jonesf4a4bd82011-10-20 12:18:42 -050038 * @author EllisLab Dev Team
Derek Allard2067d1a2008-11-13 22:59:24 +000039 * @link http://codeigniter.com/user_guide/libraries/user_agent.html
40 */
41class CI_User_agent {
42
43 var $agent = NULL;
Barry Mienydd671972010-10-04 16:33:58 +020044
Derek Allard2067d1a2008-11-13 22:59:24 +000045 var $is_browser = FALSE;
46 var $is_robot = FALSE;
47 var $is_mobile = FALSE;
48
49 var $languages = array();
50 var $charsets = array();
Barry Mienydd671972010-10-04 16:33:58 +020051
Derek Allard2067d1a2008-11-13 22:59:24 +000052 var $platforms = array();
53 var $browsers = array();
54 var $mobiles = array();
55 var $robots = array();
Barry Mienydd671972010-10-04 16:33:58 +020056
Derek Allard2067d1a2008-11-13 22:59:24 +000057 var $platform = '';
58 var $browser = '';
59 var $version = '';
60 var $mobile = '';
61 var $robot = '';
Barry Mienydd671972010-10-04 16:33:58 +020062
Derek Allard2067d1a2008-11-13 22:59:24 +000063 /**
64 * Constructor
65 *
66 * Sets the User Agent and runs the compilation routine
67 *
68 * @access public
69 * @return void
Barry Mienydd671972010-10-04 16:33:58 +020070 */
Greg Akera9263282010-11-10 15:26:43 -060071 public function __construct()
Derek Allard2067d1a2008-11-13 22:59:24 +000072 {
73 if (isset($_SERVER['HTTP_USER_AGENT']))
74 {
75 $this->agent = trim($_SERVER['HTTP_USER_AGENT']);
76 }
Barry Mienydd671972010-10-04 16:33:58 +020077
Derek Allard2067d1a2008-11-13 22:59:24 +000078 if ( ! is_null($this->agent))
79 {
80 if ($this->_load_agent_file())
81 {
82 $this->_compile_data();
83 }
84 }
Barry Mienydd671972010-10-04 16:33:58 +020085
Derek Allard2067d1a2008-11-13 22:59:24 +000086 log_message('debug', "User Agent Class Initialized");
87 }
Barry Mienydd671972010-10-04 16:33:58 +020088
Derek Allard2067d1a2008-11-13 22:59:24 +000089 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +020090
Derek Allard2067d1a2008-11-13 22:59:24 +000091 /**
92 * Compile the User Agent Data
93 *
94 * @access private
95 * @return bool
Barry Mienydd671972010-10-04 16:33:58 +020096 */
Phil Sturgeondac1b462011-01-06 17:40:10 +000097 private function _load_agent_file()
Derek Allard2067d1a2008-11-13 22:59:24 +000098 {
Greg Aker5c1aa632011-12-25 01:24:29 -060099 load_environ_config('user_agents');
100
101 // Return FALSE if we still have no mimes after trying to load them up.
102 if (count($this->mimes) === 0)
bubbafoley0ea04142011-03-17 14:55:41 -0500103 {
Derek Allard2067d1a2008-11-13 22:59:24 +0000104 return FALSE;
105 }
Barry Mienydd671972010-10-04 16:33:58 +0200106
Derek Allard2067d1a2008-11-13 22:59:24 +0000107 $return = FALSE;
Barry Mienydd671972010-10-04 16:33:58 +0200108
Derek Allard2067d1a2008-11-13 22:59:24 +0000109 if (isset($platforms))
110 {
111 $this->platforms = $platforms;
112 unset($platforms);
113 $return = TRUE;
114 }
115
116 if (isset($browsers))
117 {
118 $this->browsers = $browsers;
119 unset($browsers);
120 $return = TRUE;
121 }
122
123 if (isset($mobiles))
124 {
125 $this->mobiles = $mobiles;
126 unset($mobiles);
127 $return = TRUE;
128 }
Barry Mienydd671972010-10-04 16:33:58 +0200129
Derek Allard2067d1a2008-11-13 22:59:24 +0000130 if (isset($robots))
131 {
132 $this->robots = $robots;
133 unset($robots);
134 $return = TRUE;
135 }
136
137 return $return;
138 }
Barry Mienydd671972010-10-04 16:33:58 +0200139
Derek Allard2067d1a2008-11-13 22:59:24 +0000140 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200141
Derek Allard2067d1a2008-11-13 22:59:24 +0000142 /**
143 * Compile the User Agent Data
144 *
145 * @access private
146 * @return bool
Barry Mienydd671972010-10-04 16:33:58 +0200147 */
Phil Sturgeondac1b462011-01-06 17:40:10 +0000148 private function _compile_data()
Derek Allard2067d1a2008-11-13 22:59:24 +0000149 {
150 $this->_set_platform();
Barry Mienydd671972010-10-04 16:33:58 +0200151
Phil Sturgeon2c547df2011-08-10 08:36:02 -0600152 foreach (array('_set_robot', '_set_browser', '_set_mobile') as $function)
Derek Allard2067d1a2008-11-13 22:59:24 +0000153 {
154 if ($this->$function() === TRUE)
155 {
156 break;
157 }
Barry Mienydd671972010-10-04 16:33:58 +0200158 }
Derek Allard2067d1a2008-11-13 22:59:24 +0000159 }
Barry Mienydd671972010-10-04 16:33:58 +0200160
Derek Allard2067d1a2008-11-13 22:59:24 +0000161 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200162
Derek Allard2067d1a2008-11-13 22:59:24 +0000163 /**
164 * Set the Platform
165 *
166 * @access private
167 * @return mixed
Barry Mienydd671972010-10-04 16:33:58 +0200168 */
Phil Sturgeondac1b462011-01-06 17:40:10 +0000169 private function _set_platform()
Derek Allard2067d1a2008-11-13 22:59:24 +0000170 {
171 if (is_array($this->platforms) AND count($this->platforms) > 0)
172 {
173 foreach ($this->platforms as $key => $val)
174 {
175 if (preg_match("|".preg_quote($key)."|i", $this->agent))
176 {
177 $this->platform = $val;
178 return TRUE;
179 }
180 }
181 }
182 $this->platform = 'Unknown Platform';
183 }
184
185 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200186
Derek Allard2067d1a2008-11-13 22:59:24 +0000187 /**
188 * Set the Browser
189 *
190 * @access private
191 * @return bool
Barry Mienydd671972010-10-04 16:33:58 +0200192 */
Phil Sturgeondac1b462011-01-06 17:40:10 +0000193 private function _set_browser()
Derek Allard2067d1a2008-11-13 22:59:24 +0000194 {
195 if (is_array($this->browsers) AND count($this->browsers) > 0)
196 {
197 foreach ($this->browsers as $key => $val)
Barry Mienydd671972010-10-04 16:33:58 +0200198 {
Derek Allard2067d1a2008-11-13 22:59:24 +0000199 if (preg_match("|".preg_quote($key).".*?([0-9\.]+)|i", $this->agent, $match))
200 {
201 $this->is_browser = TRUE;
202 $this->version = $match[1];
203 $this->browser = $val;
204 $this->_set_mobile();
205 return TRUE;
206 }
207 }
208 }
209 return FALSE;
210 }
Barry Mienydd671972010-10-04 16:33:58 +0200211
Derek Allard2067d1a2008-11-13 22:59:24 +0000212 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200213
Derek Allard2067d1a2008-11-13 22:59:24 +0000214 /**
215 * Set the Robot
216 *
217 * @access private
218 * @return bool
Barry Mienydd671972010-10-04 16:33:58 +0200219 */
Phil Sturgeondac1b462011-01-06 17:40:10 +0000220 private function _set_robot()
Derek Allard2067d1a2008-11-13 22:59:24 +0000221 {
222 if (is_array($this->robots) AND count($this->robots) > 0)
Barry Mienydd671972010-10-04 16:33:58 +0200223 {
Derek Allard2067d1a2008-11-13 22:59:24 +0000224 foreach ($this->robots as $key => $val)
225 {
226 if (preg_match("|".preg_quote($key)."|i", $this->agent))
227 {
228 $this->is_robot = TRUE;
229 $this->robot = $val;
230 return TRUE;
231 }
232 }
233 }
234 return FALSE;
235 }
236
237 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200238
Derek Allard2067d1a2008-11-13 22:59:24 +0000239 /**
240 * Set the Mobile Device
241 *
242 * @access private
243 * @return bool
Barry Mienydd671972010-10-04 16:33:58 +0200244 */
Phil Sturgeondac1b462011-01-06 17:40:10 +0000245 private function _set_mobile()
Derek Allard2067d1a2008-11-13 22:59:24 +0000246 {
247 if (is_array($this->mobiles) AND count($this->mobiles) > 0)
Barry Mienydd671972010-10-04 16:33:58 +0200248 {
Derek Allard2067d1a2008-11-13 22:59:24 +0000249 foreach ($this->mobiles as $key => $val)
250 {
251 if (FALSE !== (strpos(strtolower($this->agent), $key)))
252 {
253 $this->is_mobile = TRUE;
254 $this->mobile = $val;
255 return TRUE;
256 }
257 }
Barry Mienydd671972010-10-04 16:33:58 +0200258 }
Derek Allard2067d1a2008-11-13 22:59:24 +0000259 return FALSE;
260 }
Barry Mienydd671972010-10-04 16:33:58 +0200261
Derek Allard2067d1a2008-11-13 22:59:24 +0000262 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200263
Derek Allard2067d1a2008-11-13 22:59:24 +0000264 /**
265 * Set the accepted languages
266 *
267 * @access private
268 * @return void
Barry Mienydd671972010-10-04 16:33:58 +0200269 */
Phil Sturgeondac1b462011-01-06 17:40:10 +0000270 private function _set_languages()
Derek Allard2067d1a2008-11-13 22:59:24 +0000271 {
272 if ((count($this->languages) == 0) AND isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) AND $_SERVER['HTTP_ACCEPT_LANGUAGE'] != '')
273 {
274 $languages = preg_replace('/(;q=[0-9\.]+)/i', '', strtolower(trim($_SERVER['HTTP_ACCEPT_LANGUAGE'])));
Barry Mienydd671972010-10-04 16:33:58 +0200275
Derek Allard2067d1a2008-11-13 22:59:24 +0000276 $this->languages = explode(',', $languages);
277 }
Barry Mienydd671972010-10-04 16:33:58 +0200278
Derek Allard2067d1a2008-11-13 22:59:24 +0000279 if (count($this->languages) == 0)
280 {
281 $this->languages = array('Undefined');
Barry Mienydd671972010-10-04 16:33:58 +0200282 }
Derek Allard2067d1a2008-11-13 22:59:24 +0000283 }
Barry Mienydd671972010-10-04 16:33:58 +0200284
Derek Allard2067d1a2008-11-13 22:59:24 +0000285 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200286
Derek Allard2067d1a2008-11-13 22:59:24 +0000287 /**
288 * Set the accepted character sets
289 *
290 * @access private
291 * @return void
Barry Mienydd671972010-10-04 16:33:58 +0200292 */
Phil Sturgeondac1b462011-01-06 17:40:10 +0000293 private function _set_charsets()
Barry Mienydd671972010-10-04 16:33:58 +0200294 {
Derek Allard2067d1a2008-11-13 22:59:24 +0000295 if ((count($this->charsets) == 0) AND isset($_SERVER['HTTP_ACCEPT_CHARSET']) AND $_SERVER['HTTP_ACCEPT_CHARSET'] != '')
296 {
297 $charsets = preg_replace('/(;q=.+)/i', '', strtolower(trim($_SERVER['HTTP_ACCEPT_CHARSET'])));
Barry Mienydd671972010-10-04 16:33:58 +0200298
Derek Allard2067d1a2008-11-13 22:59:24 +0000299 $this->charsets = explode(',', $charsets);
300 }
Barry Mienydd671972010-10-04 16:33:58 +0200301
Derek Allard2067d1a2008-11-13 22:59:24 +0000302 if (count($this->charsets) == 0)
303 {
304 $this->charsets = array('Undefined');
Barry Mienydd671972010-10-04 16:33:58 +0200305 }
Derek Allard2067d1a2008-11-13 22:59:24 +0000306 }
307
308 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200309
Derek Allard2067d1a2008-11-13 22:59:24 +0000310 /**
311 * Is Browser
312 *
313 * @access public
314 * @return bool
Barry Mienydd671972010-10-04 16:33:58 +0200315 */
Phil Sturgeondac1b462011-01-06 17:40:10 +0000316 public function is_browser($key = NULL)
Derek Allard2067d1a2008-11-13 22:59:24 +0000317 {
Phil Sturgeondac1b462011-01-06 17:40:10 +0000318 if ( ! $this->is_browser)
319 {
320 return FALSE;
321 }
322
323 // No need to be specific, it's a browser
324 if ($key === NULL)
325 {
326 return TRUE;
327 }
328
329 // Check for a specific browser
330 return array_key_exists($key, $this->browsers) AND $this->browser === $this->browsers[$key];
Derek Allard2067d1a2008-11-13 22:59:24 +0000331 }
332
333 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200334
Derek Allard2067d1a2008-11-13 22:59:24 +0000335 /**
336 * Is Robot
337 *
338 * @access public
339 * @return bool
Barry Mienydd671972010-10-04 16:33:58 +0200340 */
Phil Sturgeondac1b462011-01-06 17:40:10 +0000341 public function is_robot($key = NULL)
Derek Allard2067d1a2008-11-13 22:59:24 +0000342 {
Phil Sturgeondac1b462011-01-06 17:40:10 +0000343 if ( ! $this->is_robot)
344 {
345 return FALSE;
346 }
347
348 // No need to be specific, it's a robot
349 if ($key === NULL)
350 {
351 return TRUE;
352 }
353
354 // Check for a specific robot
355 return array_key_exists($key, $this->robots) AND $this->robot === $this->robots[$key];
Derek Allard2067d1a2008-11-13 22:59:24 +0000356 }
357
358 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200359
Derek Allard2067d1a2008-11-13 22:59:24 +0000360 /**
361 * Is Mobile
362 *
363 * @access public
364 * @return bool
Barry Mienydd671972010-10-04 16:33:58 +0200365 */
Phil Sturgeondac1b462011-01-06 17:40:10 +0000366 public function is_mobile($key = NULL)
Derek Allard2067d1a2008-11-13 22:59:24 +0000367 {
Phil Sturgeondac1b462011-01-06 17:40:10 +0000368 if ( ! $this->is_mobile)
369 {
370 return FALSE;
371 }
372
373 // No need to be specific, it's a mobile
374 if ($key === NULL)
375 {
376 return TRUE;
377 }
378
379 // Check for a specific robot
380 return array_key_exists($key, $this->mobiles) AND $this->mobile === $this->mobiles[$key];
Barry Mienydd671972010-10-04 16:33:58 +0200381 }
Derek Allard2067d1a2008-11-13 22:59:24 +0000382
383 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200384
Derek Allard2067d1a2008-11-13 22:59:24 +0000385 /**
386 * Is this a referral from another site?
387 *
388 * @access public
389 * @return bool
Barry Mienydd671972010-10-04 16:33:58 +0200390 */
Phil Sturgeondac1b462011-01-06 17:40:10 +0000391 public function is_referral()
Derek Allard2067d1a2008-11-13 22:59:24 +0000392 {
Eric Barnesf6f51a62011-02-05 21:41:17 -0500393 if ( ! isset($_SERVER['HTTP_REFERER']) OR $_SERVER['HTTP_REFERER'] == '')
394 {
395 return FALSE;
396 }
397 return TRUE;
Derek Allard2067d1a2008-11-13 22:59:24 +0000398 }
399
400 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200401
Derek Allard2067d1a2008-11-13 22:59:24 +0000402 /**
403 * Agent String
404 *
405 * @access public
406 * @return string
Barry Mienydd671972010-10-04 16:33:58 +0200407 */
Phil Sturgeondac1b462011-01-06 17:40:10 +0000408 public function agent_string()
Derek Allard2067d1a2008-11-13 22:59:24 +0000409 {
410 return $this->agent;
411 }
412
413 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200414
Derek Allard2067d1a2008-11-13 22:59:24 +0000415 /**
416 * Get Platform
417 *
418 * @access public
419 * @return string
Barry Mienydd671972010-10-04 16:33:58 +0200420 */
Phil Sturgeondac1b462011-01-06 17:40:10 +0000421 public function platform()
Derek Allard2067d1a2008-11-13 22:59:24 +0000422 {
423 return $this->platform;
424 }
425
426 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200427
Derek Allard2067d1a2008-11-13 22:59:24 +0000428 /**
429 * Get Browser Name
430 *
431 * @access public
432 * @return string
Barry Mienydd671972010-10-04 16:33:58 +0200433 */
Phil Sturgeondac1b462011-01-06 17:40:10 +0000434 public function browser()
Derek Allard2067d1a2008-11-13 22:59:24 +0000435 {
436 return $this->browser;
437 }
438
439 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200440
Derek Allard2067d1a2008-11-13 22:59:24 +0000441 /**
442 * Get the Browser Version
443 *
444 * @access public
445 * @return string
Barry Mienydd671972010-10-04 16:33:58 +0200446 */
Phil Sturgeondac1b462011-01-06 17:40:10 +0000447 public function version()
Derek Allard2067d1a2008-11-13 22:59:24 +0000448 {
449 return $this->version;
450 }
451
452 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200453
Derek Allard2067d1a2008-11-13 22:59:24 +0000454 /**
455 * Get The Robot Name
456 *
457 * @access public
458 * @return string
Barry Mienydd671972010-10-04 16:33:58 +0200459 */
Phil Sturgeondac1b462011-01-06 17:40:10 +0000460 public function robot()
Derek Allard2067d1a2008-11-13 22:59:24 +0000461 {
462 return $this->robot;
463 }
464 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200465
Derek Allard2067d1a2008-11-13 22:59:24 +0000466 /**
467 * Get the Mobile Device
468 *
469 * @access public
470 * @return string
Barry Mienydd671972010-10-04 16:33:58 +0200471 */
Phil Sturgeondac1b462011-01-06 17:40:10 +0000472 public function mobile()
Derek Allard2067d1a2008-11-13 22:59:24 +0000473 {
474 return $this->mobile;
475 }
Barry Mienydd671972010-10-04 16:33:58 +0200476
Derek Allard2067d1a2008-11-13 22:59:24 +0000477 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200478
Derek Allard2067d1a2008-11-13 22:59:24 +0000479 /**
480 * Get the referrer
481 *
482 * @access public
483 * @return bool
Barry Mienydd671972010-10-04 16:33:58 +0200484 */
Phil Sturgeondac1b462011-01-06 17:40:10 +0000485 public function referrer()
Derek Allard2067d1a2008-11-13 22:59:24 +0000486 {
487 return ( ! isset($_SERVER['HTTP_REFERER']) OR $_SERVER['HTTP_REFERER'] == '') ? '' : trim($_SERVER['HTTP_REFERER']);
488 }
489
490 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200491
Derek Allard2067d1a2008-11-13 22:59:24 +0000492 /**
493 * Get the accepted languages
494 *
495 * @access public
496 * @return array
Barry Mienydd671972010-10-04 16:33:58 +0200497 */
Phil Sturgeondac1b462011-01-06 17:40:10 +0000498 public function languages()
Derek Allard2067d1a2008-11-13 22:59:24 +0000499 {
500 if (count($this->languages) == 0)
501 {
502 $this->_set_languages();
503 }
Barry Mienydd671972010-10-04 16:33:58 +0200504
Derek Allard2067d1a2008-11-13 22:59:24 +0000505 return $this->languages;
506 }
507
508 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200509
Derek Allard2067d1a2008-11-13 22:59:24 +0000510 /**
511 * Get the accepted Character Sets
512 *
513 * @access public
514 * @return array
Barry Mienydd671972010-10-04 16:33:58 +0200515 */
Phil Sturgeondac1b462011-01-06 17:40:10 +0000516 public function charsets()
Derek Allard2067d1a2008-11-13 22:59:24 +0000517 {
518 if (count($this->charsets) == 0)
519 {
520 $this->_set_charsets();
521 }
Barry Mienydd671972010-10-04 16:33:58 +0200522
Derek Allard2067d1a2008-11-13 22:59:24 +0000523 return $this->charsets;
524 }
Barry Mienydd671972010-10-04 16:33:58 +0200525
Derek Allard2067d1a2008-11-13 22:59:24 +0000526 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200527
Derek Allard2067d1a2008-11-13 22:59:24 +0000528 /**
529 * Test for a particular language
530 *
531 * @access public
532 * @return bool
Barry Mienydd671972010-10-04 16:33:58 +0200533 */
Phil Sturgeondac1b462011-01-06 17:40:10 +0000534 public function accept_lang($lang = 'en')
Derek Allard2067d1a2008-11-13 22:59:24 +0000535 {
Phil Sturgeondac1b462011-01-06 17:40:10 +0000536 return (in_array(strtolower($lang), $this->languages(), TRUE));
Derek Allard2067d1a2008-11-13 22:59:24 +0000537 }
Barry Mienydd671972010-10-04 16:33:58 +0200538
Derek Allard2067d1a2008-11-13 22:59:24 +0000539 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200540
Derek Allard2067d1a2008-11-13 22:59:24 +0000541 /**
542 * Test for a particular character set
543 *
544 * @access public
545 * @return bool
Barry Mienydd671972010-10-04 16:33:58 +0200546 */
Phil Sturgeondac1b462011-01-06 17:40:10 +0000547 public function accept_charset($charset = 'utf-8')
Derek Allard2067d1a2008-11-13 22:59:24 +0000548 {
Phil Sturgeondac1b462011-01-06 17:40:10 +0000549 return (in_array(strtolower($charset), $this->charsets(), TRUE));
Derek Allard2067d1a2008-11-13 22:59:24 +0000550 }
Barry Mienydd671972010-10-04 16:33:58 +0200551
Derek Allard2067d1a2008-11-13 22:59:24 +0000552}
553
554
555/* End of file User_agent.php */
cenk115e9982011-09-27 10:07:53 +0300556/* Location: ./system/libraries/User_agent.php */