blob: a007acec87d8a6d43797b598e30d7b280d3617b8 [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 Aker3a746652011-04-19 10:59:47 -050099 if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/user_agents.php'))
bubbafoley0ea04142011-03-17 14:55:41 -0500100 {
Greg Aker3a746652011-04-19 10:59:47 -0500101 include(APPPATH.'config/'.ENVIRONMENT.'/user_agents.php');
Eric Barnesfdd5b112011-03-21 21:28:58 -0400102 }
Greg Aker3a746652011-04-19 10:59:47 -0500103 elseif (is_file(APPPATH.'config/user_agents.php'))
Eric Barnesfdd5b112011-03-21 21:28:58 -0400104 {
Greg Aker3a746652011-04-19 10:59:47 -0500105 include(APPPATH.'config/user_agents.php');
bubbafoley0ea04142011-03-17 14:55:41 -0500106 }
107 else
108 {
Derek Allard2067d1a2008-11-13 22:59:24 +0000109 return FALSE;
110 }
Barry Mienydd671972010-10-04 16:33:58 +0200111
Derek Allard2067d1a2008-11-13 22:59:24 +0000112 $return = FALSE;
Barry Mienydd671972010-10-04 16:33:58 +0200113
Derek Allard2067d1a2008-11-13 22:59:24 +0000114 if (isset($platforms))
115 {
116 $this->platforms = $platforms;
117 unset($platforms);
118 $return = TRUE;
119 }
120
121 if (isset($browsers))
122 {
123 $this->browsers = $browsers;
124 unset($browsers);
125 $return = TRUE;
126 }
127
128 if (isset($mobiles))
129 {
130 $this->mobiles = $mobiles;
131 unset($mobiles);
132 $return = TRUE;
133 }
Barry Mienydd671972010-10-04 16:33:58 +0200134
Derek Allard2067d1a2008-11-13 22:59:24 +0000135 if (isset($robots))
136 {
137 $this->robots = $robots;
138 unset($robots);
139 $return = TRUE;
140 }
141
142 return $return;
143 }
Barry Mienydd671972010-10-04 16:33:58 +0200144
Derek Allard2067d1a2008-11-13 22:59:24 +0000145 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200146
Derek Allard2067d1a2008-11-13 22:59:24 +0000147 /**
148 * Compile the User Agent Data
149 *
150 * @access private
151 * @return bool
Barry Mienydd671972010-10-04 16:33:58 +0200152 */
Phil Sturgeondac1b462011-01-06 17:40:10 +0000153 private function _compile_data()
Derek Allard2067d1a2008-11-13 22:59:24 +0000154 {
155 $this->_set_platform();
Barry Mienydd671972010-10-04 16:33:58 +0200156
Phil Sturgeon2c547df2011-08-10 08:36:02 -0600157 foreach (array('_set_robot', '_set_browser', '_set_mobile') as $function)
Derek Allard2067d1a2008-11-13 22:59:24 +0000158 {
159 if ($this->$function() === TRUE)
160 {
161 break;
162 }
Barry Mienydd671972010-10-04 16:33:58 +0200163 }
Derek Allard2067d1a2008-11-13 22:59:24 +0000164 }
Barry Mienydd671972010-10-04 16:33:58 +0200165
Derek Allard2067d1a2008-11-13 22:59:24 +0000166 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200167
Derek Allard2067d1a2008-11-13 22:59:24 +0000168 /**
169 * Set the Platform
170 *
171 * @access private
172 * @return mixed
Barry Mienydd671972010-10-04 16:33:58 +0200173 */
Phil Sturgeondac1b462011-01-06 17:40:10 +0000174 private function _set_platform()
Derek Allard2067d1a2008-11-13 22:59:24 +0000175 {
176 if (is_array($this->platforms) AND count($this->platforms) > 0)
177 {
178 foreach ($this->platforms as $key => $val)
179 {
180 if (preg_match("|".preg_quote($key)."|i", $this->agent))
181 {
182 $this->platform = $val;
183 return TRUE;
184 }
185 }
186 }
187 $this->platform = 'Unknown Platform';
188 }
189
190 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200191
Derek Allard2067d1a2008-11-13 22:59:24 +0000192 /**
193 * Set the Browser
194 *
195 * @access private
196 * @return bool
Barry Mienydd671972010-10-04 16:33:58 +0200197 */
Phil Sturgeondac1b462011-01-06 17:40:10 +0000198 private function _set_browser()
Derek Allard2067d1a2008-11-13 22:59:24 +0000199 {
200 if (is_array($this->browsers) AND count($this->browsers) > 0)
201 {
202 foreach ($this->browsers as $key => $val)
Barry Mienydd671972010-10-04 16:33:58 +0200203 {
Derek Allard2067d1a2008-11-13 22:59:24 +0000204 if (preg_match("|".preg_quote($key).".*?([0-9\.]+)|i", $this->agent, $match))
205 {
206 $this->is_browser = TRUE;
207 $this->version = $match[1];
208 $this->browser = $val;
209 $this->_set_mobile();
210 return TRUE;
211 }
212 }
213 }
214 return FALSE;
215 }
Barry Mienydd671972010-10-04 16:33:58 +0200216
Derek Allard2067d1a2008-11-13 22:59:24 +0000217 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200218
Derek Allard2067d1a2008-11-13 22:59:24 +0000219 /**
220 * Set the Robot
221 *
222 * @access private
223 * @return bool
Barry Mienydd671972010-10-04 16:33:58 +0200224 */
Phil Sturgeondac1b462011-01-06 17:40:10 +0000225 private function _set_robot()
Derek Allard2067d1a2008-11-13 22:59:24 +0000226 {
227 if (is_array($this->robots) AND count($this->robots) > 0)
Barry Mienydd671972010-10-04 16:33:58 +0200228 {
Derek Allard2067d1a2008-11-13 22:59:24 +0000229 foreach ($this->robots as $key => $val)
230 {
231 if (preg_match("|".preg_quote($key)."|i", $this->agent))
232 {
233 $this->is_robot = TRUE;
234 $this->robot = $val;
235 return TRUE;
236 }
237 }
238 }
239 return FALSE;
240 }
241
242 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200243
Derek Allard2067d1a2008-11-13 22:59:24 +0000244 /**
245 * Set the Mobile Device
246 *
247 * @access private
248 * @return bool
Barry Mienydd671972010-10-04 16:33:58 +0200249 */
Phil Sturgeondac1b462011-01-06 17:40:10 +0000250 private function _set_mobile()
Derek Allard2067d1a2008-11-13 22:59:24 +0000251 {
252 if (is_array($this->mobiles) AND count($this->mobiles) > 0)
Barry Mienydd671972010-10-04 16:33:58 +0200253 {
Derek Allard2067d1a2008-11-13 22:59:24 +0000254 foreach ($this->mobiles as $key => $val)
255 {
256 if (FALSE !== (strpos(strtolower($this->agent), $key)))
257 {
258 $this->is_mobile = TRUE;
259 $this->mobile = $val;
260 return TRUE;
261 }
262 }
Barry Mienydd671972010-10-04 16:33:58 +0200263 }
Derek Allard2067d1a2008-11-13 22:59:24 +0000264 return FALSE;
265 }
Barry Mienydd671972010-10-04 16:33:58 +0200266
Derek Allard2067d1a2008-11-13 22:59:24 +0000267 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200268
Derek Allard2067d1a2008-11-13 22:59:24 +0000269 /**
270 * Set the accepted languages
271 *
272 * @access private
273 * @return void
Barry Mienydd671972010-10-04 16:33:58 +0200274 */
Phil Sturgeondac1b462011-01-06 17:40:10 +0000275 private function _set_languages()
Derek Allard2067d1a2008-11-13 22:59:24 +0000276 {
277 if ((count($this->languages) == 0) AND isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) AND $_SERVER['HTTP_ACCEPT_LANGUAGE'] != '')
278 {
279 $languages = preg_replace('/(;q=[0-9\.]+)/i', '', strtolower(trim($_SERVER['HTTP_ACCEPT_LANGUAGE'])));
Barry Mienydd671972010-10-04 16:33:58 +0200280
Derek Allard2067d1a2008-11-13 22:59:24 +0000281 $this->languages = explode(',', $languages);
282 }
Barry Mienydd671972010-10-04 16:33:58 +0200283
Derek Allard2067d1a2008-11-13 22:59:24 +0000284 if (count($this->languages) == 0)
285 {
286 $this->languages = array('Undefined');
Barry Mienydd671972010-10-04 16:33:58 +0200287 }
Derek Allard2067d1a2008-11-13 22:59:24 +0000288 }
Barry Mienydd671972010-10-04 16:33:58 +0200289
Derek Allard2067d1a2008-11-13 22:59:24 +0000290 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200291
Derek Allard2067d1a2008-11-13 22:59:24 +0000292 /**
293 * Set the accepted character sets
294 *
295 * @access private
296 * @return void
Barry Mienydd671972010-10-04 16:33:58 +0200297 */
Phil Sturgeondac1b462011-01-06 17:40:10 +0000298 private function _set_charsets()
Barry Mienydd671972010-10-04 16:33:58 +0200299 {
Derek Allard2067d1a2008-11-13 22:59:24 +0000300 if ((count($this->charsets) == 0) AND isset($_SERVER['HTTP_ACCEPT_CHARSET']) AND $_SERVER['HTTP_ACCEPT_CHARSET'] != '')
301 {
302 $charsets = preg_replace('/(;q=.+)/i', '', strtolower(trim($_SERVER['HTTP_ACCEPT_CHARSET'])));
Barry Mienydd671972010-10-04 16:33:58 +0200303
Derek Allard2067d1a2008-11-13 22:59:24 +0000304 $this->charsets = explode(',', $charsets);
305 }
Barry Mienydd671972010-10-04 16:33:58 +0200306
Derek Allard2067d1a2008-11-13 22:59:24 +0000307 if (count($this->charsets) == 0)
308 {
309 $this->charsets = array('Undefined');
Barry Mienydd671972010-10-04 16:33:58 +0200310 }
Derek Allard2067d1a2008-11-13 22:59:24 +0000311 }
312
313 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200314
Derek Allard2067d1a2008-11-13 22:59:24 +0000315 /**
316 * Is Browser
317 *
318 * @access public
319 * @return bool
Barry Mienydd671972010-10-04 16:33:58 +0200320 */
Phil Sturgeondac1b462011-01-06 17:40:10 +0000321 public function is_browser($key = NULL)
Derek Allard2067d1a2008-11-13 22:59:24 +0000322 {
Phil Sturgeondac1b462011-01-06 17:40:10 +0000323 if ( ! $this->is_browser)
324 {
325 return FALSE;
326 }
327
328 // No need to be specific, it's a browser
329 if ($key === NULL)
330 {
331 return TRUE;
332 }
333
334 // Check for a specific browser
335 return array_key_exists($key, $this->browsers) AND $this->browser === $this->browsers[$key];
Derek Allard2067d1a2008-11-13 22:59:24 +0000336 }
337
338 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200339
Derek Allard2067d1a2008-11-13 22:59:24 +0000340 /**
341 * Is Robot
342 *
343 * @access public
344 * @return bool
Barry Mienydd671972010-10-04 16:33:58 +0200345 */
Phil Sturgeondac1b462011-01-06 17:40:10 +0000346 public function is_robot($key = NULL)
Derek Allard2067d1a2008-11-13 22:59:24 +0000347 {
Phil Sturgeondac1b462011-01-06 17:40:10 +0000348 if ( ! $this->is_robot)
349 {
350 return FALSE;
351 }
352
353 // No need to be specific, it's a robot
354 if ($key === NULL)
355 {
356 return TRUE;
357 }
358
359 // Check for a specific robot
360 return array_key_exists($key, $this->robots) AND $this->robot === $this->robots[$key];
Derek Allard2067d1a2008-11-13 22:59:24 +0000361 }
362
363 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200364
Derek Allard2067d1a2008-11-13 22:59:24 +0000365 /**
366 * Is Mobile
367 *
368 * @access public
369 * @return bool
Barry Mienydd671972010-10-04 16:33:58 +0200370 */
Phil Sturgeondac1b462011-01-06 17:40:10 +0000371 public function is_mobile($key = NULL)
Derek Allard2067d1a2008-11-13 22:59:24 +0000372 {
Phil Sturgeondac1b462011-01-06 17:40:10 +0000373 if ( ! $this->is_mobile)
374 {
375 return FALSE;
376 }
377
378 // No need to be specific, it's a mobile
379 if ($key === NULL)
380 {
381 return TRUE;
382 }
383
384 // Check for a specific robot
385 return array_key_exists($key, $this->mobiles) AND $this->mobile === $this->mobiles[$key];
Barry Mienydd671972010-10-04 16:33:58 +0200386 }
Derek Allard2067d1a2008-11-13 22:59:24 +0000387
388 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200389
Derek Allard2067d1a2008-11-13 22:59:24 +0000390 /**
391 * Is this a referral from another site?
392 *
393 * @access public
394 * @return bool
Barry Mienydd671972010-10-04 16:33:58 +0200395 */
Phil Sturgeondac1b462011-01-06 17:40:10 +0000396 public function is_referral()
Derek Allard2067d1a2008-11-13 22:59:24 +0000397 {
Eric Barnesf6f51a62011-02-05 21:41:17 -0500398 if ( ! isset($_SERVER['HTTP_REFERER']) OR $_SERVER['HTTP_REFERER'] == '')
399 {
400 return FALSE;
401 }
402 return TRUE;
Derek Allard2067d1a2008-11-13 22:59:24 +0000403 }
404
405 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200406
Derek Allard2067d1a2008-11-13 22:59:24 +0000407 /**
408 * Agent String
409 *
410 * @access public
411 * @return string
Barry Mienydd671972010-10-04 16:33:58 +0200412 */
Phil Sturgeondac1b462011-01-06 17:40:10 +0000413 public function agent_string()
Derek Allard2067d1a2008-11-13 22:59:24 +0000414 {
415 return $this->agent;
416 }
417
418 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200419
Derek Allard2067d1a2008-11-13 22:59:24 +0000420 /**
421 * Get Platform
422 *
423 * @access public
424 * @return string
Barry Mienydd671972010-10-04 16:33:58 +0200425 */
Phil Sturgeondac1b462011-01-06 17:40:10 +0000426 public function platform()
Derek Allard2067d1a2008-11-13 22:59:24 +0000427 {
428 return $this->platform;
429 }
430
431 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200432
Derek Allard2067d1a2008-11-13 22:59:24 +0000433 /**
434 * Get Browser Name
435 *
436 * @access public
437 * @return string
Barry Mienydd671972010-10-04 16:33:58 +0200438 */
Phil Sturgeondac1b462011-01-06 17:40:10 +0000439 public function browser()
Derek Allard2067d1a2008-11-13 22:59:24 +0000440 {
441 return $this->browser;
442 }
443
444 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200445
Derek Allard2067d1a2008-11-13 22:59:24 +0000446 /**
447 * Get the Browser Version
448 *
449 * @access public
450 * @return string
Barry Mienydd671972010-10-04 16:33:58 +0200451 */
Phil Sturgeondac1b462011-01-06 17:40:10 +0000452 public function version()
Derek Allard2067d1a2008-11-13 22:59:24 +0000453 {
454 return $this->version;
455 }
456
457 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200458
Derek Allard2067d1a2008-11-13 22:59:24 +0000459 /**
460 * Get The Robot Name
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 robot()
Derek Allard2067d1a2008-11-13 22:59:24 +0000466 {
467 return $this->robot;
468 }
469 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200470
Derek Allard2067d1a2008-11-13 22:59:24 +0000471 /**
472 * Get the Mobile Device
473 *
474 * @access public
475 * @return string
Barry Mienydd671972010-10-04 16:33:58 +0200476 */
Phil Sturgeondac1b462011-01-06 17:40:10 +0000477 public function mobile()
Derek Allard2067d1a2008-11-13 22:59:24 +0000478 {
479 return $this->mobile;
480 }
Barry Mienydd671972010-10-04 16:33:58 +0200481
Derek Allard2067d1a2008-11-13 22:59:24 +0000482 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200483
Derek Allard2067d1a2008-11-13 22:59:24 +0000484 /**
485 * Get the referrer
486 *
487 * @access public
488 * @return bool
Barry Mienydd671972010-10-04 16:33:58 +0200489 */
Phil Sturgeondac1b462011-01-06 17:40:10 +0000490 public function referrer()
Derek Allard2067d1a2008-11-13 22:59:24 +0000491 {
492 return ( ! isset($_SERVER['HTTP_REFERER']) OR $_SERVER['HTTP_REFERER'] == '') ? '' : trim($_SERVER['HTTP_REFERER']);
493 }
494
495 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200496
Derek Allard2067d1a2008-11-13 22:59:24 +0000497 /**
498 * Get the accepted languages
499 *
500 * @access public
501 * @return array
Barry Mienydd671972010-10-04 16:33:58 +0200502 */
Phil Sturgeondac1b462011-01-06 17:40:10 +0000503 public function languages()
Derek Allard2067d1a2008-11-13 22:59:24 +0000504 {
505 if (count($this->languages) == 0)
506 {
507 $this->_set_languages();
508 }
Barry Mienydd671972010-10-04 16:33:58 +0200509
Derek Allard2067d1a2008-11-13 22:59:24 +0000510 return $this->languages;
511 }
512
513 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200514
Derek Allard2067d1a2008-11-13 22:59:24 +0000515 /**
516 * Get the accepted Character Sets
517 *
518 * @access public
519 * @return array
Barry Mienydd671972010-10-04 16:33:58 +0200520 */
Phil Sturgeondac1b462011-01-06 17:40:10 +0000521 public function charsets()
Derek Allard2067d1a2008-11-13 22:59:24 +0000522 {
523 if (count($this->charsets) == 0)
524 {
525 $this->_set_charsets();
526 }
Barry Mienydd671972010-10-04 16:33:58 +0200527
Derek Allard2067d1a2008-11-13 22:59:24 +0000528 return $this->charsets;
529 }
Barry Mienydd671972010-10-04 16:33:58 +0200530
Derek Allard2067d1a2008-11-13 22:59:24 +0000531 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200532
Derek Allard2067d1a2008-11-13 22:59:24 +0000533 /**
534 * Test for a particular language
535 *
536 * @access public
537 * @return bool
Barry Mienydd671972010-10-04 16:33:58 +0200538 */
Phil Sturgeondac1b462011-01-06 17:40:10 +0000539 public function accept_lang($lang = 'en')
Derek Allard2067d1a2008-11-13 22:59:24 +0000540 {
Phil Sturgeondac1b462011-01-06 17:40:10 +0000541 return (in_array(strtolower($lang), $this->languages(), TRUE));
Derek Allard2067d1a2008-11-13 22:59:24 +0000542 }
Barry Mienydd671972010-10-04 16:33:58 +0200543
Derek Allard2067d1a2008-11-13 22:59:24 +0000544 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200545
Derek Allard2067d1a2008-11-13 22:59:24 +0000546 /**
547 * Test for a particular character set
548 *
549 * @access public
550 * @return bool
Barry Mienydd671972010-10-04 16:33:58 +0200551 */
Phil Sturgeondac1b462011-01-06 17:40:10 +0000552 public function accept_charset($charset = 'utf-8')
Derek Allard2067d1a2008-11-13 22:59:24 +0000553 {
Phil Sturgeondac1b462011-01-06 17:40:10 +0000554 return (in_array(strtolower($charset), $this->charsets(), TRUE));
Derek Allard2067d1a2008-11-13 22:59:24 +0000555 }
Barry Mienydd671972010-10-04 16:33:58 +0200556
Derek Allard2067d1a2008-11-13 22:59:24 +0000557}
558
559
560/* End of file User_agent.php */
cenk115e9982011-09-27 10:07:53 +0300561/* Location: ./system/libraries/User_agent.php */