⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 browser.php

📁 没什么功能
💻 PHP
📖 第 1 页 / 共 2 页
字号:
<?php/*** @version      $Id: browser.php 10707 2008-08-21 09:52:47Z eddieajau $* @package      Joomla.Framework* @subpackage   Environment* @copyright    Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.* @license      GNU/GPL, see LICENSE.php* Joomla! is free software. This version may have been modified pursuant* to the GNU General Public License, and as distributed it includes or* is derivative of works licensed under the GNU General Public License or* other free or open source software licenses.* See COPYRIGHT.php for copyright notices and details.*/// Check to ensure this file is within the rest of the frameworkdefined('JPATH_BASE') or die();/** * Browser class, provides capability information about the current web client. * * Browser identification is performed by examining the HTTP_USER_AGENT * environment variable provided by the web server. * * This class has many influences from the lib/Browser.php code in * version 3 of Horde by Chuck Hagenbuch and Jon Parise * * @package     Joomla.Framework * @subpackage  Environment * @since       1.5 */class JBrowser extends JObject{    /**     * Major version number.     *     * @var integer     */    var $_majorVersion = 0;    /**     * Minor version number.     *     * @var integer     */    var $_minorVersion = 0;    /**     * Browser name.     *     * @var string     */    var $_browser = '';    /**     * Full user agent string.     *     * @var string     */    var $_agent = '';    /**     * Lower-case user agent string.     *     * @var string     */    var $_lowerAgent = '';    /**     * HTTP_ACCEPT string     *     * @var string     */    var $_accept = '';     /**     * Platform the browser is running on.     *     * @var string     */    var $_platform = '';    /**     * Known robots.     *     * @var array     */    var $_robots = array(        /* The most common ones. */        'Googlebot',        'msnbot',        'Slurp',        'Yahoo',        /* The rest alphabetically. */        'Arachnoidea',        'ArchitextSpider',        'Ask Jeeves',        'B-l-i-t-z-Bot',        'Baiduspider',        'BecomeBot',        'cfetch',        'ConveraCrawler',        'ExtractorPro',        'FAST-WebCrawler',        'FDSE robot',        'fido',        'geckobot',        'Gigabot',        'Girafabot',        'grub-client',        'Gulliver',        'HTTrack',        'ia_archiver',        'InfoSeek',        'kinjabot',        'KIT-Fireball',        'larbin',        'LEIA',        'lmspider',        'Lycos_Spider',        'Mediapartners-Google',        'MuscatFerret',        'NaverBot',        'OmniExplorer_Bot',        'polybot',        'Pompos',        'Scooter',        'Teoma',        'TheSuBot',        'TurnitinBot',        'Ultraseek',        'ViolaBot',        'webbandit',        'www.almaden.ibm.com/cs/crawler',        'ZyBorg',    );    /**     * Is this a mobile browser?     *     * @var boolean     */    var $_mobile = false;    /**     * Features.     *     * @var array     */    var $_features = array(        'html'          => true,        'hdml'          => false,        'wml'           => false,        'images'        => true,        'iframes'       => false,        'frames'        => true,        'tables'        => true,        'java'          => true,        'javascript'    => true,        'dom'           => false,        'utf'           => false,        'rte'           => false,        'homepage'      => false,        'accesskey'     => false,        'optgroup'      => false,        'xmlhttpreq'    => false,        'cite'          => false,        'xhtml+xml'     => false,        'mathml'        => false,        'svg'           => false    );    /**     * Quirks     *     * @var array     */    var $_quirks = array(        'avoid_popup_windows'           => false,        'break_disposition_header'      => false,        'break_disposition_filename'    => false,        'broken_multipart_form'         => false,        'cache_same_url'                => false,        'cache_ssl_downloads'           => false,        'double_linebreak_textarea'     => false,        'empty_file_input_value'        => false,        'must_cache_forms'              => false,        'no_filename_spaces'            => false,        'no_hidden_overflow_tables'     => false,        'ow_gui_1.3'                    => false,        'png_transparency'              => false,        'scrollbar_in_way'              => false,        'scroll_tds'                    => false,        'windowed_controls'             => false,    );    /**     * List of viewable image MIME subtypes.     * This list of viewable images works for IE and Netscape/Mozilla.     *     * @var array     */    var $_images = array('jpeg', 'gif', 'png', 'pjpeg', 'x-png', 'bmp');    /**     * Create a browser instance (Constructor).     *     * @param string $userAgent  The browser string to parse.     * @param string $accept     The HTTP_ACCEPT settings to use.     */    function __construct($userAgent = null, $accept = null)    {        $this->match($userAgent, $accept);    }    /**     * Returns a reference to the global Browser object, only creating it     * if it doesn't already exist.     *     * This method must be invoked as:     *      <pre>  $browser = &JBrowser::getInstance([$userAgent[, $accept]]);</pre>     *     * @access public     * @param string $userAgent  The browser string to parse.     * @param string $accept     The HTTP_ACCEPT settings to use.     * @return JBrowser  The Browser object.     */    function &getInstance($userAgent = null, $accept = null)    {        static $instances;        if (!isset($instances)) {            $instances = array();        }        $signature = serialize(array($userAgent, $accept));        if (empty($instances[$signature])) {            $instances[$signature] = new JBrowser($userAgent, $accept);        }        return $instances[$signature];    }   /**     * Parses the user agent string and inititializes the object with     * all the known features and quirks for the given browser.     *     * @param string $userAgent  The browser string to parse.     * @param string $accept     The HTTP_ACCEPT settings to use.     */    function match($userAgent = null, $accept = null)    {        // Set our agent string.        if (is_null($userAgent)) {            if (isset($_SERVER['HTTP_USER_AGENT'])) {                $this->_agent = trim($_SERVER['HTTP_USER_AGENT']);            }        } else {            $this->_agent = $userAgent;        }        $this->_lowerAgent = strtolower($this->_agent);        // Set our accept string.        if (is_null($accept)) {            if (isset($_SERVER['HTTP_ACCEPT'])) {                $this->_accept = strtolower(trim($_SERVER['HTTP_ACCEPT']));            }        } else {            $this->_accept = strtolower($accept);        }        // Check if browser excepts content type xhtml+xml        if (strpos($this->_accept, 'application/xhtml+xml')) {            $this->setFeature('xhtml+xml');        }        // Check for a mathplayer plugin is installed, so we can use MathML on several browsers        if (strpos($this->_lowerAgent, 'mathplayer') !== false) {            $this->setFeature('mathml');        }        // Check for UTF support.        if (isset($_SERVER['HTTP_ACCEPT_CHARSET'])) {            $this->setFeature('utf', strpos(strtolower($_SERVER['HTTP_ACCEPT_CHARSET']), 'utf') !== false);        }        if (!empty($this->_agent)) {            $this->_setPlatform();            if (strpos($this->_lowerAgent, 'mobileexplorer') !== false ||                strpos($this->_lowerAgent, 'openwave') !== false ||                strpos($this->_lowerAgent, 'opera mini') !== false ||                strpos($this->_lowerAgent, 'operamini') !== false) {                $this->setFeature('frames', false);                $this->setFeature('javascript', false);                $this->setQuirk('avoid_popup_windows');                $this->_mobile = true;            } elseif (preg_match('|Opera[/ ]([0-9.]+)|', $this->_agent, $version)) {                        $this->setBrowser('opera');                        list($this->_majorVersion, $this->_minorVersion) = explode('.', $version[1]);                        $this->setFeature('javascript', true);                        $this->setQuirk('no_filename_spaces');                if ($this->_majorVersion >= 7) {                    $this->setFeature('dom');                    $this->setFeature('iframes');                    $this->setFeature('accesskey');                    $this->setFeature('optgroup');                    $this->setQuirk('double_linebreak_textarea');                }            } elseif (strpos($this->_lowerAgent, 'elaine/') !== false ||                        strpos($this->_lowerAgent, 'palmsource') !== false ||                        strpos($this->_lowerAgent, 'digital paths') !== false) {                $this->setBrowser('palm');                $this->setFeature('images', false);                $this->setFeature('frames', false);                $this->setFeature('javascript', false);                $this->setQuirk('avoid_popup_windows');                $this->_mobile = true;            } elseif ((preg_match('|MSIE ([0-9.]+)|', $this->_agent, $version)) ||                        (preg_match('|Internet Explorer/([0-9.]+)|', $this->_agent, $version))) {                $this->setBrowser('msie');                $this->setQuirk('cache_ssl_downloads');                $this->setQuirk('cache_same_url');                $this->setQuirk('break_disposition_filename');                if (strpos($version[1], '.') !== false) {                    list($this->_majorVersion, $this->_minorVersion) = explode('.', $version[1]);                } else {                    $this->_majorVersion = $version[1];                    $this->_minorVersion = 0;                }                /* IE (< 7) on Windows does not support alpha transparency in                 * PNG images. */                if (($this->_majorVersion < 7) &&                    preg_match('/windows/i', $this->_agent)) {                    $this->setQuirk('png_transparency');                }                /* Some Handhelds have their screen resolution in the                 * user agent string, which we can use to look for                 * mobile agents. */                if (preg_match('/; (120x160|240x280|240x320|320x320)\)/', $this->_agent)) {                    $this->_mobile = true;                }                switch ($this->_majorVersion) {                case 7:                    $this->setFeature('javascript', 1.4);                    $this->setFeature('dom');                    $this->setFeature('iframes');                    $this->setFeature('utf');                    $this->setFeature('rte');                    $this->setFeature('homepage');                    $this->setFeature('accesskey');                    $this->setFeature('optgroup');                    $this->setFeature('xmlhttpreq');                    $this->setQuirk('scrollbar_in_way');                    break;                case 6:                    $this->setFeature('javascript', 1.4);                    $this->setFeature('dom');                    $this->setFeature('iframes');                    $this->setFeature('utf');                    $this->setFeature('rte');                    $this->setFeature('homepage');                    $this->setFeature('accesskey');                    $this->setFeature('optgroup');                    $this->setFeature('xmlhttpreq');                    $this->setQuirk('scrollbar_in_way');                    $this->setQuirk('broken_multipart_form');                    $this->setQuirk('windowed_controls');                    break;                case 5:                    if ($this->getPlatform() == 'mac') {                        $this->setFeature('javascript', 1.2);                        $this->setFeature('optgroup');                    } else {                        // MSIE 5 for Windows.                        $this->setFeature('javascript', 1.4);                        $this->setFeature('dom');                        $this->setFeature('xmlhttpreq');                        if ($this->_minorVersion >= 5) {                            $this->setFeature('rte');                            $this->setQuirk('windowed_controls');                        }                    }                    $this->setFeature('iframes');                    $this->setFeature('utf');                    $this->setFeature('homepage');                    $this->setFeature('accesskey');                    if ($this->_minorVersion == 5) {                        $this->setQuirk('break_disposition_header');                        $this->setQuirk('broken_multipart_form');                    }                    break;                case 4:                    $this->setFeature('javascript', 1.2);                    $this->setFeature('accesskey');                    if ($this->_minorVersion > 0) {                        $this->setFeature('utf');                    }                    break;                case 3:                    $this->setFeature('javascript', 1.5);                    $this->setQuirk('avoid_popup_windows');                    break;                }            } elseif (preg_match('|amaya/([0-9.]+)|', $this->_agent, $version)) {                $this->setBrowser('amaya');                $this->_majorVersion = $version[1];                if (isset($version[2])) {                    $this->_minorVersion = $version[2];                }                if ($this->_majorVersion > 1) {                    $this->setFeature('mathml');                    $this->setFeature('svg');                }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -