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