/*
Document manager handling for users in dbi database
This module users dbi drivers for php which are available
at http://freshmeat.net/projects/php-dbi/
or http://pil.dk/downloads/
arguments in docman.conf file are:
$dbi = "driver:database_name:user:password";
$dbi_sql = "select login,full_name,password,email from users";
driver can be: pgsql, mysql, oracle or odbc (as supported by php-dbi)
SQL query must return login, password full_name and e-mail
This file is included early in docman.php and it should return:
$gblUserName descriptive username
$secHash md5 hash of joint login and password
$gblEmail e-mail address of user
*/
// split configuration var $dbi
// 0:driver, 1:db, 2:user, 3:password
$dbi_arr=explode(":",$dbi);
$dbi_class="$gblIncDir/dbi/dbi_".$dbi_arr[0].".php";
if (file_exists($dbi_class)) {
include($dbi_class);
} else {
Error("Configuration error","Can't find dbi classes $dbi_class needed for htusers_sql. Please download them from http://pil.dk/downloads/");
}
$pgdbi=new DBI($dbi_arr[1], $dbi_arr[2], $dbi_arr[3]);
$sth=$pgdbi->prepare("$dbi_sql");
$sth->execute();
while ($row=$sth->fetchrow_array()) {
if ($row[0] == $GLOBALS["PHP_AUTH_USER"]) {
$gblUserName=$row[1];
$secHash=$row[2];
if (substr($secHash,0,5) == "auth_" && file_exists("$gblIncDir/$secHash.php")) {
require("$gblIncDir/$secHash.php");
if ($secHash($row)) {
$secHash=md5($PHP_AUTH_USER.$PHP_AUTH_PW);
} else {
$secHash="error".md5($PHP_AUTH_USER.$PHP_AUTH_PW);
}
}
$gblEmail=$row[3];
continue ;
}
}
$sth->finish();
?>