- merged two server array checks
- dont exit if user config loading failed - dont exit with invalid server index - use file_get_contents() or file() if not present - removed wrong error message - check if $cfg['ServerDefault'] is in $cfg['Servers'] before usning it
This commit is contained in:
@@ -10,6 +10,13 @@ $Source$
|
|||||||
* phpinfo.php:
|
* phpinfo.php:
|
||||||
- respect only $GLOBALS['cfg']['ShowPhpInfo']
|
- respect only $GLOBALS['cfg']['ShowPhpInfo']
|
||||||
- minimum include
|
- minimum include
|
||||||
|
* libraries/common.lib.php
|
||||||
|
- merged two server array checks
|
||||||
|
- dont exit if user config loading failed
|
||||||
|
- dont exit with invalid server index
|
||||||
|
- use file_get_contents() or file() if not present
|
||||||
|
- removed wrong error message
|
||||||
|
- check if $cfg['ServerDefault'] is in $cfg['Servers'] before usning it
|
||||||
|
|
||||||
2005-11-21 Michal Čihař <michal@cihar.com>
|
2005-11-21 Michal Čihař <michal@cihar.com>
|
||||||
* libraries/import/sql.php: Fix query splitting in some cases (reported by
|
* libraries/import/sql.php: Fix query splitting in some cases (reported by
|
||||||
|
@@ -93,37 +93,19 @@ unset($cfg['Servers']);
|
|||||||
* Parses the configuration file and gets some constants used to define
|
* Parses the configuration file and gets some constants used to define
|
||||||
* versions of phpMyAdmin/php/mysql...
|
* versions of phpMyAdmin/php/mysql...
|
||||||
*/
|
*/
|
||||||
$old_error_reporting = error_reporting(0);
|
$success_apply_user_config = false;
|
||||||
// We can not use include as it fails on parse error
|
// We can not use include as it fails on parse error
|
||||||
if (file_exists('./config.inc.php')) {
|
$config_file = './config.inc.php';
|
||||||
$config_fd = fopen('./config.inc.php', 'r');
|
if ( file_exists( $config_file ) ) {
|
||||||
$result = eval('?>' . fread($config_fd, filesize('./config.inc.php')));
|
$old_error_reporting = error_reporting( 0 );
|
||||||
fclose( $config_fd );
|
if ( function_exists( 'file_get_contents' ) ) {
|
||||||
unset( $config_fd );
|
$success_apply_user_config = eval( '?>' . file_get_contents( $config_file ) );
|
||||||
|
} else {
|
||||||
// Eval failed
|
$success_apply_user_config =
|
||||||
if ($result === FALSE || !isset($cfg['Servers'])) {
|
eval( '?>' . implode( '\n', file( $config_file ) ) );
|
||||||
// Creates fake settings
|
|
||||||
$cfg = array('DefaultLang' => 'en-iso-8859-1',
|
|
||||||
'AllowAnywhereRecoding' => FALSE);
|
|
||||||
// Loads the language file
|
|
||||||
require_once('./libraries/select_lang.lib.php');
|
|
||||||
// Displays the error message
|
|
||||||
// (do not use & for parameters sent by header)
|
|
||||||
header( 'Location: error.php'
|
|
||||||
. '?lang=' . urlencode( $available_languages[$lang][2] )
|
|
||||||
. '&char=' . urlencode( $charset )
|
|
||||||
. '&dir=' . urlencode( $text_dir )
|
|
||||||
. '&type=' . urlencode( $strError )
|
|
||||||
. '&error=' . urlencode(
|
|
||||||
strtr( $strConfigFileError, array( '<br />' => '[br]' ) )
|
|
||||||
. '[br][br]' . '[a@./config.inc.php@_blank]config.inc.php[/a]' )
|
|
||||||
. '&' . SID
|
|
||||||
);
|
|
||||||
exit();
|
|
||||||
}
|
}
|
||||||
error_reporting($old_error_reporting);
|
error_reporting( $old_error_reporting );
|
||||||
unset( $old_error_reporting, $result );
|
unset( $old_error_reporting );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -131,6 +113,15 @@ if (file_exists('./config.inc.php')) {
|
|||||||
*/
|
*/
|
||||||
require_once('./libraries/select_lang.lib.php');
|
require_once('./libraries/select_lang.lib.php');
|
||||||
|
|
||||||
|
if ( $success_apply_user_config === FALSE ) {
|
||||||
|
require_once('./libraries/select_lang.lib.php');
|
||||||
|
// Displays the error message
|
||||||
|
$GLOBALS['PMA_errors'][] = $strConfigFileError
|
||||||
|
.'<br /><br />'
|
||||||
|
.'<a href="./config.inc.php" taregt="_blank">config.inc.php</a>';
|
||||||
|
}
|
||||||
|
unset( $success_apply_user_config );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Servers array fixups.
|
* Servers array fixups.
|
||||||
*/
|
*/
|
||||||
@@ -141,22 +132,34 @@ if (!isset($cfg['Servers']) || count($cfg['Servers']) == 0) {
|
|||||||
} else {
|
} else {
|
||||||
// We have server(s) => apply default config
|
// We have server(s) => apply default config
|
||||||
$new_servers = array();
|
$new_servers = array();
|
||||||
foreach($cfg['Servers'] as $key => $val) {
|
|
||||||
if (!is_int($key) || $key < 1) {
|
foreach($cfg['Servers'] as $server_index => $each_server ) {
|
||||||
// Show error
|
if (!is_int($server_index) || $server_index < 1) {
|
||||||
header( 'Location: error.php'
|
$GLOBALS['PMA_errors'][] = sprintf( $strInvalidServerIndex, $server_index);
|
||||||
. '?lang=' . urlencode( $available_languages[$lang][2] )
|
continue;
|
||||||
. '&char=' . urlencode( $charset )
|
|
||||||
. '&dir=' . urlencode( $text_dir )
|
|
||||||
. '&type=' . urlencode( $strError )
|
|
||||||
. '&error=' . urlencode( sprintf( $strInvalidServerIndex, $key))
|
|
||||||
. '&' . SID
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
$new_servers[$key] = array_merge($default_server, $val);
|
|
||||||
|
$each_server = array_merge($default_server, $each_server);
|
||||||
|
|
||||||
|
// Don't use servers with no hostname
|
||||||
|
if ( $each_server['connect_type'] == 'tcp' && empty($each_server['host'])) {
|
||||||
|
$GLOBALS['PMA_errors'][] = sprintf( $strInvalidServerHostname, $server_index);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Final solution to bug #582890
|
||||||
|
// If we are using a socket connection
|
||||||
|
// and there is nothing in the verbose server name
|
||||||
|
// or the host field, then generate a name for the server
|
||||||
|
// in the form of "Server 2", localized of course!
|
||||||
|
if ( $each_server['connect_type'] == 'socket' && empty($each_server['host']) && empty($each_server['verbose']) ) {
|
||||||
|
$each_server['verbose'] = $GLOBALS['strServer'] . $server_index;
|
||||||
|
}
|
||||||
|
|
||||||
|
$new_servers[$server_index] = $each_server;
|
||||||
}
|
}
|
||||||
$cfg['Servers'] = $new_servers;
|
$cfg['Servers'] = $new_servers;
|
||||||
unset( $new_servers, $key, $val );
|
unset( $new_servers, $server_index, $each_server );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cleanup
|
// Cleanup
|
||||||
@@ -1313,33 +1316,6 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) {
|
|||||||
|
|
||||||
$dblist = array();
|
$dblist = array();
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the valid servers list and parameters
|
|
||||||
*/
|
|
||||||
|
|
||||||
foreach ($cfg['Servers'] AS $key => $val) {
|
|
||||||
// Don't use servers with no hostname
|
|
||||||
if ( isset($val['connect_type']) && ($val['connect_type'] == 'tcp') && empty($val['host'])) {
|
|
||||||
unset($cfg['Servers'][$key]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Final solution to bug #582890
|
|
||||||
// If we are using a socket connection
|
|
||||||
// and there is nothing in the verbose server name
|
|
||||||
// or the host field, then generate a name for the server
|
|
||||||
// in the form of "Server 2", localized of course!
|
|
||||||
if ( isset($val['connect_type']) && $val['connect_type'] == 'socket' && empty($val['host']) && empty($val['verbose']) ) {
|
|
||||||
$cfg['Servers'][$key]['verbose'] = $GLOBALS['strServer'] . $key;
|
|
||||||
$val['verbose'] = $GLOBALS['strServer'] . $key;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
unset( $key, $val );
|
|
||||||
|
|
||||||
if (empty($server) || !isset($cfg['Servers'][$server]) || !is_array($cfg['Servers'][$server])) {
|
|
||||||
$server = $cfg['ServerDefault'];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If no server is selected, make sure that $cfg['Server'] is empty (so
|
* If no server is selected, make sure that $cfg['Server'] is empty (so
|
||||||
* that nothing will work), and skip server authentication.
|
* that nothing will work), and skip server authentication.
|
||||||
@@ -1348,15 +1324,20 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) {
|
|||||||
* present a choice of servers in the case that there are multiple servers
|
* present a choice of servers in the case that there are multiple servers
|
||||||
* and '$cfg['ServerDefault'] = 0' is set.
|
* and '$cfg['ServerDefault'] = 0' is set.
|
||||||
*/
|
*/
|
||||||
if ($server == 0) {
|
if ( ! empty( $server ) && ! empty( $cfg['Servers'][$server] ) ) {
|
||||||
$cfg['Server'] = array();
|
$cfg['Server'] = $cfg['Servers'][$server];
|
||||||
|
} else {
|
||||||
|
if ( ! empty( $cfg['Servers'][$cfg['ServerDefault']] ) ) {
|
||||||
|
$server = $cfg['ServerDefault'];
|
||||||
|
$cfg['Server'] = $cfg['Servers'][$server];
|
||||||
|
} else {
|
||||||
|
$server = 0;
|
||||||
|
$cfg['Server'] = array();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Otherwise, set up $cfg['Server'] and do the usual login stuff.
|
if ( ! empty( $cfg['Server'] ) ) {
|
||||||
*/
|
|
||||||
else if (isset($cfg['Servers'][$server])) {
|
|
||||||
$cfg['Server'] = $cfg['Servers'][$server];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads the proper database interface for this server
|
* Loads the proper database interface for this server
|
||||||
@@ -1546,12 +1527,7 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} // end server connecting
|
} // end server connecting
|
||||||
/**
|
|
||||||
* Missing server hostname
|
|
||||||
*/
|
|
||||||
else {
|
|
||||||
echo $strHostEmpty;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send HTTP header, taking IIS limits into account
|
* Send HTTP header, taking IIS limits into account
|
||||||
|
Reference in New Issue
Block a user