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

📄 config.class.php

📁 WEBGAME源码,有架设说明,只是非常简单
💻 PHP
📖 第 1 页 / 共 3 页
字号:
        return true;    }    /**     * loads configuration from $source, usally the config file     * should be called on object creation and from __wakeup if config file     * has changed     *     * @param   string $source  config file     */    function load($source = null)    {        $this->loadDefaults();        if (null !== $source) {            $this->setSource($source);        }        if (! $this->checkConfigSource()) {            return false;        }        $cfg = array();        /**         * Parses the configuration file         */        $old_error_reporting = error_reporting(0);        if (function_exists('file_get_contents')) {            $eval_result =                eval('?>' . trim(file_get_contents($this->getSource())));        } else {            $eval_result =                eval('?>' . trim(implode("\n", file($this->getSource()))));        }        error_reporting($old_error_reporting);        if ($eval_result === false) {            $this->error_config_file = true;        } else  {            $this->error_config_file = false;            $this->source_mtime = filemtime($this->getSource());        }        /**         * Backward compatibility code         */        if (!empty($cfg['DefaultTabTable'])) {            $cfg['DefaultTabTable'] = str_replace('_properties', '', str_replace('tbl_properties.php', 'tbl_sql.php', $cfg['DefaultTabTable']));        }        if (!empty($cfg['DefaultTabDatabase'])) {            $cfg['DefaultTabDatabase'] = str_replace('_details', '', str_replace('db_details.php', 'db_sql.php', $cfg['DefaultTabDatabase']));        }        $this->checkFontsize();        //$this->checkPmaAbsoluteUri();        $this->settings = PMA_array_merge_recursive($this->settings, $cfg);        // Handling of the collation must be done after merging of $cfg        // (from config.inc.php) so that $cfg['DefaultConnectionCollation']        // can have an effect. Note that the presence of collation        // information in a cookie has priority over what is defined        // in the default or user's config files.         /**         * @todo check validity of $_COOKIE['pma_collation_connection']         */        if (! empty($_COOKIE['pma_collation_connection'])) {            $this->set('collation_connection',                strip_tags($_COOKIE['pma_collation_connection']));        } else {            $this->set('collation_connection',                $this->get('DefaultConnectionCollation'));        }        // Now, a collation information could come from REQUEST        // (an example of this: the collation selector in main.php)        // so the following handles the setting of collation_connection        // and later, in common.lib.php, the cookie will be set        // according to this.        $this->checkCollationConnection();        return true;    }    /**     * set source     * @param   string  $source     */    function setSource($source)    {        $this->source = trim($source);    }    /**     * checks if the config folder still exists and terminates app if true     */    function checkConfigFolder()    {        // Refuse to work while there still might be some world writable dir:        if (is_dir('./config')) {            die('Remove "./config" directory before using phpMyAdmin!');        }    }    /**     * check config source     *     * @return  boolean wether source is valid or not     */    function checkConfigSource()    {        if (! $this->getSource()) {            // no configuration file set at all            return false;        }        if (! file_exists($this->getSource())) {            // do not trigger error here            // https://sf.net/tracker/?func=detail&aid=1370269&group_id=23067&atid=377408            /*            trigger_error(                'phpMyAdmin-ERROR: unkown configuration source: ' . $source,                E_USER_WARNING);            */            $this->source_mtime = 0;            return false;        }        if (! is_readable($this->getSource())) {            $this->source_mtime = 0;            die('Existing configuration file (' . $this->getSource() . ') is not readable.');        }        // Check for permissions (on platforms that support it):        $perms = @fileperms($this->getSource());        if (!($perms === false) && ($perms & 2)) {            // This check is normally done after loading configuration            $this->checkWebServerOs();            if ($this->get('PMA_IS_WINDOWS') == 0) {                $this->source_mtime = 0;                die('Wrong permissions on configuration file, should not be world writable!');            }        }        return true;    }    /**     * returns specific config setting     * @param   string  $setting     * @return  mixed   value     */    function get($setting)    {        if (isset($this->settings[$setting])) {            return $this->settings[$setting];        }        return null;    }    /**     * sets configuration variable     *     * @uses    $this->settings     * @param   string  $setting    configuration option     * @param   string  $value      new value for configuration option     */    function set($setting, $value)    {        if (!isset($this->settings[$setting]) || $this->settings[$setting] != $value) {            $this->settings[$setting] = $value;            $this->set_mtime = time();        }    }    /**     * returns source for current config     * @return  string  config source     */    function getSource()    {        return $this->source;    }    /**     * old PHP 4 style constructor     *     * @deprecated     */    function PMA_Config($source = null)    {        $this->__construct($source);    }    /**     * returns time of last config change.     * @return  int  Unix timestamp     */    function getMtime()    {        return max($this->source_mtime, $this->default_source_mtime, $this->set_mtime);    }    /**     * $cfg['PmaAbsoluteUri'] is a required directive else cookies won't be     * set properly and, depending on browsers, inserting or updating a     * record might fail     */    function checkPmaAbsoluteUri()    {        // Setup a default value to let the people and lazy syadmins work anyway,        // they'll get an error if the autodetect code doesn't work        $pma_absolute_uri = $this->get('PmaAbsoluteUri');        $is_https = $this->get('is_https');        if (strlen($pma_absolute_uri) < 5            // needed to catch http/https switch            || ($is_https && substr($pma_absolute_uri, 0, 6) != 'https:')            || (!$is_https && substr($pma_absolute_uri, 0, 5) != 'http:')        ) {            $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( 'path' => $_SERVER['REQUEST_URI'] );                }            }            // 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';                }                // Host and port                if (PMA_getenv('HTTP_HOST')) {                    if (strpos(PMA_getenv('HTTP_HOST'), ':') !== false) {                        list($url['host'], $url['port']) =                            explode(':', PMA_getenv('HTTP_HOST'));                    } else {                        $url['host'] = PMA_getenv('HTTP_HOST');                    }                } elseif (PMA_getenv('SERVER_NAME')) {                    $url['host'] = PMA_getenv('SERVER_NAME');                } else {                    $this->error_pma_uri = true;                    return false;                }                // If we didn't set port yet...                if (empty($url['port']) && PMA_getenv('SERVER_PORT')) {                    $url['port'] = PMA_getenv('SERVER_PORT');                }                // And finally the path could be already set from REQUEST_URI                if (empty($url['path'])) {                    if (PMA_getenv('PATH_INFO')) {                        $path = parse_url(PMA_getenv('PATH_INFO'));                    } else {                        // PHP_SELF in CGI often points to cgi executable, so use it                        // as last choice                        $path = parse_url(PMA_getenv('PHP_SELF'));                    }                    $url['path'] = $path['path'];                }            }            // Make url from parts we have            $pma_absolute_uri = $url['scheme'] . '://';            // Was there user information?            if (!empty($url['user'])) {                $pma_absolute_uri .= $url['user'];                if (!empty($url['pass'])) {                    $pma_absolute_uri .= ':' . $url['pass'];                }                $pma_absolute_uri .= '@';            }            // Add hostname            $pma_absolute_uri .= $url['host'];            // Add port, if it not the default one            if (! empty($url['port'])              && (($url['scheme'] == 'http' && $url['port'] != 80)                || ($url['scheme'] == 'https' && $url['port'] != 443))) {                $pma_absolute_uri .= ':' . $url['port'];            }            // And finally path, without script name, the 'a' is there not to            // strip our directory, when path is only /pmadir/ without filename.            // Backslashes returned by Windows have to be changed.            // Only replace backslashes by forward slashes if on Windows,            // as the backslash could be valid on a non-Windows system.            if ($this->get('PMA_IS_WINDOWS') == 1) {                $path = str_replace("\\", "/", dirname($url['path'] . 'a'));            } else {                $path = dirname($url['path'] . 'a');            }            // To work correctly within transformations overview:            if (defined('PMA_PATH_TO_BASEDIR') && PMA_PATH_TO_BASEDIR == '../../') {                if ($this->get('PMA_IS_WINDOWS') == 1) {                    $path = str_replace("\\", "/", dirname(dirname($path)));                } else {                    $path = dirname(dirname($path));                }            }            // in vhost situations, there could be already an ending slash            if (substr($path, -1) != '/') {                $path .= '/';            }            $pma_absolute_uri .= $path;            // We used to display a warning if PmaAbsoluteUri wasn't set, but now            // the autodetect code works well enough that we don't display the            // warning at all. The user can still set PmaAbsoluteUri manually.            // See            // http://sf.net/tracker/?func=detail&aid=1257134&group_id=23067&atid=377411        } else {            // The URI is specified, however users do often specify this            // wrongly, so we try to fix this.            // Adds a trailing slash et the end of the phpMyAdmin uri if it            // does not exist.            if (substr($pma_absolute_uri, -1) != '/') {                $pma_absolute_uri .= '/';            }            // If URI doesn't start with http:// or https://, we will add            // this.            if (substr($pma_absolute_uri, 0, 7) != 'http://'              && substr($pma_absolute_uri, 0, 8) != 'https://') {                $pma_absolute_uri =                    (PMA_getenv('HTTPS') && strtolower(PMA_getenv('HTTPS')) != 'off'                        ? 'https'                        : 'http')                    . ':' . (substr($pma_absolute_uri, 0, 2) == '//' ? '' : '//')

⌨️ 快捷键说明

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