summaryrefslogtreecommitdiff
path: root/plugins/htpasswd/htpasswd.module
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/htpasswd/htpasswd.module')
-rw-r--r--plugins/htpasswd/htpasswd.module18
1 files changed, 18 insertions, 0 deletions
diff --git a/plugins/htpasswd/htpasswd.module b/plugins/htpasswd/htpasswd.module
new file mode 100644
index 0000000..b97de52
--- /dev/null
+++ b/plugins/htpasswd/htpasswd.module
@@ -0,0 +1,18 @@
+<?php
+
+function htpasswd_init($config) {
+ $data = array();
+ $file = $config['htpasswd_file'];
+ if (file_exists($file) && is_readable($file)) {
+ $lines = explode("\n", trim(file_get_contents($file)));
+ foreach ($lines as $line) {
+ list($user, $password) = explode(":", trim($line), 2);
+ $data[$user] = $password;
+ }
+ }
+
+ // Load the plugin.
+ require_once __DIR__ . '/BridgeHtpasswd.php';
+ require_once __DIR__ . '/htpasswd.inc';
+ return new BridgeHtpasswd($data, $config);
+}