summaryrefslogtreecommitdiff
path: root/plugins/htpasswd/htpasswd.module
blob: b97de52a9e4a63c80766d3a98fd216842233489e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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);
}