1 |
dpavlin |
1.1 |
<? |
2 |
|
|
|
3 |
|
|
/* |
4 |
|
|
Document manager handling for .htusers file |
5 |
|
|
|
6 |
|
|
This file is included early in docman.php and it should return: |
7 |
|
|
$gblUserName descriptive username |
8 |
|
|
$secHash md5 hash of joint login and password |
9 |
|
|
$gblEmail e-mail address of user |
10 |
|
|
|
11 |
|
|
This module can use any back magic to find who the user |
12 |
|
|
is, but I suggest $PHP_AUTH_USER and $PHP_AUTH_PW |
13 |
|
|
*/ |
14 |
|
|
|
15 |
|
|
$htusers_file="$fsRealmDir/$realm.htusers"; |
16 |
|
|
if (! file_exists($htusers_file)) { |
17 |
|
|
Error("Can't find users file!","Please create users file <tt>$htusers_file</tt> by hand or using <tt>adduser.pl</tt> script! There is example in <tt>$gblIncDir/realm/localhost.htusers.dist</tt>."); |
18 |
|
|
} |
19 |
|
|
$htusers=fopen($htusers_file,"r"); |
20 |
|
|
while($user = fgetcsv($htusers,255,":")) { |
21 |
|
|
if ($user[0] == $GLOBALS[gblLogin]) { |
22 |
|
|
$gblUserName=$user[1]; |
23 |
|
|
$secHash=$user[2]; |
24 |
|
|
if (substr($secHash,0,5) == "auth_" && file_exists("$gblIncDir/$secHash.php")) { |
25 |
|
|
include_once("$gblIncDir/$secHash.php"); |
26 |
|
|
if ($secHash($user)) { |
27 |
|
|
$secHash=md5($GLOBALS[gblLogin].$GLOBALS[gblPasswd]); |
28 |
|
|
} else { |
29 |
|
|
$secHash="error".md5($GLOBALS[gblLogin].$GLOBALS[gblPasswd]); |
30 |
|
|
} |
31 |
|
|
} |
32 |
|
|
$gblEmail=$user[3]; |
33 |
|
|
continue ; |
34 |
|
|
} |
35 |
|
|
} |
36 |
|
|
fclose($htusers); |
37 |
|
|
|
38 |
|
|
?> |