summaryrefslogtreecommitdiffstats
path: root/system/libraries/User_agent.php
diff options
context:
space:
mode:
Diffstat (limited to 'system/libraries/User_agent.php')
-rw-r--r--system/libraries/User_agent.php116
1 files changed, 39 insertions, 77 deletions
diff --git a/system/libraries/User_agent.php b/system/libraries/User_agent.php
index a007acec8..5288525cb 100644
--- a/system/libraries/User_agent.php
+++ b/system/libraries/User_agent.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -40,32 +40,31 @@
*/
class CI_User_agent {
- var $agent = NULL;
+ public $agent = NULL;
- var $is_browser = FALSE;
- var $is_robot = FALSE;
- var $is_mobile = FALSE;
+ public $is_browser = FALSE;
+ public $is_robot = FALSE;
+ public $is_mobile = FALSE;
- var $languages = array();
- var $charsets = array();
+ public $languages = array();
+ public $charsets = array();
- var $platforms = array();
- var $browsers = array();
- var $mobiles = array();
- var $robots = array();
+ public $platforms = array();
+ public $browsers = array();
+ public $mobiles = array();
+ public $robots = array();
- var $platform = '';
- var $browser = '';
- var $version = '';
- var $mobile = '';
- var $robot = '';
+ public $platform = '';
+ public $browser = '';
+ public $version = '';
+ public $mobile = '';
+ public $robot = '';
/**
* Constructor
*
* Sets the User Agent and runs the compilation routine
*
- * @access public
* @return void
*/
public function __construct()
@@ -91,20 +90,14 @@ class CI_User_agent {
/**
* Compile the User Agent Data
*
- * @access private
* @return bool
*/
- private function _load_agent_file()
+ protected function _load_agent_file()
{
- if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/user_agents.php'))
- {
- include(APPPATH.'config/'.ENVIRONMENT.'/user_agents.php');
- }
- elseif (is_file(APPPATH.'config/user_agents.php'))
- {
- include(APPPATH.'config/user_agents.php');
- }
- else
+ load_environ_config('user_agents');
+
+ // Return FALSE if we still have no mimes after trying to load them up.
+ if (count($this->mimes) === 0)
{
return FALSE;
}
@@ -147,10 +140,9 @@ class CI_User_agent {
/**
* Compile the User Agent Data
*
- * @access private
* @return bool
*/
- private function _compile_data()
+ protected function _compile_data()
{
$this->_set_platform();
@@ -168,10 +160,9 @@ class CI_User_agent {
/**
* Set the Platform
*
- * @access private
* @return mixed
*/
- private function _set_platform()
+ protected function _set_platform()
{
if (is_array($this->platforms) AND count($this->platforms) > 0)
{
@@ -192,10 +183,9 @@ class CI_User_agent {
/**
* Set the Browser
*
- * @access private
* @return bool
*/
- private function _set_browser()
+ protected function _set_browser()
{
if (is_array($this->browsers) AND count($this->browsers) > 0)
{
@@ -219,10 +209,9 @@ class CI_User_agent {
/**
* Set the Robot
*
- * @access private
* @return bool
*/
- private function _set_robot()
+ protected function _set_robot()
{
if (is_array($this->robots) AND count($this->robots) > 0)
{
@@ -244,10 +233,9 @@ class CI_User_agent {
/**
* Set the Mobile Device
*
- * @access private
* @return bool
*/
- private function _set_mobile()
+ protected function _set_mobile()
{
if (is_array($this->mobiles) AND count($this->mobiles) > 0)
{
@@ -269,19 +257,16 @@ class CI_User_agent {
/**
* Set the accepted languages
*
- * @access private
* @return void
*/
- private function _set_languages()
+ protected function _set_languages()
{
- if ((count($this->languages) == 0) AND isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) AND $_SERVER['HTTP_ACCEPT_LANGUAGE'] != '')
+ if ((count($this->languages) === 0) AND isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) AND $_SERVER['HTTP_ACCEPT_LANGUAGE'] != '')
{
- $languages = preg_replace('/(;q=[0-9\.]+)/i', '', strtolower(trim($_SERVER['HTTP_ACCEPT_LANGUAGE'])));
-
- $this->languages = explode(',', $languages);
+ $this->languages = explode(',', preg_replace('/(;q=[0-9\.]+)/i', '', strtolower(trim($_SERVER['HTTP_ACCEPT_LANGUAGE']))));
}
- if (count($this->languages) == 0)
+ if (count($this->languages) === 0)
{
$this->languages = array('Undefined');
}
@@ -292,19 +277,16 @@ class CI_User_agent {
/**
* Set the accepted character sets
*
- * @access private
* @return void
*/
- private function _set_charsets()
+ protected function _set_charsets()
{
- if ((count($this->charsets) == 0) AND isset($_SERVER['HTTP_ACCEPT_CHARSET']) AND $_SERVER['HTTP_ACCEPT_CHARSET'] != '')
+ if ((count($this->charsets) === 0) AND isset($_SERVER['HTTP_ACCEPT_CHARSET']) AND $_SERVER['HTTP_ACCEPT_CHARSET'] != '')
{
- $charsets = preg_replace('/(;q=.+)/i', '', strtolower(trim($_SERVER['HTTP_ACCEPT_CHARSET'])));
-
- $this->charsets = explode(',', $charsets);
+ $this->charsets = explode(',', preg_replace('/(;q=.+)/i', '', strtolower(trim($_SERVER['HTTP_ACCEPT_CHARSET']))));
}
- if (count($this->charsets) == 0)
+ if (count($this->charsets) === 0)
{
$this->charsets = array('Undefined');
}
@@ -315,7 +297,6 @@ class CI_User_agent {
/**
* Is Browser
*
- * @access public
* @return bool
*/
public function is_browser($key = NULL)
@@ -340,7 +321,6 @@ class CI_User_agent {
/**
* Is Robot
*
- * @access public
* @return bool
*/
public function is_robot($key = NULL)
@@ -365,7 +345,6 @@ class CI_User_agent {
/**
* Is Mobile
*
- * @access public
* @return bool
*/
public function is_mobile($key = NULL)
@@ -390,16 +369,11 @@ class CI_User_agent {
/**
* Is this a referral from another site?
*
- * @access public
* @return bool
*/
public function is_referral()
{
- if ( ! isset($_SERVER['HTTP_REFERER']) OR $_SERVER['HTTP_REFERER'] == '')
- {
- return FALSE;
- }
- return TRUE;
+ return ( ! isset($_SERVER['HTTP_REFERER']) OR $_SERVER['HTTP_REFERER'] == '') ? FALSE : TRUE;
}
// --------------------------------------------------------------------
@@ -407,7 +381,6 @@ class CI_User_agent {
/**
* Agent String
*
- * @access public
* @return string
*/
public function agent_string()
@@ -420,7 +393,6 @@ class CI_User_agent {
/**
* Get Platform
*
- * @access public
* @return string
*/
public function platform()
@@ -433,7 +405,6 @@ class CI_User_agent {
/**
* Get Browser Name
*
- * @access public
* @return string
*/
public function browser()
@@ -446,7 +417,6 @@ class CI_User_agent {
/**
* Get the Browser Version
*
- * @access public
* @return string
*/
public function version()
@@ -459,7 +429,6 @@ class CI_User_agent {
/**
* Get The Robot Name
*
- * @access public
* @return string
*/
public function robot()
@@ -471,7 +440,6 @@ class CI_User_agent {
/**
* Get the Mobile Device
*
- * @access public
* @return string
*/
public function mobile()
@@ -484,7 +452,6 @@ class CI_User_agent {
/**
* Get the referrer
*
- * @access public
* @return bool
*/
public function referrer()
@@ -497,12 +464,11 @@ class CI_User_agent {
/**
* Get the accepted languages
*
- * @access public
* @return array
*/
public function languages()
{
- if (count($this->languages) == 0)
+ if (count($this->languages) === 0)
{
$this->_set_languages();
}
@@ -515,12 +481,11 @@ class CI_User_agent {
/**
* Get the accepted Character Sets
*
- * @access public
* @return array
*/
public function charsets()
{
- if (count($this->charsets) == 0)
+ if (count($this->charsets) === 0)
{
$this->_set_charsets();
}
@@ -533,7 +498,6 @@ class CI_User_agent {
/**
* Test for a particular language
*
- * @access public
* @return bool
*/
public function accept_lang($lang = 'en')
@@ -546,7 +510,6 @@ class CI_User_agent {
/**
* Test for a particular character set
*
- * @access public
* @return bool
*/
public function accept_charset($charset = 'utf-8')
@@ -556,6 +519,5 @@ class CI_User_agent {
}
-
/* End of file User_agent.php */
/* Location: ./system/libraries/User_agent.php */