From 782a1c2ee21a702e803b1153f0f1672e9465034b Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Mon, 7 Jun 2010 10:52:17 +0200 Subject: [PATCH] fixed loading of configuration (thx to f10) --- init.php | 26 +++++++++---------- ...p.default => volkszaehler.conf.default.php | 0 2 files changed, 12 insertions(+), 14 deletions(-) rename volkszaehler.conf.php.default => volkszaehler.conf.default.php (100%) diff --git a/init.php b/init.php index 2c85457..1799231 100644 --- a/init.php +++ b/init.php @@ -47,23 +47,21 @@ function __autoload($className) { // controller classes '/^(.*Controller)$/' => 'controller/$1' - ); + ); $include = preg_replace(array_keys($mapping), array_values($mapping), $className); - - if (!empty($include)) { - $include = $libs . strtolower($include) . '.php'; - if (file_exists($include)) { - require_once $include; - } - else { - throw new CustomException('Cannot load class ' . $className . '! File does not exist: ' . $include); - } - } - else { + if (empty($include)) { throw new CustomException('Cannot load class ' . $className . '! Name not mapped.'); } + + $include = $libs . strtolower($include) . '.php'; + + if (file_exists($include)) { + throw new CustomException('Cannot load class ' . $className . '! File does not exist: ' . $include); + } + + require_once $include; } // enable strict error reporting @@ -73,8 +71,8 @@ error_reporting(E_ALL); set_error_handler(array('CustomErrorException', 'errorHandler')); // load configuration into registry -if (file_exists('volkszaehler.conf.php')) { - throw new CustomException('No configuration available! Use volkszaehler.conf.php as an template'); +if (!file_exists('volkszaehler.conf.php')) { + throw new CustomException('No configuration available! Use volkszaehler.conf.default.php as an template'); } include 'volkszaehler.conf.php'; diff --git a/volkszaehler.conf.php.default b/volkszaehler.conf.default.php similarity index 100% rename from volkszaehler.conf.php.default rename to volkszaehler.conf.default.php