From 2b28fc510d3b441dac9d51ff6c80739d121a7b4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Wed, 13 Jul 2005 11:16:51 +0000 Subject: [PATCH] Use eval for config file including to catch parse errors (bug #1223319), on error page display config file that actually failed. --- ChangeLog | 5 +++++ libraries/common.lib.php | 15 +++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index ec8dde832..8e37bc1b9 100755 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,11 @@ phpMyAdmin - Changelog $Id$ $Source$ +2005-07-13 Michal Čihař + * 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 * 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) diff --git a/libraries/common.lib.php b/libraries/common.lib.php index 65ef03031..9716a2c9a 100644 --- a/libraries/common.lib.php +++ b/libraries/common.lib.php @@ -75,9 +75,9 @@ unset($cfg); * Detects the config file we want to load */ if (file_exists('./config.inc.developer.php')) { - $cfgfile_to_load = './config.inc.developer.php'; + $cfgfile_to_load = 'config.inc.developer.php'; } 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... */ $old_error_reporting = error_reporting(0); -include_once($cfgfile_to_load); -// Include failed -if (!isset($cfgServers) && !isset($cfg['Servers'])) { +// We can not use include as it fails on parse error +$config_fd = fopen($cfgfile_to_load, 'r'); +$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 $cfg = array('DefaultLang' => 'en-iso-8859-1', 'AllowAnywhereRecoding' => FALSE); @@ -118,7 +121,7 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold}

phpMyAdmin -



-config.inc.php +