config.class.php

来自「phpMyAdmin图形界面化操作,我已经配置好了,只要把解要压缩后的文件放到站」· PHP 代码 · 共 1,053 行 · 第 1/3 页

PHP
1,053 行
字号
    {        if (! empty($_REQUEST['collation_connection'])) {            $this->set('collation_connection',                strip_tags($_REQUEST['collation_connection']));        }    }    /**     * checks for font size configuration, and sets font size as requested by user     *     * @uses    $_GET     * @uses    $_POST     * @uses    $_COOKIE     * @uses    preg_match()     * @uses    function_exists()     * @uses    PMA_Config::set()     * @uses    PMA_Config::get()     * @uses    PMA_setCookie()     */    function checkFontsize()    {        $new_fontsize = '';        if (isset($_GET['fontsize'])) {            $new_fontsize = $_GET['fontsize'];        } elseif (isset($_POST['fontsize'])) {            $new_fontsize = $_POST['fontsize'];        } elseif (isset($_COOKIE['pma_fontsize'])) {            $new_fontsize = $_COOKIE['pma_fontsize'];        }        if (preg_match('/^[0-9.]+(px|em|pt|\%)$/', $new_fontsize)) {            $this->set('fontsize', $new_fontsize);        } elseif (! $this->get('fontsize')) {            // 80% would correspond to the default browser font size            // of 16, but use 82% to help read the monoface font            $this->set('fontsize', '82%');        }        if (function_exists('PMA_setCookie')) {            PMA_setCookie('pma_fontsize', $this->get('fontsize'), '82%');        }    }    /**     * checks if upload is enabled     *     */    function checkUpload()    {        if (ini_get('file_uploads')) {            $this->set('enable_upload', true);            // if set "php_admin_value file_uploads Off" in httpd.conf            // ini_get() also returns the string "Off" in this case:            if ('off' == strtolower(ini_get('file_uploads'))) {                $this->set('enable_upload', false);            }         } else {            $this->set('enable_upload', false);         }    }    /**     * Maximum upload size as limited by PHP     * Used with permission from Moodle (http://moodle.org) by Martin Dougiamas     *     * this section generates $max_upload_size in bytes     */    function checkUploadSize()    {        if (! $filesize = ini_get('upload_max_filesize')) {            $filesize = "5M";        }        if ($postsize = ini_get('post_max_size')) {            $this->set('max_upload_size',                min(PMA_get_real_size($filesize), PMA_get_real_size($postsize)));        } else {            $this->set('max_upload_size', PMA_get_real_size($filesize));        }    }    /**     * check for https     */    function checkIsHttps()    {        $this->set('is_https', PMA_Config::isHttps());    }    /**     * @static     */    static public function isHttps()    {        $is_https = false;        $url = array();        // At first we try to parse REQUEST_URI, it might contain full URL,        if (PMA_getenv('REQUEST_URI')) {            $url = @parse_url(PMA_getenv('REQUEST_URI')); // produces E_WARNING if it cannot get parsed, e.g. '/foobar:/'            if($url === false) {                $url = array();            }        }        // If we don't have scheme, we didn't have full URL so we need to        // dig deeper        if (empty($url['scheme'])) {            // Scheme            if (PMA_getenv('HTTP_SCHEME')) {                $url['scheme'] = PMA_getenv('HTTP_SCHEME');            } else {                $url['scheme'] =                    PMA_getenv('HTTPS') && strtolower(PMA_getenv('HTTPS')) != 'off'                        ? 'https'                        : 'http';            }        }        if (isset($url['scheme'])          && $url['scheme'] == 'https') {            $is_https = true;        } else {            $is_https = false;        }        return $is_https;    }    /**     * detect correct cookie path     */    function checkCookiePath()    {        $this->set('cookie_path', PMA_Config::getCookiePath());    }    /**     * @static     */    static public function getCookiePath()    {        static $cookie_path = null;        if (null !== $cookie_path) {            return $cookie_path;        }        $url = '';        /**         * REQUEST_URI contains PATH_INFO too, this is not what we want         * script-php/pathinfo/        if (PMA_getenv('REQUEST_URI')) {            $url = PMA_getenv('REQUEST_URI');        }         */        // If we don't have path        if (empty($url)) {            if ($GLOBALS['PMA_PHP_SELF']) {                // PHP_SELF in CGI often points to cgi executable, so use it                // as last choice                $url = $GLOBALS['PMA_PHP_SELF'];            // on IIS with PHP-CGI:            } elseif (PMA_getenv('SCRIPT_NAME')) {                $url = PMA_getenv('SCRIPT_NAME');            }        }        /**         * REQUEST_URI contains PATH_INFO too, this is not what we want         * script-php/pathinfo/        $parsed_url = @parse_url($_SERVER['REQUEST_URI']); // produces E_WARNING if it cannot get parsed, e.g. '/foobar:/'        if ($parsed_url === false) {         */            $parsed_url = array('path' => $url);        //}        $cookie_path   = substr($parsed_url['path'], 0, strrpos($parsed_url['path'], '/'))  . '/';        return $cookie_path;    }    /**     * enables backward compatibility     */    function enableBc()    {        $GLOBALS['cfg']             = $this->settings;        $GLOBALS['default_server']  = $this->default_server;        unset($this->default_server);        $GLOBALS['collation_connection'] = $this->get('collation_connection');        $GLOBALS['is_upload']       = $this->get('enable_upload');        $GLOBALS['max_upload_size'] = $this->get('max_upload_size');        $GLOBALS['cookie_path']     = $this->get('cookie_path');        $GLOBALS['is_https']        = $this->get('is_https');        $defines = array(            'PMA_VERSION',            'PMA_THEME_VERSION',            'PMA_THEME_GENERATION',            'PMA_PHP_STR_VERSION',            'PMA_PHP_INT_VERSION',            'PMA_IS_WINDOWS',            'PMA_IS_IIS',            'PMA_IS_GD2',            'PMA_USR_OS',            'PMA_USR_BROWSER_VER',            'PMA_USR_BROWSER_AGENT'            );        foreach ($defines as $define) {            if (! defined($define)) {                define($define, $this->get($define));            }        }    }    /**     * @todo finish     */    function save() {}    /**     * returns options for font size selection     *     * @uses    preg_replace()     * @uses    ksort()     * @static     * @param   string  $current_size   current selected font size with unit     * @return  array   selectable font sizes     */    static protected function _getFontsizeOptions($current_size = '82%')    {        $unit = preg_replace('/[0-9.]*/', '', $current_size);        $value = preg_replace('/[^0-9.]*/', '', $current_size);        $factors = array();        $options = array();        $options["$value"] = $value . $unit;        if ($unit === '%') {            $factors[] = 1;            $factors[] = 5;            $factors[] = 10;        } elseif ($unit === 'em') {            $factors[] = 0.05;            $factors[] = 0.2;            $factors[] = 1;        } elseif ($unit === 'pt') {            $factors[] = 0.5;            $factors[] = 2;        } elseif ($unit === 'px') {            $factors[] = 1;            $factors[] = 5;            $factors[] = 10;        } else {            //unknown font size unit            $factors[] = 0.05;            $factors[] = 0.2;            $factors[] = 1;            $factors[] = 5;            $factors[] = 10;        }        foreach ($factors as $key => $factor) {            $option_inc = $value + $factor;            $option_dec = $value - $factor;            while (count($options) < 21) {                $options["$option_inc"] = $option_inc . $unit;                if ($option_dec > $factors[0]) {                    $options["$option_dec"] = $option_dec . $unit;                }                $option_inc += $factor;                $option_dec -= $factor;                if (isset($factors[$key + 1])                 && $option_inc >= $value + $factors[$key + 1]) {                    break;                }            }        }        ksort($options);        return $options;    }    /**     * returns html selectbox for font sizes     *     * @uses    $_SESSION['PMA_Config']     * @uses    PMA_Config::get()     * @uses    PMA_Config::_getFontsizeOptions()     * @uses    $GLOBALS['strFontSize']     * @static     * @param   string  $current_size   currently slected font size with unit     * @return  string  html selectbox     */    static protected function _getFontsizeSelection()    {        $current_size = $_SESSION['PMA_Config']->get('fontsize');        // for the case when there is no config file (this is supported)        if (empty($current_size)) {            if (isset($_COOKIE['pma_fontsize'])) {                $current_size = $_COOKIE['pma_fontsize'];            } else {                $current_size = '82%';            }        }        $options = PMA_Config::_getFontsizeOptions($current_size);        $return = '<label for="select_fontsize">' . $GLOBALS['strFontSize'] . ':</label>' . "\n";        $return .= '<select name="fontsize" id="select_fontsize" onchange="this.form.submit();">' . "\n";        foreach ($options as $option) {            $return .= '<option value="' . $option . '"';            if ($option == $current_size) {                $return .= ' selected="selected"';            }            $return .= '>' . $option . '</option>' . "\n";        }        $return .= '</select>';        return $return;    }    /**     * return complete font size selection form     *     * @uses    PMA_generate_common_hidden_inputs()     * @uses    PMA_Config::_getFontsizeSelection()     * @uses    $GLOBALS['strGo']     * @static     * @param   string  $current_size   currently slected font size with unit     * @return  string  html selectbox     */    static public function getFontsizeForm()    {        return '<form name="form_fontsize_selection" id="form_fontsize_selection"'            . ' method="post" action="index.php" target="_parent">' . "\n"            . PMA_generate_common_hidden_inputs() . "\n"            . PMA_Config::_getFontsizeSelection() . "\n"            . '<noscript>' . "\n"            . '<input type="submit" value="' . $GLOBALS['strGo'] . '" />' . "\n"            . '</noscript>' . "\n"            . '</form>';    }}?>

⌨️ 快捷键说明

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