From 0157349b3c421a8ec76eb3b21702c0100c88e9e6 Mon Sep 17 00:00:00 2001 From: arjen Date: Fri, 6 Dec 2002 22:34:02 +0000 Subject: [PATCH] Check existance and readability of configuration file before feeding it to the XML parser. --- src/phpclasses/configuration.class.php | 22 ++++++++++++---------- src/web/classes/configuration.class.php | 22 ++++++++++++---------- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/src/phpclasses/configuration.class.php b/src/phpclasses/configuration.class.php index fa25a7d..30a1446 100644 --- a/src/phpclasses/configuration.class.php +++ b/src/phpclasses/configuration.class.php @@ -61,22 +61,24 @@ class configuration function read($app_name) { $filename = "/etc/" . $app_name . ".conf"; - $this->system = xmldocfile($filename); - - if (!$this->system) + if (!is_readable($filename)) { $filename = "/usr/local/etc/" . $app_name . ".conf"; - $this->system = xmldocfile($filename); } - - if ($this->system) + if (is_readable($filename)) { - $root = $this->system->root(); - if ($root->tagname != $app_name) + $this->system = xmldocfile($filename); + + if ($this->system) { - print("Configuration error: Wrong configuration file.
"); - $this->system = false; + $root = $this->system->root(); + + if ($root->tagname != $app_name) + { + print("Configuration error: Wrong configuration file.
"); + $this->system = false; + } } } else diff --git a/src/web/classes/configuration.class.php b/src/web/classes/configuration.class.php index fa25a7d..30a1446 100644 --- a/src/web/classes/configuration.class.php +++ b/src/web/classes/configuration.class.php @@ -61,22 +61,24 @@ class configuration function read($app_name) { $filename = "/etc/" . $app_name . ".conf"; - $this->system = xmldocfile($filename); - - if (!$this->system) + if (!is_readable($filename)) { $filename = "/usr/local/etc/" . $app_name . ".conf"; - $this->system = xmldocfile($filename); } - - if ($this->system) + if (is_readable($filename)) { - $root = $this->system->root(); - if ($root->tagname != $app_name) + $this->system = xmldocfile($filename); + + if ($this->system) { - print("Configuration error: Wrong configuration file.
"); - $this->system = false; + $root = $this->system->root(); + + if ($root->tagname != $app_name) + { + print("Configuration error: Wrong configuration file.
"); + $this->system = false; + } } } else -- 2.11.0