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

📄 browser.php

📁 没什么功能
💻 PHP
📖 第 1 页 / 共 2 页
字号:
                $this->setFeature('xhtml+xml');            } elseif (preg_match('|W3C_Validator/([0-9.]+)|', $this->_agent, $version)) {                $this->setFeature('mathml');                $this->setFeature('svg');                $this->setFeature('xhtml+xml');            } elseif (preg_match('|ANTFresco/([0-9]+)|', $this->_agent, $version)) {                $this->setBrowser('fresco');                $this->setFeature('javascript', 1.5);                $this->setQuirk('avoid_popup_windows');            } elseif (strpos($this->_lowerAgent, 'avantgo') !== false) {                $this->setBrowser('avantgo');                $this->_mobile = true;            } elseif (preg_match('|Konqueror/([0-9]+)|', $this->_agent, $version) ||                        preg_match('|Safari/([0-9]+)\.?([0-9]+)?|', $this->_agent, $version)) {                // Konqueror and Apple's Safari both use the KHTML                // rendering engine.                $this->setBrowser('konqueror');                $this->setQuirk('empty_file_input_value');                $this->setQuirk('no_hidden_overflow_tables');                $this->_majorVersion = $version[1];                if (isset($version[2])) {                    $this->_minorVersion = $version[2];                }                if (strpos($this->_agent, 'Safari') !== false &&                    $this->_majorVersion >= 60) {                    // Safari.                    $this->setFeature('utf');                    $this->setFeature('javascript', 1.4);                    $this->setFeature('dom');                    $this->setFeature('iframes');                    if ($this->_majorVersion > 125 ||                        ($this->_majorVersion == 125 &&                         $this->_minorVersion >= 1)) {                        $this->setFeature('accesskey');                        $this->setFeature('xmlhttpreq');                    }                    if ($this->_majorVersion > 522) {                        $this->setFeature('svg');                        $this->setFeature('xhtml+xml');                    }                } else {                    // Konqueror.                    $this->setFeature('javascript', 1.5);                    switch ($this->_majorVersion) {                    case 3:                        $this->setFeature('dom');                        $this->setFeature('iframes');                $this->setFeature('xhtml+xml');                        break;                    }                }            } elseif (preg_match('|Mozilla/([0-9.]+)|', $this->_agent, $version)) {                $this->setBrowser('mozilla');                $this->setQuirk('must_cache_forms');                list($this->_majorVersion, $this->_minorVersion) = explode('.', $version[1]);                switch ($this->_majorVersion) {                case 5:                    if ($this->getPlatform() == 'win') {                        $this->setQuirk('break_disposition_filename');                    }                    $this->setFeature('javascript', 1.4);                    $this->setFeature('dom');                    $this->setFeature('accesskey');                    $this->setFeature('optgroup');                    $this->setFeature('xmlhttpreq');                    $this->setFeature('cite');                    if (preg_match('|rv:(.*)\)|', $this->_agent, $revision)) {                        if ($revision[1] >= 1) {                            $this->setFeature('iframes');                        }                        if ($revision[1] >= 1.3) {                            $this->setFeature('rte');                        }                        if ($revision[1] >= 1.5) {                            $this->setFeature('svg');                            $this->setFeature('mathml');                $this->setFeature('xhtml+xml');                        }                    }                    break;                case 4:                    $this->setFeature('javascript', 1.3);                    $this->setQuirk('buggy_compression');                    break;                case 3:                default:                    $this->setFeature('javascript', 1);                    $this->setQuirk('buggy_compression');                    break;                }            } elseif (preg_match('|Lynx/([0-9]+)|', $this->_agent, $version)) {                $this->setBrowser('lynx');                $this->setFeature('images', false);                $this->setFeature('frames', false);                $this->setFeature('javascript', false);                $this->setQuirk('avoid_popup_windows');            } elseif (preg_match('|Links \(([0-9]+)|', $this->_agent, $version)) {                $this->setBrowser('links');                $this->setFeature('images', false);                $this->setFeature('frames', false);                $this->setFeature('javascript', false);                $this->setQuirk('avoid_popup_windows');            } elseif (preg_match('|HotJava/([0-9]+)|', $this->_agent, $version)) {                $this->setBrowser('hotjava');                $this->setFeature('javascript', false);            } elseif (strpos($this->_agent, 'UP/') !== false ||                        strpos($this->_agent, 'UP.B') !== false ||                        strpos($this->_agent, 'UP.L') !== false) {                $this->setBrowser('up');                $this->setFeature('html', false);                $this->setFeature('javascript', false);                $this->setFeature('hdml');                $this->setFeature('wml');                if (strpos($this->_agent, 'GUI') !== false &&                    strpos($this->_agent, 'UP.Link') !== false) {                    /* The device accepts Openwave GUI extensions for                     * WML 1.3. Non-UP.Link gateways sometimes have                     * problems, so exclude them. */                    $this->setQuirk('ow_gui_1.3');                }                $this->_mobile = true;            } elseif (strpos($this->_agent, 'Xiino/') !== false) {                $this->setBrowser('xiino');                $this->setFeature('hdml');                $this->setFeature('wml');                $this->_mobile = true;            } elseif (strpos($this->_agent, 'Palmscape/') !== false) {                $this->setBrowser('palmscape');                $this->setFeature('javascript', false);                $this->setFeature('hdml');                $this->setFeature('wml');                $this->_mobile = true;            } elseif (strpos($this->_agent, 'Nokia') !== false) {                $this->setBrowser('nokia');                $this->setFeature('html', false);                $this->setFeature('wml');                $this->setFeature('xhtml');                $this->_mobile = true;            } elseif (strpos($this->_agent, 'Ericsson') !== false) {                $this->setBrowser('ericsson');                $this->setFeature('html', false);                $this->setFeature('wml');                $this->_mobile = true;            } elseif (strpos($this->_lowerAgent, 'wap') !== false) {                $this->setBrowser('wap');                $this->setFeature('html', false);                $this->setFeature('javascript', false);                $this->setFeature('hdml');                $this->setFeature('wml');                $this->_mobile = true;            } elseif (strpos($this->_lowerAgent, 'docomo') !== false ||                        strpos($this->_lowerAgent, 'portalmmm') !== false) {                $this->setBrowser('imode');                $this->setFeature('images', false);                $this->_mobile = true;        } elseif (strpos($this->_agent, 'BlackBerry') !== false) {                $this->setBrowser('blackberry');                $this->setFeature('html', false);                $this->setFeature('javascript', false);                $this->setFeature('hdml');                $this->setFeature('wml');                $this->_mobile = true;            } elseif (strpos($this->_agent, 'MOT-') !== false) {                $this->setBrowser('motorola');                $this->setFeature('html', false);                $this->setFeature('javascript', false);                $this->setFeature('hdml');                $this->setFeature('wml');                $this->_mobile = true;            } elseif (strpos($this->_lowerAgent, 'j-') !== false) {                $this->setBrowser('mml');                $this->_mobile = true;            }        }    }     /**     * Match the platform of the browser.     *     * This is a pretty simplistic implementation, but it's intended     * to let us tell what line breaks to send, so it's good enough     * for its purpose.     */    function _setPlatform()    {        if (strpos($this->_lowerAgent, 'wind') !== false) {            $this->_platform = 'win';        } elseif (strpos($this->_lowerAgent, 'mac') !== false) {            $this->_platform = 'mac';        } else {            $this->_platform = 'unix';        }    }    /**     * Return the currently matched platform.     *     * @return string  The user's platform.     */    function getPlatform()   {        return $this->_platform;    }    /**     * Sets the current browser.     *     * @param string $browser  The browser to set as current.     */    function setBrowser($browser) {        $this->_browser = $browser;    }    /**     * Retrieve the current browser.     *     * @return string  The current browser.     */    function getBrowser()    {        return $this->_browser;    }    /**     * Retrieve the current browser's major version.     *     * @return integer  The current browser's major version.     */    function getMajor()  {        return $this->_majorVersion;    }    /**     * Retrieve the current browser's minor version.     * @return integer  The current browser's minor version.     */    function getMinor()  {        return $this->_minorVersion;    }    /**     * Retrieve the current browser's version.     * @return string  The current browser's version.     */    function getVersion()    {        return $this->_majorVersion . '.' . $this->_minorVersion;    }    /**     * Return the full browser agent string.     *     * @return string  The browser agent string.     */    function getAgentString()    {        return $this->_agent;    }    /**     * Returns the server protocol in use on the current server.     *     * @return string  The HTTP server protocol version.     */    function getHTTPProtocol()    {        if (isset($_SERVER['SERVER_PROTOCOL'])) {            if (($pos = strrpos($_SERVER['SERVER_PROTOCOL'], '/'))) {                return substr($_SERVER['SERVER_PROTOCOL'], $pos + 1);            }        }        return null;    }    /**     * Set unique behavior for the current browser.     *     * @param string $quirk  The behavior to set.     * @param string $value  Special behavior parameter.     */    function setQuirk($quirk, $value = true) {        $this->_quirks[$quirk] = $value;    }    /**     * Check unique behavior for the current browser.     *     * @param string $quirk  The behavior to check.     * @return boolean  Does the browser have the behavior set?     */    function hasQuirk($quirk) {        return !empty($this->_quirks[$quirk]);    }     /**     * Retrieve unique behavior for the current browser.     *     * @param string $quirk  The behavior to retrieve.     * @return string  The value for the requested behavior.     */    function getQuirk($quirk)    {        return isset($this->_quirks[$quirk])                ? $this->_quirks[$quirk]                : null;    }    /**     * Set capabilities for the current browser.     *     * @param string $feature  The capability to set.     * @param string $value Special capability parameter.     */    function setFeature($feature, $value = true) {        $this->_features[$feature] = $value;    }    /**     * Check the current browser capabilities.     * @param string $feature  The capability to check.     * @return boolean  Does the browser have the capability set?     */    function hasFeature($feature)    {        return !empty($this->_features[$feature]);    }    /**     * Retrieve the current browser capability.     *     * @param string $feature  The capability to retrieve.     * @return string  The value of the requested capability.     */    function getFeature($feature)    {         return isset($this->_features[$feature])                ? $this->_features[$feature]                : null;    }    /**     * Determines if a browser can display a given MIME type.     *     * @param string $mimetype  The MIME type to check.     * @return boolean  True if the browser can display the MIME type.     */    function isViewable($mimetype)    {        $mimetype = strtolower($mimetype);        list($type, $subtype) = explode('/', $mimetype);        if (!empty($this->_accept)) {            $wildcard_match = false;            if (strpos($this->_accept, $mimetype) !== false) {                return true;            }            if (strpos($this->_accept, '*/*') !== false) {                $wildcard_match = true;                if ($type != 'image') {                    return true;                }             }            /* image/jpeg and image/pjpeg *appear* to be the same            * entity, but Mozilla doesn't seem to want to accept the            * latter.  For our purposes, we will treat them the            * same.            */                if ($this->isBrowser('mozilla') &&                ($mimetype == 'image/pjpeg') &&                (strpos($this->_accept, 'image/jpeg') !== false)) {                    return true;                }            if (!$wildcard_match) {                return false;            }        }        if (!$this->hasFeature('images') || ($type != 'image')) {            return false;        }        return (in_array($subtype, $this->_images));    }    /**     * Determine if the given browser is the same as the current.     *     * @param string $browser  The browser to check.     * @return boolean  Is the given browser the same as the current?     */    function isBrowser($browser)    {        return ($this->_browser === $browser);    }    /**     * Determines if the browser is a robot or not.     *     * @return boolean  True if browser is a known robot.     */    function isRobot()    {         foreach ($this->_robots as $robot) {             if (strpos($this->_agent, $robot) !== false) {                 return true;            }        }        return false;    }    /**     * Determine if we are using a secure (SSL) connection.     *     * @return boolean  True if using SSL, false if not.     */    function isSSLConnection()    {        return ((isset($_SERVER['HTTPS']) &&            ($_SERVER['HTTPS'] == 'on')) ||            getenv('SSL_PROTOCOL_VERSION'));    }}

⌨️ 快捷键说明

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