Fix potential glob error

This commit is contained in:
Michael Gapczynski 2013-06-10 11:42:20 -04:00
parent e0359b0b24
commit b7b6075d55
1 changed files with 10 additions and 14 deletions

View File

@ -122,21 +122,17 @@ class Config {
* Reads the config file and saves it to the cache * Reads the config file and saves it to the cache
*/ */
private function readData() { private function readData() {
// read all file in config dir ending by config.php // Default config
$configFiles = glob($this->configDir.'*.config.php'); $configFiles = array($this->configFilename);
// Add all files in the config dir ending with config.php
//Filter only regular files $extra = glob($this->configDir.'*.config.php');
$configFiles = array_filter($configFiles, 'is_file'); if (is_array($extra)) {
natsort($extra);
//Sort array naturally : $configFiles = array_merge($configFiles, $extra);
natsort($configFiles); }
// Include file and merge config
// Add default config
array_unshift($configFiles, $this->configFilename);
//Include file and merge config
foreach ($configFiles as $file) { foreach ($configFiles as $file) {
if (!file_exists($file)) { if (!is_file($file)) {
continue; continue;
} }
unset($CONFIG); unset($CONFIG);