diff options
Diffstat (limited to 'plugins/htpasswd/htpasswd.module')
-rw-r--r-- | plugins/htpasswd/htpasswd.module | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/plugins/htpasswd/htpasswd.module b/plugins/htpasswd/htpasswd.module index b97de52..6e1c9d2 100644 --- a/plugins/htpasswd/htpasswd.module +++ b/plugins/htpasswd/htpasswd.module @@ -1,8 +1,23 @@ <?php function htpasswd_init($config) { - $data = array(); - $file = $config['htpasswd_file']; + $data = [NULL => []]; + $file = $config['file']; + if (!is_array($file)) { + $file = [NULL => $file]; + } + foreach ($file as $d => $f) { + $data[$d] = htpasswd_load($f); + } + + // Load the plugin. + require_once __DIR__ . '/BridgeHtpasswd.php'; + require_once __DIR__ . '/htpasswd.inc'; + return new BridgeHtpasswd($data, $config); +} + +function htpasswd_load($file) { + $data = []; if (file_exists($file) && is_readable($file)) { $lines = explode("\n", trim(file_get_contents($file))); foreach ($lines as $line) { @@ -10,9 +25,5 @@ function htpasswd_init($config) { $data[$user] = $password; } } - - // Load the plugin. - require_once __DIR__ . '/BridgeHtpasswd.php'; - require_once __DIR__ . '/htpasswd.inc'; - return new BridgeHtpasswd($data, $config); + return $data; } |