Browse Source

Fix potential glob error

tags/v6.0.0alpha2
Michael Gapczynski 11 years ago
parent
commit
b7b6075d55
1 changed files with 10 additions and 14 deletions
  1. 10
    14
      lib/config.php

+ 10
- 14
lib/config.php View File

@@ -122,21 +122,17 @@ class Config {
* Reads the config file and saves it to the cache
*/
private function readData() {
// read all file in config dir ending by config.php
$configFiles = glob($this->configDir.'*.config.php');

//Filter only regular files
$configFiles = array_filter($configFiles, 'is_file');

//Sort array naturally :
natsort($configFiles);

// Add default config
array_unshift($configFiles, $this->configFilename);

//Include file and merge config
// Default config
$configFiles = array($this->configFilename);
// Add all files in the config dir ending with config.php
$extra = glob($this->configDir.'*.config.php');
if (is_array($extra)) {
natsort($extra);
$configFiles = array_merge($configFiles, $extra);
}
// Include file and merge config
foreach ($configFiles as $file) {
if (!file_exists($file)) {
if (!is_file($file)) {
continue;
}
unset($CONFIG);

Loading…
Cancel
Save