1 |
<? |
2 |
|
3 |
/* |
4 |
Document manager handling for users in dbi database |
5 |
|
6 |
This module users dbi drivers for php which are available |
7 |
at http://freshmeat.net/projects/php-dbi/ |
8 |
or http://pil.dk/downloads/ |
9 |
|
10 |
arguments in docman.conf file are: |
11 |
|
12 |
$dbi = "driver:database_name:user:password"; |
13 |
$dbi_sql = "select login,full_name,password,email from users"; |
14 |
|
15 |
driver can be: pgsql, mysql, oracle or odbc (as supported by php-dbi) |
16 |
SQL query must return login, password full_name and e-mail |
17 |
|
18 |
This file is included early in docman.php and it should return: |
19 |
$gblUserName descriptive username |
20 |
$gblPw md5 hash of joint login and password |
21 |
$gblEmail e-mail address of user |
22 |
*/ |
23 |
|
24 |
// split configuration var $dbi |
25 |
// 0:driver, 1:db, 2:user, 3:password |
26 |
$dbi_arr=explode(":",$dbi); |
27 |
|
28 |
$dbi_class="$gblIncDir/dbi/dbi_".$dbi_arr[0].".php"; |
29 |
if (file_exists($dbi_class)) { |
30 |
include($dbi_class); |
31 |
} else { |
32 |
Error("Configuration error","Can't find dbi classes <tt>$dbi_class</tt> needed for htusers_sql. Please download them from <a href=http://pil.dk/downloads/>http://pil.dk/downloads/</a>"); |
33 |
} |
34 |
|
35 |
$pgdbi=new DBI($dbi_arr[1], $dbi_arr[2], $dbi_arr[3]); |
36 |
$sth=$pgdbi->prepare("$dbi_sql"); |
37 |
$sth->execute(); |
38 |
while ($row=$sth->fetchrow_array()) { |
39 |
if ($row[0] == $GLOBALS["PHP_AUTH_USER"]) { |
40 |
$gblUserName=$row[1]; |
41 |
$gblPw=$row[2]; |
42 |
if (substr($gblPw,0,5) == "auth_" && file_exists("$gblIncDir/$gblPw.php")) { |
43 |
require("$gblIncDir/$gblPw.php"); |
44 |
if ($gblPw($row)) { |
45 |
$gblPw=md5($PHP_AUTH_USER.$PHP_AUTH_PW); |
46 |
} else { |
47 |
$gblPw="error".md5($PHP_AUTH_USER.$PHP_AUTH_PW); |
48 |
} |
49 |
} |
50 |
$gblEmail=$row[3]; |
51 |
continue ; |
52 |
} |
53 |
} |
54 |
$sth->finish(); |
55 |
|
56 |
?> |