Use eval for config file including to catch parse errors (bug #1223319), on error page display config file that actually failed.

This commit is contained in:
Michal Čihař
2005-07-13 11:16:51 +00:00
parent a3cc57896d
commit 2b28fc510d
2 changed files with 14 additions and 6 deletions

View File

@@ -5,6 +5,11 @@ phpMyAdmin - Changelog
$Id$ $Id$
$Source$ $Source$
2005-07-13 Michal Čihař <michal@cihar.com>
* libraries/common.lib.php: Use eval for config file including to catch
parse errors (bug #1223319), on error page display config file that
actually failed.
2005-07-12 Marc Delisle <lem9@users.sourceforge.net> 2005-07-12 Marc Delisle <lem9@users.sourceforge.net>
* sql.php: for Insert row and Export, use post when the query is too big * sql.php: for Insert row and Export, use post when the query is too big
* export.php: bug #1116026, export under IE 6 (XP SP2) * export.php: bug #1116026, export under IE 6 (XP SP2)

View File

@@ -75,9 +75,9 @@ unset($cfg);
* Detects the config file we want to load * Detects the config file we want to load
*/ */
if (file_exists('./config.inc.developer.php')) { if (file_exists('./config.inc.developer.php')) {
$cfgfile_to_load = './config.inc.developer.php'; $cfgfile_to_load = 'config.inc.developer.php';
} else { } else {
$cfgfile_to_load = './config.inc.php'; $cfgfile_to_load = 'config.inc.php';
} }
/** /**
@@ -85,9 +85,12 @@ if (file_exists('./config.inc.developer.php')) {
* versions of phpMyAdmin/php/mysql... * versions of phpMyAdmin/php/mysql...
*/ */
$old_error_reporting = error_reporting(0); $old_error_reporting = error_reporting(0);
include_once($cfgfile_to_load); // We can not use include as it fails on parse error
// Include failed $config_fd = fopen($cfgfile_to_load, 'r');
if (!isset($cfgServers) && !isset($cfg['Servers'])) { $result = eval('?>' . fread($config_fd, filesize($cfgfile_to_load)));
fclose($config_fd);
// Eval failed
if ($result === FALSE || (!isset($cfgServers) && !isset($cfg['Servers']))) {
// Creates fake settings // Creates fake settings
$cfg = array('DefaultLang' => 'en-iso-8859-1', $cfg = array('DefaultLang' => 'en-iso-8859-1',
'AllowAnywhereRecoding' => FALSE); 'AllowAnywhereRecoding' => FALSE);
@@ -118,7 +121,7 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold}
<h1>phpMyAdmin - <?php echo $strError; ?></h1> <h1>phpMyAdmin - <?php echo $strError; ?></h1>
<p> <p>
<?php echo $strConfigFileError; ?><br /><br /> <?php echo $strConfigFileError; ?><br /><br />
<a href="config.inc.php" target="_blank">config.inc.php</a> <a href="<?php echo $cfgfile_to_load; ?>" target="_blank"><?php echo $cfgfile_to_load; ?></a>
</p> </p>
</body> </body>