clear old config values

This commit is contained in:
Sebastian Mendel
2005-12-07 08:32:21 +00:00
parent 8fb1f3ce4c
commit 50c4439d30

View File

@@ -2,8 +2,8 @@
/* $Id$ */
// vim: expandtab sw=4 ts=4 sts=4:
class PMA_Config {
class PMA_Config
{
/**
* @var string default config source
*/
@@ -56,7 +56,9 @@ class PMA_Config {
*
* @param string source to read config from
*/
function __construct( $source = NULL ) {
function __construct($source = NULL)
{
$this->settings = array();
// functions need to refresh in case of config file changed goes in
// PMA_Config::load()
@@ -69,7 +71,8 @@ class PMA_Config {
/**
* sets system and application settings
*/
function checkSystem() {
function checkSystem()
{
$this->set('PMA_VERSION', '2.7.1-dev');
/**
* @deprecated
@@ -93,7 +96,8 @@ class PMA_Config {
/**
* wether to use gzip output compression or not
*/
function checkOutputCompression() {
function checkOutputCompression()
{
// If zlib output compression is set in the php configuration file, no
// output buffering should be run
if ( @ini_get('zlib.output_compression') ) {
@@ -117,7 +121,8 @@ class PMA_Config {
* Based on a phpBuilder article:
* @see http://www.phpbuilder.net/columns/tim20000821.php
*/
function checkClient() {
function checkClient()
{
if (!empty($_SERVER['HTTP_USER_AGENT'])) {
$HTTP_USER_AGENT = $_SERVER['HTTP_USER_AGENT'];
} elseif (!isset($HTTP_USER_AGENT)) {
@@ -173,7 +178,8 @@ class PMA_Config {
/**
* Whether GD2 is present
*/
function checkGd2() {
function checkGd2()
{
if ( $this->get('GD2Available') == 'yes' ) {
$this->set('PMA_IS_GD2', 1);
} elseif ( $this->get('GD2Available') == 'no' ) {
@@ -216,7 +222,8 @@ class PMA_Config {
/**
* Whether the Web server php is running on is IIS
*/
function checkWebServer() {
function checkWebServer()
{
if ( isset( $_SERVER['SERVER_SOFTWARE'] )
&& stristr($_SERVER['SERVER_SOFTWARE'], 'Microsoft/IIS') ) {
$this->set('PMA_IS_IIS', 1);
@@ -228,7 +235,8 @@ class PMA_Config {
/**
* Whether the os php is running on is windows or not
*/
function checkWebServerOs() {
function checkWebServerOs()
{
if ( defined('PHP_OS') && stristr(PHP_OS, 'win') ) {
$this->set('PMA_IS_WINDOWS', 1);
} else {
@@ -239,7 +247,8 @@ class PMA_Config {
/**
* detects PHP version
*/
function checkPhpVersion() {
function checkPhpVersion()
{
$match = array();
if ( ! preg_match('@([0-9]{1,2}).([0-9]{1,2}).([0-9]{1,2})@',
phpversion(), $match) ) {
@@ -265,9 +274,11 @@ class PMA_Config {
* re-init object after loadiong from session file
* checks config file for changes and relaods if neccessary
*/
function __wakeup() {
function __wakeup()
{
if ( $this->source_mtime !== filemtime($this->getSource())
|| $this->error_config_file || $this->error_config_default_file ) {
$this->settings = array();
$this->load($this->getSource());
$this->checkSystem();
}
@@ -284,7 +295,8 @@ class PMA_Config {
* @uses $this->settings
* @return boolean success
*/
function loadDefaults() {
function loadDefaults()
{
$cfg = array();
if ( ! file_exists($this->default_source) ) {
$this->error_config_default_file = true;
@@ -306,8 +318,8 @@ class PMA_Config {
*
* @param string $source config file
*/
function load( $source = NULL ) {
function load($source = NULL)
{
$this->loadDefaults();
if ( ! $source || ! $this->setSource($source) ) {
@@ -357,7 +369,8 @@ class PMA_Config {
* set source
* @param string $source
*/
function setSource( $source ) {
function setSource($source)
{
if ( ! file_exists($source) ) {
// do not trigger error here
// https://sf.net/tracker/?func=detail&aid=1370269&group_id=23067&atid=377408
@@ -377,7 +390,8 @@ class PMA_Config {
* @param string $setting
* @return mixed value
*/
function get( $setting ) {
function get($setting)
{
if ( isset( $this->settings[$setting] ) ) {
return $this->settings[$setting];
}
@@ -391,7 +405,8 @@ class PMA_Config {
* @param string $setting configuration option
* @param string $value new value for configuration option
*/
function set( $setting, $value ) {
function set($setting, $value)
{
$this->settings[$setting] = $value;
}
@@ -399,7 +414,8 @@ class PMA_Config {
* returns source for current config
* @return string config source
*/
function getSource() {
function getSource()
{
return $this->source;
}
@@ -408,7 +424,8 @@ class PMA_Config {
*
* @deprecated
*/
function PMA_Config( $source ) {
function PMA_Config($source)
{
$this->__construct($source);
}
@@ -417,8 +434,8 @@ class PMA_Config {
* set properly and, depending on browsers, inserting or updating a
* record might fail
*/
function checkPmaAbsoluteUri() {
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');
@@ -539,7 +556,8 @@ class PMA_Config {
* check selected collation_connection
* @TODO check validity of $_REQUEST['collation_connection']
*/
function checkCollationConnection() {
function checkCollationConnection()
{
// (could be improved by executing it after the MySQL connection only if
// PMA_MYSQL_INT_VERSION >= 40100 )
if ( ! empty( $_REQUEST['collation_connection'] ) ) {
@@ -552,7 +570,8 @@ class PMA_Config {
* checks if upload is enabled
*
*/
function checkUpload() {
function checkUpload()
{
$this->set('enbale_upload', true);
if ( strtolower(@ini_get('file_uploads')) == 'off'
|| @ini_get('file_uploads') == 0 ) {
@@ -566,7 +585,8 @@ class PMA_Config {
*
* this section generates $max_upload_size in bytes
*/
function checkUploadSize() {
function checkUploadSize()
{
if ( ! $filesize = ini_get('upload_max_filesize') ) {
$filesize = "5M";
}
@@ -582,14 +602,16 @@ class PMA_Config {
/**
* check for https
*/
function checkIsHttps() {
function checkIsHttps()
{
$this->set('is_https', PMA_Config::isHttps());
}
/**
* @static
*/
function isHttps() {
function isHttps()
{
static $is_https = NULL;
if ( NULL !== $is_https ) {
@@ -630,14 +652,16 @@ class PMA_Config {
/**
* detect correct cookie path
*/
function checkCookiePath() {
function checkCookiePath()
{
$this->set('cookie_path', PMA_Config::getCookiePath());
}
/**
* @static
*/
function getCookiePath() {
function getCookiePath()
{
static $cookie_path = NULL;
if ( NULL !== $cookie_path ) {
@@ -668,8 +692,8 @@ class PMA_Config {
/**
* enables backward compatibility
*/
function enableBc() {
function enableBc()
{
$GLOBALS['cfg'] =& $this->settings;
$GLOBALS['default_server'] =& $this->default_server;
$GLOBALS['collation_connection'] = $this->get('collation_connection');