From 6c9f736650bd9eafb2c44bb844f13de259d5efb6 Mon Sep 17 00:00:00 2001 From: admin Date: Mon, 9 Oct 2006 03:33:48 +0000 Subject: --- system/libraries/Calendar.php | 42 +++++----- system/libraries/User_agent.php | 178 +++++++++++++++++++++++++++++++++++++--- 2 files changed, 189 insertions(+), 31 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php index 23a6bf791..048934b82 100644 --- a/system/libraries/Calendar.php +++ b/system/libraries/Calendar.php @@ -398,27 +398,27 @@ class CI_Calendar { function default_template() { return array ( - 'table_open' => '', - 'heading_row_start' => '', - 'heading_previous_cell' => '', - 'heading_title_cell' => '', - 'heading_next_cell' => '', - 'heading_row_end' => '', - 'week_row_start' => '', - 'week_day_cell' => '', - 'week_row_end' => '', - 'cal_row_start' => '', - 'cal_cell_start' => '', - 'cal_cell_end_today' => '', - 'cal_row_end' => '', - 'table_close' => '
<<{heading}>>
{week_day}
', - 'cal_cell_start_today' => '', - 'cal_cell_content' => '{day}', - 'cal_cell_content_today' => '{day}', - 'cal_cell_no_content' => '{day}', - 'cal_cell_no_content_today' => '{day}', - 'cal_cell_blank' => ' ', - 'cal_cell_end' => '
' + 'table_open' => '', + 'heading_row_start' => '', + 'heading_previous_cell' => '', + 'heading_title_cell' => '', + 'heading_next_cell' => '', + 'heading_row_end' => '', + 'week_row_start' => '', + 'week_day_cell' => '', + 'week_row_end' => '', + 'cal_row_start' => '', + 'cal_cell_start' => '', + 'cal_cell_end_today' => '', + 'cal_row_end' => '', + 'table_close' => '
<<{heading}>>
{week_day}
', + 'cal_cell_start_today' => '', + 'cal_cell_content' => '{day}', + 'cal_cell_content_today' => '{day}', + 'cal_cell_no_content' => '{day}', + 'cal_cell_no_content_today' => '{day}', + 'cal_cell_blank' => ' ', + 'cal_cell_end' => '
' ); } diff --git a/system/libraries/User_agent.php b/system/libraries/User_agent.php index 33e8451c6..8c63924b9 100644 --- a/system/libraries/User_agent.php +++ b/system/libraries/User_agent.php @@ -33,6 +33,9 @@ class CI_User_agent { var $is_browser = FALSE; var $is_robot = FALSE; var $is_mobile = FALSE; + + var $languages = array(); + var $charsets = array(); var $platform = ''; var $browser = ''; @@ -40,7 +43,6 @@ class CI_User_agent { var $moble = ''; var $robot = ''; - var $platforms = array ( 'windows nt 6.0' => 'Windows Longhorn', 'windows nt 5.2' => 'Windows 2003', @@ -55,12 +57,13 @@ class CI_User_agent { 'windows 95' => 'Windows 95', 'win95' => 'Windows 95', 'windows' => 'Unknown Windows OS', - 'mac os x' => 'Mac OS X', + 'os x' => 'Mac OS X', + 'ppc mac' => 'Power PC Mac', 'freebsd' => 'FreeBSD', 'ppc' => 'Macintosh', - 'sunos' => 'Sun Solaris', 'linux' => 'Linux', 'debian' => 'Debian', + 'sunos' => 'Sun Solaris', 'beos' => 'BeOS', 'apachebench' => 'ApacheBench', 'aix' => 'AIX', @@ -80,12 +83,21 @@ class CI_User_agent { 'Internet Explorer' => 'Internet Explorer', 'Shiira' => 'Shiira', 'Firefox' => 'Firefox', + 'Chimera' => 'Chimera', + 'Phoenix' => 'Phoenix', + 'Firebird' => 'Firebird', 'Camino' => 'Camino', + 'Netscape' => 'Netscape', + 'OmniWeb' => 'OmniWeb', 'Mozilla' => 'Mozilla', 'Safari' => 'Safari', 'Konqueror' => 'Konqueror', + 'icab' => 'iCab', 'Lynx' => 'Lynx', - 'ANTFresco' => 'Fresco' + 'Links' => 'Links', + 'hotjava' => 'HotJava', + 'amaya' => 'Amaya', + 'IBrowse' => 'IBrowse' ); var $mobiles = array( @@ -488,7 +500,7 @@ class CI_User_agent { return FALSE; } - + // -------------------------------------------------------------------- /** @@ -535,6 +547,51 @@ class CI_User_agent { return FALSE; } + // -------------------------------------------------------------------- + + /** + * Set the accepted languages + * + * @access private + * @return void + */ + function _set_languages() + { + if ((count($this->languages) == 0) AND isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) AND $_SERVER['HTTP_ACCEPT_LANGUAGE'] != '') + { + $languages = preg_replace('/(;q=.+)/i', '', $_SERVER['HTTP_ACCEPT_LANGUAGE']); + + $this->languages = explode(',', $languages); + } + + if (count($this->languages) == 0) + { + $this->languages = array('Undefined'); + } + } + + // -------------------------------------------------------------------- + + /** + * Set the accepted character sets + * + * @access private + * @return void + */ + function _set_charsets() + { + if ((count($this->charsets) == 0) AND isset($_SERVER['HTTP_ACCEPT_CHARSET']) AND $_SERVER['HTTP_ACCEPT_CHARSET'] != '') + { + $charsets = preg_replace('/(;q=.+)/i', '', $_SERVER['HTTP_ACCEPT_CHARSET']); + + $this->charsets = explode(',', $charsets); + } + + if (count($this->charsets) == 0) + { + $this->charsets = array('Undefined'); + } + } // -------------------------------------------------------------------- @@ -577,13 +634,39 @@ class CI_User_agent { // -------------------------------------------------------------------- + /** + * Is this a referral from another site? + * + * @access public + * @return bool + */ + function is_referral() + { + return ( ! isset($_SERVER['HTTP_REFERER']) OR $_SERVER['HTTP_REFERER'] == '') ? FALSE : TRUE; + } + + // -------------------------------------------------------------------- + + /** + * Agent String + * + * @access public + * @return string + */ + function agent() + { + return $this->agent; + } + + // -------------------------------------------------------------------- + /** * Get Platform * * @access public * @return string */ - function get_platform() + function platform() { return $this->platform; } @@ -596,7 +679,7 @@ class CI_User_agent { * @access public * @return string */ - function get_browser() + function browser() { return $this->browser; } @@ -609,7 +692,7 @@ class CI_User_agent { * @access public * @return string */ - function get_version() + function version() { return $this->version; } @@ -622,7 +705,7 @@ class CI_User_agent { * @access public * @return string */ - function get_robot() + function robot() { return $this->robot; } @@ -634,11 +717,86 @@ class CI_User_agent { * @access public * @return string */ - function get_mobile() + function mobile() { return $this->mobile; } + // -------------------------------------------------------------------- + + /** + * Get the referrer + * + * @access public + * @return bool + */ + function referrer() + { + return ( ! isset($_SERVER['HTTP_REFERER']) OR $_SERVER['HTTP_REFERER'] == '') ? '' : $_SERVER['HTTP_REFERER']; + } + + // -------------------------------------------------------------------- + + /** + * Get the accepted languages + * + * @access public + * @return array + */ + function languages() + { + if (count($this->languages) == 0) + { + $this->_set_languages(); + } + + return $this->languages; + } + + // -------------------------------------------------------------------- + + /** + * Get the accepted Character Sets + * + * @access public + * @return array + */ + function charsets() + { + if (count($this->charsets) == 0) + { + $this->_set_charsets(); + } + + return $this->charsets; + } + + // -------------------------------------------------------------------- + + /** + * Test for a particular language + * + * @access public + * @return bool + */ + function accept_lang($lang = 'en') + { + return (in_array(strtolower($lang), $this->languages(), TRUE)) ? TRUE : FALSE; + } + + // -------------------------------------------------------------------- + + /** + * Test for a particular character set + * + * @access public + * @return bool + */ + function accept_charset($charset = 'utf-8') + { + return (in_array(strtolower($charset), $this->charsets(), TRUE)) ? TRUE : FALSE; + } + } -- cgit v1.2.3-24-g4f1b