public static function loadConfig($file = NULL, $force = false) { //If no attempt has been made to load the config, attempt to load it, and patch it over $configData if (!is_bool($force)) { throw new UserInvalidModeException('loadConfig', $force, 'false (don\'t force), true (force)'); } if (User::$configLoaded && !$force) { return; } $pairs = NULL; $pathRegex = '%^(?:~?/|[A-Z]:[\\\\/]).+%i'; if ($file === NULL) { $file = User::DEFAULT_CONFIG_FILE; if (!preg_match($pathRegex, User::DEFAULT_CONFIG_FILE)) { $file = __DIR__ . '/' . $file; } if (is_file($file) && is_readable($file)) { $pairs = array_change_key_case(parse_ini_file($file)); } } else { if (!is_file($file)) { throw new UserIncorrectDatatypeException('loadConfig()', 1, 'file path', $file); } else { if (!is_readable($file)) { throw new UserFileUnreadableException('loadConfig()', $file); } else { $pairs = array_change_key_case(parse_ini_file($file)); } } } if ($pairs) { $pairs = array_uintersect_assoc($pairs, User::$configData, create_function(NULL, "return 0;")); User::$configData = array_merge(User::$configData, $pairs); } //Convert relative db_path values to absolute, taking '.' to be the parent directory of User.php if (!preg_match($pathRegex, User::$configData['db_path'])) { User::$configData['db_path'] = __DIR__ . '/' . User::$configData['db_path']; } User::$configLoaded = true; }